-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add regression test for issue 127562
The test fails in this commit. The next commit fixes it.
- Loading branch information
Showing
2 changed files
with
22 additions
and
0 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
tests/ui/borrowck/no-invalid-mut-suggestion-for-raw-pointer-issue-127562.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
14 changes: 14 additions & 0 deletions
14
tests/ui/borrowck/no-invalid-mut-suggestion-for-raw-pointer-issue-127562.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |