Remove namespacing

This commit is contained in:
Manish Goregaokar 2014-12-26 05:24:44 +05:30
parent ccf996c348
commit e57396bc52
3 changed files with 17 additions and 17 deletions

View File

@ -22,7 +22,7 @@ pub fn plugin_registrar(reg: &mut Registry) {
reg.register_lint_pass(box misc::MiscPass as LintPassObject);
reg.register_lint_pass(box misc::StrToStringPass as LintPassObject);
reg.register_lint_pass(box misc::TopLevelRefPass as LintPassObject);
reg.register_lint_group("clippy", vec![types::CLIPPY_BOX_VEC, types::CLIPPY_DLIST,
misc::CLIPPY_SINGLE_MATCH, misc::CLIPPY_STR_TO_STRING,
misc::CLIPPY_TOPLEVEL_REF_ARG]);
reg.register_lint_group("clippy", vec![types::BOX_VEC, types::DLIST,
misc::SINGLE_MATCH, misc::STR_TO_STRING,
misc::TOPLEVEL_REF_ARG]);
}

View File

@ -14,12 +14,12 @@ use types::span_note_and_lint;
pub struct MiscPass;
declare_lint!(pub CLIPPY_SINGLE_MATCH, Warn,
declare_lint!(pub SINGLE_MATCH, Warn,
"Warn on usage of matches with a single nontrivial arm");
impl LintPass for MiscPass {
fn get_lints(&self) -> LintArray {
lint_array!(CLIPPY_SINGLE_MATCH)
lint_array!(SINGLE_MATCH)
}
fn check_expr(&mut self, cx: &Context, expr: &Expr) {
@ -35,7 +35,7 @@ impl LintPass for MiscPass {
// an enum is extended. So we only consider cases where a `_` wildcard is used
if arms[1].pats[0].node == PatWild(PatWildSingle) && arms[0].pats.len() == 1 {
let map = cx.sess().codemap();
span_note_and_lint(cx, CLIPPY_SINGLE_MATCH, expr.span,
span_note_and_lint(cx, SINGLE_MATCH, expr.span,
"You seem to be trying to use match for destructuring a single type. Did you mean to use `if let`?",
format!("Try if let {} = {} {{ ... }}",
map.span_to_snippet(arms[0].pats[0].span).unwrap_or("..".to_string()),
@ -49,14 +49,14 @@ impl LintPass for MiscPass {
}
declare_lint!(pub CLIPPY_STR_TO_STRING, Warn, "Warn when a String could use into_string() instead of to_string()");
declare_lint!(pub STR_TO_STRING, Warn, "Warn when a String could use into_string() instead of to_string()");
#[allow(missing_copy_implementations)]
pub struct StrToStringPass;
impl LintPass for StrToStringPass {
fn get_lints(&self) -> LintArray {
lint_array!(CLIPPY_STR_TO_STRING)
lint_array!(STR_TO_STRING)
}
fn check_expr(&mut self, cx: &Context, expr: &ast::Expr) {
@ -64,7 +64,7 @@ impl LintPass for StrToStringPass {
ast::ExprMethodCall(ref method, _, ref args)
if method.node.as_str() == "to_string"
&& is_str(cx, &*args[0]) => {
cx.span_lint(CLIPPY_STR_TO_STRING, expr.span, "str.into_string() is faster");
cx.span_lint(STR_TO_STRING, expr.span, "str.into_string() is faster");
},
_ => ()
}
@ -86,21 +86,21 @@ impl LintPass for StrToStringPass {
}
declare_lint!(pub CLIPPY_TOPLEVEL_REF_ARG, Warn, "Warn about pattern matches with top-level `ref` bindings");
declare_lint!(pub TOPLEVEL_REF_ARG, Warn, "Warn about pattern matches with top-level `ref` bindings");
#[allow(missing_copy_implementations)]
pub struct TopLevelRefPass;
impl LintPass for TopLevelRefPass {
fn get_lints(&self) -> LintArray {
lint_array!(CLIPPY_TOPLEVEL_REF_ARG)
lint_array!(TOPLEVEL_REF_ARG)
}
fn check_fn(&mut self, cx: &Context, _: FnKind, decl: &FnDecl, _: &Block, _: Span, _: NodeId) {
for ref arg in decl.inputs.iter() {
if let PatIdent(BindByRef(_), _, _) = arg.pat.node {
cx.span_lint(
CLIPPY_TOPLEVEL_REF_ARG,
TOPLEVEL_REF_ARG,
arg.pat.span,
"`ref` directly on a function argument is ignored. Have you considered using a reference type instead?"
);

View File

@ -10,9 +10,9 @@ use syntax::codemap::Span;
#[allow(missing_copy_implementations)]
pub struct TypePass;
declare_lint!(pub CLIPPY_BOX_VEC, Warn,
declare_lint!(pub BOX_VEC, Warn,
"Warn on usage of Box<Vec<T>>");
declare_lint!(pub CLIPPY_DLIST, Warn,
declare_lint!(pub DLIST, Warn,
"Warn on usage of DList");
/// Matches a type with a provided string, and returns its type parameters if successful
@ -48,7 +48,7 @@ pub fn span_note_and_lint(cx: &Context, lint: &'static Lint, span: Span, msg: &s
impl LintPass for TypePass {
fn get_lints(&self) -> LintArray {
lint_array!(CLIPPY_BOX_VEC, CLIPPY_DLIST)
lint_array!(BOX_VEC, DLIST)
}
fn check_ty(&mut self, cx: &Context, ty: &ast::Ty) {
@ -60,7 +60,7 @@ impl LintPass for TypePass {
match_ty_unwrap(ty, &["std", "boxed", "Box"]).and_then(|t| t.head())
.map(|t| match_ty_unwrap(&**t, &["std", "vec", "Vec"]))
.map(|_| {
span_note_and_lint(cx, CLIPPY_BOX_VEC, ty.span,
span_note_and_lint(cx, BOX_VEC, ty.span,
"You seem to be trying to use Box<Vec<T>>. Did you mean to use Vec<T>?",
"Vec<T> is already on the heap, Box<Vec<T>> makes an extra allocation");
});
@ -75,7 +75,7 @@ impl LintPass for TypePass {
vec!["collections","dlist","DList"]];
for path in dlists.iter() {
if match_ty_unwrap(ty, path.as_slice()).is_some() {
span_note_and_lint(cx, CLIPPY_DLIST, ty.span,
span_note_and_lint(cx, DLIST, ty.span,
"I see you're using a DList! Perhaps you meant some other data structure?",
"A RingBuf might work.");
return;