diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs index 83ffd194fad..2fb8b2d4ac9 100644 --- a/src/librustc/driver/driver.rs +++ b/src/librustc/driver/driver.rs @@ -786,7 +786,7 @@ pub fn collect_crate_types(session: &Session, } Some(ref n) if n.equiv(&("bin")) => Some(config::CrateTypeExecutable), Some(_) => { - session.add_lint(lint::builtin::unknown_crate_type, + session.add_lint(lint::builtin::UNKNOWN_CRATE_TYPE, ast::CRATE_NODE_ID, a.span, "invalid `crate_type` \ @@ -794,7 +794,7 @@ pub fn collect_crate_types(session: &Session, None } _ => { - session.add_lint(lint::builtin::unknown_crate_type, + session.add_lint(lint::builtin::UNKNOWN_CRATE_TYPE, ast::CRATE_NODE_ID, a.span, "`crate_type` requires a \ diff --git a/src/librustc/front/feature_gate.rs b/src/librustc/front/feature_gate.rs index b7c1ebcda98..89697dc1674 100644 --- a/src/librustc/front/feature_gate.rs +++ b/src/librustc/front/feature_gate.rs @@ -409,7 +409,7 @@ pub fn check_crate(sess: &Session, krate: &ast::Crate) { directive not necessary"); } None => { - sess.add_lint(lint::builtin::unknown_features, + sess.add_lint(lint::builtin::UNKNOWN_FEATURES, ast::CRATE_NODE_ID, mi.span, "unknown feature".to_string()); diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index f6172b8e7df..903cb7f4f26 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -54,14 +54,14 @@ use syntax::codemap::Span; use syntax::parse::token; use syntax::{ast, ast_util, visit}; -declare_lint!(while_true, Warn, +declare_lint!(WHILE_TRUE, Warn, "suggest using `loop { }` instead of `while true { }`") pub struct WhileTrue; impl LintPass for WhileTrue { fn get_lints(&self) -> LintArray { - lint_array!(while_true) + lint_array!(WHILE_TRUE) } fn check_expr(&mut self, cx: &Context, e: &ast::Expr) { @@ -71,7 +71,7 @@ impl LintPass for WhileTrue { ast::ExprLit(lit) => { match lit.node { ast::LitBool(true) => { - cx.span_lint(while_true, e.span, + cx.span_lint(WHILE_TRUE, e.span, "denote infinite loops with loop \ { ... }"); } @@ -86,14 +86,14 @@ impl LintPass for WhileTrue { } } -declare_lint!(unnecessary_typecast, Allow, +declare_lint!(UNNECESSARY_TYPECAST, Allow, "detects unnecessary type casts, that can be removed") pub struct UnusedCasts; impl LintPass for UnusedCasts { fn get_lints(&self) -> LintArray { - lint_array!(unnecessary_typecast) + lint_array!(UNNECESSARY_TYPECAST) } fn check_expr(&mut self, cx: &Context, e: &ast::Expr) { @@ -101,7 +101,7 @@ impl LintPass for UnusedCasts { ast::ExprCast(expr, ty) => { let t_t = ast_ty_to_ty(cx, &infer::new_infer_ctxt(cx.tcx), ty); if ty::get(ty::expr_ty(cx.tcx, expr)).sty == ty::get(t_t).sty { - cx.span_lint(unnecessary_typecast, ty.span, "unnecessary type cast"); + cx.span_lint(UNNECESSARY_TYPECAST, ty.span, "unnecessary type cast"); } } _ => () @@ -109,13 +109,13 @@ impl LintPass for UnusedCasts { } } -declare_lint!(unsigned_negate, Warn, +declare_lint!(UNSIGNED_NEGATE, Warn, "using an unary minus operator on unsigned type") -declare_lint!(type_limits, Warn, +declare_lint!(TYPE_LIMITS, Warn, "comparisons made useless by limits of the types involved") -declare_lint!(type_overflow, Warn, +declare_lint!(TYPE_OVERFLOW, Warn, "literal out of range for its type") pub struct TypeLimits { @@ -133,7 +133,7 @@ impl TypeLimits { impl LintPass for TypeLimits { fn get_lints(&self) -> LintArray { - lint_array!(unsigned_negate, type_limits, type_overflow) + lint_array!(UNSIGNED_NEGATE, TYPE_LIMITS, TYPE_OVERFLOW) } fn check_expr(&mut self, cx: &Context, e: &ast::Expr) { @@ -143,7 +143,7 @@ impl LintPass for TypeLimits { ast::ExprLit(lit) => { match lit.node { ast::LitUint(..) => { - cx.span_lint(unsigned_negate, e.span, + cx.span_lint(UNSIGNED_NEGATE, e.span, "negation of unsigned int literal may \ be unintentional"); }, @@ -154,7 +154,7 @@ impl LintPass for TypeLimits { let t = ty::expr_ty(cx.tcx, expr); match ty::get(t).sty { ty::ty_uint(_) => { - cx.span_lint(unsigned_negate, e.span, + cx.span_lint(UNSIGNED_NEGATE, e.span, "negation of unsigned int variable may \ be unintentional"); }, @@ -172,7 +172,7 @@ impl LintPass for TypeLimits { }, ast::ExprBinary(binop, l, r) => { if is_comparison(binop) && !check_limits(cx.tcx, binop, l, r) { - cx.span_lint(type_limits, e.span, + cx.span_lint(TYPE_LIMITS, e.span, "comparison is useless due to type limits"); } }, @@ -193,7 +193,7 @@ impl LintPass for TypeLimits { lit_val *= -1; } if lit_val < min || lit_val > max { - cx.span_lint(type_overflow, e.span, + cx.span_lint(TYPE_OVERFLOW, e.span, "literal out of range for its type"); } }, @@ -209,7 +209,7 @@ impl LintPass for TypeLimits { _ => fail!() }; if lit_val < min || lit_val > max { - cx.span_lint(type_overflow, e.span, + cx.span_lint(TYPE_OVERFLOW, e.span, "literal out of range for its type"); } }, @@ -315,14 +315,14 @@ impl LintPass for TypeLimits { } } -declare_lint!(ctypes, Warn, +declare_lint!(CTYPES, Warn, "proper use of libc types in foreign modules") pub struct CTypes; impl LintPass for CTypes { fn get_lints(&self) -> LintArray { - lint_array!(ctypes) + lint_array!(CTYPES) } fn check_item(&mut self, cx: &Context, it: &ast::Item) { @@ -331,18 +331,18 @@ impl LintPass for CTypes { ast::TyPath(_, _, id) => { match cx.tcx.def_map.borrow().get_copy(&id) { def::DefPrimTy(ast::TyInt(ast::TyI)) => { - cx.span_lint(ctypes, ty.span, + cx.span_lint(CTYPES, ty.span, "found rust type `int` in foreign module, while \ libc::c_int or libc::c_long should be used"); } def::DefPrimTy(ast::TyUint(ast::TyU)) => { - cx.span_lint(ctypes, ty.span, + cx.span_lint(CTYPES, ty.span, "found rust type `uint` in foreign module, while \ libc::c_uint or libc::c_ulong should be used"); } def::DefTy(def_id) => { if !adt::is_ffi_safe(cx.tcx, def_id) { - cx.span_lint(ctypes, ty.span, + cx.span_lint(CTYPES, ty.span, "found enum type without foreign-function-safe \ representation annotation in foreign module"); // hmm... this message could be more helpful @@ -377,13 +377,13 @@ impl LintPass for CTypes { } } -declare_lint!(managed_heap_memory, Allow, +declare_lint!(MANAGED_HEAP_MEMORY, Allow, "use of managed (@ type) heap memory") -declare_lint!(owned_heap_memory, Allow, +declare_lint!(OWNED_HEAP_MEMORY, Allow, "use of owned (Box type) heap memory") -declare_lint!(heap_memory, Allow, +declare_lint!(HEAP_MEMORY, Allow, "use of any (Box type or @ type) heap memory") pub struct HeapMemory; @@ -416,22 +416,22 @@ impl HeapMemory { if n_uniq > 0 { let s = ty_to_str(cx.tcx, ty); let m = format!("type uses owned (Box type) pointers: {}", s); - cx.span_lint(owned_heap_memory, span, m.as_slice()); - cx.span_lint(heap_memory, span, m.as_slice()); + cx.span_lint(OWNED_HEAP_MEMORY, span, m.as_slice()); + cx.span_lint(HEAP_MEMORY, span, m.as_slice()); } if n_box > 0 { let s = ty_to_str(cx.tcx, ty); let m = format!("type uses managed (@ type) pointers: {}", s); - cx.span_lint(managed_heap_memory, span, m.as_slice()); - cx.span_lint(heap_memory, span, m.as_slice()); + cx.span_lint(MANAGED_HEAP_MEMORY, span, m.as_slice()); + cx.span_lint(HEAP_MEMORY, span, m.as_slice()); } } } impl LintPass for HeapMemory { fn get_lints(&self) -> LintArray { - lint_array!(managed_heap_memory, owned_heap_memory, heap_memory) + lint_array!(MANAGED_HEAP_MEMORY, OWNED_HEAP_MEMORY, HEAP_MEMORY) } fn check_item(&mut self, cx: &Context, it: &ast::Item) { @@ -463,7 +463,7 @@ impl LintPass for HeapMemory { } } -declare_lint!(raw_pointer_deriving, Warn, +declare_lint!(RAW_POINTER_DERIVING, Warn, "uses of #[deriving] with raw pointers are rarely correct") struct RawPtrDerivingVisitor<'a> { @@ -474,7 +474,7 @@ impl<'a> visit::Visitor<()> for RawPtrDerivingVisitor<'a> { fn visit_ty(&mut self, ty: &ast::Ty, _: ()) { static MSG: &'static str = "use of `#[deriving]` with a raw pointer"; match ty.node { - ast::TyPtr(..) => self.cx.span_lint(raw_pointer_deriving, ty.span, MSG), + ast::TyPtr(..) => self.cx.span_lint(RAW_POINTER_DERIVING, ty.span, MSG), _ => {} } visit::walk_ty(self, ty, ()); @@ -498,7 +498,7 @@ impl RawPointerDeriving { impl LintPass for RawPointerDeriving { fn get_lints(&self) -> LintArray { - lint_array!(raw_pointer_deriving) + lint_array!(RAW_POINTER_DERIVING) } fn check_item(&mut self, cx: &Context, item: &ast::Item) { @@ -531,14 +531,14 @@ impl LintPass for RawPointerDeriving { } } -declare_lint!(unused_attribute, Warn, +declare_lint!(UNUSED_ATTRIBUTE, Warn, "detects attributes that were not used by the compiler") pub struct UnusedAttribute; impl LintPass for UnusedAttribute { fn get_lints(&self) -> LintArray { - lint_array!(unused_attribute) + lint_array!(UNUSED_ATTRIBUTE) } fn check_attribute(&mut self, cx: &Context, attr: &ast::Attribute) { @@ -598,7 +598,7 @@ impl LintPass for UnusedAttribute { } if !attr::is_used(attr) { - cx.span_lint(unused_attribute, attr.span, "unused attribute"); + cx.span_lint(UNUSED_ATTRIBUTE, attr.span, "unused attribute"); if CRATE_ATTRS.contains(&attr.name().get()) { let msg = match attr.node.style { ast::AttrOuter => "crate-level attribute should be an inner \ @@ -606,27 +606,27 @@ impl LintPass for UnusedAttribute { ast::AttrInner => "crate-level attribute should be in the \ root module", }; - cx.span_lint(unused_attribute, attr.span, msg); + cx.span_lint(UNUSED_ATTRIBUTE, attr.span, msg); } } } } -declare_lint!(path_statement, Warn, +declare_lint!(PATH_STATEMENT, Warn, "path statements with no effect") pub struct PathStatement; impl LintPass for PathStatement { fn get_lints(&self) -> LintArray { - lint_array!(path_statement) + lint_array!(PATH_STATEMENT) } fn check_stmt(&mut self, cx: &Context, s: &ast::Stmt) { match s.node { ast::StmtSemi(expr, _) => { match expr.node { - ast::ExprPath(_) => cx.span_lint(path_statement, s.span, + ast::ExprPath(_) => cx.span_lint(PATH_STATEMENT, s.span, "path statement with no effect"), _ => () } @@ -636,17 +636,17 @@ impl LintPass for PathStatement { } } -declare_lint!(unused_must_use, Warn, +declare_lint!(UNUSED_MUST_USE, Warn, "unused result of a type flagged as #[must_use]") -declare_lint!(unused_result, Allow, +declare_lint!(UNUSED_RESULT, Allow, "unused result of an expression in a statement") pub struct UnusedResult; impl LintPass for UnusedResult { fn get_lints(&self) -> LintArray { - lint_array!(unused_must_use, unused_result) + lint_array!(UNUSED_MUST_USE, UNUSED_RESULT) } fn check_stmt(&mut self, cx: &Context, s: &ast::Stmt) { @@ -674,7 +674,7 @@ impl LintPass for UnusedResult { ast_map::NodeItem(it) => { if attr::contains_name(it.attrs.as_slice(), "must_use") { - cx.span_lint(unused_must_use, s.span, + cx.span_lint(UNUSED_MUST_USE, s.span, "unused result which must be used"); warned = true; } @@ -684,7 +684,7 @@ impl LintPass for UnusedResult { } else { csearch::get_item_attrs(&cx.sess().cstore, did, |attrs| { if attr::contains_name(attrs.as_slice(), "must_use") { - cx.span_lint(unused_must_use, s.span, + cx.span_lint(UNUSED_MUST_USE, s.span, "unused result which must be used"); warned = true; } @@ -694,19 +694,19 @@ impl LintPass for UnusedResult { _ => {} } if !warned { - cx.span_lint(unused_result, s.span, "unused result"); + cx.span_lint(UNUSED_RESULT, s.span, "unused result"); } } } -declare_lint!(deprecated_owned_vector, Allow, +declare_lint!(DEPRECATED_OWNED_VECTOR, Allow, "use of a `~[T]` vector") pub struct DeprecatedOwnedVector; impl LintPass for DeprecatedOwnedVector { fn get_lints(&self) -> LintArray { - lint_array!(deprecated_owned_vector) + lint_array!(DEPRECATED_OWNED_VECTOR) } fn check_expr(&mut self, cx: &Context, e: &ast::Expr) { @@ -714,7 +714,7 @@ impl LintPass for DeprecatedOwnedVector { match ty::get(t).sty { ty::ty_uniq(t) => match ty::get(t).sty { ty::ty_vec(_, None) => { - cx.span_lint(deprecated_owned_vector, e.span, + cx.span_lint(DEPRECATED_OWNED_VECTOR, e.span, "use of deprecated `~[]` vector; replaced by `std::vec::Vec`") } _ => {} @@ -724,14 +724,14 @@ impl LintPass for DeprecatedOwnedVector { } } -declare_lint!(non_camel_case_types, Warn, +declare_lint!(NON_CAMEL_CASE_TYPES, Warn, "types, variants and traits should have camel case names") pub struct NonCamelCaseTypes; impl LintPass for NonCamelCaseTypes { fn get_lints(&self) -> LintArray { - lint_array!(non_camel_case_types) + lint_array!(NON_CAMEL_CASE_TYPES) } fn check_item(&mut self, cx: &Context, it: &ast::Item) { @@ -756,7 +756,7 @@ impl LintPass for NonCamelCaseTypes { let s = token::get_ident(ident); if !is_camel_case(ident) { - cx.span_lint(non_camel_case_types, span, + cx.span_lint(NON_CAMEL_CASE_TYPES, span, format!("{} `{}` should have a camel case name such as `{}`", sort, s, to_camel_case(s.get())).as_slice()); } @@ -809,7 +809,7 @@ fn method_context(cx: &Context, m: &ast::Method) -> MethodContext { } } -declare_lint!(non_snake_case_functions, Warn, +declare_lint!(NON_SNAKE_CASE_FUNCTIONS, Warn, "methods and functions should have snake case names") pub struct NonSnakeCaseFunctions; @@ -852,7 +852,7 @@ impl NonSnakeCaseFunctions { let s = token::get_ident(ident); if !is_snake_case(ident) { - cx.span_lint(non_snake_case_functions, span, + cx.span_lint(NON_SNAKE_CASE_FUNCTIONS, span, format!("{} `{}` should have a snake case name such as `{}`", sort, s, to_snake_case(s.get())).as_slice()); } @@ -861,7 +861,7 @@ impl NonSnakeCaseFunctions { impl LintPass for NonSnakeCaseFunctions { fn get_lints(&self) -> LintArray { - lint_array!(non_snake_case_functions) + lint_array!(NON_SNAKE_CASE_FUNCTIONS) } fn check_fn(&mut self, cx: &Context, @@ -886,14 +886,14 @@ impl LintPass for NonSnakeCaseFunctions { } } -declare_lint!(non_uppercase_statics, Allow, +declare_lint!(NON_UPPERCASE_STATICS, Allow, "static constants should have uppercase identifiers") pub struct NonUppercaseStatics; impl LintPass for NonUppercaseStatics { fn get_lints(&self) -> LintArray { - lint_array!(non_uppercase_statics) + lint_array!(NON_UPPERCASE_STATICS) } fn check_item(&mut self, cx: &Context, it: &ast::Item) { @@ -905,7 +905,7 @@ impl LintPass for NonUppercaseStatics { // ones (some scripts don't have a concept of // upper/lowercase) if s.get().chars().any(|c| c.is_lowercase()) { - cx.span_lint(non_uppercase_statics, it.span, + cx.span_lint(NON_UPPERCASE_STATICS, it.span, format!("static constant `{}` should have an uppercase name \ such as `{}`", s.get(), s.get().chars().map(|c| c.to_uppercase()) @@ -917,14 +917,14 @@ impl LintPass for NonUppercaseStatics { } } -declare_lint!(non_uppercase_pattern_statics, Warn, +declare_lint!(NON_UPPERCASE_PATTERN_STATICS, Warn, "static constants in match patterns should be all caps") pub struct NonUppercasePatternStatics; impl LintPass for NonUppercasePatternStatics { fn get_lints(&self) -> LintArray { - lint_array!(non_uppercase_pattern_statics) + lint_array!(NON_UPPERCASE_PATTERN_STATICS) } fn check_pat(&mut self, cx: &Context, p: &ast::Pat) { @@ -935,7 +935,7 @@ impl LintPass for NonUppercasePatternStatics { let ident = path.segments.last().unwrap().identifier; let s = token::get_ident(ident); if s.get().chars().any(|c| c.is_lowercase()) { - cx.span_lint(non_uppercase_pattern_statics, path.span, + cx.span_lint(NON_UPPERCASE_PATTERN_STATICS, path.span, format!("static constant in pattern `{}` should have an uppercase \ name such as `{}`", s.get(), s.get().chars().map(|c| c.to_uppercase()) @@ -947,14 +947,14 @@ impl LintPass for NonUppercasePatternStatics { } } -declare_lint!(uppercase_variables, Warn, +declare_lint!(UPPERCASE_VARIABLES, Warn, "variable and structure field names should start with a lowercase character") pub struct UppercaseVariables; impl LintPass for UppercaseVariables { fn get_lints(&self) -> LintArray { - lint_array!(uppercase_variables) + lint_array!(UPPERCASE_VARIABLES) } fn check_pat(&mut self, cx: &Context, p: &ast::Pat) { @@ -967,7 +967,7 @@ impl LintPass for UppercaseVariables { let ident = path.segments.last().unwrap().identifier; let s = token::get_ident(ident); if s.get().len() > 0 && s.get().char_at(0).is_uppercase() { - cx.span_lint(uppercase_variables, path.span, + cx.span_lint(UPPERCASE_VARIABLES, path.span, "variable names should start with a lowercase character"); } } @@ -985,7 +985,7 @@ impl LintPass for UppercaseVariables { ast::StructField_ { kind: ast::NamedField(ident, _), .. } => { let s = token::get_ident(ident); if s.get().char_at(0).is_uppercase() { - cx.span_lint(uppercase_variables, sf.span, + cx.span_lint(UPPERCASE_VARIABLES, sf.span, "structure field names should start with a lowercase character"); } } @@ -995,7 +995,7 @@ impl LintPass for UppercaseVariables { } } -declare_lint!(unnecessary_parens, Warn, +declare_lint!(UNNECESSARY_PARENS, Warn, "`if`, `match`, `while` and `return` do not need parentheses") pub struct UnnecessaryParens; @@ -1004,7 +1004,7 @@ impl UnnecessaryParens { fn check_unnecessary_parens_core(&self, cx: &Context, value: &ast::Expr, msg: &str) { match value.node { ast::ExprParen(_) => { - cx.span_lint(unnecessary_parens, value.span, + cx.span_lint(UNNECESSARY_PARENS, value.span, format!("unnecessary parentheses around {}", msg).as_slice()) } _ => {} @@ -1014,7 +1014,7 @@ impl UnnecessaryParens { impl LintPass for UnnecessaryParens { fn get_lints(&self) -> LintArray { - lint_array!(unnecessary_parens) + lint_array!(UNNECESSARY_PARENS) } fn check_expr(&mut self, cx: &Context, e: &ast::Expr) { @@ -1045,14 +1045,14 @@ impl LintPass for UnnecessaryParens { } } -declare_lint!(unused_unsafe, Warn, +declare_lint!(UNUSED_UNSAFE, Warn, "unnecessary use of an `unsafe` block") pub struct UnusedUnsafe; impl LintPass for UnusedUnsafe { fn get_lints(&self) -> LintArray { - lint_array!(unused_unsafe) + lint_array!(UNUSED_UNSAFE) } fn check_expr(&mut self, cx: &Context, e: &ast::Expr) { @@ -1061,7 +1061,7 @@ impl LintPass for UnusedUnsafe { ast::ExprBlock(ref blk) => { if blk.rules == ast::UnsafeBlock(ast::UserProvided) && !cx.tcx.used_unsafe.borrow().contains(&blk.id) { - cx.span_lint(unused_unsafe, blk.span, "unnecessary `unsafe` block"); + cx.span_lint(UNUSED_UNSAFE, blk.span, "unnecessary `unsafe` block"); } } _ => () @@ -1069,28 +1069,28 @@ impl LintPass for UnusedUnsafe { } } -declare_lint!(unsafe_block, Allow, +declare_lint!(UNSAFE_BLOCK, Allow, "usage of an `unsafe` block") pub struct UnsafeBlock; impl LintPass for UnsafeBlock { fn get_lints(&self) -> LintArray { - lint_array!(unsafe_block) + lint_array!(UNSAFE_BLOCK) } fn check_expr(&mut self, cx: &Context, e: &ast::Expr) { match e.node { // Don't warn about generated blocks, that'll just pollute the output. ast::ExprBlock(ref blk) if blk.rules == ast::UnsafeBlock(ast::UserProvided) => { - cx.span_lint(unsafe_block, blk.span, "usage of an `unsafe` block"); + cx.span_lint(UNSAFE_BLOCK, blk.span, "usage of an `unsafe` block"); } _ => () } } } -declare_lint!(unused_mut, Warn, +declare_lint!(UNUSED_MUT, Warn, "detect mut variables which don't need to be mutable") pub struct UnusedMut; @@ -1124,7 +1124,7 @@ impl UnusedMut { let used_mutables = cx.tcx.used_mut_nodes.borrow(); for (_, v) in mutables.iter() { if !v.iter().any(|e| used_mutables.contains(e)) { - cx.span_lint(unused_mut, cx.tcx.map.span(*v.get(0)), + cx.span_lint(UNUSED_MUT, cx.tcx.map.span(*v.get(0)), "variable does not need to be mutable"); } } @@ -1133,7 +1133,7 @@ impl UnusedMut { impl LintPass for UnusedMut { fn get_lints(&self) -> LintArray { - lint_array!(unused_mut) + lint_array!(UNUSED_MUT) } fn check_expr(&mut self, cx: &Context, e: &ast::Expr) { @@ -1175,14 +1175,14 @@ enum Allocation { BoxAllocation } -declare_lint!(unnecessary_allocation, Warn, +declare_lint!(UNNECESSARY_ALLOCATION, Warn, "detects unnecessary allocations that can be eliminated") pub struct UnnecessaryAllocation; impl LintPass for UnnecessaryAllocation { fn get_lints(&self) -> LintArray { - lint_array!(unnecessary_allocation) + lint_array!(UNNECESSARY_ALLOCATION) } fn check_expr(&mut self, cx: &Context, e: &ast::Expr) { @@ -1210,17 +1210,17 @@ impl LintPass for UnnecessaryAllocation { ty::AutoDerefRef(ty::AutoDerefRef { autoref, .. }) => { match (allocation, autoref) { (VectorAllocation, Some(ty::AutoBorrowVec(..))) => { - cx.span_lint(unnecessary_allocation, e.span, + cx.span_lint(UNNECESSARY_ALLOCATION, e.span, "unnecessary allocation, the sigil can be removed"); } (BoxAllocation, Some(ty::AutoPtr(_, ast::MutImmutable))) => { - cx.span_lint(unnecessary_allocation, e.span, + cx.span_lint(UNNECESSARY_ALLOCATION, e.span, "unnecessary allocation, use & instead"); } (BoxAllocation, Some(ty::AutoPtr(_, ast::MutMutable))) => { - cx.span_lint(unnecessary_allocation, e.span, + cx.span_lint(UNNECESSARY_ALLOCATION, e.span, "unnecessary allocation, use &mut instead"); } _ => () @@ -1234,7 +1234,7 @@ impl LintPass for UnnecessaryAllocation { } } -declare_lint!(missing_doc, Allow, +declare_lint!(MISSING_DOC, Allow, "detects missing documentation for public members") pub struct MissingDoc { @@ -1291,7 +1291,7 @@ impl MissingDoc { } }); if !has_doc { - cx.span_lint(missing_doc, sp, + cx.span_lint(MISSING_DOC, sp, format!("missing documentation for {}", desc).as_slice()); } } @@ -1299,7 +1299,7 @@ impl MissingDoc { impl LintPass for MissingDoc { fn get_lints(&self) -> LintArray { - lint_array!(missing_doc) + lint_array!(MISSING_DOC) } fn enter_lint_attrs(&mut self, _: &Context, attrs: &[ast::Attribute]) { @@ -1388,13 +1388,13 @@ impl LintPass for MissingDoc { } } -declare_lint!(deprecated, Warn, +declare_lint!(DEPRECATED, Warn, "detects use of #[deprecated] items") -declare_lint!(experimental, Warn, +declare_lint!(EXPERIMENTAL, Warn, "detects use of #[experimental] items") -declare_lint!(unstable, Allow, +declare_lint!(UNSTABLE, Allow, "detects use of #[unstable] items (incl. items with no stability attribute)") /// Checks for use of items with `#[deprecated]`, `#[experimental]` and @@ -1403,7 +1403,7 @@ pub struct Stability; impl LintPass for Stability { fn get_lints(&self) -> LintArray { - lint_array!(deprecated, experimental, unstable) + lint_array!(DEPRECATED, EXPERIMENTAL, UNSTABLE) } fn check_expr(&mut self, cx: &Context, e: &ast::Expr) { @@ -1474,13 +1474,13 @@ impl LintPass for Stability { let (lint, label) = match stability { // no stability attributes == Unstable - None => (unstable, "unmarked"), + None => (UNSTABLE, "unmarked"), Some(attr::Stability { level: attr::Unstable, .. }) => - (unstable, "unstable"), + (UNSTABLE, "unstable"), Some(attr::Stability { level: attr::Experimental, .. }) => - (experimental, "experimental"), + (EXPERIMENTAL, "experimental"), Some(attr::Stability { level: attr::Deprecated, .. }) => - (deprecated, "deprecated"), + (DEPRECATED, "deprecated"), _ => return }; @@ -1495,40 +1495,40 @@ impl LintPass for Stability { } } -declare_lint!(pub unused_imports, Warn, +declare_lint!(pub UNUSED_IMPORTS, Warn, "imports that are never used") -declare_lint!(pub unnecessary_qualification, Allow, +declare_lint!(pub UNNECESSARY_QUALIFICATION, Allow, "detects unnecessarily qualified names") -declare_lint!(pub unrecognized_lint, Warn, +declare_lint!(pub UNRECOGNIZED_LINT, Warn, "unrecognized lint attribute") -declare_lint!(pub unused_variable, Warn, +declare_lint!(pub UNUSED_VARIABLE, Warn, "detect variables which are not used in any way") -declare_lint!(pub dead_assignment, Warn, +declare_lint!(pub DEAD_ASSIGNMENT, Warn, "detect assignments that will never be read") -declare_lint!(pub dead_code, Warn, +declare_lint!(pub DEAD_CODE, Warn, "detect piece of code that will never be used") -declare_lint!(pub visible_private_types, Warn, +declare_lint!(pub VISIBLE_PRIVATE_TYPES, Warn, "detect use of private types in exported type signatures") -declare_lint!(pub unreachable_code, Warn, +declare_lint!(pub UNREACHABLE_CODE, Warn, "detects unreachable code") -declare_lint!(pub warnings, Warn, +declare_lint!(pub WARNINGS, Warn, "mass-change the level for lints which produce warnings") -declare_lint!(pub unknown_features, Deny, +declare_lint!(pub UNKNOWN_FEATURES, Deny, "unknown features found in crate-level #[feature] directives") -declare_lint!(pub unknown_crate_type, Deny, +declare_lint!(pub UNKNOWN_CRATE_TYPE, Deny, "unknown crate type found in #[crate_type] directive") -declare_lint!(pub variant_size_difference, Allow, +declare_lint!(pub VARIANT_SIZE_DIFFERENCE, Allow, "detects enums with widely varying variant sizes") /// Does nothing as a lint pass, but registers some `Lint`s @@ -1538,9 +1538,9 @@ pub struct HardwiredLints; impl LintPass for HardwiredLints { fn get_lints(&self) -> LintArray { lint_array!( - unused_imports, unnecessary_qualification, unrecognized_lint, - unused_variable, dead_assignment, dead_code, visible_private_types, - unreachable_code, warnings, unknown_features, unknown_crate_type, - variant_size_difference) + UNUSED_IMPORTS, UNNECESSARY_QUALIFICATION, UNRECOGNIZED_LINT, + UNUSED_VARIABLE, DEAD_ASSIGNMENT, DEAD_CODE, VISIBLE_PRIVATE_TYPES, + UNREACHABLE_CODE, WARNINGS, UNKNOWN_FEATURES, UNKNOWN_CRATE_TYPE, + VARIANT_SIZE_DIFFERENCE) } } diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index 0b843e84561..31e6f3907dc 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -264,7 +264,7 @@ impl<'a> Context<'a> { let (level, src) = match self.lints.levels.find(&LintId::of(lint)) { None => return, Some(&(Warn, src)) => { - let lint_id = LintId::of(builtin::warnings); + let lint_id = LintId::of(builtin::WARNINGS); (self.lints.get_level_source(lint_id).val0(), src) } Some(&pair) => pair, @@ -359,7 +359,7 @@ impl<'a> Context<'a> { match self.lints.by_name.find_equiv(&lint_name.get()) { Some(lint_id) => out.push((*lint_id, level, meta.span)), - None => self.span_lint(builtin::unrecognized_lint, + None => self.span_lint(builtin::UNRECOGNIZED_LINT, meta.span, format!("unknown `{}` attribute: `{}`", level.as_str(), lint_name).as_slice()), @@ -588,7 +588,7 @@ impl LintPass for GatherNodeLevels { fn check_item(&mut self, cx: &Context, it: &ast::Item) { match it.node { ast::ItemEnum(..) => { - let lint_id = LintId::of(builtin::variant_size_difference); + let lint_id = LintId::of(builtin::VARIANT_SIZE_DIFFERENCE); match cx.lints.get_level_source(lint_id) { lvlsrc @ (lvl, _) if lvl != Allow => { cx.node_levels.borrow_mut() diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index 98c045dd8a4..50ba073aafc 100644 --- a/src/librustc/middle/dead.rs +++ b/src/librustc/middle/dead.rs @@ -461,7 +461,7 @@ impl<'a> DeadVisitor<'a> { ident: ast::Ident) { self.tcx .sess - .add_lint(lint::builtin::dead_code, + .add_lint(lint::builtin::DEAD_CODE, id, span, format!("code is never used: `{}`", diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index 5841a13280b..f09af6ea441 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -1560,11 +1560,11 @@ impl<'a> Liveness<'a> { }; if is_assigned { - self.ir.tcx.sess.add_lint(lint::builtin::unused_variable, id, sp, + self.ir.tcx.sess.add_lint(lint::builtin::UNUSED_VARIABLE, id, sp, format!("variable `{}` is assigned to, but never used", *name)); } else { - self.ir.tcx.sess.add_lint(lint::builtin::unused_variable, id, sp, + self.ir.tcx.sess.add_lint(lint::builtin::UNUSED_VARIABLE, id, sp, format!("unused variable: `{}`", *name)); } } @@ -1582,7 +1582,7 @@ impl<'a> Liveness<'a> { if self.live_on_exit(ln, var).is_none() { let r = self.should_warn(var); for name in r.iter() { - self.ir.tcx.sess.add_lint(lint::builtin::dead_assignment, id, sp, + self.ir.tcx.sess.add_lint(lint::builtin::DEAD_ASSIGNMENT, id, sp, format!("value assigned to `{}` is never read", *name)); } } diff --git a/src/librustc/middle/privacy.rs b/src/librustc/middle/privacy.rs index 86a24838850..414aac47cdc 100644 --- a/src/librustc/middle/privacy.rs +++ b/src/librustc/middle/privacy.rs @@ -1394,7 +1394,7 @@ impl<'a> Visitor<()> for VisiblePrivateTypesVisitor<'a> { ast::TyPath(ref p, _, path_id) => { if self.path_is_private_type(path_id) { self.tcx.sess.add_lint( - lint::builtin::visible_private_types, + lint::builtin::VISIBLE_PRIVATE_TYPES, path_id, p.span, "private type in exported type \ signature".to_string()); diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index f0abcc27282..2329d5d685d 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -4632,7 +4632,7 @@ impl<'a> Resolver<'a> { match (def, unqualified_def) { (Some((d, _)), Some((ud, _))) if d == ud => { self.session - .add_lint(lint::builtin::unnecessary_qualification, + .add_lint(lint::builtin::UNNECESSARY_QUALIFICATION, id, path.span, "unnecessary qualification".to_string()); @@ -5487,7 +5487,7 @@ impl<'a> Resolver<'a> { if !self.used_imports.contains(&(id, TypeNS)) && !self.used_imports.contains(&(id, ValueNS)) { self.session - .add_lint(lint::builtin::unused_imports, + .add_lint(lint::builtin::UNUSED_IMPORTS, id, p.span, "unused import".to_string()); @@ -5511,7 +5511,7 @@ impl<'a> Resolver<'a> { if !self.used_imports.contains(&(id, TypeNS)) && !self.used_imports.contains(&(id, ValueNS)) { - self.session.add_lint(lint::builtin::unused_imports, + self.session.add_lint(lint::builtin::UNUSED_IMPORTS, id, span, "unused import".to_string()); diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index 56ec7ea8654..9c38fa938b5 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -1553,7 +1553,7 @@ fn enum_variant_size_lint(ccx: &CrateContext, enum_def: &ast::EnumDef, sp: Span, let mut sizes = Vec::new(); // does no allocation if no pushes, thankfully let levels = ccx.tcx.node_lint_levels.borrow(); - let lint_id = lint::LintId::of(lint::builtin::variant_size_difference); + let lint_id = lint::LintId::of(lint::builtin::VARIANT_SIZE_DIFFERENCE); let lvlsrc = match levels.find(&(id, lint_id)) { None | Some(&(lint::Allow, _)) => return, Some(&lvlsrc) => lvlsrc, @@ -1590,7 +1590,7 @@ fn enum_variant_size_lint(ccx: &CrateContext, enum_def: &ast::EnumDef, sp: Span, if largest > slargest * 3 && slargest > 0 { // Use lint::raw_emit_lint rather than sess.add_lint because the lint-printing // pass for the latter already ran. - lint::raw_emit_lint(&ccx.tcx().sess, lint::builtin::variant_size_difference, + lint::raw_emit_lint(&ccx.tcx().sess, lint::builtin::VARIANT_SIZE_DIFFERENCE, lvlsrc, Some(sp), format!("enum variant is more than three times larger \ ({} bytes) than the next largest (ignoring padding)", diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index bb781307668..9d155ef31f9 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -3416,7 +3416,7 @@ pub fn check_block_with_expected(fcx: &FnCtxt, fcx.ccx .tcx .sess - .add_lint(lint::builtin::unreachable_code, + .add_lint(lint::builtin::UNREACHABLE_CODE, s_id, s.span, "unreachable statement".to_string()); @@ -3443,7 +3443,7 @@ pub fn check_block_with_expected(fcx: &FnCtxt, fcx.ccx .tcx .sess - .add_lint(lint::builtin::unreachable_code, + .add_lint(lint::builtin::UNREACHABLE_CODE, e.id, e.span, "unreachable expression".to_string()); diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 36bf02cac30..ba0161da7e6 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -75,7 +75,7 @@ fn get_ast_and_resolve(cpath: &Path, libs: HashSet, cfgs: Vec) let input = FileInput(cpath.clone()); - let warning_lint = lint::builtin::warnings.name.to_string(); + let warning_lint = lint::builtin::WARNINGS.name_lower(); let sessopts = driver::config::Options { maybe_sysroot: Some(os::self_exe_path().unwrap().dir_path()),