Skip to content

Commit 897cb61

Browse files
committed
validation: fix invalid-fn-ptr error message
1 parent 090dac0 commit 897cb61

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

compiler/rustc_mir/src/interpret/validity.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,8 +586,11 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
586586
self.path,
587587
err_unsup!(ReadPointerAsBytes) => { "part of a pointer" } expected { "a proper pointer or integer value" },
588588
);
589+
// Make sure we print a `ScalarMaybeUninit` (and not an `ImmTy`) in the error
590+
// message below.
591+
let value = value.to_scalar_or_uninit();
589592
let _fn = try_validation!(
590-
value.to_scalar().and_then(|ptr| self.ecx.memory.get_fn(ptr)),
593+
value.check_init().and_then(|ptr| self.ecx.memory.get_fn(ptr)),
591594
self.path,
592595
err_ub!(DanglingIntPointer(..)) |
593596
err_ub!(InvalidFunctionPointer(..)) |

0 commit comments

Comments
 (0)