about summary refs log tree commit diff
path: root/compiler/rustc_plugin_impl/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-03-10 08:40:51 +0000
committerbors <bors@rust-lang.org>2021-03-10 08:40:51 +0000
commitdff1edf919198aa4dea106e63b7d1899f1061fe0 (patch)
treee89b1e39488265fccd99dc2161d0dc60187a1445 /compiler/rustc_plugin_impl/src
parent861872bc453bde79b83ff99d443d035225f10e87 (diff)
parent77c0f217ff2197aa0bbafc3cdb01b3da9016e514 (diff)
downloadrust-dff1edf919198aa4dea106e63b7d1899f1061fe0.tar.gz
rust-dff1edf919198aa4dea106e63b7d1899f1061fe0.zip
Auto merge of #79519 - cjgillot:noattr, r=wesleywiser
Store HIR attributes in a side table

Same idea as #72015 but for attributes.
The objective is to reduce incr-comp invalidations due to modified attributes.
Notably, those due to modified doc comments.

Implementation:
- collect attributes during AST->HIR lowering, in `LocalDefId -> ItemLocalId -> &[Attributes]` nested tables;
- access the attributes through a `hir_owner_attrs` query;
- local refactorings to use this access;
- remove `attrs` from HIR data structures one-by-one.

Change in behaviour:
- the HIR visitor traverses all attributes at once instead of parent-by-parent;
- attribute arrays are sometimes duplicated: for statements and variant constructors;
- as a consequence, attributes are marked as used after unused-attribute lint emission to avoid duplicate lints.

~~Current bug: the lint level is not correctly applied in `std::backtrace_rs`, triggering an unused attribute warning on `#![no_std]`. I welcome suggestions.~~
Diffstat (limited to 'compiler/rustc_plugin_impl/src')
-rw-r--r--compiler/rustc_plugin_impl/src/build.rs3
1 files changed, 2 insertions, 1 deletions
diff --git a/compiler/rustc_plugin_impl/src/build.rs b/compiler/rustc_plugin_impl/src/build.rs
index d5c287fb3bc..a49afa35e46 100644
--- a/compiler/rustc_plugin_impl/src/build.rs
+++ b/compiler/rustc_plugin_impl/src/build.rs
@@ -16,7 +16,8 @@ struct RegistrarFinder<'tcx> {
 impl<'v, 'tcx> ItemLikeVisitor<'v> for RegistrarFinder<'tcx> {
     fn visit_item(&mut self, item: &hir::Item<'_>) {
         if let hir::ItemKind::Fn(..) = item.kind {
-            if self.tcx.sess.contains_name(&item.attrs, sym::plugin_registrar) {
+            let attrs = self.tcx.hir().attrs(item.hir_id());
+            if self.tcx.sess.contains_name(attrs, sym::plugin_registrar) {
                 self.registrars.push((item.def_id, item.span));
             }
         }