Skip to content

Commit dc1eeaf

Browse files
committed
cleanup, use base groups to build them
1 parent 80d904f commit dc1eeaf

File tree

1 file changed

+68
-29
lines changed

1 file changed

+68
-29
lines changed

src/librustc_incremental/persist/dirty_clean.rs

Lines changed: 68 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,28 @@ use rustc_data_structures::fx::{FxHashSet, FxHashMap};
5858
use syntax_pos::Span;
5959
use rustc::ty::TyCtxt;
6060

61-
const EXCEPT: &'static str = "except";
62-
const LABEL: &'static str = "label";
63-
const CFG: &'static str = "cfg";
61+
const EXCEPT: &str = "except";
62+
const LABEL: &str = "label";
63+
const CFG: &str = "cfg";
6464

65-
// Free standing functions
66-
const LABELS_FN: [&'static str; 9] = [
65+
// Base and Extra labels to build up the labels
66+
67+
/// DefNodes for Hir, which is pretty much everything
68+
const BASE_HIR: &[&str] = &[
6769
// Hir and HirBody should be computed for all nodes
6870
label_strs::Hir,
6971
label_strs::HirBody,
72+
];
7073

71-
// These represent executable code, so we want to test their MIR:
74+
/// DefNodes for MirValidated/Optimized, which is relevant in "executable"
75+
/// code, i.e. functions+methods
76+
const BASE_MIR: &[&str] = &[
7277
label_strs::MirValidated,
7378
label_strs::MirOptimized,
79+
];
7480

81+
/// DefNodes for functions + methods
82+
const BASE_FN: &[&str] = &[
7583
// Callers will depend on the signature of these items, so we better test
7684
label_strs::TypeOfItem,
7785
label_strs::GenericsOfItem,
@@ -83,30 +91,59 @@ const LABELS_FN: [&'static str; 9] = [
8391
label_strs::TypeckTables,
8492
];
8593

86-
// FIXME(vitiral):
87-
// ### Methods
88-
//
89-
// methods are identical to functions, but add:
90-
//
91-
// AssociatedItems
92-
//
93-
// ### Struct, Enum, and Union Definitions
94-
//
95-
// For these we should at least test
96-
//
97-
// TypeOfItem,
98-
// GenericsOfItem, and
99-
// PredicatesOfItem.
100-
//
101-
// in addition to Hir and HirBody. Note that changing the type of a
102-
// field does not change the type of the struct or enum, but adding/removing
103-
// fields or changing a fields name or visibility does.
104-
// ### Struct/Enum/Unions Fields
94+
/// Struct, Enum and Union DefNodes
95+
///
96+
/// Note that changing the type of a field does not change the type of the struct or enum, but
97+
/// adding/removing fields or changing a fields name or visibility does.
98+
const BASE_STRUCT: &[&str] = &[
99+
label_strs::TypeOfItem,
100+
label_strs::GenericsOfItem,
101+
label_strs::PredicatesOfItem,
102+
];
103+
104+
/// For associated items (types, constants, and (FIXME: trait?) methods)
105+
///
106+
/// FIXME: why would a type/constant assert TraitOfItem?
107+
const BASE_ASSOCIATED: &[&str] = &[
108+
label_strs::AssociatedItems,
109+
label_strs::TraitOfItem,
110+
];
111+
112+
/// Extra DefNodes for methods (as opposed to functions)
113+
const EXTRA_METHOD: &[&str] = &[
114+
label_strs::AssociatedItems,
115+
];
116+
117+
// Fully Built Labels
118+
119+
/// Function DefNodes
120+
const LABELS_FN: &[&[&str]] = &[
121+
BASE_HIR,
122+
BASE_MIR,
123+
BASE_FN,
124+
];
125+
126+
/// Method DefNodes
127+
const LABELS_METHOD: &[&[&str]] = &[
128+
BASE_HIR,
129+
BASE_MIR,
130+
BASE_FN,
131+
EXTRA_METHOD,
132+
];
133+
134+
/// Struct DefNodes
135+
const LABELS_STRUCT: &[&[&str]] = &[
136+
BASE_HIR,
137+
BASE_STRUCT,
138+
];
139+
140+
// FIXME: Struct/Enum/Unions Fields (there is currently no way to attach these)
105141
//
106142
// Fields are kind of separate from their containers, as they can change independently from them. We should at least check
107143
//
108144
// TypeOfItem for these.
109-
//
145+
146+
// FIXME: need to add these
110147
// ### Trait Definitions
111148
//
112149
// For these we'll want to check
@@ -129,7 +166,7 @@ const LABELS_FN: [&'static str; 9] = [
129166
//
130167
// ### Associated Items
131168
//
132-
// For associated items (types, constants, and methods) we should check
169+
// For associated items (types, constants, and trait-methods) we should check
133170
//
134171
// TraitOfItem,
135172
// AssociatedItems.
@@ -142,7 +179,6 @@ struct Assertion {
142179
dirty: Labels,
143180
}
144181

145-
146182
impl Assertion {
147183
fn from_clean_labels(labels: Labels) -> Assertion {
148184
Assertion {
@@ -288,7 +324,10 @@ impl<'a, 'tcx> DirtyCleanVisitor<'a, 'tcx> {
288324
},
289325
_ => panic!("clean/dirty auto-assertions not yet defined for {:?}", node),
290326
};
291-
(name, Labels::from_iter(labels.iter().map(|l| l.to_string())))
327+
let labels = Labels::from_iter(
328+
labels.iter().flat_map(|s| s.iter().map(|l| l.to_string()))
329+
);
330+
(name, labels)
292331
}
293332

294333
fn resolve_labels(&self, item: &NestedMetaItem, value: &str) -> Labels {

0 commit comments

Comments
 (0)