Skip to content

Commit 294cfd6

Browse files
Merge #9786
9786: fix: Fix detection of macro file in inactive-code diag r=jonas-schievink a=jonas-schievink Fixes #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>
2 parents 1b02caf + 260936d commit 294cfd6

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

crates/hir_expand/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@ impl HirFileId {
173173
_ => false,
174174
}
175175
}
176+
177+
pub fn is_macro(self) -> bool {
178+
matches!(self.0, HirFileIdRepr::MacroFile(_))
179+
}
176180
}
177181

178182
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]

crates/ide_diagnostics/src/handlers/inactive_code.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub(crate) fn inactive_code(
1111
d: &hir::InactiveCode,
1212
) -> Option<Diagnostic> {
1313
// If there's inactive code somewhere in a macro, don't propagate to the call-site.
14-
if d.node.file_id.expansion_info(ctx.sema.db).is_some() {
14+
if d.node.file_id.is_macro() {
1515
return None;
1616
}
1717

0 commit comments

Comments
 (0)