Fill match prioritises unimported Type over imported Type when names are the same
Diagnostics correctly shows Direction as imported - Up, Down, Left, Right
This is Direction from crate::core::Direction

Code Action incorrectly fills match with bevy::ui::Direction - Inherit, LeftToRight, RightToLeft
Bevy is included in this project, but not imported in this file.

- match works correctly if bevy is not included in the project (even if installed on system)
- match works correctly in the file that my Direction is declared
NeoVim with LSP rust-analyzer version: rust-analyzer 0.0.0 (427061da1 2022-06-19) rustc version: rustc 1.62.0 (a8314ef7d 2022-06-27)
Can you provide the code for this, or a separate reproduction?
This is the repo it occurs in for me: https://github.com/jroddev/bevy_snake I open src/food.rs in neovim with lsp+rust_analyzer add this piece of code
use crate::core::Direction;
fn use_dir(dir: &Direction) {
match dir {
}
}
instead of filling with create::core::Direction it fills with bevy::ui::Direction.
CLion fills crate::core::Direction here as expected.
I have tried to reproduce the issue in a smaller repository but it works as expected there.
Ah there is a use bevy::prelude::*; in this file, I imagine some part of the code is getting confused and picks the glob imported Direction over the explicit import...
Looked into this a bit, the following is a repro:
//- minicore: derive
//- /lib.rs crate:lib deps:dep
use crate::z::Direction;
mod z {
use dep::*;
#[derive()]
pub struct Direction {}
//^^^^^^^^^
}
fn use_dir(dir: &Direction$0) {}
//- /dep.rs crate:dep
pub struct Direction {}
This goto_def test fails, the important part is the derive, remove that and it succeeds...
Fixed by #13602
Oh my, how could I forget to link this when it is the very issue I started with :sweat_smile:
@Veykril Thanks for catching it, and also for your reduced repro, it helped a ton!