This commit is contained in:
mcarton 2016-06-29 22:35:58 +02:00
parent 7a1fc9fce5
commit a3c505551f
No known key found for this signature in database
GPG key ID: 5E427C794CBA45E8

View file

@ -672,20 +672,20 @@ fn lint_cstring_as_ptr(cx: &LateContext, expr: &hir::Expr, new: &hir::Expr, unwr
#[allow(ptr_arg)] #[allow(ptr_arg)]
// Type of MethodArgs is potentially a Vec // Type of MethodArgs is potentially a Vec
fn lint_iter_nth(cx: &LateContext, expr: &hir::Expr, iter_args: &MethodArgs, is_mut: bool){ fn lint_iter_nth(cx: &LateContext, expr: &hir::Expr, iter_args: &MethodArgs, is_mut: bool){
let caller_type;
let mut_str = if is_mut { "_mut" } else {""}; let mut_str = if is_mut { "_mut" } else {""};
if let Some(_) = derefs_to_slice(cx, &iter_args[0], &cx.tcx.expr_ty(&iter_args[0])) { let caller_type = if let Some(_) = derefs_to_slice(cx, &iter_args[0], &cx.tcx.expr_ty(&iter_args[0])) {
caller_type = "slice"; "slice"
} }
else if match_type(cx, cx.tcx.expr_ty(&iter_args[0]), &paths::VEC) { else if match_type(cx, cx.tcx.expr_ty(&iter_args[0]), &paths::VEC) {
caller_type = "Vec"; "Vec"
} }
else if match_type(cx, cx.tcx.expr_ty(&iter_args[0]), &paths::VEC_DEQUE) { else if match_type(cx, cx.tcx.expr_ty(&iter_args[0]), &paths::VEC_DEQUE) {
caller_type = "VecDeque"; "VecDeque"
} }
else { else {
return; // caller is not a type that we want to lint return; // caller is not a type that we want to lint
} };
span_lint( span_lint(
cx, cx,
ITER_NTH, ITER_NTH,