rust-lang / rust-lang/rust-analyzer

analyzer: code is inactive due to #[cfg] directives: doc is disabled

Open
#14,395 13 comments 13 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

The inactive-code check appears to false positive (IMO) on #[cfg(doc)].

Sample code

#[cfg(doc)]
use std::future::Future;

/// Handy struct that pairs well with [`Future`].
pub struct Past;

One could potentially argue that this is behaving-as-designed, since it's analyzing the code, but not the docs - but I found it a bit un-useful.

Some possible proposed solutions

  • not include cfg(doc) code blocks in the inactive-code analyzer.
  • Include docstrings in the analyzer
    Open to other ideas to solve.

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

Start with the provided #[cfg(doc)] reproduction and trace how the inactive-code analyzer handles cfg directives and documentation links. Compare the proposed options, then establish the expected behavior and add a regression test covering the sample code and its [Future] reference.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.