1- //! Debugging code to test fingerprints computed for query results.
2- //! For each node marked with `#[rustc_clean]` or `#[rustc_dirty]`,
3- //! we will compare the fingerprint from the current and from the previous
1+ //! Debugging code to test fingerprints computed for query results. For each node marked with
2+ //! `#[rustc_clean]` we will compare the fingerprint from the current and from the previous
43//! compilation session as appropriate:
54//!
65//! - `#[rustc_clean(cfg="rev2", except="typeck")]` if we are
@@ -132,7 +131,7 @@ pub fn check_dirty_clean_annotations(tcx: TyCtxt<'_>) {
132131 return ;
133132 }
134133
135- // can't add `#[rustc_dirty ]` etc without opting in to this feature
134+ // can't add `#[rustc_clean ]` etc without opting in to this feature
136135 if !tcx. features ( ) . rustc_attrs {
137136 return ;
138137 }
@@ -142,11 +141,7 @@ pub fn check_dirty_clean_annotations(tcx: TyCtxt<'_>) {
142141 let mut dirty_clean_visitor = DirtyCleanVisitor { tcx, checked_attrs : Default :: default ( ) } ;
143142 krate. visit_all_item_likes ( & mut dirty_clean_visitor) ;
144143
145- let mut all_attrs = FindAllAttrs {
146- tcx,
147- attr_names : & [ sym:: rustc_dirty, sym:: rustc_clean] ,
148- found_attrs : vec ! [ ] ,
149- } ;
144+ let mut all_attrs = FindAllAttrs { tcx, found_attrs : vec ! [ ] } ;
150145 intravisit:: walk_crate ( & mut all_attrs, krate) ;
151146
152147 // Note that we cannot use the existing "unused attribute"-infrastructure
@@ -164,29 +159,20 @@ pub struct DirtyCleanVisitor<'tcx> {
164159impl DirtyCleanVisitor < ' tcx > {
165160 /// Possibly "deserialize" the attribute into a clean/dirty assertion
166161 fn assertion_maybe ( & mut self , item_id : LocalDefId , attr : & Attribute ) -> Option < Assertion > {
167- let is_clean = if self . tcx . sess . check_name ( attr, sym:: rustc_dirty) {
168- false
169- } else if self . tcx . sess . check_name ( attr, sym:: rustc_clean) {
170- true
171- } else {
162+ if !self . tcx . sess . check_name ( attr, sym:: rustc_clean) {
172163 // skip: not rustc_clean/dirty
173164 return None ;
174- } ;
165+ }
175166 if !check_config ( self . tcx , attr) {
176167 // skip: not the correct `cfg=`
177168 return None ;
178169 }
179- let assertion = self . assertion_auto ( item_id, attr, is_clean ) ;
170+ let assertion = self . assertion_auto ( item_id, attr) ;
180171 Some ( assertion)
181172 }
182173
183174 /// Gets the "auto" assertion on pre-validated attr, along with the `except` labels.
184- fn assertion_auto (
185- & mut self ,
186- item_id : LocalDefId ,
187- attr : & Attribute ,
188- is_clean : bool ,
189- ) -> Assertion {
175+ fn assertion_auto ( & mut self , item_id : LocalDefId , attr : & Attribute ) -> Assertion {
190176 let ( name, mut auto) = self . auto_labels ( item_id, attr) ;
191177 let except = self . except ( attr) ;
192178 for e in except. iter ( ) {
@@ -198,11 +184,7 @@ impl DirtyCleanVisitor<'tcx> {
198184 self . tcx . sess . span_fatal ( attr. span , & msg) ;
199185 }
200186 }
201- if is_clean {
202- Assertion { clean : auto, dirty : except }
203- } else {
204- Assertion { clean : except, dirty : auto }
205- }
187+ Assertion { clean : auto, dirty : except }
206188 }
207189
208190 /// `except=` attribute value
@@ -398,9 +380,8 @@ impl ItemLikeVisitor<'tcx> for DirtyCleanVisitor<'tcx> {
398380 }
399381}
400382
401- /// Given a `#[rustc_dirty]` or `#[rustc_clean]` attribute, scan
402- /// for a `cfg="foo"` attribute and check whether we have a cfg
403- /// flag called `foo`.
383+ /// Given a `#[rustc_clean]` attribute, scan for a `cfg="foo"` attribute and check whether we have
384+ /// a cfg flag called `foo`.
404385fn check_config ( tcx : TyCtxt < ' _ > , attr : & Attribute ) -> bool {
405386 debug ! ( "check_config(attr={:?})" , attr) ;
406387 let config = & tcx. sess . parse_sess . config ;
@@ -436,21 +417,18 @@ fn expect_associated_value(tcx: TyCtxt<'_>, item: &NestedMetaItem) -> Symbol {
436417 }
437418}
438419
439- // A visitor that collects all #[rustc_dirty]/#[ rustc_clean] attributes from
420+ // A visitor that collects all #[rustc_clean] attributes from
440421// the HIR. It is used to verify that we really ran checks for all annotated
441422// nodes.
442- pub struct FindAllAttrs < ' a , ' tcx > {
423+ pub struct FindAllAttrs < ' tcx > {
443424 tcx : TyCtxt < ' tcx > ,
444- attr_names : & ' a [ Symbol ] ,
445425 found_attrs : Vec < & ' tcx Attribute > ,
446426}
447427
448- impl FindAllAttrs < ' _ , ' tcx > {
428+ impl FindAllAttrs < ' tcx > {
449429 fn is_active_attr ( & mut self , attr : & Attribute ) -> bool {
450- for attr_name in self . attr_names {
451- if self . tcx . sess . check_name ( attr, * attr_name) && check_config ( self . tcx , attr) {
452- return true ;
453- }
430+ if self . tcx . sess . check_name ( attr, sym:: rustc_clean) && check_config ( self . tcx , attr) {
431+ return true ;
454432 }
455433
456434 false
@@ -459,17 +437,14 @@ impl FindAllAttrs<'_, 'tcx> {
459437 fn report_unchecked_attrs ( & self , mut checked_attrs : FxHashSet < ast:: AttrId > ) {
460438 for attr in & self . found_attrs {
461439 if !checked_attrs. contains ( & attr. id ) {
462- self . tcx . sess . span_err (
463- attr. span ,
464- "found unchecked `#[rustc_dirty]` / `#[rustc_clean]` attribute" ,
465- ) ;
440+ self . tcx . sess . span_err ( attr. span , "found unchecked `#[rustc_clean]` attribute" ) ;
466441 checked_attrs. insert ( attr. id ) ;
467442 }
468443 }
469444 }
470445}
471446
472- impl intravisit:: Visitor < ' tcx > for FindAllAttrs < ' _ , ' tcx > {
447+ impl intravisit:: Visitor < ' tcx > for FindAllAttrs < ' tcx > {
473448 type Map = Map < ' tcx > ;
474449
475450 fn nested_visit_map ( & mut self ) -> intravisit:: NestedVisitorMap < Self :: Map > {
0 commit comments