-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Improve help messages for E0425 #33878
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
use `{module}::{ident}(..)`", | ||
module = path, | ||
ident = ident.node) | ||
} | ||
_ => { | ||
format!("Module `{module}` cannot be used as an expression", | ||
format!("`{module}` cannot be used as an expression", |
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.
we should suggest "module {module}" cannot be used if the path is not self, and mention that self
isn't available in static methods if we are in self.
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.
Oh, I see, it warns on other non-modules too, because traits and enums and self are modules. In that case, keep the current message but output something special for self
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.
(It would be nice if you can disambiguate between traits, enums, and real modules too, though that's a bit harder)
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.
(It would be nice if you can disambiguate between traits, enums, and real modules too, though that's a bit harder)
That's what I wanted to do at first but I couldn't find any information for this in the context. Do you know where I could find it?
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.
Check where the PathIsMod
is created, there's a Success(Module)
there. The module contains a def which you can match on.
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!
4ec36d2
to
162d93a
Compare
@Manishearth: Updated. Thanks for the tip! :) |
@@ -430,19 +431,20 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>, | |||
UnresolvedNameContext::PathIsMod(parent) => { | |||
err.help(&match parent.map(|parent| &parent.node) { | |||
Some(&ExprKind::Field(_, ident)) => { | |||
format!("To reference an item from the `{module}` module, \ | |||
format!("to reference an item from the `{module}` module, \ |
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.
Why are these being changed?
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.
Oh, I see, the things below. hmmmmmm
@jonathandturner what do you think of this? I'm not sure about this capitalization |
The help messages aren't supposed to start with capital letters. |
@steveklabnik - caps at the start of a hint? I think lower-case is what I've been seeing for other things, like notes, so it's probably okay. |
@GuillaumeGomez - can you add some tests to show off the new functionality? None of them seem to test the |
Sure. |
162d93a
to
9d530ea
Compare
@jonathandturner: Done. |
9d530ea
to
f4e6f3c
Compare
@bors: r+ |
📌 Commit f4e6f3c has been approved by |
⌛ Testing commit f4e6f3c with merge 5b7d8af... |
💔 Test failed - auto-win-gnu-64-opt |
The run-pass tests worked on my linux. So if anyone has an idea of what happened? |
@bors: retry |
Improve help messages for E0425 Fixes #33876. r? @Manishearth cc @steveklabnik cc @jonathandturner
Fixes #33876.
r? @Manishearth
cc @steveklabnik
cc @jonathandturner