Skip to content
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

use structured suggestions for E0432 #58498

Merged
merged 1 commit into from
Mar 10, 2019
Merged

Conversation

euclio
Copy link
Contributor

@euclio euclio commented Feb 15, 2019

No description provided.

@rust-highfive
Copy link
Collaborator

r? @petrochenkov

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 15, 2019
Copy link
Member

@zackmdavis zackmdavis left a comment

Choose a reason for hiding this comment

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

💖 thanks!! (one wording suggestion)

String::from("unresolved import"),
Some((
ident.span,
String::from("a similar path resolves"),
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
String::from("a similar path resolves"),
String::from("a similar path exists"),

Word choice: I think "exists" feels less stilted than "resolves" here.

note,
suggestion: Some((
span,
String::from("a similar path resolves"),
Copy link
Member

Choose a reason for hiding this comment

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

as above

@zackmdavis
Copy link
Member

r? @zackmdavis

@bors delegate+

@bors
Copy link
Contributor

bors commented Feb 16, 2019

✌️ @euclio can now approve this pull request

| ^^^^^---
| | |
| | help: a similar name exists in the module: `bar`
| no `baz` in `zed`
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to move the "no baz in zed" message into the main error message and have the help end up in the position that it was previously? Not sure if our emitters will do that though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean an error message like:

-> $DIR/import.rs:2:5
   |
LL | use zed::baz; //~ ERROR unresolved import: no `baz` in `zed` [E0432]
   |          --- help: a similar name exists in the module: `bar`
   | 

Copy link
Contributor

Choose a reason for hiding this comment

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

oh yea, that's even better than what I had in mind.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

error[E0432]: unresolved imports `zed::baz`, `zed::bay`
 --> src/test/ui/import.rs:7:11
  |
7 | use zed::{baz, bay};
  |           ^^^  ^^^ no `bay` in `zed`
  |           |
  |           no `baz` in `zed`
help: a similar name exists in the module
  |
7 | use zed::{bar, bay};
  |           ^^^
help: a similar name exists in the module
  |
7 | use zed::{baz, bar};
  |                ^^^

Well, my idea won't work with the multi-import case, though.

Copy link
Contributor

Choose a reason for hiding this comment

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

That message still has the no bay in zed messages, if we eliminate them entirely, at least one of the help messages should show up in the correct space

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, that's the output of my code as it stands. I think that removing the label entirely would regress the error message if there's no suggestion. I'm not sure that making them mutually exclusive would be better, either. @estebank, what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that for the last case shown here it is best to be conservative (and verbose). An option you have @euclio is to use span_suggestion_hidden (#58296) to display only the message without the code snippet, but you would have to explicitly write the found identifier in the message to be usable from the cli output (as opposed to VSCode):

error[E0432]: unresolved imports `zed::baz`, `zed::bay`
 --> src/test/ui/import.rs:7:11
  |
7 | use zed::{baz, bay};
  |           ^^^  ^^^ no `bay` in `zed`
  |           |
  |           no `baz` in `zed`
  = help: `bar`, which is similar to `baz`, exists in `zed`
  = help: `bar`, which is similar to `bay`, exists in `zed`

It'd be also neat to collect the suggestions to avoid suggesting the same name multiple times, but that's gold plating.

Copy link
Contributor

Choose a reason for hiding this comment

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

Feel free not to do this, I think that the output as is is already pretty good (modulo Zack's wording comments).

@Centril
Copy link
Contributor

Centril commented Feb 23, 2019

r? @estebank

@rust-highfive rust-highfive assigned estebank and unassigned zackmdavis Feb 23, 2019
@Dylan-DPC-zz
Copy link

ping from triage @estebank waiting for your review on this

@estebank
Copy link
Contributor

estebank commented Mar 4, 2019

Beyond @zackmdavis' comments and mine above, it looks good!

@euclio
Copy link
Contributor Author

euclio commented Mar 9, 2019

@estebank I've fixed the wording suggestions. I think I'll leave the label improvements to a future PR.

@estebank
Copy link
Contributor

estebank commented Mar 9, 2019

@bors r+

@bors
Copy link
Contributor

bors commented Mar 9, 2019

📌 Commit 4bbe883 has been approved by estebank

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 9, 2019
@bors
Copy link
Contributor

bors commented Mar 10, 2019

⌛ Testing commit 4bbe883 with merge 8ad727e...

bors added a commit that referenced this pull request Mar 10, 2019
use structured suggestions for E0432
@bors
Copy link
Contributor

bors commented Mar 10, 2019

☀️ Test successful - checks-travis, status-appveyor
Approved by: estebank
Pushing 8ad727e to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Mar 10, 2019
@bors bors merged commit 4bbe883 into rust-lang:master Mar 10, 2019
@euclio euclio deleted the e0432-suggestions branch March 13, 2019 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants