-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
fix the false 'defined here' messages #82220
Conversation
r? @varkor (rust-highfive has picked a reviewer for you, use r? to override) |
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.
I don't know if adding the note is more helpful since it felt redundant. The error at the top already says so.
expected function, found `Empty2`
And we show
note: unit struct `Empty2` is not a function
If it errors with "expected function" means Empty2
is not a function right? Why do we need to repeat?
Thanks for the review @pickfire. I agree, I'll remove that redundant note. By doing so, the local variable mistake is also fixed. |
@varkor This PR is now ready for review. |
@rustbot label +S-waiting-on-author -S-waiting-on-review |
@rustbot label -S-waiting-on-author +S-waiting-on-review |
If you could address the last two comments and squash the commits, I think this is good to go! |
There is another case that I don't think this handles: const FOO: usize = 0;
fn main() {
FOO();
} Errors:
|
Perhaps the fix would be also checking for |
@rustbot label +S-waiting-on-author -S-waiting-on-review |
cedf24a
to
4e78e7b
Compare
Sorry for taking a while, I was on vacation. @varkor, I believed I have addressed all your comments. @camelid I did the check that you have suggested but it does bring us back to the original problem, like this:
It should say |
This comment has been minimized.
This comment has been minimized.
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.
This looks great @henryboisdequin, thanks! Could you squash your commits? Then it's good to go. |
6e027cb
to
0757b82
Compare
@varkor Commits are squashed ✅ |
@henryboisdequin: there are some commits that don't appear to be squashed. It's fine to separate different changes into separate commits, but when later commits are reverting changes in previous commits, it just creates churn (which makes tools like |
0757b82
to
7d85592
Compare
@varkor Done |
@henryboisdequin: thanks for improving this diagnostic! @bors r+ |
📌 Commit 7d85592713c495e4b746c06e78bd8f90ab6653cd has been approved by |
7d85592
to
d7cb66d
Compare
📌 Commit d7cb66d has been approved by |
Rollup of 16 pull requests Successful merges: - rust-lang#75807 (Convert core/num/mod.rs to intra-doc links) - rust-lang#80534 (Use #[doc = include_str!()] in std) - rust-lang#80553 (Add an impl of Error on `Arc<impl Error>`.) - rust-lang#81167 (Make ptr::write const) - rust-lang#81575 (rustdoc: Name fields of `ResolutionFailure::WrongNamespace`) - rust-lang#81713 (Account for associated consts in the "unstable assoc item name colission" lint) - rust-lang#82078 (Make char and u8 methods const) - rust-lang#82087 (Fix ICE caused by suggestion with no code substitutions) - rust-lang#82090 (Do not consider using a semicolon inside of a different-crate macro) - rust-lang#82213 (Slices for vecs) - rust-lang#82214 (Remove redundant to_string calls) - rust-lang#82220 (fix the false 'defined here' messages) - rust-lang#82313 (Update normalize.css to 8.0.1) - rust-lang#82321 (AST: Remove some unnecessary boxes) - rust-lang#82364 (Improve error msgs when found type is deref of expected) - rust-lang#82514 (Update Clippy) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Closes #80853.
Take this code:
Previously, the error message would be this:
This is incorrect as
S
is not defined in the function arguments,thing
is defined there. With this change, the following is emitted:As you can see, this error message points out that
thing
is of typeS
and later in a note, thatS
is not a function. This change does seem like a downside for some error messages. Take this example:As you can see, the error message shows that the definition of
Empty2
is of typeEmpty2
. Although this isn't wrong, it would be more helpful if it would say something like this (which was there previously):If there is a better way of doing this, where the
Empty2
example would stay the same as without this change, please inform me.Update: This is now fixed
CC @camelid