diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-08-04 16:04:35 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-08-04 16:04:35 +0000 |
| commit | 294cfd61c79d031da20e042c56cf621db1918228 (patch) | |
| tree | fa8afc3d22f8d55eb91ca3580bdaac4cab5db1d6 | |
| parent | 1b02cafa43a97dd4475b2d255c0f5662726a68f1 (diff) | |
| parent | 260936d0b70061e999bead3159a96b73047ab3a6 (diff) | |
| download | rust-294cfd61c79d031da20e042c56cf621db1918228.tar.gz rust-294cfd61c79d031da20e042c56cf621db1918228.zip | |
Merge #9786
9786: fix: Fix detection of macro file in inactive-code diag r=jonas-schievink a=jonas-schievink Fixes https://github.com/rust-analyzer/rust-analyzer/issues/9753 `HirFileId::expansion_info` can return `None` for builtin macros or if there's an error in the macro call or definition, so add a `HirFileId::is_macro` method that checks the right thing. bors r+ Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
| -rw-r--r-- | crates/hir_expand/src/lib.rs | 4 | ||||
| -rw-r--r-- | crates/ide_diagnostics/src/handlers/inactive_code.rs | 2 |
2 files changed, 5 insertions, 1 deletions
diff --git a/crates/hir_expand/src/lib.rs b/crates/hir_expand/src/lib.rs index c31426d7cc7..d156d1bda66 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 b6a7aee59e4..155bbc569d0 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<Diagnostic> { // 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; } |
