Most dead code warnings don't work inside const _
#101532
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Given the following code:
The current output is:
Ideally the output should look like:
What's surprising is that adding
pub
changes the output to the expected one, even thoughpub
doesn't make any meaning onconst _: ()
:It's also interesting that the logic matches what happens with functions. For example, in:
the function
foo
itself and also only the variablea
are reported as unused, while the rest of the items don't get a warning:However, once
foo
is made public, all the items get warnings:Either way,
const _
should have different treatment due to being anonymous, but it's still a bit surprising that onlylet
variables get inside bothconst _
andfn foo
.The text was updated successfully, but these errors were encountered: