mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-04 19:29:07 +00:00
Add regression test for issue 127562
The test fails in this commit. The next commit fixes it.
This commit is contained in:
parent
e17ca31b22
commit
d7fa8ee680
@ -0,0 +1,8 @@
|
||||
//! Regression test for invalid suggestion for `&raw const expr` reported in
|
||||
//! <https://github.com/rust-lang/rust/issues/127562>.
|
||||
|
||||
fn main() {
|
||||
let val = 2;
|
||||
let ptr = &raw const val;
|
||||
unsafe { *ptr = 3; } //~ ERROR cannot assign to `*ptr`, which is behind a `*const` pointer
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
error[E0594]: cannot assign to `*ptr`, which is behind a `*const` pointer
|
||||
--> $DIR/no-invalid-mut-suggestion-for-raw-pointer-issue-127562.rs:7:14
|
||||
|
|
||||
LL | unsafe { *ptr = 3; }
|
||||
| ^^^^^^^^ `ptr` is a `*const` pointer, so the data it refers to cannot be written
|
||||
|
|
||||
help: consider changing this to be a mutable pointer
|
||||
|
|
||||
LL | let ptr = &mut raw const val;
|
||||
| +++
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0594`.
|
Loading…
Reference in New Issue
Block a user