Skip to content

replace qualified path with use adds to pub use, should not #5657

@jbr

Description

@jbr

First of all, thank you so much for rust-analyzer! recent changes have made it so much more pleasant to write rust in emacs!

I especially appreciate the "replace qualified path with use" code action, and recently noticed this behavior. Given this contrived example:

pub use std::sync::Mutex;

fn main() {
    let _: std::sync::Arc<()>;
}

If I move the insertion point to Arc and execute "replace qualified path with use," we get:

pub use std::sync::{Arc, Mutex};

fn main() {
    let _: Arc<()>;
}

However, what I would expect is:

pub use std::sync::Mutex;
use std::sync::Arc;

fn main() {
    let _: Arc<()>;
}

Adding something to a pub use changes the external api of a module, but in other circumstances "replace qualified path with use" is just a code-organizing refactor that changes nothing about the meaning of the file.

I'd love to dig into fixing this, but figured I'd file first to confirm that this is a bug. Thanks again!


$ rust-analyzer --version
rust-analyzer 33e53d4
$ rustc --version
rustc 1.47.0-nightly (6c8927b0c 2020-07-26)

Metadata

Metadata

Assignees

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