-
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.
Remove invalid help diagnostics for const pointer
- Loading branch information
1 parent
03c2100
commit b44a484
Showing
3 changed files
with
36 additions
and
12 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
7 changes: 7 additions & 0 deletions
7
tests/ui/suggestions/dont_suggest_raw_pointer_syntax-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,7 @@ | ||
fn main() { | ||
let val = 2; | ||
let ptr = std::ptr::addr_of!(val); | ||
unsafe { | ||
*ptr = 3; //~ ERROR cannot assign to `*ptr`, which is behind a `*const` pointer | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
tests/ui/suggestions/dont_suggest_raw_pointer_syntax-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/dont_suggest_raw_pointer_syntax-issue-127562.rs:5:9 | ||
| | ||
LL | *ptr = 3; | ||
| ^^^^^^^^ `ptr` is a `*const` pointer, so the data it refers to cannot be written | ||
| | ||
help: consider specifying this binding's type | ||
| | ||
LL | let ptr: *mut i32 = std::ptr::addr_of!(val); | ||
| ++++++++++ | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0594`. |