diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2023-09-27 11:35:09 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2023-09-28 16:13:38 +0000 |
| commit | 0031cf7c7e5bd255a504df19f44cc0eaf240fd57 (patch) | |
| tree | 5110f2ce5dd3163593da6c073bf849f3e3656991 /compiler/rustc_const_eval/src/transform/validate.rs | |
| parent | 2d4201f7c65b223967bb12aed2a790f85e457969 (diff) | |
| download | rust-0031cf7c7e5bd255a504df19f44cc0eaf240fd57.tar.gz rust-0031cf7c7e5bd255a504df19f44cc0eaf240fd57.zip | |
Add a mir validation check to prevent OpaqueCast after analysis passes finish
Diffstat (limited to 'compiler/rustc_const_eval/src/transform/validate.rs')
| -rw-r--r-- | compiler/rustc_const_eval/src/transform/validate.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/rustc_const_eval/src/transform/validate.rs b/compiler/rustc_const_eval/src/transform/validate.rs index 0d8733070a4..18b22882e7d 100644 --- a/compiler/rustc_const_eval/src/transform/validate.rs +++ b/compiler/rustc_const_eval/src/transform/validate.rs @@ -633,6 +633,14 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { location: Location, ) { match elem { + ProjectionElem::OpaqueCast(ty) + if self.mir_phase >= MirPhase::Runtime(RuntimePhase::Initial) => + { + self.fail( + location, + format!("explicit opaque type cast to `{ty}` after `RevealAll`"), + ) + } ProjectionElem::Index(index) => { let index_ty = self.body.local_decls[index].ty; if index_ty != self.tcx.types.usize { |
