Skip to content

Duplicate resolution error messages when using both extern crate and use #91471

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

Open
mjptree opened this issue Dec 2, 2021 · 0 comments
Open
Assignees
Labels
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.

Comments

@mjptree
Copy link
Contributor

mjptree commented Dec 2, 2021

Due to recently merged PR #91045 duplicate error message can occur if a crate introduced via extern crate is not resolved successfully and subsequently symbol paths are derived via use from this missing crate.

Given the following code:

extern crate foo;

use foo::bar;

fn main() {
    bar::baz();
}

The current output is:

error[E0463]: can't find crate for `foo`
 --> src\main.rs:1:1
  |
1 | extern crate foo;
  | ^^^^^^^^^^^^^^^^^ can't find crate

error[E0433]: failed to resolve: use of undeclared crate or module `bar`
 --> src\main.rs:6:5
  |
6 |     bar::buzz();
  |     ^^^ use of undeclared crate or module `bar`

Ideally, a missing name should be issued for the missing crate and then silenced for names whose path is rooted in that crate:

error[E0463]: can't find crate for `foo`
 --> src\main.rs:1:1
  |
1 | extern crate foo;
  | ^^^^^^^^^^^^^^^^^ can't find crate

@rustbot claim

@mjptree mjptree 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 Dec 2, 2021
@mjptree mjptree changed the title Fix duplicate resolution error messages when using both extern crate and use Duplicate resolution error messages when using both extern crate and use Dec 2, 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 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

1 participant