Skip to content

formatting removes part of qualified path inside macro #5005

@jsen-

Description

@jsen-

Pretty niche use case, but running rustfmt makes the code no longer compile.

#![feature(more_qualified_paths)]
macro_rules! show {
    ($ty:ty, $ex:expr) => {
        match $ex {
            <$ty>::A(_val) => println!("got a"), // formatting removes <$ty>::
            <$ty>::B => println!("got b"),
        }
    };
}

#[derive(Debug)]
pub enum Enum1 {
    A(u8),
    B,
}

fn main() {
    show!(Enum1, Enum1::B);
}
$ rustfmt --version
rustfmt 1.4.37-nightly (addb4da 2021-09-25)

Metadata

Metadata

Assignees

No one assigned

    Labels

    2x-port:pendingA-macrosArea: macros (procedural macros, macro_rules! macros, etc.)E-help-wantedCall for participation: help is requested to fix this issuegood first issueIssues up for grabs, also good candidates for new rustfmt contributors

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions