-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-decl-macros-2-0Area: Declarative macros 2.0 (#39412)Area: Declarative macros 2.0 (#39412)
Description
Consider this hygiene demonstration (playground):
#![feature(decl_macro)]
macro x() {
println!("x");
}
macro y() {
x!(); // This `x` identifier is in a fresh hygiene scope within `y`,
macro x() { println!("y"); } // so it resolves to this definition.
}
fn main() {
y!();
}
This prints "y"
, as expected.
However, if we 'launder' the definition macro x()
using an identity macro (playground):
#![feature(decl_macro)]
macro id($($tt:tt)*) {
$($tt)*
}
macro x() {
println!("x");
}
macro y() {
x!();
id!(macro x() { println!("y"); }); // What is the scope of this `x`?
}
fn main() {
y!();
}
We get an error that the invocation of x
is ambiguous.
Is this the expected behaviour?
alexreg
Metadata
Metadata
Assignees
Labels
A-decl-macros-2-0Area: Declarative macros 2.0 (#39412)Area: Declarative macros 2.0 (#39412)