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 is no_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:
#![doc(test(attr(allow(unused_variables), deny(warnings))))]
/// Example
///
/// ```rust,no_run
/// trait T { fn f(); }
/// ```
pub fn f() {}
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 with standalone.
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 why no_run is significant here.
Meta
rustdoc 1.83.0-nightly (da889684c 2024-09-20)
binary: rustdoc
commit-hash: da889684c80508036ff036db8c159ffdcf27648a
commit-date: 2024-09-20
host: aarch64-apple-darwin
release: 1.83.0-nightly
LLVM version: 19.1.0
With the 2024 merged doctests, there is a slight change in behavior with regards to the unused lints with a
no_runtest. 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_runis significant here.Meta