diff options
| author | Jack Huey <31162821+jackh726@users.noreply.github.com> | 2024-01-16 18:39:00 -0500 |
|---|---|---|
| committer | Jack Huey <31162821+jackh726@users.noreply.github.com> | 2024-01-17 21:27:34 -0500 |
| commit | acab76573fffe8a3c2578506f277a89ef772a05d (patch) | |
| tree | 763d63e8c4f70ba68db0b7bea32198e1cfb16311 /compiler/rustc_trait_selection | |
| parent | d96003dd2a780ecb19252229b1927b1dc09f699b (diff) | |
| download | rust-acab76573fffe8a3c2578506f277a89ef772a05d.tar.gz rust-acab76573fffe8a3c2578506f277a89ef772a05d.zip | |
Add -Zno-implied-bounds-compat option and use it
Diffstat (limited to 'compiler/rustc_trait_selection')
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/misc.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/outlives_bounds.rs | 18 |
2 files changed, 17 insertions, 3 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/misc.rs b/compiler/rustc_trait_selection/src/traits/misc.rs index 52de8c4ceae..0cd376fcbbd 100644 --- a/compiler/rustc_trait_selection/src/traits/misc.rs +++ b/compiler/rustc_trait_selection/src/traits/misc.rs @@ -191,7 +191,7 @@ pub fn all_fields_implement_trait<'tcx>( // Check regions assuming the self type of the impl is WF let outlives_env = OutlivesEnvironment::with_bounds( param_env, - infcx.implied_bounds_tys_compat( + infcx.implied_bounds_tys( param_env, parent_cause.body_id, &FxIndexSet::from_iter([self_type]), diff --git a/compiler/rustc_trait_selection/src/traits/outlives_bounds.rs b/compiler/rustc_trait_selection/src/traits/outlives_bounds.rs index ec17024345a..52631d4353b 100644 --- a/compiler/rustc_trait_selection/src/traits/outlives_bounds.rs +++ b/compiler/rustc_trait_selection/src/traits/outlives_bounds.rs @@ -12,13 +12,17 @@ pub use rustc_middle::traits::query::OutlivesBound; pub type BoundsCompat<'a, 'tcx: 'a> = impl Iterator<Item = OutlivesBound<'tcx>> + 'a; pub type Bounds<'a, 'tcx: 'a> = impl Iterator<Item = OutlivesBound<'tcx>> + 'a; pub trait InferCtxtExt<'a, 'tcx> { + /// Do *NOT* call this directly. fn implied_bounds_tys_compat( &'a self, param_env: ty::ParamEnv<'tcx>, body_id: LocalDefId, tys: &'a FxIndexSet<Ty<'tcx>>, + compat: bool, ) -> BoundsCompat<'a, 'tcx>; + /// If `-Z no-implied-bounds-compat` is set, calls `implied_bounds_tys_compat` + /// with `compat` set to `true`, otherwise `false`. fn implied_bounds_tys( &'a self, param_env: ty::ParamEnv<'tcx>, @@ -132,8 +136,10 @@ impl<'a, 'tcx: 'a> InferCtxtExt<'a, 'tcx> for InferCtxt<'tcx> { param_env: ParamEnv<'tcx>, body_id: LocalDefId, tys: &'a FxIndexSet<Ty<'tcx>>, + compat: bool, ) -> BoundsCompat<'a, 'tcx> { - tys.iter().flat_map(move |ty| implied_outlives_bounds(self, param_env, body_id, *ty, true)) + tys.iter() + .flat_map(move |ty| implied_outlives_bounds(self, param_env, body_id, *ty, compat)) } fn implied_bounds_tys( @@ -142,6 +148,14 @@ impl<'a, 'tcx: 'a> InferCtxtExt<'a, 'tcx> for InferCtxt<'tcx> { body_id: LocalDefId, tys: &'a FxIndexSet<Ty<'tcx>>, ) -> Bounds<'a, 'tcx> { - tys.iter().flat_map(move |ty| implied_outlives_bounds(self, param_env, body_id, *ty, false)) + tys.iter().flat_map(move |ty| { + implied_outlives_bounds( + self, + param_env, + body_id, + *ty, + !self.tcx.sess.opts.unstable_opts.no_implied_bounds_compat, + ) + }) } } |
