You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
error: no rules expected the token const
--> src/main.rs:3:18
|
3 | let _ = vec![const { 1 }; 0];
| ^^^^^ no rules expected this token in macro call
|
= note: while trying to match end of macro
It seems that, macro could not recognize const { 1 } as a block expression, which leads to the error.
What's more, with adding an unnecessary bracket, let _ = vec![(const { 1 }); 0];, the code compiles, but an warning about unnecessary bracket generated, which suggests me delete the unnecessary bracket and facing the error directly.
The text was updated successfully, but these errors were encountered:
Edit: It works in edition 2024 and it's a breaking change to make it work in edition 2021. So the appropriate action is suppress the unused paren lint in edition 2021 I guess. See #126457
Indeed this looks like a duplicate of the two above linked issues, so closing in favor of them. If there is a reason to keep this open separately, let us know! Thanks!
saethlin
added
A-macros
Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)
and removed
needs-triage
This issue may need triage. Remove it if it has been sufficiently triaged.
labels
Sep 12, 2024
I tried this code:
I expected to see this happen: Compiles.
Instead, this happened:
error: no rules expected the token
const
--> src/main.rs:3:18
|
3 | let _ = vec![const { 1 }; 0];
| ^^^^^ no rules expected this token in macro call
|
= note: while trying to match end of macro
Meta
rustc --version --verbose
:It seems that, macro could not recognize
const { 1 }
as a block expression, which leads to the error.What's more, with adding an unnecessary bracket,
let _ = vec![(const { 1 }); 0];
, the code compiles, but an warning about unnecessary bracket generated, which suggests me delete the unnecessary bracket and facing the error directly.The text was updated successfully, but these errors were encountered: