Skip to content

Commit 2b2acf1

Browse files
committed
Fix dogfood error.
1 parent 2d1c931 commit 2b2acf1

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

clippy_lints/src/literal_representation.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ impl<'a> DigitInfo<'a> {
210210
.filter(|&c| c != '_')
211211
.collect::<Vec<_>>()
212212
.chunks(group_size)
213-
.map(|chunk| chunk.into_iter().rev().collect())
213+
.map(|chunk| chunk.iter().rev().collect())
214214
.rev()
215215
.collect::<Vec<String>>()
216216
.join("_");
@@ -221,7 +221,7 @@ impl<'a> DigitInfo<'a> {
221221
.filter(|&c| c != '_')
222222
.collect::<Vec<_>>()
223223
.chunks(group_size)
224-
.map(|chunk| chunk.into_iter().collect())
224+
.map(|chunk| chunk.iter().collect())
225225
.collect::<Vec<String>>()
226226
.join("_");
227227
format!(
@@ -238,7 +238,7 @@ impl<'a> DigitInfo<'a> {
238238
.collect::<Vec<_>>();
239239
let mut hint = filtered_digits_vec
240240
.chunks(group_size)
241-
.map(|chunk| chunk.into_iter().rev().collect())
241+
.map(|chunk| chunk.iter().rev().collect())
242242
.rev()
243243
.collect::<Vec<String>>()
244244
.join("_");

clippy_lints/src/methods/mod.rs

+17-17
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ declare_clippy_lint! {
575575
/// temporary placeholder for dealing with the `Option` type, then this does
576576
/// not mitigate the need for error handling. If there is a chance that `.get()`
577577
/// will be `None` in your program, then it is advisable that the `None` case
578-
/// is handled in a future refactor instead of using `.unwrap()` or the Index
578+
/// is handled in a future refactor instead of using `.unwrap()` or the Index
579579
/// trait.
580580
///
581581
/// **Example:**
@@ -2135,22 +2135,6 @@ fn lint_asref(cx: &LateContext<'_, '_>, expr: &hir::Expr, call_name: &str, as_re
21352135
}
21362136

21372137
fn ty_has_iter_method(cx: &LateContext<'_, '_>, self_ref_ty: ty::Ty<'_>) -> Option<(&'static Lint, &'static str, &'static str)> {
2138-
let (self_ty, mutbl) = match self_ref_ty.sty {
2139-
ty::TyKind::Ref(_, self_ty, mutbl) => (self_ty, mutbl),
2140-
_ => unreachable!(),
2141-
};
2142-
let method_name = match mutbl {
2143-
hir::MutImmutable => "iter",
2144-
hir::MutMutable => "iter_mut",
2145-
};
2146-
2147-
let def_id = match self_ty.sty {
2148-
ty::TyKind::Array(..) => return Some((INTO_ITER_ON_ARRAY, "array", method_name)),
2149-
ty::TyKind::Slice(..) => return Some((INTO_ITER_ON_REF, "slice", method_name)),
2150-
ty::Adt(adt, _) => adt.did,
2151-
_ => return None,
2152-
};
2153-
21542138
// FIXME: instead of this hard-coded list, we should check if `<adt>::iter`
21552139
// exists and has the desired signature. Unfortunately FnCtxt is not exported
21562140
// so we can't use its `lookup_method` method.
@@ -2170,6 +2154,22 @@ fn ty_has_iter_method(cx: &LateContext<'_, '_>, self_ref_ty: ty::Ty<'_>) -> Opti
21702154
(INTO_ITER_ON_REF, &["std", "sync", "mpsc", "Receiver"]),
21712155
];
21722156

2157+
let (self_ty, mutbl) = match self_ref_ty.sty {
2158+
ty::TyKind::Ref(_, self_ty, mutbl) => (self_ty, mutbl),
2159+
_ => unreachable!(),
2160+
};
2161+
let method_name = match mutbl {
2162+
hir::MutImmutable => "iter",
2163+
hir::MutMutable => "iter_mut",
2164+
};
2165+
2166+
let def_id = match self_ty.sty {
2167+
ty::TyKind::Array(..) => return Some((INTO_ITER_ON_ARRAY, "array", method_name)),
2168+
ty::TyKind::Slice(..) => return Some((INTO_ITER_ON_REF, "slice", method_name)),
2169+
ty::Adt(adt, _) => adt.did,
2170+
_ => return None,
2171+
};
2172+
21732173
for (lint, path) in &INTO_ITER_COLLECTIONS {
21742174
if match_def_path(cx.tcx, def_id, path) {
21752175
return Some((lint, path.last().unwrap(), method_name))

0 commit comments

Comments
 (0)