diff options
| author | Ralf Jung <post@ralfj.de> | 2021-02-16 09:57:21 +0100 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2021-02-16 09:58:35 +0100 |
| commit | 897cb610767741c0f49ff1e68cda41b521186003 (patch) | |
| tree | 7722f4e8176edfe81b3262befa12f54cef82a529 | |
| parent | 090dac0c3892a2d21afb0f82aa72920760e08078 (diff) | |
| download | rust-897cb610767741c0f49ff1e68cda41b521186003.tar.gz rust-897cb610767741c0f49ff1e68cda41b521186003.zip | |
validation: fix invalid-fn-ptr error message
| -rw-r--r-- | compiler/rustc_mir/src/interpret/validity.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/compiler/rustc_mir/src/interpret/validity.rs b/compiler/rustc_mir/src/interpret/validity.rs index dac8ddccad6..64e7a4d9ca7 100644 --- a/compiler/rustc_mir/src/interpret/validity.rs +++ b/compiler/rustc_mir/src/interpret/validity.rs @@ -586,8 +586,11 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, ' self.path, err_unsup!(ReadPointerAsBytes) => { "part of a pointer" } expected { "a proper pointer or integer value" }, ); + // Make sure we print a `ScalarMaybeUninit` (and not an `ImmTy`) in the error + // message below. + let value = value.to_scalar_or_uninit(); let _fn = try_validation!( - value.to_scalar().and_then(|ptr| self.ecx.memory.get_fn(ptr)), + value.check_init().and_then(|ptr| self.ecx.memory.get_fn(ptr)), self.path, err_ub!(DanglingIntPointer(..)) | err_ub!(InvalidFunctionPointer(..)) | |
