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

Typo'd Imports Result in Confusing Error Message #76208

Open
jackie-scholl opened this issue Sep 1, 2020 · 2 comments
Open

Typo'd Imports Result in Confusing Error Message #76208

jackie-scholl opened this issue Sep 1, 2020 · 2 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-resolve Area: Path resolution C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@jackie-scholl
Copy link

jackie-scholl commented Sep 1, 2020

I wanted to use the chrono crate, so I added it to Cargo.toml and put an import at the top of main.rs: use chono::prelude::*, where I typo`d chrono as chono. I got this error message:

error[E0433]: failed to resolve: use of undeclared type or module `chono`
 --> src/main.rs:2:5
  |
2 | use chono::prelude::*;
  |     ^^^^^ use of undeclared type or module `chono`

I didn't see the typo, and I was confused because I thought I must have put the import in the wrong place, because it said I hadn't declared the module that I was declaring on that line. I checked the docs for E0433, and in the example given someone had forgotten to import the module at all, so I was surprised to see that error on an import line.

Meta

rustc --version --verbose:

rustc 1.45.0
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-unknown-linux-gnu
release: 1.45.0
LLVM version: 10.0
@jackie-scholl jackie-scholl added the C-bug Category: This is a bug. label Sep 1, 2020
@jonas-schievink jonas-schievink added A-diagnostics Area: Messages for errors, warnings, and lints A-resolve Area: Path resolution C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed C-bug Category: This is a bug. labels Sep 1, 2020
@petrochenkov
Copy link
Contributor

This is one of few cases for which typo suggestions are not yet implemented (#30197 (comment)).

@TaKO8Ki
Copy link
Member

TaKO8Ki commented Sep 28, 2021

@rustbot claim

the8472 added a commit to the8472/rust that referenced this issue Oct 13, 2021
…ebank

suggestion for typoed crate or module

Previously, the compiler didn't suggest similarly named crates or modules. This pull request adds a suggestion for typoed crates or modules.

rust-lang#76208

before:

```
error[E0433]: failed to resolve: use of undeclared type or module `chono`
 --> src/main.rs:2:5
  |
2 | use chono::prelude::*;
  |     ^^^^^ use of undeclared type or module `chono`
```

after:

```
error[E0433]: failed to resolve: use of undeclared type or module `chono`
 --> src/main.rs:2:5
  |
2 | use chono::prelude::*;
  |     ^^^^^
  |     |
  |     use of undeclared crate or module `chono`
  |     help: a similar crate or module exists: `chrono`
```
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Oct 13, 2021
…ebank

suggestion for typoed crate or module

Previously, the compiler didn't suggest similarly named crates or modules. This pull request adds a suggestion for typoed crates or modules.

rust-lang#76208

before:

```
error[E0433]: failed to resolve: use of undeclared type or module `chono`
 --> src/main.rs:2:5
  |
2 | use chono::prelude::*;
  |     ^^^^^ use of undeclared type or module `chono`
```

after:

```
error[E0433]: failed to resolve: use of undeclared type or module `chono`
 --> src/main.rs:2:5
  |
2 | use chono::prelude::*;
  |     ^^^^^
  |     |
  |     use of undeclared crate or module `chono`
  |     help: a similar crate or module exists: `chrono`
```
@TaKO8Ki TaKO8Ki removed their assignment Nov 29, 2022
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 A-resolve Area: Path resolution C-enhancement Category: An issue proposing an enhancement or a PR with one. 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.

4 participants