Skip to content

use suggestions for local paths are missing crate:: in edition 2018 #52202

Closed
@zackmdavis

Description

@zackmdavis

Consider the following program.

mod inner_mod {
    pub struct MyInnerStruct;
}

fn main() {
    let _s = MyInnerStruct {};
}

When compiled with --edition 2018 with the 6 July nightly, we get this error message:

error[E0422]: cannot find struct, variant or union type `MyInnerStruct` in this scope
 --> import_suggestion.rs:6:14
  |
6 |     let _s = MyInnerStruct {};
  |              ^^^^^^^^^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
  |
1 | use inner_mod::MyInnerStruct;
  |

error: aborting due to previous error

For more information about this error, try `rustc --explain E0422`.

But if we take the suggestion literally (and continue using the 2018 edition), inner_mod is presumed to be a crate:

error[E0463]: can't find crate for `inner_mod`
 --> import_suggestion.rs:1:5
  |
1 | use inner_mod::MyInnerStruct;
  |     ^^^^^^^^^ can't find crate

error: aborting due to previous error

A pull request is forthcoming.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions