Skip to content

Unhelpful error message for missing crate in uses import #56821

Closed
@fabric-and-ink

Description

@fabric-and-ink

This problem occurs with the new path rules in edition 2018. If the crate keyword from a uses import is missing, the current error message is not very helpful. For example:

mod bla {
    pub struct Bla;
}

use bla::Bla;

returns on stable, beta and nightly the following error message:

error[E0658]: imports can only refer to extern crate names passed with `--extern` on stable channel (see issue #53130)
 --> src/main.rs:9:5
  |
5 | / mod bla {
6 | |     pub struct Bla;
7 | | }
  | |_- not an extern crate passed with `--extern`
8 | 
9 |   use bla::Bla;
  |       ^^^
  |
note: this import refers to the module defined here
 --> src/main.rs:5:1
  |
5 | / mod bla {
6 | |     pub struct Bla;
7 | | }
  | |_^

warning: unused import: `bla::Bla`
 --> src/main.rs:9:5
  |
9 | use bla::Bla;
  |     ^^^^^^^^
  |
  = note: #[warn(unused_imports)] on by default

The compiler looks for a crate bla but doesn't find one, therefore the error message. I'm not sure, how this relates to the upcoming decision regarding the efforts for path clarity. But I stumbled over this several times now, out of habit...

(If this issue is accepted, I would like to improve it :) I would probably need mentoring though.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions