-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
improve diagnostic for raw pointer field access with -> #139921
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This comment has been minimized.
This comment has been minimized.
|
Please squash the last commit into the first |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
13d0ac8 to
11a6b40
Compare
340d7ee to
9ee67a5
Compare
|
@Kivooeo as errs said, a few days of inactivity is very common, reviewing PRs takes time and energy and people have lifes besides rustc :) The sponsor page talks more about being on review rotation, doing PR review as a big part of the work. I still occasionally review PRs if I feel like it. I wouldn't assign myself to the PR if I wouldn't want to review it. |
This comment has been minimized.
This comment has been minimized.
|
@WaffleLapkin check this changes, tldr I reverted sugesstion attribute for Rarrow span in parser, removed rustfix in my testfile, updated error messages. I actually little bit ruined commits, starting this in master was awful idea, I will try to fix it tomorrow if could, if no I will close this and open new PR in separate branch |
WaffleLapkin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, modulo 1 nit
acab75e to
d9d8a9c
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
WaffleLapkin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
…enton Rollup of 8 pull requests Successful merges: - rust-lang#139617 (Use posix_spawn on cygwin) - rust-lang#139921 (improve diagnostic for raw pointer field access with ->) - rust-lang#140031 (compiletest: Fix deadline bugs in new executor) - rust-lang#140072 (handle function alignment in miri) - rust-lang#140104 (Fix auto diff failing on inherent impl blocks) - rust-lang#140124 (Update books) - rust-lang#140144 (Handle another negated literal in `eat_token_lit`.) - rust-lang#140149 (test_nan: ensure the NAN contant is quiet) r? `@ghost` `@rustbot` modify labels: rollup
…enton Rollup of 8 pull requests Successful merges: - rust-lang#139617 (Use posix_spawn on cygwin) - rust-lang#139921 (improve diagnostic for raw pointer field access with ->) - rust-lang#140031 (compiletest: Fix deadline bugs in new executor) - rust-lang#140072 (handle function alignment in miri) - rust-lang#140104 (Fix auto diff failing on inherent impl blocks) - rust-lang#140124 (Update books) - rust-lang#140144 (Handle another negated literal in `eat_token_lit`.) - rust-lang#140149 (test_nan: ensure the NAN contant is quiet) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#139921 - Kivooeo:master, r=WaffleLapkin improve diagnostic for raw pointer field access with -> This PR enhances the error messages emitted by the Rust compiler when users attempt to use the `->` operator for field access on raw pointers or when dereferencing is needed. The changes aim to provide clearer guidance, by suggesting the correct use of the `.` operator and explicit dereferencing. **Before:** ``` help: `xs` is a raw pointer; try dereferencing it | LL | (*xs)->count += 1; | ++ + ``` **Now:** ``` help: use `.` on a dereferenced raw pointer instead | LL - xs->count += 1; LL + (*xs).count += 1; | ``` I added extra clarification in the message. Since this error occurs in the parser, we can't be certain that the type is a raw pointer. That's why the message includes only a small note in brackets. (In contrast, the message above is emitted in HIR, where we *can* check whether it's a raw pointer.) **Before:** ``` --> main.rs:11:11 | 11 | xs->count += 1; | ^^ | = help: the . operator will dereference the value if needed ``` **After:** ``` --> main.rs:11:11 | 11 | xs->count += 1; | ^^ | = help: the `.` operator will automatically dereference the value, except if the value is a raw pointer ```

This PR enhances the error messages emitted by the Rust compiler when users attempt to use the
->operator for field access on raw pointers or when dereferencing is needed. The changes aim to provide clearer guidance, by suggesting the correct use of the.operator and explicit dereferencing.Before:
Now: