Skip to content

"Replace qualified path with use" should replace all paths in the module #4836

@jonas-schievink

Description

@jonas-schievink

When running assists like "Implement missing members" or "Fill match arms", rust-analyzer will qualify all paths in the inserted code as necessary for them to resolve correctly. However, this can create rather long paths, which require many uses of the "Replace qualified path with use" assist to make the code more readable.

This could be fixed by having the "Replace qualified path with use" assist not just replace the path it is invoked on, but all paths in the module that refer to the imported item.

For example:

fn f(e: m::n::Enum) {
    match e {
        m::n::E<|>num::A => {}
        m::n::Enum::B => {}
        m::n::Enum::C => {}
        m::n::Enum::D => {}
    }
}

Invoking "Replace qualified path with use" once at this point should result in the code below:

fn f(e: Enum) {
    match e {
        Enum::A => {}
        Enum::B => {}
        Enum::C => {}
        Enum::D => {}
    }
}

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