From 2eccd52157071599a2659feb4b92e47e0eddb992 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Wed, 8 Mar 2023 14:39:39 +0000 Subject: [PATCH] Test `let _ =` for const_mut_refs. --- .../ui/consts/min_const_fn/min_const_fn_unsafe_bad.rs | 3 +++ .../min_const_fn/min_const_fn_unsafe_bad.stderr | 11 ++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) 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 fn bad_const_fn_deref_raw(x: *mut usize) -> &'static usize { unsafe { &*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 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 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`.