Skip to content

Cryptic error on crate root import #104276

Closed
@SparkyPotato

Description

@SparkyPotato

Given the following code:

use crate::{self};

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=edadec50c25bbafc952c63f878b76af5

The current output is:

error: crate root imports need to be explicitly named: `use crate as name;`
 --> src/lib.rs:1:5
  |
1 | use crate::{self};
  |     ^^^^^

warning: unused import: `self`
 --> src/lib.rs:1:13
  |
1 | use crate::{self};
  |             ^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

Ideally the output should look like:

error: crate root imports need to be explicitly named: `self as name`
 --> src/lib.rs:1:5
  |
1 | use crate::{self};
  |             ^^^^

This happens on both stable and the latest nightly.

Metadata

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