intellij-rust / intellij-rust

Rust plugin for the IntelliJ Platform
https://intellij-rust.github.io
MIT License
4.53k stars 380 forks source link

Macros in proc-macro crates resolved incorectly #9478

Open neonaot opened 2 years ago

neonaot commented 2 years ago

Environment

Problem description

There are two macros with the same name, and plugin resolved imported one as macros from line 9.

image

Working code:

image

Steps to reproduce

main.rs:

use myprocmacro::{Builder};

#[derive(Builder)]
struct Foo {
    x: u8
}

fn main() {
    let t = Foo{x: 2};
//    Builder!();
    println!("{}", answer());
}

lib.rs:

use proc_macro::TokenStream;

#[proc_macro_derive(Builder)]
pub fn builder2(_item: TokenStream) -> TokenStream {
    "fn answer() -> u32 {  42 }".parse().unwrap()
}

macro_rules! Builder {
    () => {println!("hello")};
}
dima74 commented 2 years ago

Probably should support multiresolve in VisItem.scopedMacroToPsi and then do filtration by visibility