]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_infer/infer/outlives/mod.rs
Rollup merge of #70038 - DutchGhost:const-forget-tests, r=RalfJung
[rust.git] / src / librustc_infer / infer / outlives / mod.rs
index 6fc72470c9fb7816a822e689ee5f57557fec7451..75cf742de31a7a5f01f6e186dd22aef176219724 100644 (file)
@@ -3,3 +3,25 @@
 pub mod env;
 pub mod obligations;
 pub mod verify;
+
+use rustc::traits::query::OutlivesBound;
+use rustc::ty;
+
+pub fn explicit_outlives_bounds<'tcx>(
+    param_env: ty::ParamEnv<'tcx>,
+) -> impl Iterator<Item = OutlivesBound<'tcx>> + 'tcx {
+    debug!("explicit_outlives_bounds()");
+    param_env.caller_bounds.into_iter().filter_map(move |predicate| match predicate {
+        ty::Predicate::Projection(..)
+        | ty::Predicate::Trait(..)
+        | ty::Predicate::Subtype(..)
+        | ty::Predicate::WellFormed(..)
+        | ty::Predicate::ObjectSafe(..)
+        | ty::Predicate::ClosureKind(..)
+        | ty::Predicate::TypeOutlives(..)
+        | ty::Predicate::ConstEvaluatable(..) => None,
+        ty::Predicate::RegionOutlives(ref data) => data
+            .no_bound_vars()
+            .map(|ty::OutlivesPredicate(r_a, r_b)| OutlivesBound::RegionSubRegion(r_b, r_a)),
+    })
+}