rust-lang / rust-lang/rust-analyzer

macro behind optional flag is still checked

Open
#12,192 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

image

lib.rs
pub fn stuff() {
    #[cfg(f = "1")]
    tracing::dispatcher::set_global_default(todo!());
    #[cfg(f = "1")]
    tracing::info!(todo!());
}
Cargo.toml
[package]
name = "cfg-stuff"
version = "0.1.0"
edition = "2021"
[dependencies]
tracing = {version = "0.1.34", optional = true }

gives "unresolved macro tracing::info!" on line 5, but no unresolved stuff on line 3

rust-analyzer version: 5d5bbec9b60010dd

rustc version: rustc 1.62.0-nightly (30f386087 2022-05-05)

relevant settings: "rust-analyzer.procMacro.enable": true

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 by reproducing the report with the lib.rs and Cargo.toml examples, using the stated rust-analyzer and proc-macro settings. Compare diagnostics for the two cfg-gated statements; done means the macro behind the disabled optional dependency is no longer reported as unresolved while the configuration behavior remains correct.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.