Skip to content

Re-implement lint with less emphasis on item ids #6093

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/libcore/hashmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use container::{Container, Mutable, Map, Set};
use cmp::{Eq, Equiv};
use hash::Hash;
use old_iter::BaseIter;
use hash::Hash;
use old_iter;
use option::{None, Option, Some};
use rand::RngUtil;
Expand Down
1 change: 0 additions & 1 deletion src/librustc/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ pub mod write {
use back::link::{output_type_assembly, output_type_bitcode};
use back::link::{output_type_exe, output_type_llvm_assembly};
use back::link::{output_type_object};
use back::link::output_type;
use driver::session::Session;
use driver::session;
use lib::llvm::llvm;
Expand Down
7 changes: 2 additions & 5 deletions src/librustc/driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use middle;
use util::common::time;
use util::ppaux;

use core::hashmap::HashMap;
use core::int;
use core::io;
use core::os;
Expand Down Expand Up @@ -200,9 +201,6 @@ pub fn compile_rest(sess: Session,
crate = time(time_passes, ~"core injection", ||
front::core_inject::maybe_inject_libcore_ref(sess, crate));

time(time_passes, ~"building lint settings table", ||
lint::build_settings_crate(sess, crate));

let ast_map = time(time_passes, ~"ast indexing", ||
syntax::ast_map::map_crate(sess.diagnostic(), crate));

Expand Down Expand Up @@ -709,7 +707,6 @@ pub fn build_session_(sopts: @session::options,
&sopts.maybe_sysroot,
sopts.target_triple,
/*bad*/copy sopts.addl_lib_search_paths);
let lint_settings = lint::mk_lint_settings();
@Session_ {
targ_cfg: target_cfg,
opts: sopts,
Expand All @@ -723,7 +720,7 @@ pub fn build_session_(sopts: @session::options,
filesearch: filesearch,
building_library: @mut false,
working_dir: os::getcwd(),
lint_settings: lint_settings
lints: @mut HashMap::new(),
}
}

Expand Down
26 changes: 8 additions & 18 deletions src/librustc/driver/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ use syntax::{ast, codemap};
use syntax::abi;
use syntax;

use core::hashmap::HashMap;

#[deriving(Eq)]
pub enum os { os_win32, os_macos, os_linux, os_android, os_freebsd, }

Expand Down Expand Up @@ -170,7 +172,7 @@ pub struct Session_ {
filesearch: @filesearch::FileSearch,
building_library: @mut bool,
working_dir: Path,
lint_settings: lint::LintSettings
lints: @mut HashMap<ast::node_id, ~[(lint::lint, codemap::span, ~str)]>,
}

pub type Session = @Session_;
Expand Down Expand Up @@ -221,24 +223,12 @@ pub impl Session_ {
fn unimpl(@self, msg: &str) -> ! {
self.span_diagnostic.handler().unimpl(msg)
}
fn span_lint_level(@self, level: lint::level, sp: span, msg: &str) {
match level {
lint::allow => { },
lint::warn => self.span_warn(sp, msg),
lint::deny | lint::forbid => {
self.span_err(sp, msg);
}
fn add_lint(@self, lint: lint::lint, id: ast::node_id, sp: span, msg: ~str) {
match self.lints.find_mut(&id) {
Some(arr) => { arr.push((lint, sp, msg)); return; }
None => {}
}
}
fn span_lint(@self, lint_mode: lint::lint,
expr_id: ast::node_id,
item_id: ast::node_id,
span: span,
msg: &str) {
let level = lint::get_lint_settings_level(
self.lint_settings, lint_mode, expr_id, item_id);
let msg = fmt!("%s [-W %s]", msg, lint::get_lint_name(lint_mode));
self.span_lint_level(level, span, msg);
self.lints.insert(id, ~[(lint, sp, msg)]);
}
fn next_node_id(@self) -> ast::node_id {
return syntax::parse::next_node_id(self.parse_sess);
Expand Down
Loading