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

Feature request: Silence not-found error when a suggested import is already in-place but typo'd #84093

Open
jplatte opened this issue Apr 11, 2021 · 0 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints D-verbose Diagnostics: Too much output caused by a single piece of incorrect code. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@jplatte
Copy link
Contributor

jplatte commented Apr 11, 2021

When trying to import and then use an item, but there is a typo in the import (which rustc successfully provides a suggestion for), I think the usage of the item should not trigger a not-found error. Example with a trait method (playground):

use std::convert::Tryinto;

fn main() {
    let x = 0i32;
    let y: usize = x.try_into();
}

Currently triggers two errors, with the second one being redundant IMO:

error[E0432]: unresolved import `std::convert::Tryinto`
 --> src/lib.rs:1:5
  |
1 | use std::convert::Tryinto;
  |     ^^^^^^^^^^^^^^-------
  |     |             |
  |     |             help: a similar name exists in the module (notice the capitalization): `TryInto`
  |     no `Tryinto` in `convert`

error[E0599]: no method named `try_into` found for type `i32` in the current scope
 --> src/lib.rs:5:22
  |
5 |     let y: usize = x.try_into();
  |                      ^^^^^^^^ method not found in `i32`
  |
  = help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
  |
1 | use std::convert::TryInto;
  |
@jyn514 jyn514 added A-diagnostics Area: Messages for errors, warnings, and lints D-verbose Diagnostics: Too much output caused by a single piece of incorrect code. labels Apr 11, 2021
@estebank estebank added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Apr 13, 2021
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-verbose Diagnostics: Too much output caused by a single piece of incorrect code. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants