Closed
Description
Is this a known issue?
Consider the following setup:
mod foo {
pub struct Bar<T>(pub T);
}
You can construct a Bar
:
let _ = foo::Bar::<i32>(42);
Now I want to try it with a macro.
macro_rules! construct {
($strukt:path, $val:expr) => {
$strukt($val)
}
}
The obvious thing doesn't parse at all:
let _ = construct!(foo::Bar::<i32>, 42); // ERROR
// ^ unexpected token `::`
We need to remove the second ::
, which makes things inconsistent with the macro-less syntax:
let _ = construct!(foo::Bar<i32>, 42); // ok
Why this inconsistency? It seems like a struct constructor isn't really a path
. But that's the only macro fragment that can be used in that position (besides ident
and tt
).