merged doctests: implicit unused overrides explicit attributes with no_run #130681
Labels
A-doctests
Area: Documentation tests, run by rustdoc
A-edition-2024
Area: The 2024 edition
C-bug
Category: This is a bug.
T-rustdoc
Relevant to the rustdoc team, which will review and decide on the PR/issue.
With the 2024 merged doctests, there is a slight change in behavior with regards to the unused lints with a
no_run
test. Because there is an implicit#![allow(unused)]
on each test when the test isno_run
(code), this overrides any#![doc(test(attr(...)))]
attributes.When building standalone, this doesn't happen because I believe this code checks for any doc test attributes before adding the
allow(unused)
.I tried this code:
On edition 2021, the above will fail because the
deny(warnings)
generates an error with#[deny(dead_code)]
implied by#[deny(warnings)]
. This also fails on 2024 withstandalone
.On edition 2024, the above will pass.
I generally would expect the behavior to be the same. I'm not sure if it is possible to check if there are any attributes before adding the
allow(unused)
. I'm also unclear whyno_run
is significant here.Meta
The text was updated successfully, but these errors were encountered: