about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2021-02-16 19:21:21 +0100
committerGitHub <noreply@github.com>2021-02-16 19:21:21 +0100
commit866dc5aae5696bd36f4c0965febacc4ccffcb6d4 (patch)
treea0af02dca47a6fcb26edd8a1e019ebaf512d1b63 /compiler
parent46b93b2e44405a3d914eb07dfe33bc39226bfe71 (diff)
parente5514efab25a4cefac730d6fb6d7917a4cf1cbb6 (diff)
downloadrust-866dc5aae5696bd36f4c0965febacc4ccffcb6d4.tar.gz
rust-866dc5aae5696bd36f4c0965febacc4ccffcb6d4.zip
Rollup merge of #82175 - RalfJung:invalid-fn-ptr, r=oli-obk
validation: fix invalid-fn-ptr error message

https://github.com/rust-lang/rust/pull/82061 changed the code here to print an `ImmTy` instead of a `ScalarMaybeUninit`; that was an accident. So go back to printing a `ScalarMaybeUninit`.

r? ```@oli-obk```
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_mir/src/interpret/validity.rs5
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(..)) |