Closed
Description
I tried this code:
macro_rules! impl_primitive {
($ty:ty) => { impl_primitive!(impl $ty);};
(impl $ty:ty) => { fn a(_: $ty) {} }
}
impl_primitive! { u8 }
I expected to see this happen:
Macro is expanded to fn a(_: u8) {}
Instead, this happened:
On stable 1.67
it works as expected.
On beta 1.68
and nightly 1.69
it fails with the following error
error: expected a trait, found type
--> src/lib.rs:6:19
|
2 | ($ty:ty) => { impl_primitive!(impl $ty);};
| ------ while parsing argument for this `ty` macro fragment
...
6 | impl_primitive! { u8 }
| ^^
It is probably caused by ty
fragment that now treats impl
as a start of impl Trait
type.
So makes sense. But breaks existing code :)