@@ -144,6 +144,7 @@ Additional help:
144
144
}
145
145
146
146
pub fn describe_warnings ( ) {
147
+ use extra:: sort:: Sort ;
147
148
io:: println ( fmt ! ( "
148
149
Available lint options:
149
150
-W <foo> Warn about <foo>
@@ -153,8 +154,15 @@ Available lint options:
153
154
" ) ) ;
154
155
155
156
let lint_dict = lint:: get_lint_dict ( ) ;
157
+ let mut lint_dict = lint_dict. consume_iter ( )
158
+ . transform ( |( k, v) | ( v, k) )
159
+ . collect :: < ~[ ( lint:: LintSpec , & ' static str ) ] > ( ) ;
160
+ lint_dict. qsort ( ) ;
161
+
156
162
let mut max_key = 0 ;
157
- for lint_dict. each_key |k| { max_key = num:: max ( k. len ( ) , max_key) ; }
163
+ for lint_dict. iter( ) . advance |& ( _, name) | {
164
+ max_key = num:: max( name. len( ) , max_key) ;
165
+ }
158
166
fn padded ( max : uint , s : & str ) -> ~str {
159
167
str:: from_bytes ( vec:: from_elem ( max - s. len ( ) , ' ' as u8 ) ) + s
160
168
}
@@ -163,17 +171,12 @@ Available lint options:
163
171
padded( max_key, "name" ) , "default" , "meaning" ) ) ;
164
172
io:: println ( fmt ! ( " %s %7.7s %s\n " ,
165
173
padded( max_key, "----" ) , "-------" , "-------" ) ) ;
166
- for lint_dict. iter ( ) . advance |( k , v ) | {
167
- let k = k . replace( "_" , "-" ) ;
174
+ for lint_dict. consume_iter ( ) . advance |( spec , name ) | {
175
+ let name = name . replace( "_" , "-" ) ;
168
176
io:: println( fmt ! ( " %s %7.7s %s" ,
169
- padded( max_key, k) ,
170
- match v. default {
171
- lint:: allow => ~"allow",
172
- lint::warn => ~" warn",
173
- lint::deny => ~" deny",
174
- lint::forbid => ~" forbid"
175
- },
176
- v.desc));
177
+ padded( max_key, name) ,
178
+ lint:: level_to_str( spec. default ) ,
179
+ spec. desc) ) ;
177
180
}
178
181
io:: println( "" ) ;
179
182
}
0 commit comments