Skip to content

Commit fc069d3

Browse files
committed
Remove remains of rustc_dirty.
1 parent 175345b commit fc069d3

File tree

9 files changed

+56
-79
lines changed

9 files changed

+56
-79
lines changed

compiler/rustc_feature/src/builtin_attrs.rs

-4
Original file line numberDiff line numberDiff line change
@@ -567,10 +567,6 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
567567
rustc_attr!(TEST, rustc_dump_user_substs, AssumedUsed, template!(Word)),
568568
rustc_attr!(TEST, rustc_if_this_changed, AssumedUsed, template!(Word, List: "DepNode")),
569569
rustc_attr!(TEST, rustc_then_this_would_need, AssumedUsed, template!(List: "DepNode")),
570-
rustc_attr!(
571-
TEST, rustc_dirty, AssumedUsed,
572-
template!(List: r#"cfg = "...", /*opt*/ label = "...", /*opt*/ except = "...""#),
573-
),
574570
rustc_attr!(
575571
TEST, rustc_clean, AssumedUsed,
576572
template!(List: r#"cfg = "...", /*opt*/ label = "...", /*opt*/ except = "...""#),

compiler/rustc_incremental/src/persist/dirty_clean.rs

+18-43
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
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> {
164159
impl 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`.
404385
fn 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> {

src/test/incremental/dirty_clean.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ mod x {
2525
mod y {
2626
use x;
2727

28-
#[rustc_dirty(except="typeck", cfg="cfail2")]
28+
#[rustc_clean(
29+
except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of,fn_sig",
30+
cfg="cfail2",
31+
)]
2932
pub fn y() {
3033
//[cfail2]~^ ERROR `hir_owner(y)` should be dirty but is not
3134
//[cfail2]~| ERROR `hir_owner_nodes(y)` should be dirty but is not

src/test/incremental/hashes/enum_defs.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ enum EnumChangeNameOfTypeParameter<S> {
370370
}
371371

372372
#[cfg(not(cfail1))]
373-
#[rustc_dirty(cfg="cfail2")]
373+
#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of")]
374374
#[rustc_clean(cfg="cfail3")]
375375
enum EnumChangeNameOfTypeParameter<T> {
376376
Variant1(T),
@@ -386,7 +386,7 @@ enum EnumAddTypeParameter<S> {
386386
}
387387

388388
#[cfg(not(cfail1))]
389-
#[rustc_dirty(cfg="cfail2")]
389+
#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of")]
390390
#[rustc_clean(cfg="cfail3")]
391391
enum EnumAddTypeParameter<S, T> {
392392
Variant1(S),
@@ -402,7 +402,7 @@ enum EnumChangeNameOfLifetimeParameter<'a> {
402402
}
403403

404404
#[cfg(not(cfail1))]
405-
#[rustc_dirty(cfg="cfail2", except="predicates_of")]
405+
#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,type_of")]
406406
#[rustc_clean(cfg="cfail3")]
407407
enum EnumChangeNameOfLifetimeParameter<'b> {
408408
Variant1(&'b u32),
@@ -418,7 +418,7 @@ enum EnumAddLifetimeParameter<'a> {
418418
}
419419

420420
#[cfg(not(cfail1))]
421-
#[rustc_dirty(cfg="cfail2", except="predicates_of")]
421+
#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,type_of")]
422422
#[rustc_clean(cfg="cfail3")]
423423
enum EnumAddLifetimeParameter<'a, 'b> {
424424
Variant1(&'a u32),
@@ -435,7 +435,7 @@ enum EnumAddLifetimeParameterBound<'a, 'b> {
435435
}
436436

437437
#[cfg(not(cfail1))]
438-
#[rustc_dirty(cfg="cfail2", except="generics_of,type_of")]
438+
#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,predicates_of")]
439439
#[rustc_clean(cfg="cfail3")]
440440
enum EnumAddLifetimeParameterBound<'a, 'b: 'a> {
441441
Variant1(&'a u32),
@@ -450,7 +450,7 @@ enum EnumAddLifetimeBoundToParameter<'a, T> {
450450
}
451451

452452
#[cfg(not(cfail1))]
453-
#[rustc_dirty(cfg="cfail2", except="type_of")]
453+
#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,predicates_of")]
454454
#[rustc_clean(cfg="cfail3")]
455455
enum EnumAddLifetimeBoundToParameter<'a, T: 'a> {
456456
Variant1(T),
@@ -466,7 +466,7 @@ enum EnumAddTraitBound<S> {
466466
}
467467

468468
#[cfg(not(cfail1))]
469-
#[rustc_dirty(cfg="cfail2")]
469+
#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of")]
470470
#[rustc_clean(cfg="cfail3")]
471471
enum EnumAddTraitBound<T: Sync> {
472472
Variant1(T),
@@ -482,7 +482,7 @@ enum EnumAddLifetimeParameterBoundWhere<'a, 'b> {
482482
}
483483

484484
#[cfg(not(cfail1))]
485-
#[rustc_dirty(cfg="cfail2", except="generics_of,type_of")]
485+
#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,predicates_of")]
486486
#[rustc_clean(cfg="cfail3")]
487487
enum EnumAddLifetimeParameterBoundWhere<'a, 'b> where 'b: 'a {
488488
Variant1(&'a u32),
@@ -499,7 +499,7 @@ enum EnumAddLifetimeBoundToParameterWhere<'a, T> {
499499
}
500500

501501
#[cfg(not(cfail1))]
502-
#[rustc_dirty(cfg="cfail2", except="type_of")]
502+
#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,predicates_of")]
503503
#[rustc_clean(cfg="cfail3")]
504504
enum EnumAddLifetimeBoundToParameterWhere<'a, T> where T: 'a {
505505
Variant1(T),
@@ -515,7 +515,7 @@ enum EnumAddTraitBoundWhere<S> {
515515
}
516516

517517
#[cfg(not(cfail1))]
518-
#[rustc_dirty(cfg="cfail2")]
518+
#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of")]
519519
#[rustc_clean(cfg="cfail3")]
520520
enum EnumAddTraitBoundWhere<T> where T: Sync {
521521
Variant1(T),

src/test/incremental/hashes/extern_mods.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ extern "C" {
2121
}
2222

2323
#[cfg(not(cfail1))]
24-
#[rustc_dirty(cfg = "cfail2", except = "hir_owner_nodes")]
24+
#[rustc_clean(cfg = "cfail2", except = "hir_owner")]
2525
#[rustc_clean(cfg = "cfail3")]
2626
extern "C" {
2727
pub fn change_function_name2(c: i64) -> i32;
@@ -34,7 +34,7 @@ extern "C" {
3434
}
3535

3636
#[cfg(not(cfail1))]
37-
#[rustc_dirty(cfg = "cfail2", except = "hir_owner,hir_owner_nodes")]
37+
#[rustc_clean(cfg = "cfail2")]
3838
#[rustc_clean(cfg = "cfail3")]
3939
extern "C" {
4040
pub fn change_parameter_name(d: i64) -> i32;
@@ -47,7 +47,7 @@ extern "C" {
4747
}
4848

4949
#[cfg(not(cfail1))]
50-
#[rustc_dirty(cfg = "cfail2", except = "hir_owner,hir_owner_nodes")]
50+
#[rustc_clean(cfg = "cfail2")]
5151
#[rustc_clean(cfg = "cfail3")]
5252
extern "C" {
5353
pub fn change_parameter_type(c: i32) -> i32;
@@ -60,7 +60,7 @@ extern "C" {
6060
}
6161

6262
#[cfg(not(cfail1))]
63-
#[rustc_dirty(cfg = "cfail2", except = "hir_owner,hir_owner_nodes")]
63+
#[rustc_clean(cfg = "cfail2")]
6464
#[rustc_clean(cfg = "cfail3")]
6565
extern "C" {
6666
pub fn change_return_type(c: i32) -> i8;
@@ -73,7 +73,7 @@ extern "C" {
7373
}
7474

7575
#[cfg(not(cfail1))]
76-
#[rustc_dirty(cfg = "cfail2", except = "hir_owner,hir_owner_nodes")]
76+
#[rustc_clean(cfg = "cfail2")]
7777
#[rustc_clean(cfg = "cfail3")]
7878
extern "C" {
7979
pub fn add_parameter(c: i32, d: i32) -> i32;
@@ -86,7 +86,7 @@ extern "C" {
8686
}
8787

8888
#[cfg(not(cfail1))]
89-
#[rustc_dirty(cfg = "cfail2", except = "hir_owner,hir_owner_nodes")]
89+
#[rustc_clean(cfg = "cfail2")]
9090
#[rustc_clean(cfg = "cfail3")]
9191
extern "C" {
9292
pub fn add_return_type(c: i32) -> i32;
@@ -99,7 +99,7 @@ extern "C" {
9999
}
100100

101101
#[cfg(not(cfail1))]
102-
#[rustc_dirty(cfg = "cfail2", except = "hir_owner,hir_owner_nodes")]
102+
#[rustc_clean(cfg = "cfail2")]
103103
#[rustc_clean(cfg = "cfail3")]
104104
extern "C" {
105105
pub fn make_function_variadic(c: i32, ...);
@@ -112,7 +112,7 @@ extern "C" {
112112
}
113113

114114
#[cfg(not(cfail1))]
115-
#[rustc_dirty(cfg = "cfail2", except = "hir_owner_nodes")]
115+
#[rustc_clean(cfg = "cfail2", except = "hir_owner")]
116116
#[rustc_clean(cfg = "cfail3")]
117117
extern "rust-call" {
118118
pub fn change_calling_convention(c: i32);
@@ -125,7 +125,7 @@ extern "C" {
125125
}
126126

127127
#[cfg(not(cfail1))]
128-
#[rustc_dirty(cfg = "cfail2", except = "hir_owner_nodes")]
128+
#[rustc_clean(cfg = "cfail2", except = "hir_owner")]
129129
#[rustc_clean(cfg = "cfail3")]
130130
extern "C" {
131131
pub fn make_function_public(c: i32);
@@ -138,7 +138,7 @@ extern "C" {
138138
}
139139

140140
#[cfg(not(cfail1))]
141-
#[rustc_dirty(cfg = "cfail2", except = "hir_owner_nodes")]
141+
#[rustc_clean(cfg = "cfail2", except = "hir_owner")]
142142
#[rustc_clean(cfg = "cfail3")]
143143
extern "C" {
144144
pub fn add_function1(c: i32);
@@ -153,7 +153,7 @@ extern "C" {
153153
}
154154

155155
#[cfg(not(cfail1))]
156-
#[rustc_dirty(cfg = "cfail2", except = "hir_owner,hir_owner_nodes")]
156+
#[rustc_clean(cfg = "cfail2")]
157157
#[rustc_clean(cfg = "cfail3")]
158158
#[link(name = "bar")]
159159
extern "C" {
@@ -170,7 +170,7 @@ mod indirectly_change_parameter_type {
170170
#[cfg(not(cfail1))]
171171
use super::c_i64 as c_int;
172172

173-
#[rustc_dirty(cfg = "cfail2", except = "hir_owner,hir_owner_nodes")]
173+
#[rustc_clean(cfg = "cfail2")]
174174
#[rustc_clean(cfg = "cfail3")]
175175
extern "C" {
176176
pub fn indirectly_change_parameter_type(c: c_int);
@@ -184,7 +184,7 @@ mod indirectly_change_return_type {
184184
#[cfg(not(cfail1))]
185185
use super::c_i64 as c_int;
186186

187-
#[rustc_dirty(cfg = "cfail2", except = "hir_owner,hir_owner_nodes")]
187+
#[rustc_clean(cfg = "cfail2")]
188188
#[rustc_clean(cfg = "cfail3")]
189189
extern "C" {
190190
pub fn indirectly_change_return_type() -> c_int;

src/test/incremental/hashes/inherent_impls.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@ impl Foo {
103103
#[rustc_clean(cfg="cfail2", except="hir_owner")]
104104
#[rustc_clean(cfg="cfail3")]
105105
impl Foo {
106-
#[rustc_dirty(cfg="cfail2", except="type_of,predicates_of,promoted_mir")]
106+
#[rustc_clean(
107+
cfg="cfail2",
108+
except="hir_owner,hir_owner_nodes,fn_sig,generics_of,typeck,associated_item,optimized_mir",
109+
)]
107110
#[rustc_clean(cfg="cfail3")]
108111
pub fn method_selfness(&self) { }
109112
}

0 commit comments

Comments
 (0)