From 6e1c87eb92f129cc6f5977b8b0f5893de4ae8d78 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Thu, 3 Dec 2020 20:46:16 +0100 Subject: Don't diagnose `#[cfg]` in macros --- crates/ide/src/diagnostics.rs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'crates/ide') diff --git a/crates/ide/src/diagnostics.rs b/crates/ide/src/diagnostics.rs index 9d3d88289..c8453edb3 100644 --- a/crates/ide/src/diagnostics.rs +++ b/crates/ide/src/diagnostics.rs @@ -135,6 +135,11 @@ pub(crate) fn diagnostics( res.borrow_mut().push(warning_with_fix(d, &sema)); }) .on::(|d| { + // If there's inactive code somewhere in a macro, don't propagate to the call-site. + if d.display_source().file_id.expansion_info(db).is_some() { + return; + } + // Override severity and mark as unused. res.borrow_mut().push( Diagnostic::hint(sema.diagnostics_display_range(d).range, d.message()) -- cgit v1.2.3