-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Macros: limitation in the expression parser for <$:path>::<ident> #48067
Comments
cc @jseyfried This is known issue, but I don't know how hard it would be to make it "just work". |
We can even do |
I just ran into this myself. |
No progress, someone needs to try implementing this and make a PR. |
I see.. thanks for the quick response! |
I just run into a variation of this issue today. I was trying to append another struct Foo;
macro_rules! test {
(inner, $tr: path) => {
impl $tr for Foo {}
};
($cr: path) => { test!(inner, $cr::Buf); }
}
test!(bytes); This generates an |
Me too encounter the problem. As workaround I used pattern |
@Wandalen life saver!. I ran into this issue trying to write a macro that adds macro_rules! all_owned {
($first:ident$(::$rest:ident)* { $($key:ident:$value:expr,)* }) => {
$first$(::$rest)* {
$($key: ($value).to_owned(),)*
}
};
} |
For some reason $path::whatever is not a valid `path` according to rustc. See: - nextest-rs/datatest-stable#4 - rust-lang/rust#48067
Background: https://users.rust-lang.org/t/macros-using-path-tokens-with-format-args/15480
When passing in a
path
token to a macro, then trying to suffix the metavariable with::<ident>
(or more), the parser cannot recognize the whole thing as an:expr
, which causes failures on calls to macros likeformat_args!
.Repro:
It fails with three instances of this error (with
RUSTFLAGS='-Z external-macro-backtrace'
):A workaround is to use:
but would be great if we could just use:
I couldn't find an existing report. I'm guessing it falls under RFE.
The text was updated successfully, but these errors were encountered: