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

"E0432 unresolved import" on the same line should emit one diagnostic #53359

Closed
estebank opened this issue Aug 14, 2018 · 5 comments
Closed

"E0432 unresolved import" on the same line should emit one diagnostic #53359

estebank opened this issue Aug 14, 2018 · 5 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one.

Comments

@estebank
Copy link
Contributor

Currently when writing use foo::{bar, baz, qux} when foo exists but none of bar, baz and qux do, we emit one diagnostic per unresolved import. We should collect these onto a single multispan error.

@estebank estebank added C-enhancement Category: An issue proposing an enhancement or a PR with one. A-diagnostics Area: Messages for errors, warnings, and lints labels Aug 14, 2018
@PramodBisht
Copy link
Contributor

@estebank I would like to take this on if you are not planning to solve it yourself. It may take me sometime to solve it though. BTW, how you are planning to show the diagnostic message.

@estebank
Copy link
Contributor Author

I would like to take this on if you are not planning to solve it yourself.

Go ahead!

It may take me sometime to solve it though.

That it's fine.

BTW, how you are planning to show the diagnostic message.

My thinking is that it should look similar to what it already does. The approach I'd take would be to just collect all of the unresolved imports for a single use statement in a vector and then emit an error using the spans of those turned into a MultiSpan, and adding a span label for each one of them that reads the same as it currently does.

@PramodBisht
Copy link
Contributor

@estebank I have created a basic structure to fix the issue, now I am stuck in a situation where I need to show help like did you mean ...? How I should display that?

@PramodBisht
Copy link
Contributor

Now this type of output we are getting

error[E0432]: unresolved imports: `std::time::foo`, `std::time::bar`, `std::time::buzz`, `std::time::abc`, `std::time::def`
 --> /tmp/test.rs:1:17
  |
1 | use std::time::{foo, bar, buzz};
  |                 ^^^  ^^^  ^^^^
2 | use std::time::{abc, def};
  |                 ^^^  ^^^

warning: unused imports: `bar`, `buzz`, `foo`
 --> /tmp/test.rs:1:17
  |
1 | use std::time::{foo, bar, buzz};
  |                 ^^^  ^^^  ^^^^
  |
  = note: #[warn(unused_imports)] on by default

warning: unused imports: `abc`, `def`
 --> /tmp/test.rs:2:17
  |
2 | use std::time::{abc, def};
  |                 ^^^  ^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0432`.

instead of

error[E0432]: unresolved import `std::time::foo`
 --> /tmp/test.rs:1:17
  |
1 | use std::time::{foo, bar, buzz};
  |                 ^^^ no `foo` in `time`

error[E0432]: unresolved import `std::time::bar`
 --> /tmp/test.rs:1:22
  |
1 | use std::time::{foo, bar, buzz};
  |                      ^^^ no `bar` in `time`

error[E0432]: unresolved import `std::time::buzz`
 --> /tmp/test.rs:1:27
  |
1 | use std::time::{foo, bar, buzz};
  |                           ^^^^ no `buzz` in `time`

error[E0432]: unresolved import `std::time::abc`
 --> /tmp/test.rs:2:17
  |
2 | use std::time::{abc, def};
  |                 ^^^ no `abc` in `time`

error[E0432]: unresolved import `std::time::def`
 --> /tmp/test.rs:2:22
  |
2 | use std::time::{abc, def};
  |                      ^^^ no `def` in `time`

warning: unused imports: `bar`, `buzz`, `foo`
 --> /tmp/test.rs:1:17
  |
1 | use std::time::{foo, bar, buzz};
  |                 ^^^  ^^^  ^^^^
  |
  = note: #[warn(unused_imports)] on by default

warning: unused imports: `abc`, `def`
 --> /tmp/test.rs:2:17
  |
2 | use std::time::{abc, def};
  |                 ^^^  ^^^

error: aborting due to 5 previous errors

For more information about this error, try `rustc --explain E0432`.

bors added a commit that referenced this issue Sep 10, 2018
#53359: putting multiple unresolved import on single line

r? @estebank
Here is WIP implementation of #53359
this PR have clubbed multiple unresolved imports into a single line.
I think still two things need to improve like giving specific `label message` for each span of multi_span(how we can do this?) and second we are getting a warning while compiling, stating something like `E0432` have been passed before.
@PramodBisht
Copy link
Contributor

I think now this can be closed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

No branches or pull requests

2 participants