Skip to content

Commit

Permalink
Auto merge of #17823 - Veykril:mod-unconfigured-diag, r=Veykril
Browse files Browse the repository at this point in the history
fix: Fix unconfigured diagnostic being attached to the wrong file for modules

Fixes #17817
  • Loading branch information
bors committed Aug 7, 2024
2 parents 4523657 + e3e31ce commit 0e282fc
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion crates/hir-def/src/nameres/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2003,7 +2003,7 @@ impl ModCollector<'_, '_> {
Err(cfg) => {
self.emit_unconfigured_diagnostic(
self.tree_id,
AttrOwner::TopLevel,
AttrOwner::ModItem(module_id.into()),
&cfg,
);
}
Expand Down
26 changes: 25 additions & 1 deletion crates/ide-diagnostics/src/handlers/inactive_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ mod tests {
use crate::{tests::check_diagnostics_with_config, DiagnosticsConfig};

pub(crate) fn check(ra_fixture: &str) {
let config = DiagnosticsConfig::test_sample();
let config = DiagnosticsConfig {
disabled: std::iter::once("unlinked-file".to_owned()).collect(),
..DiagnosticsConfig::test_sample()
};
check_diagnostics_with_config(config, ra_fixture)
}

Expand Down Expand Up @@ -168,6 +171,27 @@ union FooBar {
#[cfg(a)] baz: u32,
//^^^^^^^^^^^^^^^^^^ weak: code is inactive due to #[cfg] directives: a is disabled
}
"#,
);
}

#[test]
fn modules() {
check(
r#"
//- /main.rs
#[cfg(outline)] mod outline;
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ weak: code is inactive due to #[cfg] directives: outline is disabled
mod outline_inner;
//^^^^^^^^^^^^^^^^^^ weak: code is inactive due to #[cfg] directives: outline_inner is disabled
#[cfg(inline)] mod inline {}
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ weak: code is inactive due to #[cfg] directives: inline is disabled
//- /outline_inner.rs
#![cfg(outline_inner)]
//- /outline.rs
"#,
);
}
Expand Down

0 comments on commit 0e282fc

Please sign in to comment.