@@ -4,6 +4,7 @@ import syntax::{ast, visit};
4
4
import syntax:: attr;
5
5
import syntax:: codemap:: span;
6
6
import std:: map:: { map, hashmap, int_hash, hash_from_strs} ;
7
+ import std:: smallintmap:: { map, smallintmap} ;
7
8
import io:: writer_util;
8
9
import syntax:: print:: pprust:: expr_to_str;
9
10
@@ -29,6 +30,18 @@ enum lint {
29
30
old_vecs,
30
31
}
31
32
33
+ // This is pretty unfortunate. We really want some sort of "deriving Enum"
34
+ // type of thing.
35
+ fn int_to_lint ( i : int ) -> lint {
36
+ alt check i {
37
+ 0 { ctypes }
38
+ 1 { unused_imports }
39
+ 2 { while_true }
40
+ 3 { path_statement }
41
+ 4 { old_vecs }
42
+ }
43
+ }
44
+
32
45
enum level {
33
46
ignore, warn, error
34
47
}
@@ -75,22 +88,22 @@ fn get_lint_dict() -> lint_dict {
75
88
}
76
89
77
90
type ctxt = @{ dict : lint_dict ,
78
- curr : hashmap < lint , level > ,
91
+ curr : smallintmap < level > ,
79
92
tcx : ty:: ctxt } ;
80
93
81
94
impl methods for ctxt {
82
95
fn get_level ( lint : lint ) -> level {
83
- alt self . curr . find ( lint) {
96
+ alt self . curr . find ( lint as uint ) {
84
97
some ( c) { c }
85
98
none { ignore }
86
99
}
87
100
}
88
101
89
102
fn set_level ( lint : lint , level : level ) {
90
103
if level == ignore {
91
- self . curr . remove ( lint) ;
104
+ self . curr . remove ( lint as uint ) ;
92
105
} else {
93
- self . curr . insert ( lint, level) ;
106
+ self . curr . insert ( lint as uint , level) ;
94
107
}
95
108
}
96
109
@@ -186,7 +199,7 @@ fn time(do_it: bool, what: str, thunk: fn()) {
186
199
fn check_item ( cx : ctxt , i : @ast:: item ) {
187
200
cx. with_warn_attrs ( i. attrs ) { |cx|
188
201
for cx. curr . each { |lint, level|
189
- alt lint {
202
+ alt int_to_lint ( lint as int ) {
190
203
ctypes { check_item_ctypes( cx, level, i) ; }
191
204
unused_imports { check_item_unused_imports( cx, level, i) ; }
192
205
while_true { check_item_while_true( cx, level, i) ; }
@@ -338,7 +351,7 @@ fn check_crate(tcx: ty::ctxt, crate: @ast::crate,
338
351
fn eq_lint ( & & a: lint , & & b: lint ) -> bool { a == b }
339
352
340
353
let cx = @{ dict: get_lint_dict ( ) ,
341
- curr: hashmap ( hash_lint , eq_lint ) ,
354
+ curr: std :: smallintmap :: mk ( ) ,
342
355
tcx: tcx} ;
343
356
344
357
// Install defaults.
0 commit comments