Skip to content

proc macro attributes considered to be unresolvedReference #10935

@jhgg

Description

@jhgg

consider the following code used w/ the serde library:

use serde::Deserialize;

#[derive(Deserialize)]
struct Foo {
    #[serde(default)]
   // ^^^^^ unresolvedReference 
    bar: u64,
}

We should be able to figure out if this is a valid attribute or not, by looking at the things the structs derive from and looking at the attributes for each proc macro to compute a list of identifiers that are valid within this context:

// in serde_derive/src/lib.rs
#[proc_macro_derive(Deserialize, attributes(serde))]
                                         // ^^^^^ we should find these.
pub fn derive_deserialize(input: TokenStream) -> TokenStream {
    let mut input = parse_macro_input!(input as DeriveInput);
    de::expand_derive_deserialize(&mut input)
        .unwrap_or_else(to_compile_errors)
        .into()
}

Bonus points would be to have a hover implementation that shows which proc macro's are consuming this attribute as well!

rust-analyzer version: 6434ada 2021-12-05 dev
rustc-version: 1.57.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-idegeneral IDE featuresC-featureCategory: feature request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions