Skip to content

Commit 142f2fa

Browse files
committed
---
yaml --- r: 13164 b: refs/heads/master c: 7b02f29 h: refs/heads/master v: v3
1 parent 75e5c11 commit 142f2fa

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 3dfb1747939cb5b97dda29842772cfbe52c7b224
2+
refs/heads/master: 7b02f29d47a05eb4cc018b362e87f3c05181e4e2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/rustc/middle/lint.rs

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import syntax::{ast, visit};
44
import syntax::attr;
55
import syntax::codemap::span;
66
import std::map::{map,hashmap,int_hash,hash_from_strs};
7+
import std::smallintmap::{map,smallintmap};
78
import io::writer_util;
89
import syntax::print::pprust::expr_to_str;
910

@@ -29,6 +30,18 @@ enum lint {
2930
old_vecs,
3031
}
3132

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+
3245
enum level {
3346
ignore, warn, error
3447
}
@@ -75,22 +88,22 @@ fn get_lint_dict() -> lint_dict {
7588
}
7689

7790
type ctxt = @{dict: lint_dict,
78-
curr: hashmap<lint, level>,
91+
curr: smallintmap<level>,
7992
tcx: ty::ctxt};
8093

8194
impl methods for ctxt {
8295
fn get_level(lint: lint) -> level {
83-
alt self.curr.find(lint) {
96+
alt self.curr.find(lint as uint) {
8497
some(c) { c }
8598
none { ignore }
8699
}
87100
}
88101

89102
fn set_level(lint: lint, level: level) {
90103
if level == ignore {
91-
self.curr.remove(lint);
104+
self.curr.remove(lint as uint);
92105
} else {
93-
self.curr.insert(lint, level);
106+
self.curr.insert(lint as uint, level);
94107
}
95108
}
96109

@@ -186,7 +199,7 @@ fn time(do_it: bool, what: str, thunk: fn()) {
186199
fn check_item(cx: ctxt, i: @ast::item) {
187200
cx.with_warn_attrs(i.attrs) {|cx|
188201
for cx.curr.each {|lint, level|
189-
alt lint {
202+
alt int_to_lint(lint as int) {
190203
ctypes { check_item_ctypes(cx, level, i); }
191204
unused_imports { check_item_unused_imports(cx, level, i); }
192205
while_true { check_item_while_true(cx, level, i); }
@@ -338,7 +351,7 @@ fn check_crate(tcx: ty::ctxt, crate: @ast::crate,
338351
fn eq_lint(&&a: lint, &&b: lint) -> bool { a == b }
339352

340353
let cx = @{dict: get_lint_dict(),
341-
curr: hashmap(hash_lint, eq_lint),
354+
curr: std::smallintmap::mk(),
342355
tcx: tcx};
343356

344357
// Install defaults.

0 commit comments

Comments
 (0)