Erroneous unused_unsafe diagnostic for macro invocations #94912
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: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=4fc81da81334f7865f292f98a62735a3
The current output is:
This is obviously wrong, because
macro_inner!
is also invoked at line 14, in themain
function, outside anunsafe
block. The analyzer seems to only take in account the invocation occurring inside themacro_outer!
expansion during theunused_unsafe
check.Although it makes technical sense to perform the analysis that way, the result is that an incorrect piece of advice is given to the user ("This
unsafe
specifier is unnecessary, remove it"). Here, removing theunsafe
block breaks the code, for the first invocation.Tested on stable 1.58.1 and nightly 1.61.0 (2022-02-23).
EDIT: still present on 1.67.0 (2022-11-02).
PS: Sorry if this is not in the right triage category, I wasn't sure whether it would better fit the "Diagnostics" or the "Bug" label.
The text was updated successfully, but these errors were encountered: