diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2023-03-08 14:39:39 +0000 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2023-03-09 17:45:13 +0000 |
| commit | 2eccd52157071599a2659feb4b92e47e0eddb992 (patch) | |
| tree | 7d59929a4eb9c8879afacf93299acf08b1590dee | |
| parent | 09dc10c9c2d7a905f3fe966b32d442f2c27128e4 (diff) | |
| download | rust-2eccd52157071599a2659feb4b92e47e0eddb992.tar.gz rust-2eccd52157071599a2659feb4b92e47e0eddb992.zip | |
Test `let _ =` for const_mut_refs.
| -rw-r--r-- | tests/ui/consts/min_const_fn/min_const_fn_unsafe_bad.rs | 3 | ||||
| -rw-r--r-- | tests/ui/consts/min_const_fn/min_const_fn_unsafe_bad.stderr | 11 |
2 files changed, 13 insertions, 1 deletions
diff --git a/tests/ui/consts/min_const_fn/min_const_fn_unsafe_bad.rs b/tests/ui/consts/min_const_fn/min_const_fn_unsafe_bad.rs index a6e1788bb7f..df20ff446cd 100644 --- a/tests/ui/consts/min_const_fn/min_const_fn_unsafe_bad.rs +++ b/tests/ui/consts/min_const_fn/min_const_fn_unsafe_bad.rs @@ -7,4 +7,7 @@ const unsafe fn bad_const_unsafe_deref_raw(x: *mut usize) -> usize { *x } const unsafe fn bad_const_unsafe_deref_raw_ref(x: *mut usize) -> &'static usize { &*x } //~^ dereferencing raw mutable pointers in constant functions +const unsafe fn bad_const_unsafe_deref_raw_underscore(x: *mut usize) { let _ = *x; } +//~^ dereferencing raw mutable pointers in constant functions + fn main() {} diff --git a/tests/ui/consts/min_const_fn/min_const_fn_unsafe_bad.stderr b/tests/ui/consts/min_const_fn/min_const_fn_unsafe_bad.stderr index 820b6433f36..e68376e7b87 100644 --- a/tests/ui/consts/min_const_fn/min_const_fn_unsafe_bad.stderr +++ b/tests/ui/consts/min_const_fn/min_const_fn_unsafe_bad.stderr @@ -25,6 +25,15 @@ LL | const unsafe fn bad_const_unsafe_deref_raw_ref(x: *mut usize) -> &'static u = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable -error: aborting due to 3 previous errors +error[E0658]: dereferencing raw mutable pointers in constant functions is unstable + --> $DIR/min_const_fn_unsafe_bad.rs:10:80 + | +LL | const unsafe fn bad_const_unsafe_deref_raw_underscore(x: *mut usize) { let _ = *x; } + | ^^ + | + = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information + = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable + +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0658`. |
