rename use_retain => manual_retain

This commit is contained in:
kyoto7250 2022-06-10 21:02:43 +09:00
parent 4decfdec76
commit dd3d0fdad3
9 changed files with 34 additions and 34 deletions

View file

@ -3528,6 +3528,7 @@ Released 2018-09-13
[`manual_ok_or`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_ok_or [`manual_ok_or`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_ok_or
[`manual_range_contains`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_range_contains [`manual_range_contains`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_range_contains
[`manual_rem_euclid`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_rem_euclid [`manual_rem_euclid`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_rem_euclid
[`manual_retain`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_retain
[`manual_saturating_arithmetic`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_saturating_arithmetic [`manual_saturating_arithmetic`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_saturating_arithmetic
[`manual_split_once`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_split_once [`manual_split_once`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_split_once
[`manual_str_repeat`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_str_repeat [`manual_str_repeat`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_str_repeat
@ -3840,7 +3841,6 @@ Released 2018-09-13
[`unwrap_used`]: https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_used [`unwrap_used`]: https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_used
[`upper_case_acronyms`]: https://rust-lang.github.io/rust-clippy/master/index.html#upper_case_acronyms [`upper_case_acronyms`]: https://rust-lang.github.io/rust-clippy/master/index.html#upper_case_acronyms
[`use_debug`]: https://rust-lang.github.io/rust-clippy/master/index.html#use_debug [`use_debug`]: https://rust-lang.github.io/rust-clippy/master/index.html#use_debug
[`use_retain`]: https://rust-lang.github.io/rust-clippy/master/index.html#use_retain
[`use_self`]: https://rust-lang.github.io/rust-clippy/master/index.html#use_self [`use_self`]: https://rust-lang.github.io/rust-clippy/master/index.html#use_self
[`used_underscore_binding`]: https://rust-lang.github.io/rust-clippy/master/index.html#used_underscore_binding [`used_underscore_binding`]: https://rust-lang.github.io/rust-clippy/master/index.html#used_underscore_binding
[`useless_asref`]: https://rust-lang.github.io/rust-clippy/master/index.html#useless_asref [`useless_asref`]: https://rust-lang.github.io/rust-clippy/master/index.html#useless_asref

View file

@ -136,6 +136,7 @@ store.register_group(true, "clippy::all", Some("clippy_all"), vec![
LintId::of(manual_bits::MANUAL_BITS), LintId::of(manual_bits::MANUAL_BITS),
LintId::of(manual_non_exhaustive::MANUAL_NON_EXHAUSTIVE), LintId::of(manual_non_exhaustive::MANUAL_NON_EXHAUSTIVE),
LintId::of(manual_rem_euclid::MANUAL_REM_EUCLID), LintId::of(manual_rem_euclid::MANUAL_REM_EUCLID),
LintId::of(manual_retain::MANUAL_RETAIN),
LintId::of(manual_strip::MANUAL_STRIP), LintId::of(manual_strip::MANUAL_STRIP),
LintId::of(map_clone::MAP_CLONE), LintId::of(map_clone::MAP_CLONE),
LintId::of(map_unit_fn::OPTION_MAP_UNIT_FN), LintId::of(map_unit_fn::OPTION_MAP_UNIT_FN),
@ -336,7 +337,6 @@ store.register_group(true, "clippy::all", Some("clippy_all"), vec![
LintId::of(unwrap::PANICKING_UNWRAP), LintId::of(unwrap::PANICKING_UNWRAP),
LintId::of(unwrap::UNNECESSARY_UNWRAP), LintId::of(unwrap::UNNECESSARY_UNWRAP),
LintId::of(upper_case_acronyms::UPPER_CASE_ACRONYMS), LintId::of(upper_case_acronyms::UPPER_CASE_ACRONYMS),
LintId::of(use_retain::USE_RETAIN),
LintId::of(useless_conversion::USELESS_CONVERSION), LintId::of(useless_conversion::USELESS_CONVERSION),
LintId::of(vec::USELESS_VEC), LintId::of(vec::USELESS_VEC),
LintId::of(vec_init_then_push::VEC_INIT_THEN_PUSH), LintId::of(vec_init_then_push::VEC_INIT_THEN_PUSH),

View file

@ -255,6 +255,7 @@ store.register_lints(&[
manual_non_exhaustive::MANUAL_NON_EXHAUSTIVE, manual_non_exhaustive::MANUAL_NON_EXHAUSTIVE,
manual_ok_or::MANUAL_OK_OR, manual_ok_or::MANUAL_OK_OR,
manual_rem_euclid::MANUAL_REM_EUCLID, manual_rem_euclid::MANUAL_REM_EUCLID,
manual_retain::MANUAL_RETAIN,
manual_strip::MANUAL_STRIP, manual_strip::MANUAL_STRIP,
map_clone::MAP_CLONE, map_clone::MAP_CLONE,
map_err_ignore::MAP_ERR_IGNORE, map_err_ignore::MAP_ERR_IGNORE,
@ -563,7 +564,6 @@ store.register_lints(&[
unwrap::UNNECESSARY_UNWRAP, unwrap::UNNECESSARY_UNWRAP,
unwrap_in_result::UNWRAP_IN_RESULT, unwrap_in_result::UNWRAP_IN_RESULT,
upper_case_acronyms::UPPER_CASE_ACRONYMS, upper_case_acronyms::UPPER_CASE_ACRONYMS,
use_retain::USE_RETAIN,
use_self::USE_SELF, use_self::USE_SELF,
useless_conversion::USELESS_CONVERSION, useless_conversion::USELESS_CONVERSION,
vec::USELESS_VEC, vec::USELESS_VEC,

View file

@ -13,6 +13,7 @@ store.register_group(true, "clippy::perf", Some("clippy_perf"), vec![
LintId::of(loops::MANUAL_MEMCPY), LintId::of(loops::MANUAL_MEMCPY),
LintId::of(loops::MISSING_SPIN_LOOP), LintId::of(loops::MISSING_SPIN_LOOP),
LintId::of(loops::NEEDLESS_COLLECT), LintId::of(loops::NEEDLESS_COLLECT),
LintId::of(manual_retain::MANUAL_RETAIN),
LintId::of(methods::EXPECT_FUN_CALL), LintId::of(methods::EXPECT_FUN_CALL),
LintId::of(methods::EXTEND_WITH_DRAIN), LintId::of(methods::EXTEND_WITH_DRAIN),
LintId::of(methods::ITER_NTH), LintId::of(methods::ITER_NTH),
@ -26,7 +27,6 @@ store.register_group(true, "clippy::perf", Some("clippy_perf"), vec![
LintId::of(slow_vector_initialization::SLOW_VECTOR_INITIALIZATION), LintId::of(slow_vector_initialization::SLOW_VECTOR_INITIALIZATION),
LintId::of(types::BOX_COLLECTION), LintId::of(types::BOX_COLLECTION),
LintId::of(types::REDUNDANT_ALLOCATION), LintId::of(types::REDUNDANT_ALLOCATION),
LintId::of(use_retain::USE_RETAIN),
LintId::of(vec::USELESS_VEC), LintId::of(vec::USELESS_VEC),
LintId::of(vec_init_then_push::VEC_INIT_THEN_PUSH), LintId::of(vec_init_then_push::VEC_INIT_THEN_PUSH),
]) ])

View file

@ -283,6 +283,7 @@ mod manual_bits;
mod manual_non_exhaustive; mod manual_non_exhaustive;
mod manual_ok_or; mod manual_ok_or;
mod manual_rem_euclid; mod manual_rem_euclid;
mod manual_retain;
mod manual_strip; mod manual_strip;
mod map_clone; mod map_clone;
mod map_err_ignore; mod map_err_ignore;
@ -410,7 +411,6 @@ mod unused_unit;
mod unwrap; mod unwrap;
mod unwrap_in_result; mod unwrap_in_result;
mod upper_case_acronyms; mod upper_case_acronyms;
mod use_retain;
mod use_self; mod use_self;
mod useless_conversion; mod useless_conversion;
mod vec; mod vec;
@ -915,7 +915,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
store.register_late_pass(|| Box::new(read_zero_byte_vec::ReadZeroByteVec)); store.register_late_pass(|| Box::new(read_zero_byte_vec::ReadZeroByteVec));
store.register_late_pass(|| Box::new(default_instead_of_iter_empty::DefaultIterEmpty)); store.register_late_pass(|| Box::new(default_instead_of_iter_empty::DefaultIterEmpty));
store.register_late_pass(move || Box::new(manual_rem_euclid::ManualRemEuclid::new(msrv))); store.register_late_pass(move || Box::new(manual_rem_euclid::ManualRemEuclid::new(msrv)));
store.register_late_pass(move || Box::new(use_retain::UseRetain::new(msrv))); store.register_late_pass(move || Box::new(manual_retain::ManualRetain::new(msrv)));
// add lints here, do not remove this comment, it's used in `new_lint` // add lints here, do not remove this comment, it's used in `new_lint`
} }

View file

@ -44,25 +44,25 @@ declare_clippy_lint! {
/// vec.retain(|x| x % 2 == 0); /// vec.retain(|x| x % 2 == 0);
/// ``` /// ```
#[clippy::version = "1.63.0"] #[clippy::version = "1.63.0"]
pub USE_RETAIN, pub MANUAL_RETAIN,
perf, perf,
"`retain()` is simpler and the same functionalitys" "`retain()` is simpler and the same functionalitys"
} }
pub struct UseRetain { pub struct ManualRetain {
msrv: Option<RustcVersion>, msrv: Option<RustcVersion>,
} }
impl UseRetain { impl ManualRetain {
#[must_use] #[must_use]
pub fn new(msrv: Option<RustcVersion>) -> Self { pub fn new(msrv: Option<RustcVersion>) -> Self {
Self { msrv } Self { msrv }
} }
} }
impl_lint_pass!(UseRetain => [USE_RETAIN]); impl_lint_pass!(ManualRetain => [MANUAL_RETAIN]);
impl<'tcx> LateLintPass<'tcx> for UseRetain { impl<'tcx> LateLintPass<'tcx> for ManualRetain {
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>) { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>) {
if let Some(parent_expr) = get_parent_expr(cx, expr) if let Some(parent_expr) = get_parent_expr(cx, expr)
&& let Assign(left_expr, collect_expr, _) = &parent_expr.kind && let Assign(left_expr, collect_expr, _) = &parent_expr.kind
@ -170,7 +170,7 @@ fn suggest(cx: &LateContext<'_>, parent_expr: &hir::Expr<'_>, left_expr: &hir::E
} { } {
span_lint_and_sugg( span_lint_and_sugg(
cx, cx,
USE_RETAIN, MANUAL_RETAIN,
parent_expr.span, parent_expr.span,
"this expression can be written more simply using `.retain()`", "this expression can be written more simply using `.retain()`",
"consider calling `.retain()` instead", "consider calling `.retain()` instead",

View file

@ -1,6 +1,6 @@
// run-rustfix // run-rustfix
#![feature(custom_inner_attributes)] #![feature(custom_inner_attributes)]
#![warn(clippy::use_retain)] #![warn(clippy::manual_retain)]
#![allow(unused)] #![allow(unused)]
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::collections::BTreeSet; use std::collections::BTreeSet;

View file

@ -1,6 +1,6 @@
// run-rustfix // run-rustfix
#![feature(custom_inner_attributes)] #![feature(custom_inner_attributes)]
#![warn(clippy::use_retain)] #![warn(clippy::manual_retain)]
#![allow(unused)] #![allow(unused)]
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::collections::BTreeSet; use std::collections::BTreeSet;

View file

@ -1,19 +1,19 @@
error: this expression can be written more simply using `.retain()` error: this expression can be written more simply using `.retain()`
--> $DIR/use_retain.rs:52:5 --> $DIR/manual_retain.rs:52:5
| |
LL | btree_map = btree_map.into_iter().filter(|(k, _)| k % 2 == 0).collect(); LL | btree_map = btree_map.into_iter().filter(|(k, _)| k % 2 == 0).collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_map.retain(|k, _| k % 2 == 0)` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_map.retain(|k, _| k % 2 == 0)`
| |
= note: `-D clippy::use-retain` implied by `-D warnings` = note: `-D clippy::manual-retain` implied by `-D warnings`
error: this expression can be written more simply using `.retain()` error: this expression can be written more simply using `.retain()`
--> $DIR/use_retain.rs:53:5 --> $DIR/manual_retain.rs:53:5
| |
LL | btree_map = btree_map.into_iter().filter(|(_, v)| v % 2 == 0).collect(); LL | btree_map = btree_map.into_iter().filter(|(_, v)| v % 2 == 0).collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_map.retain(|_, &mut v| v % 2 == 0)` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_map.retain(|_, &mut v| v % 2 == 0)`
error: this expression can be written more simply using `.retain()` error: this expression can be written more simply using `.retain()`
--> $DIR/use_retain.rs:54:5 --> $DIR/manual_retain.rs:54:5
| |
LL | / btree_map = btree_map LL | / btree_map = btree_map
LL | | .into_iter() LL | | .into_iter()
@ -22,37 +22,37 @@ LL | | .collect();
| |__________________^ help: consider calling `.retain()` instead: `btree_map.retain(|k, &mut v| (k % 2 == 0) && (v % 2 == 0))` | |__________________^ help: consider calling `.retain()` instead: `btree_map.retain(|k, &mut v| (k % 2 == 0) && (v % 2 == 0))`
error: this expression can be written more simply using `.retain()` error: this expression can be written more simply using `.retain()`
--> $DIR/use_retain.rs:76:5 --> $DIR/manual_retain.rs:76:5
| |
LL | btree_set = btree_set.iter().filter(|&x| x % 2 == 0).copied().collect(); LL | btree_set = btree_set.iter().filter(|&x| x % 2 == 0).copied().collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_set.retain(|x| x % 2 == 0)` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_set.retain(|x| x % 2 == 0)`
error: this expression can be written more simply using `.retain()` error: this expression can be written more simply using `.retain()`
--> $DIR/use_retain.rs:77:5 --> $DIR/manual_retain.rs:77:5
| |
LL | btree_set = btree_set.iter().filter(|&x| x % 2 == 0).cloned().collect(); LL | btree_set = btree_set.iter().filter(|&x| x % 2 == 0).cloned().collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_set.retain(|x| x % 2 == 0)` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_set.retain(|x| x % 2 == 0)`
error: this expression can be written more simply using `.retain()` error: this expression can be written more simply using `.retain()`
--> $DIR/use_retain.rs:78:5 --> $DIR/manual_retain.rs:78:5
| |
LL | btree_set = btree_set.into_iter().filter(|x| x % 2 == 0).collect(); LL | btree_set = btree_set.into_iter().filter(|x| x % 2 == 0).collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_set.retain(|x| x % 2 == 0)` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_set.retain(|x| x % 2 == 0)`
error: this expression can be written more simply using `.retain()` error: this expression can be written more simply using `.retain()`
--> $DIR/use_retain.rs:108:5 --> $DIR/manual_retain.rs:108:5
| |
LL | hash_map = hash_map.into_iter().filter(|(k, _)| k % 2 == 0).collect(); LL | hash_map = hash_map.into_iter().filter(|(k, _)| k % 2 == 0).collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_map.retain(|k, _| k % 2 == 0)` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_map.retain(|k, _| k % 2 == 0)`
error: this expression can be written more simply using `.retain()` error: this expression can be written more simply using `.retain()`
--> $DIR/use_retain.rs:109:5 --> $DIR/manual_retain.rs:109:5
| |
LL | hash_map = hash_map.into_iter().filter(|(_, v)| v % 2 == 0).collect(); LL | hash_map = hash_map.into_iter().filter(|(_, v)| v % 2 == 0).collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_map.retain(|_, &mut v| v % 2 == 0)` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_map.retain(|_, &mut v| v % 2 == 0)`
error: this expression can be written more simply using `.retain()` error: this expression can be written more simply using `.retain()`
--> $DIR/use_retain.rs:110:5 --> $DIR/manual_retain.rs:110:5
| |
LL | / hash_map = hash_map LL | / hash_map = hash_map
LL | | .into_iter() LL | | .into_iter()
@ -61,61 +61,61 @@ LL | | .collect();
| |__________________^ help: consider calling `.retain()` instead: `hash_map.retain(|k, &mut v| (k % 2 == 0) && (v % 2 == 0))` | |__________________^ help: consider calling `.retain()` instead: `hash_map.retain(|k, &mut v| (k % 2 == 0) && (v % 2 == 0))`
error: this expression can be written more simply using `.retain()` error: this expression can be written more simply using `.retain()`
--> $DIR/use_retain.rs:131:5 --> $DIR/manual_retain.rs:131:5
| |
LL | hash_set = hash_set.into_iter().filter(|x| x % 2 == 0).collect(); LL | hash_set = hash_set.into_iter().filter(|x| x % 2 == 0).collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_set.retain(|x| x % 2 == 0)` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_set.retain(|x| x % 2 == 0)`
error: this expression can be written more simply using `.retain()` error: this expression can be written more simply using `.retain()`
--> $DIR/use_retain.rs:132:5 --> $DIR/manual_retain.rs:132:5
| |
LL | hash_set = hash_set.iter().filter(|&x| x % 2 == 0).copied().collect(); LL | hash_set = hash_set.iter().filter(|&x| x % 2 == 0).copied().collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_set.retain(|x| x % 2 == 0)` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_set.retain(|x| x % 2 == 0)`
error: this expression can be written more simply using `.retain()` error: this expression can be written more simply using `.retain()`
--> $DIR/use_retain.rs:133:5 --> $DIR/manual_retain.rs:133:5
| |
LL | hash_set = hash_set.iter().filter(|&x| x % 2 == 0).cloned().collect(); LL | hash_set = hash_set.iter().filter(|&x| x % 2 == 0).cloned().collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_set.retain(|x| x % 2 == 0)` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_set.retain(|x| x % 2 == 0)`
error: this expression can be written more simply using `.retain()` error: this expression can be written more simply using `.retain()`
--> $DIR/use_retain.rs:162:5 --> $DIR/manual_retain.rs:162:5
| |
LL | s = s.chars().filter(|&c| c != 'o').to_owned().collect(); LL | s = s.chars().filter(|&c| c != 'o').to_owned().collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `s.retain(|c| c != 'o')` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `s.retain(|c| c != 'o')`
error: this expression can be written more simply using `.retain()` error: this expression can be written more simply using `.retain()`
--> $DIR/use_retain.rs:174:5 --> $DIR/manual_retain.rs:174:5
| |
LL | vec = vec.iter().filter(|&x| x % 2 == 0).copied().collect(); LL | vec = vec.iter().filter(|&x| x % 2 == 0).copied().collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|x| x % 2 == 0)` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|x| x % 2 == 0)`
error: this expression can be written more simply using `.retain()` error: this expression can be written more simply using `.retain()`
--> $DIR/use_retain.rs:175:5 --> $DIR/manual_retain.rs:175:5
| |
LL | vec = vec.iter().filter(|&x| x % 2 == 0).cloned().collect(); LL | vec = vec.iter().filter(|&x| x % 2 == 0).cloned().collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|x| x % 2 == 0)` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|x| x % 2 == 0)`
error: this expression can be written more simply using `.retain()` error: this expression can be written more simply using `.retain()`
--> $DIR/use_retain.rs:176:5 --> $DIR/manual_retain.rs:176:5
| |
LL | vec = vec.into_iter().filter(|x| x % 2 == 0).collect(); LL | vec = vec.into_iter().filter(|x| x % 2 == 0).collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|x| x % 2 == 0)` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|x| x % 2 == 0)`
error: this expression can be written more simply using `.retain()` error: this expression can be written more simply using `.retain()`
--> $DIR/use_retain.rs:198:5 --> $DIR/manual_retain.rs:198:5
| |
LL | vec_deque = vec_deque.iter().filter(|&x| x % 2 == 0).copied().collect(); LL | vec_deque = vec_deque.iter().filter(|&x| x % 2 == 0).copied().collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec_deque.retain(|x| x % 2 == 0)` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec_deque.retain(|x| x % 2 == 0)`
error: this expression can be written more simply using `.retain()` error: this expression can be written more simply using `.retain()`
--> $DIR/use_retain.rs:199:5 --> $DIR/manual_retain.rs:199:5
| |
LL | vec_deque = vec_deque.iter().filter(|&x| x % 2 == 0).cloned().collect(); LL | vec_deque = vec_deque.iter().filter(|&x| x % 2 == 0).cloned().collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec_deque.retain(|x| x % 2 == 0)` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec_deque.retain(|x| x % 2 == 0)`
error: this expression can be written more simply using `.retain()` error: this expression can be written more simply using `.retain()`
--> $DIR/use_retain.rs:200:5 --> $DIR/manual_retain.rs:200:5
| |
LL | vec_deque = vec_deque.into_iter().filter(|x| x % 2 == 0).collect(); LL | vec_deque = vec_deque.into_iter().filter(|x| x % 2 == 0).collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec_deque.retain(|x| x % 2 == 0)` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec_deque.retain(|x| x % 2 == 0)`