Skip to content

Suggestion for a typoed crate or module results in compile error #89592

Open
@TaKO8Ki

Description

@TaKO8Ki

This issue is

I implemented a suggestion for typoed crate or module in #89347. However there are still some edge cases.

Given the following code:

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=36133bfa20fc000bce25b7b1ea075df9

The current output is:

error[E0433]: failed to resolve: use of undeclared crate or module `my_cor`
  --> $DIR/extern-prelude-from-opaque-fail.rs:10:5
   |
LL |     my_cor::mem::drop(0);
   |     ^^^^^^ use of undeclared crate or module `my_cor`
   |
help: there is a crate or module with a similar name
   |
LL |     my_core::mem::drop(0);
   |     ~~~~~~~

error: aborting due to previous error

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

However if you apply this suggestion, you get a compiler error like the following.

error[E0433]: failed to resolve: use of undeclared crate or module `my_core`
  --> $DIR/extern-prelude-from-opaque-fail.rs:10:5
   |
LL |     my_core::mem::drop(0);
   |     ^^^^^^^ use of undeclared crate or module `my_core`

error: aborting due to previous error

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

Ideally the output should look like:

The compiler shouldn't suggest a crate or module name which you can't use.

error[E0433]: failed to resolve: use of undeclared crate or module `my_cor`
  --> $DIR/extern-prelude-from-opaque-fail.rs:10:5
   |
LL |     my_cor::mem::drop(0);
   |     ^^^^^^ use of undeclared crate or module `my_cor`
   |

error: aborting due to previous error

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

#89347 (comment) might help you.

Other things to do: #89347 (comment)

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.D-papercutDiagnostics: An error or lint that needs small tweaks.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions