From 74e87b1dc573c2488c6cd319216f08b0c39d7e6f Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 12 Aug 2022 11:24:55 -0400 Subject: [PATCH] add test for raw_eq on a pointer --- tests/fail/intrinsics/raw_eq_on_ptr.rs | 11 +++++++++++ tests/fail/intrinsics/raw_eq_on_ptr.stderr | 14 ++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 tests/fail/intrinsics/raw_eq_on_ptr.rs create mode 100644 tests/fail/intrinsics/raw_eq_on_ptr.stderr diff --git a/tests/fail/intrinsics/raw_eq_on_ptr.rs b/tests/fail/intrinsics/raw_eq_on_ptr.rs new file mode 100644 index 00000000000..675b7cf9224 --- /dev/null +++ b/tests/fail/intrinsics/raw_eq_on_ptr.rs @@ -0,0 +1,11 @@ +#![feature(intrinsics)] + +extern "rust-intrinsic" { + fn raw_eq(a: &T, b: &T) -> bool; +} + +fn main() { + let x = &0; + // FIXME: the error message is not great (should be UB rather than 'unsupported') + unsafe { raw_eq(&x, &x) }; //~ERROR: unsupported operation +} diff --git a/tests/fail/intrinsics/raw_eq_on_ptr.stderr b/tests/fail/intrinsics/raw_eq_on_ptr.stderr new file mode 100644 index 00000000000..6c5e618315c --- /dev/null +++ b/tests/fail/intrinsics/raw_eq_on_ptr.stderr @@ -0,0 +1,14 @@ +error: unsupported operation: unable to turn pointer into raw bytes + --> $DIR/raw_eq_on_ptr.rs:LL:CC + | +LL | unsafe { raw_eq(&x, &x) }; + | ^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | + = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support + = note: backtrace: + = note: inside `main` at $DIR/raw_eq_on_ptr.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error +