out_of_scope_macro_calls: Detect calls inside attributes more precisely

This commit is contained in:
Vadim Petrochenkov
2024-06-26 13:00:51 +03:00
parent 28cc0b643d
commit 83cf471361
4 changed files with 35 additions and 12 deletions

View File

@@ -1139,7 +1139,7 @@ pub struct Resolver<'a, 'tcx> {
/// When collecting definitions from an AST fragment produced by a macro invocation `ExpnId`
/// we know what parent node that fragment should be attached to thanks to this table,
/// and how the `impl Trait` fragments were introduced.
invocation_parents: FxHashMap<LocalExpnId, (LocalDefId, ImplTraitContext)>,
invocation_parents: FxHashMap<LocalExpnId, (LocalDefId, ImplTraitContext, bool /*in_attr*/)>,
/// Some way to know that we are in a *trait* impl in `visit_assoc_item`.
/// FIXME: Replace with a more general AST map (together with some other fields).
@@ -1371,7 +1371,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
node_id_to_def_id.insert(CRATE_NODE_ID, crate_feed);
let mut invocation_parents = FxHashMap::default();
invocation_parents.insert(LocalExpnId::ROOT, (CRATE_DEF_ID, ImplTraitContext::Existential));
invocation_parents
.insert(LocalExpnId::ROOT, (CRATE_DEF_ID, ImplTraitContext::Existential, false));
let mut extern_prelude: FxHashMap<Ident, ExternPreludeEntry<'_>> = tcx
.sess