Skip to content

Import suggestions suggest inserting imports in the wrong place #42835

Closed
@nrc

Description

@nrc

For this kind of error:

pub mod foo {
    struct Foo;
}

fn main() {
    let a = Foo;
}

We get an error like

error[E0425]: cannot find value `Foo` in this scope
  --> <anon>:10:14
   |
10 |     let a = Foo;
   |             ^^^ not found in this scope
   |
help: possible candidate is found in another module, you can import it into scope
   | use foo::Foo;

Which is good. But if you put this whole example in a submodule and then look at the json error, the suggestion is add the import to the enclosing module, not the submodule, which is incorrect.

cc #42823, @oli-obk

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions