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

diagnostics for E404 suggests use which already exists #120559

Closed
jendrikw opened this issue Feb 1, 2024 · 2 comments · Fixed by #120966
Closed

diagnostics for E404 suggests use which already exists #120559

jendrikw opened this issue Feb 1, 2024 · 2 comments · Fixed by #120966
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints D-confusing Diagnostics: Confusing error or lint that should be reworked. D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@jendrikw
Copy link
Contributor

jendrikw commented Feb 1, 2024

(A better title would be appreciated)

Code

use std::io::Read;

fn f<T: Read, U, Read>() {}

Current output

Compiling playground v0.0.1 (/playground)
error[E0404]: expected trait, found type parameter `Read`
 --> src/lib.rs:3:9
  |
1 | use std::io::Read;
  |              ---- you might have meant to refer to this trait
2 |
3 | fn f<T: Read, U, Read>() {}
  |         ^^^^     ---- found this type parameter
  |         |
  |         not a trait
  |
help: consider importing one of these items instead
  |
1 + use exr::io::Read;
  |
1 + use hyper::rt::Read;
  |
1 + use serde_json::de::Read;
  |
1 + use std::io::Read;
  |

Desired output

I like this part:

 --> src/lib.rs:3:9
  |
1 | use std::io::Read;
  |              ---- you might have meant to refer to this trait
2 |
3 | fn f<T: Read, U, Read>() {}
  |         ^^^^     ---- found this type parameter
  |         |
  |         not a trait

It could have a suggestion like did you mean : instead of ,, especially because ,<.>;: are very close to each other on a US keyboard and could very well be a typo.

Rationale and extra context

Applying the suggestion use std::io::Read will result in a compile error.

Other cases

No response

Rust Version

rustc 1.75.0 (82e1608df 2023-12-21)
binary: rustc
commit-hash: 82e1608dfa6e0b5569232559e3d385fea5a93112
commit-date: 2023-12-21
host: x86_64-unknown-linux-gnu
release: 1.75.0
LLVM version: 17.0.6

Also reproducable with current playground nightly (1.77.0)

Anything else?

No response

@jendrikw jendrikw added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 1, 2024
@clubby789 clubby789 added the D-confusing Diagnostics: Confusing error or lint that should be reworked. label Feb 1, 2024
@jendrikw
Copy link
Contributor Author

jendrikw commented Feb 3, 2024

I think the label D-invalid-suggestion might be fitting as well.

@rustbot
Copy link
Collaborator

rustbot commented Feb 4, 2024

Error: Parsing assign command in comment failed: ...' claim' | error: expected end of command at >| ' +D-invali'...

Please file an issue on GitHub at triagebot if there's a problem with this bot, or reach out on #t-infra on Zulip.

@rustbot rustbot added the D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. label Feb 4, 2024
@trevyn trevyn removed their assignment Feb 8, 2024
@chenyukang chenyukang self-assigned this Feb 12, 2024
@bors bors closed this as completed in 8e690fd Feb 14, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Feb 14, 2024
Rollup merge of rust-lang#120966 - chenyukang:yukang-fix-120599-resolve, r=pnkfelix

Remove importing suggestions when there is a shadowed typo candidate

Fixes rust-lang#120559
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 D-confusing Diagnostics: Confusing error or lint that should be reworked. D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants