From 5eab397e7c9840bd01f9ca165428e8eb4156cdc4 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Thu, 13 Aug 2015 19:58:11 +0530 Subject: [PATCH] Some fixes from dogfooding clippy --- src/eq_op.rs | 1 + src/lib.rs | 2 +- src/lifetimes.rs | 2 +- src/loops.rs | 4 ++-- src/utils.rs | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/eq_op.rs b/src/eq_op.rs index 495696b810cf..0b7511e7dbd9 100644 --- a/src/eq_op.rs +++ b/src/eq_op.rs @@ -1,3 +1,4 @@ +#![allow(redundant_closure)] // FIXME (#116) use rustc::lint::*; use syntax::ast::*; use syntax::ast_util as ast_util; diff --git a/src/lib.rs b/src/lib.rs index 7cb2877b2fdf..9135ecaca6c9 100755 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,6 @@ #![feature(plugin_registrar, box_syntax)] #![feature(rustc_private, collections)] -#![allow(unused_imports)] +#![allow(unused_imports, unknown_lints)] #[macro_use] extern crate syntax; diff --git a/src/lifetimes.rs b/src/lifetimes.rs index 644537f9be17..25be88746913 100644 --- a/src/lifetimes.rs +++ b/src/lifetimes.rs @@ -103,7 +103,7 @@ fn could_use_elision(kind: FnKind, func: &FnDecl) -> bool { } /// Number of unique lifetimes in the given vector. -fn unique_lifetimes(lts: &Vec) -> usize { +fn unique_lifetimes(lts: &[RefLt]) -> usize { lts.iter().collect::>().len() } diff --git a/src/loops.rs b/src/loops.rs index bfb5ad6861da..937e95970ef2 100644 --- a/src/loops.rs +++ b/src/loops.rs @@ -31,7 +31,7 @@ impl LintPass for LoopsPass { walk_expr(&mut visitor, body); // linting condition: we only indexed one variable if visitor.indexed.len() == 1 { - let indexed = visitor.indexed.into_iter().next().unwrap(); + let indexed = visitor.indexed.into_iter().next().expect("Len was nonzero, but no contents found"); if visitor.nonindex { span_lint(cx, NEEDLESS_RANGE_LOOP, expr.span, &format!( "the loop variable `{}` is used to index `{}`. Consider using \ @@ -72,7 +72,7 @@ impl LintPass for LoopsPass { /// Recover the essential nodes of a desugared for loop: /// `for pat in arg { body }` becomes `(pat, arg, body)`. -fn recover_for_loop<'a>(expr: &'a Expr) -> Option<(&'a Pat, &'a Expr, &'a Expr)> { +fn recover_for_loop<'a>(expr: &Expr) -> Option<(&Pat, &Expr, &Expr)> { if_let_chain! { [ let ExprMatch(ref iterexpr, ref arms, _) = expr.node, diff --git a/src/utils.rs b/src/utils.rs index 220dc6215fdb..c54a7f56f7e8 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -86,7 +86,7 @@ pub fn span_help_and_lint(cx: &Context, lint: &'static Lint, span: Span, } /// return the base type for references and raw pointers -pub fn walk_ptrs_ty<'t>(ty: ty::Ty<'t>) -> ty::Ty<'t> { +pub fn walk_ptrs_ty(ty: ty::Ty) -> ty::Ty { match ty.sty { ty::TyRef(_, ref tm) | ty::TyRawPtr(ref tm) => walk_ptrs_ty(tm.ty), _ => ty