Inappropriate unused_parens
for inline const
inside vec!
/macros
#126457
Labels
A-lints
Area: Lints (warnings about flaws in source code) such as unused_mut.
A-macros
Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)
C-bug
Category: This is a bug.
D-incorrect
Diagnostics: A diagnostic that is giving misleading or incorrect information.
F-inline_const
Inline constants (aka: const blocks, const expressions, anonymous constants)
L-unused_parens
Lint: unused_parens
S-has-mcve
Status: A Minimal Complete and Verifiable Example has been found for this issue
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/Weird.20interaction.20between.20vec!.5B.5D.20macro.20and.20inline.20const
In this example, the inline
const
must be wrapped in parentheses, in order to work insidevec!
under editions <2024:(playground)
However, notice that in the case of
vec![(const { vec![] }); 10]
, the compiler accepts the code but warns that the parentheses are unnecessary:The warning is incorrect, because removing the parentheses would result in an error under edition <2024.
(The
vec![(const { vec![] })]
case correctly reports no warning.)The text was updated successfully, but these errors were encountered: