1 use crate::infer
::canonical
::{Canonicalized, CanonicalizedQueryResponse}
;
2 use crate::traits
::query
::Fallible
;
3 use rustc_infer
::traits
::query
::OutlivesBound
;
4 use rustc_middle
::ty
::{self, ParamEnvAnd, Ty, TyCtxt}
;
6 #[derive(Copy, Clone, Debug, HashStable, TypeFoldable, TypeVisitable, Lift)]
7 pub struct ImpliedOutlivesBounds
<'tcx
> {
11 impl<'tcx
> super::QueryTypeOp
<'tcx
> for ImpliedOutlivesBounds
<'tcx
> {
12 type QueryResponse
= Vec
<OutlivesBound
<'tcx
>>;
16 key
: &ParamEnvAnd
<'tcx
, Self>,
17 ) -> Option
<Self::QueryResponse
> {
18 // Don't go into the query for things that can't possibly have lifetimes.
19 match key
.value
.ty
.kind() {
20 ty
::Tuple(elems
) if elems
.is_empty() => Some(vec
![]),
21 ty
::Never
| ty
::Str
| ty
::Bool
| ty
::Char
| ty
::Int(_
) | ty
::Uint(_
) | ty
::Float(_
) => {
30 canonicalized
: Canonicalized
<'tcx
, ParamEnvAnd
<'tcx
, Self>>,
31 ) -> Fallible
<CanonicalizedQueryResponse
<'tcx
, Self::QueryResponse
>> {
32 // FIXME this `unchecked_map` is only necessary because the
33 // query is defined as taking a `ParamEnvAnd<Ty>`; it should
34 // take an `ImpliedOutlivesBounds` instead
35 let canonicalized
= canonicalized
.unchecked_map(|ParamEnvAnd { param_env, value }
| {
36 let ImpliedOutlivesBounds { ty }
= value
;
40 tcx
.implied_outlives_bounds(canonicalized
)