Some fixes from dogfooding clippy

This commit is contained in:
Manish Goregaokar 2015-08-13 19:58:11 +05:30
parent 0d8447e0f8
commit 5eab397e7c
5 changed files with 6 additions and 5 deletions

View file

@ -1,3 +1,4 @@
#![allow(redundant_closure)] // FIXME (#116)
use rustc::lint::*;
use syntax::ast::*;
use syntax::ast_util as ast_util;

View file

@ -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;

View file

@ -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<RefLt>) -> usize {
fn unique_lifetimes(lts: &[RefLt]) -> usize {
lts.iter().collect::<HashSet<_>>().len()
}

View file

@ -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,

View file

@ -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