Skip to content

"Expand macro recursively" no longer works for custom derives #21712

@SludgePhD

Description

@SludgePhD

rust-analyzer version: 0.3.2803-standalone

rustc version: 1.93.0

editor or extension: VS Code

relevant settings: none

code snippet to reproduce:
lib.rs:

#[derive(Trait)]
struct S;

mac/lib.rs:

use proc_macro::{Literal, TokenStream, TokenTree};

#[proc_macro_derive(Trait)]
pub fn derive(item: TokenStream) -> TokenStream {
    let string = item.to_string();
    TokenStream::from_iter([TokenTree::Literal(Literal::string(&string))])
}

Placing the cursor in the Trait identifier no longer highlights Trait as a use (as it does for other traits), and "expand macro recursively" doesn't work (it opens a file that only contains "Not available").

Adding Default before Trait in the list of derives fixes the issue, apparently permanently (removing Default again keeps Trait working).

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions