-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #134244 - Enselic:no-mut-hint-for-raw-ref, r=jieyouxu
rustc_borrowck: Stop suggesting the invalid syntax `&mut raw const` A legitimate suggestion would be to change from &raw const val to &raw mut val But until we have figured out how to make that happen we should at least stop suggesting invalid syntax. I recommend review commit-by-commit. Part of #127562
- Loading branch information
Showing
3 changed files
with
70 additions
and
16 deletions.
There are no files selected for viewing
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
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 | ||
} |
9 changes: 9 additions & 0 deletions
9
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,9 @@ | ||
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 | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0594`. |