]> git.proxmox.com Git - rustc.git/blame - src/librustc_infer/infer/outlives/mod.rs
New upstream version 1.47.0+dfsg1
[rustc.git] / src / librustc_infer / infer / outlives / mod.rs
CommitLineData
ff7c6d11
XL
1//! Various code related to computing outlives relations.
2
abe05a73 3pub mod env;
8faf50e0 4pub mod obligations;
0bf4aa26 5pub mod verify;
ba9703b0
XL
6
7use rustc_middle::traits::query::OutlivesBound;
8use rustc_middle::ty;
3dfed10e 9use rustc_middle::ty::fold::TypeFoldable;
ba9703b0
XL
10
11pub fn explicit_outlives_bounds<'tcx>(
12 param_env: ty::ParamEnv<'tcx>,
13) -> impl Iterator<Item = OutlivesBound<'tcx>> + 'tcx {
14 debug!("explicit_outlives_bounds()");
3dfed10e
XL
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 })
ba9703b0 34}