Fix an invalid suggestion in needless_collect
test
This commit is contained in:
parent
9c9aa2db52
commit
3ce820bf83
@ -3001,7 +3001,14 @@ fn get_iter_method(&self, cx: &LateContext<'_>) -> String {
|
||||
IterFunctionKind::IntoIter => String::new(),
|
||||
IterFunctionKind::Len => String::from(".count()"),
|
||||
IterFunctionKind::IsEmpty => String::from(".next().is_none()"),
|
||||
IterFunctionKind::Contains(span) => format!(".any(|x| x == {})", snippet(cx, *span, "..")),
|
||||
IterFunctionKind::Contains(span) => {
|
||||
let s = snippet(cx, *span, "..");
|
||||
if let Some(stripped) = s.strip_prefix('&') {
|
||||
format!(".any(|x| x == {})", stripped)
|
||||
} else {
|
||||
format!(".any(|x| x == *{})", s)
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
fn get_suggestion_text(&self) -> &'static str {
|
||||
|
@ -48,7 +48,7 @@ LL | | indirect_contains.contains(&&5);
|
||||
help: Check if the original Iterator contains an element instead of collecting then checking
|
||||
|
|
||||
LL |
|
||||
LL | sample.iter().any(|x| x == &&5);
|
||||
LL | sample.iter().any(|x| x == &5);
|
||||
|
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
Loading…
Reference in New Issue
Block a user