Skip to content

rustdoc: generate-macro-expansion produces incorrect expansion for macros in type position #150197

@el-ev

Description

@el-ev

Code

macro_rules! foo {
    () => {
        ()
    };
    ($baz:expr) => {
        [(); 1]
    };
}

fn bar() {
    let _: foo!();
    let _: foo!(42);
}

Reproduction Steps

rustdoc -Zunstable-options --generate-macro-expansion thefile.rs

Expected Outcome

  1. foo!() should expand to ().
  2. foo!(42) should expand to [(); 1].

Actual Output

  1. let _: foo!(); does not show an expansion toggle at all.
  2. let _: foo!(42); expands to let _: 1;
Image

Version

rustdoc 1.94.0-nightly (806c2a3 2025-12-19)

Additional Details

Tracking issue: #148222
Found while working on #150154

@rustbot label +A-macros +A-rustdoc-ui +B-unstable

Metadata

Metadata

Assignees

Labels

A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-rustdoc-uiArea: Rustdoc UI (generated HTML)C-bugCategory: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.T-rustdoc-frontendRelevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions