@@ -39,22 +39,15 @@ impl fmt::Display for Status {
39
39
}
40
40
}
41
41
42
-
43
42
struct Feature {
44
- name : String ,
45
- level : Status ,
46
- since : String ,
47
- }
48
-
49
- struct LibFeature {
50
43
level : Status ,
51
44
since : String ,
52
45
}
53
46
54
47
pub fn check ( path : & Path , bad : & mut bool ) {
55
48
let features = collect_lang_features ( & path. join ( "libsyntax/feature_gate.rs" ) ) ;
56
49
assert ! ( !features. is_empty( ) ) ;
57
- let mut lib_features = HashMap :: < String , LibFeature > :: new ( ) ;
50
+ let mut lib_features = HashMap :: < String , Feature > :: new ( ) ;
58
51
59
52
let mut contents = String :: new ( ) ;
60
53
super :: walk ( path,
@@ -97,7 +90,7 @@ pub fn check(path: &Path, bad: &mut bool) {
97
90
None => "None" ,
98
91
} ;
99
92
100
- if features. iter ( ) . any ( |f| f . name == feature_name) {
93
+ if features. contains_key ( feature_name) {
101
94
err ( "duplicating a lang feature" ) ;
102
95
}
103
96
if let Some ( ref s) = lib_features. get ( feature_name) {
@@ -110,7 +103,7 @@ pub fn check(path: &Path, bad: &mut bool) {
110
103
continue ;
111
104
}
112
105
lib_features. insert ( feature_name. to_owned ( ) ,
113
- LibFeature {
106
+ Feature {
114
107
level : level,
115
108
since : since. to_owned ( ) ,
116
109
} ) ;
@@ -122,9 +115,9 @@ pub fn check(path: &Path, bad: &mut bool) {
122
115
}
123
116
124
117
let mut lines = Vec :: new ( ) ;
125
- for feature in features {
118
+ for ( name , feature) in features {
126
119
lines. push ( format ! ( "{:<32} {:<8} {:<12} {:<8}" ,
127
- feature . name,
120
+ name,
128
121
"lang" ,
129
122
feature. level,
130
123
feature. since) ) ;
@@ -150,7 +143,7 @@ fn find_attr_val<'a>(line: &'a str, attr: &str) -> Option<&'a str> {
150
143
. map ( |( i, j) | & line[ i..j] )
151
144
}
152
145
153
- fn collect_lang_features ( path : & Path ) -> Vec < Feature > {
146
+ fn collect_lang_features ( path : & Path ) -> HashMap < String , Feature > {
154
147
let mut contents = String :: new ( ) ;
155
148
t ! ( t!( File :: open( path) ) . read_to_string( & mut contents) ) ;
156
149
@@ -165,11 +158,11 @@ fn collect_lang_features(path: &Path) -> Vec<Feature> {
165
158
} ;
166
159
let name = parts. next ( ) . unwrap ( ) . trim ( ) ;
167
160
let since = parts. next ( ) . unwrap ( ) . trim ( ) . trim_matches ( '"' ) ;
168
- Some ( Feature {
169
- name : name . to_owned ( ) ,
170
- level : level,
171
- since : since. to_owned ( ) ,
172
- } )
161
+ Some ( ( name . to_owned ( ) ,
162
+ Feature {
163
+ level : level,
164
+ since : since. to_owned ( ) ,
165
+ } ) )
173
166
} )
174
167
. collect ( )
175
168
}
0 commit comments