about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src/traits
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2025-01-25 04:26:32 +0000
committerMichael Goulet <michael@errs.io>2025-01-28 18:55:03 +0000
commit48b7e38c0607e856dbbb932e60ecc85e45a1427d (patch)
tree8940572ec00be905372772a0ce230cacab287750 /compiler/rustc_trait_selection/src/traits
parent2b8930c71c8040d338f99e1b1be6f1056edd6638 (diff)
downloadrust-48b7e38c0607e856dbbb932e60ecc85e45a1427d.tar.gz
rust-48b7e38c0607e856dbbb932e60ecc85e45a1427d.zip
Move outlives env computation into methods
Diffstat (limited to 'compiler/rustc_trait_selection/src/traits')
-rw-r--r--compiler/rustc_trait_selection/src/traits/auto_trait.rs4
-rw-r--r--compiler/rustc_trait_selection/src/traits/outlives_bounds.rs21
2 files changed, 6 insertions, 19 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/auto_trait.rs b/compiler/rustc_trait_selection/src/traits/auto_trait.rs
index 9a53e8a5d51..1fca2f4da7e 100644
--- a/compiler/rustc_trait_selection/src/traits/auto_trait.rs
+++ b/compiler/rustc_trait_selection/src/traits/auto_trait.rs
@@ -6,6 +6,7 @@ use std::iter;
 
 use rustc_data_structures::fx::{FxIndexMap, FxIndexSet, IndexEntry};
 use rustc_data_structures::unord::UnordSet;
+use rustc_hir::def_id::CRATE_DEF_ID;
 use rustc_infer::infer::DefineOpaqueTypes;
 use rustc_middle::ty::{Region, RegionVid};
 use tracing::debug;
@@ -13,6 +14,7 @@ use tracing::debug;
 use super::*;
 use crate::errors::UnableToConstructConstantValue;
 use crate::infer::region_constraints::{Constraint, RegionConstraintData};
+use crate::regions::OutlivesEnvironmentBuildExt;
 use crate::traits::project::ProjectAndUnifyResult;
 
 // FIXME(twk): this is obviously not nice to duplicate like that
@@ -158,7 +160,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
             panic!("Unable to fulfill trait {trait_did:?} for '{ty:?}': {errors:?}");
         }
 
-        let outlives_env = OutlivesEnvironment::new(full_env);
+        let outlives_env = OutlivesEnvironment::new(&infcx, CRATE_DEF_ID, full_env, []);
         let _ = infcx.process_registered_region_obligations(&outlives_env, |ty, _| Ok(ty));
 
         let region_data = infcx.inner.borrow_mut().unwrap_region_constraints().data().clone();
diff --git a/compiler/rustc_trait_selection/src/traits/outlives_bounds.rs b/compiler/rustc_trait_selection/src/traits/outlives_bounds.rs
index eecc499f384..18932695807 100644
--- a/compiler/rustc_trait_selection/src/traits/outlives_bounds.rs
+++ b/compiler/rustc_trait_selection/src/traits/outlives_bounds.rs
@@ -108,8 +108,9 @@ fn implied_outlives_bounds<'a, 'tcx>(
 
 #[extension(pub trait InferCtxtExt<'tcx>)]
 impl<'tcx> InferCtxt<'tcx> {
-    /// Do *NOT* call this directly.
-    fn implied_bounds_tys_compat<Tys: IntoIterator<Item = Ty<'tcx>>>(
+    /// Do *NOT* call this directly. You probably want to construct a `OutlivesEnvironment`
+    /// instead if you're interested in the implied bounds for a given signature.
+    fn implied_bounds_tys_with_compat<Tys: IntoIterator<Item = Ty<'tcx>>>(
         &self,
         body_id: LocalDefId,
         param_env: ParamEnv<'tcx>,
@@ -119,20 +120,4 @@ impl<'tcx> InferCtxt<'tcx> {
         tys.into_iter()
             .flat_map(move |ty| implied_outlives_bounds(self, param_env, body_id, ty, compat))
     }
-
-    /// If `-Z no-implied-bounds-compat` is set, calls `implied_bounds_tys_compat`
-    /// with `compat` set to `true`, otherwise `false`.
-    fn implied_bounds_tys(
-        &self,
-        body_id: LocalDefId,
-        param_env: ParamEnv<'tcx>,
-        tys: impl IntoIterator<Item = Ty<'tcx>>,
-    ) -> impl Iterator<Item = OutlivesBound<'tcx>> {
-        self.implied_bounds_tys_compat(
-            body_id,
-            param_env,
-            tys,
-            !self.tcx.sess.opts.unstable_opts.no_implied_bounds_compat,
-        )
-    }
 }