Skip to content

Type ascription syntax can subtly change the behaviour of macros #30531

Closed
@jonas-schievink

Description

@jonas-schievink

In the wild: phsym/prettytable-rs#11

This program prints "1" on stable and beta, but "0" on nightly:

macro_rules! cell {
    ($value:expr) => { 0 };
    ($style:ident : $value:expr) => { 1 };
}

fn main() {
    println!("{}", cell!(t : T));
}

Originally reported by @hoodie

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)T-langRelevant to the language team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.relnotesMarks issues that should be documented in the release notes of the next release.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions