rust-lang/rust-analyzer

Flyimport breaks macro import when a macro and a module have the same name

Closed this issue · 1 comments

rust-analyzer version: 0.3.2593-standalone

rustc version: 1.92.0-nightly (2cb4e7d 2025-10-04)

editor or extension: VSCodium (extension ver. 0.3.2593)

relevant settings: Imports > Granularity: Group = Crate, Imports > Group: Enable = false, Imports: Prefix = crate

code snippet to reproduce:

use alloc::vec;

fn foo() {
    let x = vec![1, 2, 3];
    let y = Ve<|>
}

Flyimport offers to import alloc::vec::Vec (at least in a #![no_std] crate). Accepting its suggestion yields:

use alloc::vec::{self, Vec};

fn foo() {
    let x = vec![1, 2, 3];
    let y = Vec
}

... which means that vec! is no longer imported:

error: cannot find macro `vec` in this scope
 --> kernel/src/ra_issue.rs:4:13
  |
4 |     let x = vec![1, 2, 3];
  |             ^^^
  |
note: `vec` is imported here, but it is a module, not a macro
 --> kernel/src/ra_issue.rs:1:18
  |
1 | use alloc::vec::{self, Vec};
  |                  ^^^^
help: consider importing this macro
  |
1 + use alloc::vec;
  |

Duplicate of #20790