Skip to content

Commit dc48a55

Browse files
committed
Show lint names
1 parent 356ebe8 commit dc48a55

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/librustc/driver/session.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ pub impl Session_ {
234234
msg: &str) {
235235
let level = lint::get_lint_settings_level(
236236
self.lint_settings, lint_mode, expr_id, item_id);
237+
let msg = fmt!("%s [-W%s]", msg, lint::get_lint_name(lint_mode));
237238
self.span_lint_level(level, span, msg);
238239
}
239240
fn next_node_id(@self) -> ast::node_id {

src/librustc/middle/lint.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,14 @@ pub fn get_lint_dict() -> LintDict {
245245
return @map;
246246
}
247247

248+
pub fn get_lint_name(lint_mode: lint) -> ~str {
249+
for lint_table.each |&(name, spec)| {
250+
if spec.lint == lint_mode {
251+
return name.to_str();
252+
}
253+
}
254+
fail!();
255+
}
248256
// This is a highly not-optimal set of data structure decisions.
249257
type LintModes = @mut SmallIntMap<level>;
250258
type LintModeMap = @mut HashMap<ast::node_id, LintModes>;

0 commit comments

Comments
 (0)