@@ -58,20 +58,28 @@ use rustc_data_structures::fx::{FxHashSet, FxHashMap};
58
58
use syntax_pos:: Span ;
59
59
use rustc:: ty:: TyCtxt ;
60
60
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" ;
64
64
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 ] = & [
67
69
// Hir and HirBody should be computed for all nodes
68
70
label_strs:: Hir ,
69
71
label_strs:: HirBody ,
72
+ ] ;
70
73
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 ] = & [
72
77
label_strs:: MirValidated ,
73
78
label_strs:: MirOptimized ,
79
+ ] ;
74
80
81
+ /// DefNodes for functions + methods
82
+ const BASE_FN : & [ & str ] = & [
75
83
// Callers will depend on the signature of these items, so we better test
76
84
label_strs:: TypeOfItem ,
77
85
label_strs:: GenericsOfItem ,
@@ -83,30 +91,59 @@ const LABELS_FN: [&'static str; 9] = [
83
91
label_strs:: TypeckTables ,
84
92
] ;
85
93
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)
105
141
//
106
142
// Fields are kind of separate from their containers, as they can change independently from them. We should at least check
107
143
//
108
144
// TypeOfItem for these.
109
- //
145
+
146
+ // FIXME: need to add these
110
147
// ### Trait Definitions
111
148
//
112
149
// For these we'll want to check
@@ -129,7 +166,7 @@ const LABELS_FN: [&'static str; 9] = [
129
166
//
130
167
// ### Associated Items
131
168
//
132
- // For associated items (types, constants, and methods) we should check
169
+ // For associated items (types, constants, and trait- methods) we should check
133
170
//
134
171
// TraitOfItem,
135
172
// AssociatedItems.
@@ -142,7 +179,6 @@ struct Assertion {
142
179
dirty : Labels ,
143
180
}
144
181
145
-
146
182
impl Assertion {
147
183
fn from_clean_labels ( labels : Labels ) -> Assertion {
148
184
Assertion {
@@ -288,7 +324,10 @@ impl<'a, 'tcx> DirtyCleanVisitor<'a, 'tcx> {
288
324
} ,
289
325
_ => panic ! ( "clean/dirty auto-assertions not yet defined for {:?}" , node) ,
290
326
} ;
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)
292
331
}
293
332
294
333
fn resolve_labels ( & self , item : & NestedMetaItem , value : & str ) -> Labels {
0 commit comments