Skip to content

Commit

Permalink
Test let _ = for const_mut_refs.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Mar 9, 2023
1 parent 09dc10c commit 2eccd52
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions tests/ui/consts/min_const_fn/min_const_fn_unsafe_bad.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
11 changes: 10 additions & 1 deletion tests/ui/consts/min_const_fn/min_const_fn_unsafe_bad.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

0 comments on commit 2eccd52

Please sign in to comment.