Skip to content

Commit 2eccd52

Browse files
committed
Test let _ = for const_mut_refs.
1 parent 09dc10c commit 2eccd52

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

tests/ui/consts/min_const_fn/min_const_fn_unsafe_bad.rs

+3
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,7 @@ const unsafe fn bad_const_unsafe_deref_raw(x: *mut usize) -> usize { *x }
77
const unsafe fn bad_const_unsafe_deref_raw_ref(x: *mut usize) -> &'static usize { &*x }
88
//~^ dereferencing raw mutable pointers in constant functions
99

10+
const unsafe fn bad_const_unsafe_deref_raw_underscore(x: *mut usize) { let _ = *x; }
11+
//~^ dereferencing raw mutable pointers in constant functions
12+
1013
fn main() {}

tests/ui/consts/min_const_fn/min_const_fn_unsafe_bad.stderr

+10-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ LL | const unsafe fn bad_const_unsafe_deref_raw_ref(x: *mut usize) -> &'static u
2525
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
2626
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
2727

28-
error: aborting due to 3 previous errors
28+
error[E0658]: dereferencing raw mutable pointers in constant functions is unstable
29+
--> $DIR/min_const_fn_unsafe_bad.rs:10:80
30+
|
31+
LL | const unsafe fn bad_const_unsafe_deref_raw_underscore(x: *mut usize) { let _ = *x; }
32+
| ^^
33+
|
34+
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
35+
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
36+
37+
error: aborting due to 4 previous errors
2938

3039
For more information about this error, try `rustc --explain E0658`.

0 commit comments

Comments
 (0)