Skip to content

Commit

Permalink
Rename lint::Lint to lint::LintId
Browse files Browse the repository at this point in the history
  • Loading branch information
Keegan McAllister committed Jun 24, 2014
1 parent 3144614 commit 5d4c96a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/librustc/driver/config.rs
Expand Up @@ -70,7 +70,7 @@ pub struct Options {
pub gc: bool,
pub optimize: OptLevel,
pub debuginfo: DebugInfoLevel,
pub lint_opts: Vec<(lint::Lint, lint::Level)> ,
pub lint_opts: Vec<(lint::LintId, lint::Level)> ,
pub output_types: Vec<back::link::OutputType> ,
// This was mutable for rustpkg, which updates search paths based on the
// parsed code. It remains mutable in case its replacements wants to use
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/driver/session.rs
Expand Up @@ -43,7 +43,7 @@ pub struct Session {
// expected to be absolute. `None` means that there is no source file.
pub local_crate_source_file: Option<Path>,
pub working_dir: Path,
pub lints: RefCell<NodeMap<Vec<(lint::Lint, codemap::Span, String)>>>,
pub lints: RefCell<NodeMap<Vec<(lint::LintId, codemap::Span, String)>>>,
pub node_id: Cell<ast::NodeId>,
pub crate_types: RefCell<Vec<config::CrateType>>,
pub features: front::feature_gate::Features,
Expand Down Expand Up @@ -106,7 +106,7 @@ impl Session {
self.diagnostic().handler().unimpl(msg)
}
pub fn add_lint(&self,
lint: lint::Lint,
lint: lint::LintId,
id: ast::NodeId,
sp: Span,
msg: String) {
Expand Down
20 changes: 10 additions & 10 deletions src/librustc/lint/mod.rs
Expand Up @@ -59,7 +59,7 @@ use syntax::{ast, ast_util, visit};
mod builtin;

#[deriving(Clone, Show, PartialEq, PartialOrd, Eq, Ord, Hash)]
pub enum Lint {
pub enum LintId {
CTypes,
UnusedImports,
UnnecessaryQualification,
Expand Down Expand Up @@ -126,7 +126,7 @@ pub enum Level {
#[deriving(Clone, PartialEq, PartialOrd, Eq, Ord)]
pub struct LintSpec {
pub default: Level,
pub lint: Lint,
pub lint: LintId,
pub desc: &'static str,
}

Expand Down Expand Up @@ -449,7 +449,7 @@ struct Context<'a> {
/// When recursing into an attributed node of the ast which modifies lint
/// levels, this stack keeps track of the previous lint levels of whatever
/// was modified.
lint_stack: Vec<(Lint, Level, LintSource)>,
lint_stack: Vec<(LintId, Level, LintSource)>,

/// Id of the last visited negated expression
negated_expr_id: ast::NodeId,
Expand All @@ -459,7 +459,7 @@ struct Context<'a> {

/// Level of lints for certain NodeIds, stored here because the body of
/// the lint needs to run in trans.
node_levels: HashMap<(ast::NodeId, Lint), (Level, LintSource)>,
node_levels: HashMap<(ast::NodeId, LintId), (Level, LintSource)>,
}

pub fn emit_lint(level: Level, src: LintSource, msg: &str, span: Span,
Expand Down Expand Up @@ -496,7 +496,7 @@ pub fn emit_lint(level: Level, src: LintSource, msg: &str, span: Span,
}
}

pub fn lint_to_str(lint: Lint) -> &'static str {
pub fn lint_to_str(lint: LintId) -> &'static str {
for &(name, lspec) in lint_table.iter() {
if lspec.lint == lint {
return name;
Expand All @@ -507,29 +507,29 @@ pub fn lint_to_str(lint: Lint) -> &'static str {
}

impl<'a> Context<'a> {
fn get_level(&self, lint: Lint) -> Level {
fn get_level(&self, lint: LintId) -> Level {
match self.cur.find(&(lint as uint)) {
Some(&(lvl, _)) => lvl,
None => Allow
}
}

fn get_source(&self, lint: Lint) -> LintSource {
fn get_source(&self, lint: LintId) -> LintSource {
match self.cur.find(&(lint as uint)) {
Some(&(_, src)) => src,
None => Default
}
}

fn set_level(&mut self, lint: Lint, level: Level, src: LintSource) {
fn set_level(&mut self, lint: LintId, level: Level, src: LintSource) {
if level == Allow {
self.cur.remove(&(lint as uint));
} else {
self.cur.insert(lint as uint, (level, src));
}
}

fn lint_to_str(&self, lint: Lint) -> &'static str {
fn lint_to_str(&self, lint: LintId) -> &'static str {
for (k, v) in self.dict.iter() {
if v.lint == lint {
return *k;
Expand All @@ -538,7 +538,7 @@ impl<'a> Context<'a> {
fail!("unregistered lint {}", lint);
}

fn span_lint(&self, lint: Lint, span: Span, msg: &str) {
fn span_lint(&self, lint: LintId, span: Span, msg: &str) {
let (level, src) = match self.cur.find(&(lint as uint)) {
None => { return }
Some(&(Warn, src)) => (self.get_level(Warnings), src),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/ty.rs
Expand Up @@ -367,7 +367,7 @@ pub struct ctxt {

pub dependency_formats: RefCell<dependency_format::Dependencies>,

pub node_lint_levels: RefCell<HashMap<(ast::NodeId, lint::Lint),
pub node_lint_levels: RefCell<HashMap<(ast::NodeId, lint::LintId),
(lint::Level, lint::LintSource)>>,

/// The types that must be asserted to be the same size for `transmute`
Expand Down

0 comments on commit 5d4c96a

Please sign in to comment.