Deduplicate unchecked_attrs errors.

This commit is contained in:
Camille GILLOT 2020-12-07 22:46:35 +01:00
parent 2658fb7783
commit 90a562c7ff
1 changed files with 3 additions and 2 deletions

View File

@ -168,7 +168,7 @@ pub fn check_dirty_clean_annotations(tcx: TyCtxt<'_>) {
// Note that we cannot use the existing "unused attribute"-infrastructure
// here, since that is running before codegen. This is also the reason why
// all codegen-specific attributes are `AssumedUsed` in rustc_ast::feature_gate.
all_attrs.report_unchecked_attrs(&dirty_clean_visitor.checked_attrs);
all_attrs.report_unchecked_attrs(dirty_clean_visitor.checked_attrs);
})
}
@ -535,13 +535,14 @@ impl FindAllAttrs<'_, 'tcx> {
false
}
fn report_unchecked_attrs(&self, checked_attrs: &FxHashSet<ast::AttrId>) {
fn report_unchecked_attrs(&self, mut checked_attrs: FxHashSet<ast::AttrId>) {
for attr in &self.found_attrs {
if !checked_attrs.contains(&attr.id) {
self.tcx.sess.span_err(
attr.span,
"found unchecked `#[rustc_dirty]` / `#[rustc_clean]` attribute",
);
checked_attrs.insert(attr.id);
}
}
}