-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
Closed
Labels
A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an ASTC-bugCategory: This is a bug.Category: This is a bug.
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); // okWhy 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).
Metadata
Metadata
Assignees
Labels
A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an ASTC-bugCategory: This is a bug.Category: This is a bug.