There are 3 kinds of path styles:
-
Module, generic parameters disallowed i.e.
Result::Err. These styles of paths are used in:
- Attributes
#[path::attribute]
- Macro invocations
path::macro!()
- Module reference (
pub(restricted) and use)
-
Type, double-colons prohibited before generic parameters i.e.
Result<T, U>::Err. These styles of paths are used in:
- Type and trait references
- Macros 1.0
:path
-
Expression, double-colons required before generic parameters i.e.
Result::<T,U>::Err
(In a qualified path <P as Trait>::Q, if the whole path uses style X, the inner path P is also parsed using style X.)
The oddity is $x:path is parsed where a type is expected (i.e. Vec<i32>::new is parsed like an inner type called new inside the struct Vec<i32>). After a path is parsed the style information is thrown out, so it can be used like an expression $x(). This causes the strange syntax mismatch here.
I’m not sure if this is something Macros 2.0 (#![feature(decl_macro)]) is going to improve or worsen here, as I heard that $x there will eventually just mean the token stream Vec<i32>::new without any special meaning, so it will become a syntax error.