]> git.proxmox.com Git - rustc.git/blob - src/librustc_infer/infer/outlives/mod.rs
New upstream version 1.47.0+dfsg1
[rustc.git] / src / librustc_infer / 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(..) => None,
30 ty::PredicateAtom::RegionOutlives(ty::OutlivesPredicate(r_a, r_b)) => {
31 Some(OutlivesBound::RegionSubRegion(r_b, r_a))
32 }
33 })
34 }