Skip to content

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

Open

Description

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsT-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