rust-analyzer icon indicating copy to clipboard operation
rust-analyzer copied to clipboard

Unresolved import with `macro_rules_attribute`

Open ModProg opened this issue 2 years ago • 2 comments

rust-analyzer version: rust-analyzer 1.69.0-nightly (8996ea9 2023-02-09)

rustc version: rustc 1.67.1 (d5a82bbd2 2023-02-07)

The following code runs/compiles fine, but in rust-analyzer yields an unresoved import error on use module::Struct, that seems to be caused by apply. Importing from the parent module works without error (i.e. use crate::NonModule does not produce any error).

#[macro_use]
extern crate macro_rules_attribute;

attribute_alias! {
    #[apply(Test)] = #[derive(Debug)];
}

mod module {
    use crate::NonModule;

    #[apply(Test)]
    pub struct Struct(pub NonModule);
}

use module::Struct;

#[apply(Test)]
pub struct NonModule;

fn main() {
    println!("{:?}", Struct(NonModule));
    println!("{NonModule:?}");
}

ModProg avatar Feb 10 '23 10:02 ModProg