diff options
| author | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2019-12-14 12:15:37 +0100 |
|---|---|---|
| committer | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2019-12-26 22:50:17 +0100 |
| commit | 0e969b73f6f633187a829111d3e80423e85fd513 (patch) | |
| tree | 0dea1f997f1c0b16f3f27a057346586512b7f97b | |
| parent | a0bd1a695d20da88668a4549f71e86d0f976de15 (diff) | |
| download | rust-0e969b73f6f633187a829111d3e80423e85fd513.tar.gz rust-0e969b73f6f633187a829111d3e80423e85fd513.zip | |
Interning even happens when validation of a constant fails
| -rw-r--r-- | src/librustc_mir/interpret/intern.rs | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/librustc_mir/interpret/intern.rs b/src/librustc_mir/interpret/intern.rs index aaeff02fc05..2d66fb46311 100644 --- a/src/librustc_mir/interpret/intern.rs +++ b/src/librustc_mir/interpret/intern.rs @@ -191,12 +191,18 @@ impl<'rt, 'mir, 'tcx, M: CompileTimeMachine<'mir, 'tcx>> ValueVisitor<'mir, 'tcx if let ty::Dynamic(..) = self.ecx.tcx.struct_tail_erasing_lifetimes(referenced_ty, self.ecx.param_env).kind { - // Validation has already errored on an invalid vtable pointer so this `assert_ptr` - // will never panic. - let vtable = mplace.meta.unwrap().assert_ptr(); - // explitly choose `Immutable` here, since vtables are immutable, even - // if the reference of the fat pointer is mutable - self.intern_shallow(vtable.alloc_id, Mutability::Not, None)?; + // Validation has already errored on an invalid vtable pointer so we can safely not + // do anything if this is not a real pointer + if let Scalar::Ptr(vtable) = mplace.meta.unwrap() { + // explitly choose `Immutable` here, since vtables are immutable, even + // if the reference of the fat pointer is mutable + self.intern_shallow(vtable.alloc_id, Mutability::Not, None)?; + } else { + self.ecx().tcx.sess.delay_span_bug( + syntax_pos::DUMMY_SP, + "vtables pointers cannot be integer pointers", + ); + } } // Check if we have encountered this pointer+layout combination before. // Only recurse for allocation-backed pointers. |
