]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_infer/src/infer/outlives/mod.rs
Merge commit '03f01bbe901d60b71cf2c5ec766aef5e532ab79d' into update_cg_clif-2020...
[rust.git] / compiler / rustc_infer / src / infer / outlives / mod.rs
1 //! Various code related to computing outlives relations.
2
3 pub mod env;
4 pub mod obligations;
5 pub mod verify;
6
7 use rustc_middle::traits::query::OutlivesBound;
8 use rustc_middle::ty;
9 use rustc_middle::ty::fold::TypeFoldable;
10
11 pub fn explicit_outlives_bounds<'tcx>(
12     param_env: ty::ParamEnv<'tcx>,
13 ) -> impl Iterator<Item = OutlivesBound<'tcx>> + 'tcx {
14     debug!("explicit_outlives_bounds()");
15     param_env
16         .caller_bounds()
17         .into_iter()
18         .map(ty::Predicate::skip_binders)
19         .filter(|atom| !atom.has_escaping_bound_vars())
20         .filter_map(move |atom| match atom {
21             ty::PredicateAtom::Projection(..)
22             | ty::PredicateAtom::Trait(..)
23             | ty::PredicateAtom::Subtype(..)
24             | ty::PredicateAtom::WellFormed(..)
25             | ty::PredicateAtom::ObjectSafe(..)
26             | ty::PredicateAtom::ClosureKind(..)
27             | ty::PredicateAtom::TypeOutlives(..)
28             | ty::PredicateAtom::ConstEvaluatable(..)
29             | ty::PredicateAtom::ConstEquate(..)
30             | ty::PredicateAtom::TypeWellFormedFromEnv(..) => None,
31             ty::PredicateAtom::RegionOutlives(ty::OutlivesPredicate(r_a, r_b)) => {
32                 Some(OutlivesBound::RegionSubRegion(r_b, r_a))
33             }
34         })
35 }