]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_infer/src/infer/outlives/mod.rs
Rollup merge of #98101 - vladimir-ea:stdlib_watch_os, r=thomcc
[rust.git] / compiler / rustc_infer / src / infer / outlives / mod.rs
1 //! Various code related to computing outlives relations.
2
3 pub mod components;
4 pub mod env;
5 pub mod obligations;
6 pub mod test_type_match;
7 pub mod verify;
8
9 use rustc_middle::traits::query::OutlivesBound;
10 use rustc_middle::ty;
11
12 #[instrument(level = "debug", skip(param_env))]
13 pub fn explicit_outlives_bounds<'tcx>(
14     param_env: ty::ParamEnv<'tcx>,
15 ) -> impl Iterator<Item = OutlivesBound<'tcx>> + 'tcx {
16     param_env
17         .caller_bounds()
18         .into_iter()
19         .map(ty::Predicate::kind)
20         .filter_map(ty::Binder::no_bound_vars)
21         .filter_map(move |kind| match kind {
22             ty::PredicateKind::Projection(..)
23             | ty::PredicateKind::Trait(..)
24             | ty::PredicateKind::Coerce(..)
25             | ty::PredicateKind::Subtype(..)
26             | ty::PredicateKind::WellFormed(..)
27             | ty::PredicateKind::ObjectSafe(..)
28             | ty::PredicateKind::ClosureKind(..)
29             | ty::PredicateKind::TypeOutlives(..)
30             | ty::PredicateKind::ConstEvaluatable(..)
31             | ty::PredicateKind::ConstEquate(..)
32             | ty::PredicateKind::TypeWellFormedFromEnv(..) => None,
33             ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(r_a, r_b)) => {
34                 Some(OutlivesBound::RegionSubRegion(r_b, r_a))
35             }
36         })
37 }