forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
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 rust-lang#56966 - varkor:raw-pointer-deref-parens, r=…
…zackmdavis Correct strings for raw pointer deref and array access suggestions Fixes rust-lang#56714. Fixes rust-lang#56963. r? @zackmdavis
- Loading branch information
Showing
5 changed files
with
49 additions
and
7 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
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
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,11 @@ | ||
struct Session { | ||
opts: u8, | ||
} | ||
|
||
fn main() { | ||
let sess: &Session = &Session { opts: 0 }; | ||
(sess as *const Session).opts; //~ ERROR no field `opts` on type `*const Session` | ||
|
||
let x = [0u32]; | ||
(x as [u32; 1]).0; //~ ERROR no field `0` on type `[u32; 1]` | ||
} |
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,21 @@ | ||
error[E0609]: no field `opts` on type `*const Session` | ||
--> $DIR/parenthesised-deref-suggestion.rs:7:30 | ||
| | ||
LL | (sess as *const Session).opts; //~ ERROR no field `opts` on type `*const Session` | ||
| ^^^^ | ||
help: `(sess as *const Session)` is a raw pointer; try dereferencing it | ||
| | ||
LL | (*(sess as *const Session)).opts; //~ ERROR no field `opts` on type `*const Session` | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error[E0609]: no field `0` on type `[u32; 1]` | ||
--> $DIR/parenthesised-deref-suggestion.rs:10:21 | ||
| | ||
LL | (x as [u32; 1]).0; //~ ERROR no field `0` on type `[u32; 1]` | ||
| ----------------^ | ||
| | | ||
| help: instead of using tuple indexing, use array indexing: `(x as [u32; 1])[0]` | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0609`. |
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