From 260936d0b70061e999bead3159a96b73047ab3a6 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Wed, 4 Aug 2021 18:02:45 +0200 Subject: [PATCH] Fix detection of macro file in inactive-code diag --- crates/hir_expand/src/lib.rs | 4 ++++ crates/ide_diagnostics/src/handlers/inactive_code.rs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/hir_expand/src/lib.rs b/crates/hir_expand/src/lib.rs index c31426d7cc..d156d1bda6 100644 --- a/crates/hir_expand/src/lib.rs +++ b/crates/hir_expand/src/lib.rs @@ -173,6 +173,10 @@ impl HirFileId { _ => false, } } + + pub fn is_macro(self) -> bool { + matches!(self.0, HirFileIdRepr::MacroFile(_)) + } } #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] diff --git a/crates/ide_diagnostics/src/handlers/inactive_code.rs b/crates/ide_diagnostics/src/handlers/inactive_code.rs index b6a7aee59e..155bbc569d 100644 --- a/crates/ide_diagnostics/src/handlers/inactive_code.rs +++ b/crates/ide_diagnostics/src/handlers/inactive_code.rs @@ -11,7 +11,7 @@ pub(crate) fn inactive_code( d: &hir::InactiveCode, ) -> Option { // If there's inactive code somewhere in a macro, don't propagate to the call-site. - if d.node.file_id.expansion_info(ctx.sema.db).is_some() { + if d.node.file_id.is_macro() { return None; }