Skip to content

Macro hygiene change breaks Firefox builds. #76480

Closed
@emilio

Description

@emilio

The following program with paste = "0.1.12" compiles on stable (rustc 1.46.0 (04488afe3 2020-08-24)), but doesn't on Nightly (rustc 1.48.0-nightly (0e2c1281e 2020-09-07)).

This is minimized from Firefox source code, which doesn't build anymore with Rust Nightly.

To be fair, I'm surprised it built in the first place...

#[macro_use] extern crate paste;

#[derive(Clone, Copy)]
struct Bar {
    member: i32,
}

impl Bar {
    fn get_member(&self, _: i32, _: i32) -> i32 {
        self.member
    }
}

macro_rules! foo {
    ($fn_name:ident $(, $arg:ident)*) => {
        paste::expr! {
            Bar::[<get_ $fn_name>](&self.bar $(, $arg)* ,callback)
        }
    };
}

struct Foo {
    bar: Bar,
}

impl Foo {
    fn member(&self, n: i32, callback: i32) -> i32 {
        foo!(member, n)
    }
}

fn main() {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions