Hi,
I'm pretty new to rust - so I'm not completely sure if this is a bug or a feature request (and there is still the possibility that I'm doing something wrong).
rust-analyzer 1.98.0 (88d9e12a 2026-08-18)
I want to extract a struct into its own module using "Extract module", but when the struct is already imported via a use binding, the assist adds a redundant qualifier to usages of that struct instead of updating the existing import.
There are two files, main.rs and my_module.rs
// main.rs
use crate::my_module::{First, Second};
mod my_module;
fn main() {
let first = First {};
let second = Second {};
}
// my_module.rs
pub(crate) struct First {}
pub(crate) struct Second {}
Running "Extract module" on struct First results in the following code:
// main.rs
use crate::my_module::{Second, modname::First}; // <- already imported
mod my_module;
fn main() {
let first = modname::First {}; // <- qualifier added
let second = Second {};
}
and
// my_module.rs
mod modname {
pub(crate) struct First {}
}
pub(crate) struct Second {}
The visibility is quickly corrected by running "Change visibility to pub(crate)".
The problem is that the usage of First is now qualified with modname::, even though the import was already updated to bring First into scope directly.
Hi,
I'm pretty new to rust - so I'm not completely sure if this is a bug or a feature request (and there is still the possibility that I'm doing something wrong).
rust-analyzer 1.98.0 (88d9e12a 2026-08-18)
I want to extract a struct into its own module using "Extract module", but when the struct is already imported via a use binding, the assist adds a redundant qualifier to usages of that struct instead of updating the existing import.
There are two files, main.rs and my_module.rs
Running "Extract module" on struct First results in the following code:
and
The visibility is quickly corrected by running "Change visibility to pub(crate)".
The problem is that the usage of First is now qualified with modname::, even though the import was already updated to bring First into scope directly.