Skip to content

future-incompatibility: default #[allow(...)] incompatible with #[forbid(...)] #148599

@peter-lyons-kehl

Description

@peter-lyons-kehl

Code

// - have at least one doctest, and
//
// - at the top of lib.rs `forbid` any of the `allow` that rustdoc injects by default. For example

#![doc(test(attr(forbid(unused, dead_code))))]

Reproduction Steps

cargo test
...

warning: allow(unused_extern_crates) incompatible with previous forbid
 --> src/lib.rs:16:9
  |
1 | #![forbid(unused, dead_code)]
  |           ------ `forbid` level set here
2 | #[allow(unused_extern_crates)]
  |         ^^^^^^^^^^^^^^^^^^^^ overruled by previous forbid
  |
  = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
  = note: for more information, see issue #81670 <https://github.com/rust-lang/rust/issues/81670>
  = note: `#[warn(forbidden_lint_groups)]` (part of `#[warn(future_incompatible)]`) on by default

Version

rustdoc 1.91.0 (f8297e351 2025-10-28)
installed with rustup, standard x64 Linux

Suggestions

Please,

  • provide a configuration for rustdoc NOT to inject the default #[allow(...)]. If there already exists such a configuration, please document - I couldn't see it obvious anywhere at https://doc.rust-lang.org/rustdoc/write-documentation/documentation-tests.html. Or
  • document which exact lints are injected, so that the author/doc writer can #[allow(...)] them individually, instead of using a group lint.

Related to #81670.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-doctestsArea: Documentation tests, run by rustdocA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-enhancementCategory: An issue proposing an enhancement or a PR with one.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions