Skip to content

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

Merged
merged 1 commit into from
Jun 3, 2016
Merged

Conversation

GuillaumeGomez
Copy link
Member

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",
Copy link
Member

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.

Copy link
Member

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

Copy link
Member

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)

Copy link
Member Author

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?

Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@GuillaumeGomez GuillaumeGomez force-pushed the improve_helps branch 3 times, most recently from 4ec36d2 to 162d93a Compare May 27, 2016 14:42
@GuillaumeGomez
Copy link
Member Author

@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, \
Copy link
Member

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?

Copy link
Member

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

@steveklabnik
Copy link
Member

@jonathandturner what do you think of this? I'm not sure about this capitalization

@GuillaumeGomez
Copy link
Member Author

The help messages aren't supposed to start with capital letters.

@sophiajt
Copy link
Contributor

@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.

@sophiajt
Copy link
Contributor

sophiajt commented Jun 1, 2016

@GuillaumeGomez - can you add some tests to show off the new functionality? None of them seem to test the format!("{def} {module} cannot be used as an expression" line

@GuillaumeGomez
Copy link
Member Author

Sure.

@GuillaumeGomez
Copy link
Member Author

@jonathandturner: Done.

@sophiajt
Copy link
Contributor

sophiajt commented Jun 2, 2016

@bors: r+

@bors
Copy link
Collaborator

bors commented Jun 2, 2016

📌 Commit f4e6f3c has been approved by jonathandturner

@bors
Copy link
Collaborator

bors commented Jun 2, 2016

⌛ Testing commit f4e6f3c with merge 5b7d8af...

@bors
Copy link
Collaborator

bors commented Jun 2, 2016

💔 Test failed - auto-win-gnu-64-opt

@GuillaumeGomez
Copy link
Member Author

The run-pass tests worked on my linux. So if anyone has an idea of what happened?

@GuillaumeGomez
Copy link
Member Author

@bors: retry

bors added a commit that referenced this pull request Jun 3, 2016
@bors
Copy link
Collaborator

bors commented Jun 3, 2016

⌛ Testing commit f4e6f3c with merge 0646e8a...

@bors bors merged commit f4e6f3c into rust-lang:master Jun 3, 2016
@GuillaumeGomez GuillaumeGomez deleted the improve_helps branch June 3, 2016 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants