diff options
| author | bors <bors@rust-lang.org> | 2023-10-03 10:02:52 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-10-03 10:02:52 +0000 |
| commit | eb0f3ed59c6508a37c6598bc9762987f053993a7 (patch) | |
| tree | 96ad3accf1316b08d9ecf9bffa50d3dd73f4b630 /compiler/rustc_trait_selection/src | |
| parent | 9998f4add08c3d09c82e00975cf3a293b30160ec (diff) | |
| parent | 5d753abb300eebfb6492dc2b47bd32052a322b71 (diff) | |
| download | rust-eb0f3ed59c6508a37c6598bc9762987f053993a7.tar.gz rust-eb0f3ed59c6508a37c6598bc9762987f053993a7.zip | |
Auto merge of #115025 - ouz-a:ouz_testing, r=lcnr
Make subtyping explicit in MIR This adds new mir-opt that pushes new `ProjectionElem` called `ProjectionElem::Subtype(T)` to `Rvalue` of a subtyped assignment so we can unsoundness issues like https://github.com/rust-lang/rust/issues/107205 Addresses https://github.com/rust-lang/rust/issues/112651 r? `@lcnr`
Diffstat (limited to 'compiler/rustc_trait_selection/src')
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/engine.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/engine.rs b/compiler/rustc_trait_selection/src/traits/engine.rs index 820973dc090..015e38b2ac0 100644 --- a/compiler/rustc_trait_selection/src/traits/engine.rs +++ b/compiler/rustc_trait_selection/src/traits/engine.rs @@ -23,6 +23,7 @@ use rustc_middle::traits::query::NoSolution; use rustc_middle::ty::error::TypeError; use rustc_middle::ty::ToPredicate; use rustc_middle::ty::TypeFoldable; +use rustc_middle::ty::Variance; use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_session::config::TraitSolver; @@ -156,6 +157,20 @@ impl<'a, 'tcx> ObligationCtxt<'a, 'tcx> { .map(|infer_ok| self.register_infer_ok_obligations(infer_ok)) } + pub fn relate<T: ToTrace<'tcx>>( + &self, + cause: &ObligationCause<'tcx>, + param_env: ty::ParamEnv<'tcx>, + variance: Variance, + expected: T, + actual: T, + ) -> Result<(), TypeError<'tcx>> { + self.infcx + .at(cause, param_env) + .relate(DefineOpaqueTypes::Yes, expected, variance, actual) + .map(|infer_ok| self.register_infer_ok_obligations(infer_ok)) + } + /// Checks whether `expected` is a supertype of `actual`: `expected :> actual`. pub fn sup<T: ToTrace<'tcx>>( &self, |
