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
4
3
//! compilation session as appropriate:
5
4
//!
6
5
//! - `#[rustc_clean(cfg="rev2", except="typeck")]` if we are
@@ -132,7 +131,7 @@ pub fn check_dirty_clean_annotations(tcx: TyCtxt<'_>) {
132
131
return ;
133
132
}
134
133
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
136
135
if !tcx. features ( ) . rustc_attrs {
137
136
return ;
138
137
}
@@ -142,11 +141,7 @@ pub fn check_dirty_clean_annotations(tcx: TyCtxt<'_>) {
142
141
let mut dirty_clean_visitor = DirtyCleanVisitor { tcx, checked_attrs : Default :: default ( ) } ;
143
142
krate. visit_all_item_likes ( & mut dirty_clean_visitor) ;
144
143
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 ! [ ] } ;
150
145
intravisit:: walk_crate ( & mut all_attrs, krate) ;
151
146
152
147
// Note that we cannot use the existing "unused attribute"-infrastructure
@@ -164,29 +159,20 @@ pub struct DirtyCleanVisitor<'tcx> {
164
159
impl DirtyCleanVisitor < ' tcx > {
165
160
/// Possibly "deserialize" the attribute into a clean/dirty assertion
166
161
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) {
172
163
// skip: not rustc_clean/dirty
173
164
return None ;
174
- } ;
165
+ }
175
166
if !check_config ( self . tcx , attr) {
176
167
// skip: not the correct `cfg=`
177
168
return None ;
178
169
}
179
- let assertion = self . assertion_auto ( item_id, attr, is_clean ) ;
170
+ let assertion = self . assertion_auto ( item_id, attr) ;
180
171
Some ( assertion)
181
172
}
182
173
183
174
/// 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 {
190
176
let ( name, mut auto) = self . auto_labels ( item_id, attr) ;
191
177
let except = self . except ( attr) ;
192
178
for e in except. iter ( ) {
@@ -198,11 +184,7 @@ impl DirtyCleanVisitor<'tcx> {
198
184
self . tcx . sess . span_fatal ( attr. span , & msg) ;
199
185
}
200
186
}
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 }
206
188
}
207
189
208
190
/// `except=` attribute value
@@ -398,9 +380,8 @@ impl ItemLikeVisitor<'tcx> for DirtyCleanVisitor<'tcx> {
398
380
}
399
381
}
400
382
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`.
404
385
fn check_config ( tcx : TyCtxt < ' _ > , attr : & Attribute ) -> bool {
405
386
debug ! ( "check_config(attr={:?})" , attr) ;
406
387
let config = & tcx. sess . parse_sess . config ;
@@ -436,21 +417,18 @@ fn expect_associated_value(tcx: TyCtxt<'_>, item: &NestedMetaItem) -> Symbol {
436
417
}
437
418
}
438
419
439
- // A visitor that collects all #[rustc_dirty]/#[ rustc_clean] attributes from
420
+ // A visitor that collects all #[rustc_clean] attributes from
440
421
// the HIR. It is used to verify that we really ran checks for all annotated
441
422
// nodes.
442
- pub struct FindAllAttrs < ' a , ' tcx > {
423
+ pub struct FindAllAttrs < ' tcx > {
443
424
tcx : TyCtxt < ' tcx > ,
444
- attr_names : & ' a [ Symbol ] ,
445
425
found_attrs : Vec < & ' tcx Attribute > ,
446
426
}
447
427
448
- impl FindAllAttrs < ' _ , ' tcx > {
428
+ impl FindAllAttrs < ' tcx > {
449
429
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 ;
454
432
}
455
433
456
434
false
@@ -459,17 +437,14 @@ impl FindAllAttrs<'_, 'tcx> {
459
437
fn report_unchecked_attrs ( & self , mut checked_attrs : FxHashSet < ast:: AttrId > ) {
460
438
for attr in & self . found_attrs {
461
439
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" ) ;
466
441
checked_attrs. insert ( attr. id ) ;
467
442
}
468
443
}
469
444
}
470
445
}
471
446
472
- impl intravisit:: Visitor < ' tcx > for FindAllAttrs < ' _ , ' tcx > {
447
+ impl intravisit:: Visitor < ' tcx > for FindAllAttrs < ' tcx > {
473
448
type Map = Map < ' tcx > ;
474
449
475
450
fn nested_visit_map ( & mut self ) -> intravisit:: NestedVisitorMap < Self :: Map > {
0 commit comments