Some fixes from dogfooding clippy
This commit is contained in:
parent
0d8447e0f8
commit
5eab397e7c
@ -1,3 +1,4 @@
|
|||||||
|
#![allow(redundant_closure)] // FIXME (#116)
|
||||||
use rustc::lint::*;
|
use rustc::lint::*;
|
||||||
use syntax::ast::*;
|
use syntax::ast::*;
|
||||||
use syntax::ast_util as ast_util;
|
use syntax::ast_util as ast_util;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#![feature(plugin_registrar, box_syntax)]
|
#![feature(plugin_registrar, box_syntax)]
|
||||||
#![feature(rustc_private, collections)]
|
#![feature(rustc_private, collections)]
|
||||||
#![allow(unused_imports)]
|
#![allow(unused_imports, unknown_lints)]
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate syntax;
|
extern crate syntax;
|
||||||
|
@ -103,7 +103,7 @@ fn could_use_elision(kind: FnKind, func: &FnDecl) -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Number of unique lifetimes in the given vector.
|
/// 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()
|
lts.iter().collect::<HashSet<_>>().len()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ impl LintPass for LoopsPass {
|
|||||||
walk_expr(&mut visitor, body);
|
walk_expr(&mut visitor, body);
|
||||||
// linting condition: we only indexed one variable
|
// linting condition: we only indexed one variable
|
||||||
if visitor.indexed.len() == 1 {
|
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 {
|
if visitor.nonindex {
|
||||||
span_lint(cx, NEEDLESS_RANGE_LOOP, expr.span, &format!(
|
span_lint(cx, NEEDLESS_RANGE_LOOP, expr.span, &format!(
|
||||||
"the loop variable `{}` is used to index `{}`. Consider using \
|
"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:
|
/// Recover the essential nodes of a desugared for loop:
|
||||||
/// `for pat in arg { body }` becomes `(pat, arg, body)`.
|
/// `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! {
|
if_let_chain! {
|
||||||
[
|
[
|
||||||
let ExprMatch(ref iterexpr, ref arms, _) = expr.node,
|
let ExprMatch(ref iterexpr, ref arms, _) = expr.node,
|
||||||
|
@ -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
|
/// 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 {
|
match ty.sty {
|
||||||
ty::TyRef(_, ref tm) | ty::TyRawPtr(ref tm) => walk_ptrs_ty(tm.ty),
|
ty::TyRef(_, ref tm) | ty::TyRawPtr(ref tm) => walk_ptrs_ty(tm.ty),
|
||||||
_ => ty
|
_ => ty
|
||||||
|
Loading…
Reference in New Issue
Block a user