mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 21:43:37 +00:00
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>
This commit is contained in:
commit
294cfd61c7
2 changed files with 5 additions and 1 deletions
|
@ -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)]
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue