Skip to content

suggest crate::... for "local" paths in 2018 #54230

Closed
@nikomatsakis

Description

@nikomatsakis

The following code, when compiled in Rust 2018, errors out (as expected). However, the error could be more helpful.

mod foo {
    type Bar = u32;
}

use foo::Bar;

fn main() {
    let x: Bar = 22;
}

Error:

error[E0463]: can't find crate for `foo`
 --> src/main.rs:5:5
  |
5 | use foo::Bar;
  |     ^^^ can't find crate

error: aborting due to previous error

but I think we should suggest something like

did you mean `crate::foo::Bar`?

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-edition-2018Area: The 2018 editionA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyT-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