-
Notifications
You must be signed in to change notification settings - Fork 385
Open
Labels
bugsubsystem::cfgIssues related to conditional compilation (processing of `cfg` attributes)Issues related to conditional compilation (processing of `cfg` attributes)subsystem::doc comentsIssues related to documentation commentsIssues related to documentation commentssubsystem::highlightingIssues related to code highlightingIssues related to code highlighting
Description
Environment
- IntelliJ Rust plugin version: 0.4.177.4822-222-nightly
- Rust toolchain version: 1.63.0 (4b91a6ea7 2022-08-08) x86_64-apple-darwin
- IDE name and version: IntelliJ IDEA 2022.2 Ultimate Edition (IU-222.3345.118)
- Operating system: macOS 12.3.1
- Macro expansion engine: new
- Name resolution engine: new
- Additional experimental features: org.rust.cargo.features.settings.gutter, org.rust.cargo.emulate.terminal, org.rust.cargo.evaluate.build.scripts, org.rust.macros.proc
Problem description
The plugin tries not to perform complex analysis (like unresolved references, type mismatched, etc) in cfg-disabled code.
At the same time, if the corresponding item has doc tests in its doc comment, the plugin analyzes the code of the doctest regardless cfg predicate value. It may lead to unexpected errors
In particular, I faced with this issue in #8961 where plugin doesn't download dependencies not related to the current target. As a result, the plugin started to produce few false positive errors in doc tests of cfg disabled items
Steps to reproduce
lib.rs
///
/// ```
/// use rust_project::bar;
///
/// bar(123)
/// ```
#[cfg(feature = "foo")]
pub fn foo() {
bar(123)
}
///
/// ```
/// use rust_project::bar;
///
/// bar()
/// ```
#[cfg(not(feature = "foo"))]
pub fn foo() {
bar()
}
pub fn bar(#[cfg(feature = "foo")] x: i32) {}
Cargo.toml
[package]
name = "rust-project"
edition = "2018"
version = "0.1.0"
[features]
foo = []
Metadata
Metadata
Assignees
Labels
bugsubsystem::cfgIssues related to conditional compilation (processing of `cfg` attributes)Issues related to conditional compilation (processing of `cfg` attributes)subsystem::doc comentsIssues related to documentation commentsIssues related to documentation commentssubsystem::highlightingIssues related to code highlightingIssues related to code highlighting