]> git.lizzy.rs Git - rust.git/commitdiff
Don't diagnose `#[cfg]` in macros
authorJonas Schievink <jonasschievink@gmail.com>
Thu, 3 Dec 2020 19:46:16 +0000 (20:46 +0100)
committerJonas Schievink <jonasschievink@gmail.com>
Thu, 3 Dec 2020 19:46:16 +0000 (20:46 +0100)
crates/ide/src/diagnostics.rs

index 9d3d8828956f5be8ffc91cf97a38a9880abc4734..c8453edb308e6d8e6123edbf0d9cc2b553caf5ef 100644 (file)
@@ -135,6 +135,11 @@ pub(crate) fn diagnostics(
             res.borrow_mut().push(warning_with_fix(d, &sema));
         })
         .on::<hir::diagnostics::InactiveCode, _>(|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())