Skip to content

rust_analyzer is an unexpected cfg condition #160736

Description

@coolcatcoder

Code

#![cfg(rust_analyzer)]

Current output

warning: unexpected `cfg` condition name: `rust_analyzer`
 --> src/lib.rs:1:8
  |
1 | #![cfg(rust_analyzer)]
  |        ^^^^^^^^^^^^^
  |
  = help: expected names are: `docsrs`, `feature`, and `test` and 32 more
  = help: consider using a Cargo feature instead
  = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:
           [lints.rust]
           unexpected_cfgs = { level = "warn", check-cfg = ['cfg(rust_analyzer)'] }
  = help: or consider adding `println!("cargo::rustc-check-cfg=cfg(rust_analyzer)");` to the top of the `build.rs`
  = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
  = note: `#[warn(unexpected_cfgs)]` on by default

Desired output

Rationale and extra context

Rust analyzer should be in the list of known cfgs, given that it works out of the box.

Rust Version

rustc 1.99.0-nightly (1a98b1e13 2026-08-07)
binary: rustc
commit-hash: 1a98b1e135b254f209c67d447b6d8bcd56a859e0
commit-date: 2026-08-07
host: x86_64-unknown-linux-gnu
release: 1.99.0-nightly
LLVM version: 23.1.0

Anything else?

No response

Metadata

Metadata

Labels

A-cfgArea: `cfg` conditional compilationA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-feature-requestCategory: A feature request, i.e: not implemented / a PR.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.F-check-cfg--check-cfgT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-rust-analyzerRelevant to the rust-analyzer team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions