rust-lang / rust-lang/rust

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

Open
#148,599 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-doctests A-lints C-enhancement T-rustdoc
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

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 https://github.com/rust-lang/rust/issues/81670.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the doctest case in src/lib.rs with cargo test, then read rustdoc's documentation-test attribute handling and the documentation-tests guidance mentioned in the issue. Done means providing a documented way to avoid the injected allows or documenting the exact lints so the forbid example no longer produces the future-incompatibility warning.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
documentation, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.