Skip to content

Commit 71d35df

Browse files
committed
rename use_retain => manual_retain
1 parent e71d5fa commit 71d35df

9 files changed

+34
-34
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3528,6 +3528,7 @@ Released 2018-09-13
35283528
[`manual_ok_or`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_ok_or
35293529
[`manual_range_contains`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_range_contains
35303530
[`manual_rem_euclid`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_rem_euclid
3531+
[`manual_retain`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_retain
35313532
[`manual_saturating_arithmetic`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_saturating_arithmetic
35323533
[`manual_split_once`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_split_once
35333534
[`manual_str_repeat`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_str_repeat
@@ -3840,7 +3841,6 @@ Released 2018-09-13
38403841
[`unwrap_used`]: https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_used
38413842
[`upper_case_acronyms`]: https://rust-lang.github.io/rust-clippy/master/index.html#upper_case_acronyms
38423843
[`use_debug`]: https://rust-lang.github.io/rust-clippy/master/index.html#use_debug
3843-
[`use_retain`]: https://rust-lang.github.io/rust-clippy/master/index.html#use_retain
38443844
[`use_self`]: https://rust-lang.github.io/rust-clippy/master/index.html#use_self
38453845
[`used_underscore_binding`]: https://rust-lang.github.io/rust-clippy/master/index.html#used_underscore_binding
38463846
[`useless_asref`]: https://rust-lang.github.io/rust-clippy/master/index.html#useless_asref

clippy_lints/src/lib.register_all.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ store.register_group(true, "clippy::all", Some("clippy_all"), vec![
136136
LintId::of(manual_bits::MANUAL_BITS),
137137
LintId::of(manual_non_exhaustive::MANUAL_NON_EXHAUSTIVE),
138138
LintId::of(manual_rem_euclid::MANUAL_REM_EUCLID),
139+
LintId::of(manual_retain::MANUAL_RETAIN),
139140
LintId::of(manual_strip::MANUAL_STRIP),
140141
LintId::of(map_clone::MAP_CLONE),
141142
LintId::of(map_unit_fn::OPTION_MAP_UNIT_FN),
@@ -336,7 +337,6 @@ store.register_group(true, "clippy::all", Some("clippy_all"), vec![
336337
LintId::of(unwrap::PANICKING_UNWRAP),
337338
LintId::of(unwrap::UNNECESSARY_UNWRAP),
338339
LintId::of(upper_case_acronyms::UPPER_CASE_ACRONYMS),
339-
LintId::of(use_retain::USE_RETAIN),
340340
LintId::of(useless_conversion::USELESS_CONVERSION),
341341
LintId::of(vec::USELESS_VEC),
342342
LintId::of(vec_init_then_push::VEC_INIT_THEN_PUSH),

clippy_lints/src/lib.register_lints.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ store.register_lints(&[
255255
manual_non_exhaustive::MANUAL_NON_EXHAUSTIVE,
256256
manual_ok_or::MANUAL_OK_OR,
257257
manual_rem_euclid::MANUAL_REM_EUCLID,
258+
manual_retain::MANUAL_RETAIN,
258259
manual_strip::MANUAL_STRIP,
259260
map_clone::MAP_CLONE,
260261
map_err_ignore::MAP_ERR_IGNORE,
@@ -563,7 +564,6 @@ store.register_lints(&[
563564
unwrap::UNNECESSARY_UNWRAP,
564565
unwrap_in_result::UNWRAP_IN_RESULT,
565566
upper_case_acronyms::UPPER_CASE_ACRONYMS,
566-
use_retain::USE_RETAIN,
567567
use_self::USE_SELF,
568568
useless_conversion::USELESS_CONVERSION,
569569
vec::USELESS_VEC,

clippy_lints/src/lib.register_perf.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ store.register_group(true, "clippy::perf", Some("clippy_perf"), vec![
1313
LintId::of(loops::MANUAL_MEMCPY),
1414
LintId::of(loops::MISSING_SPIN_LOOP),
1515
LintId::of(loops::NEEDLESS_COLLECT),
16+
LintId::of(manual_retain::MANUAL_RETAIN),
1617
LintId::of(methods::EXPECT_FUN_CALL),
1718
LintId::of(methods::EXTEND_WITH_DRAIN),
1819
LintId::of(methods::ITER_NTH),
@@ -26,7 +27,6 @@ store.register_group(true, "clippy::perf", Some("clippy_perf"), vec![
2627
LintId::of(slow_vector_initialization::SLOW_VECTOR_INITIALIZATION),
2728
LintId::of(types::BOX_COLLECTION),
2829
LintId::of(types::REDUNDANT_ALLOCATION),
29-
LintId::of(use_retain::USE_RETAIN),
3030
LintId::of(vec::USELESS_VEC),
3131
LintId::of(vec_init_then_push::VEC_INIT_THEN_PUSH),
3232
])

clippy_lints/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ mod manual_bits;
283283
mod manual_non_exhaustive;
284284
mod manual_ok_or;
285285
mod manual_rem_euclid;
286+
mod manual_retain;
286287
mod manual_strip;
287288
mod map_clone;
288289
mod map_err_ignore;
@@ -410,7 +411,6 @@ mod unused_unit;
410411
mod unwrap;
411412
mod unwrap_in_result;
412413
mod upper_case_acronyms;
413-
mod use_retain;
414414
mod use_self;
415415
mod useless_conversion;
416416
mod vec;
@@ -915,7 +915,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
915915
store.register_late_pass(|| Box::new(read_zero_byte_vec::ReadZeroByteVec));
916916
store.register_late_pass(|| Box::new(default_instead_of_iter_empty::DefaultIterEmpty));
917917
store.register_late_pass(move || Box::new(manual_rem_euclid::ManualRemEuclid::new(msrv)));
918-
store.register_late_pass(move || Box::new(use_retain::UseRetain::new(msrv)));
918+
store.register_late_pass(move || Box::new(manual_retain::ManualRetain::new(msrv)));
919919
// add lints here, do not remove this comment, it's used in `new_lint`
920920
}
921921

clippy_lints/src/use_retain.rs renamed to clippy_lints/src/manual_retain.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -44,25 +44,25 @@ declare_clippy_lint! {
4444
/// vec.retain(|x| x % 2 == 0);
4545
/// ```
4646
#[clippy::version = "1.63.0"]
47-
pub USE_RETAIN,
47+
pub MANUAL_RETAIN,
4848
perf,
4949
"`retain()` is simpler and the same functionalitys"
5050
}
5151

52-
pub struct UseRetain {
52+
pub struct ManualRetain {
5353
msrv: Option<RustcVersion>,
5454
}
5555

56-
impl UseRetain {
56+
impl ManualRetain {
5757
#[must_use]
5858
pub fn new(msrv: Option<RustcVersion>) -> Self {
5959
Self { msrv }
6060
}
6161
}
6262

63-
impl_lint_pass!(UseRetain => [USE_RETAIN]);
63+
impl_lint_pass!(ManualRetain => [MANUAL_RETAIN]);
6464

65-
impl<'tcx> LateLintPass<'tcx> for UseRetain {
65+
impl<'tcx> LateLintPass<'tcx> for ManualRetain {
6666
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>) {
6767
if let Some(parent_expr) = get_parent_expr(cx, expr)
6868
&& 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
170170
} {
171171
span_lint_and_sugg(
172172
cx,
173-
USE_RETAIN,
173+
MANUAL_RETAIN,
174174
parent_expr.span,
175175
"this expression can be written more simply using `.retain()`",
176176
"consider calling `.retain()` instead",

tests/ui/use_retain.fixed renamed to tests/ui/manual_retain.fixed

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// run-rustfix
22
#![feature(custom_inner_attributes)]
3-
#![warn(clippy::use_retain)]
3+
#![warn(clippy::manual_retain)]
44
#![allow(unused)]
55
use std::collections::BTreeMap;
66
use std::collections::BTreeSet;

tests/ui/use_retain.rs renamed to tests/ui/manual_retain.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// run-rustfix
22
#![feature(custom_inner_attributes)]
3-
#![warn(clippy::use_retain)]
3+
#![warn(clippy::manual_retain)]
44
#![allow(unused)]
55
use std::collections::BTreeMap;
66
use std::collections::BTreeSet;

tests/ui/use_retain.stderr renamed to tests/ui/manual_retain.stderr

+20-20
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
error: this expression can be written more simply using `.retain()`
2-
--> $DIR/use_retain.rs:52:5
2+
--> $DIR/manual_retain.rs:52:5
33
|
44
LL | btree_map = btree_map.into_iter().filter(|(k, _)| k % 2 == 0).collect();
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_map.retain(|k, _| k % 2 == 0)`
66
|
7-
= note: `-D clippy::use-retain` implied by `-D warnings`
7+
= note: `-D clippy::manual-retain` implied by `-D warnings`
88

99
error: this expression can be written more simply using `.retain()`
10-
--> $DIR/use_retain.rs:53:5
10+
--> $DIR/manual_retain.rs:53:5
1111
|
1212
LL | btree_map = btree_map.into_iter().filter(|(_, v)| v % 2 == 0).collect();
1313
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_map.retain(|_, &mut v| v % 2 == 0)`
1414

1515
error: this expression can be written more simply using `.retain()`
16-
--> $DIR/use_retain.rs:54:5
16+
--> $DIR/manual_retain.rs:54:5
1717
|
1818
LL | / btree_map = btree_map
1919
LL | | .into_iter()
@@ -22,37 +22,37 @@ LL | | .collect();
2222
| |__________________^ help: consider calling `.retain()` instead: `btree_map.retain(|k, &mut v| (k % 2 == 0) && (v % 2 == 0))`
2323

2424
error: this expression can be written more simply using `.retain()`
25-
--> $DIR/use_retain.rs:76:5
25+
--> $DIR/manual_retain.rs:76:5
2626
|
2727
LL | btree_set = btree_set.iter().filter(|&x| x % 2 == 0).copied().collect();
2828
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_set.retain(|x| x % 2 == 0)`
2929

3030
error: this expression can be written more simply using `.retain()`
31-
--> $DIR/use_retain.rs:77:5
31+
--> $DIR/manual_retain.rs:77:5
3232
|
3333
LL | btree_set = btree_set.iter().filter(|&x| x % 2 == 0).cloned().collect();
3434
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_set.retain(|x| x % 2 == 0)`
3535

3636
error: this expression can be written more simply using `.retain()`
37-
--> $DIR/use_retain.rs:78:5
37+
--> $DIR/manual_retain.rs:78:5
3838
|
3939
LL | btree_set = btree_set.into_iter().filter(|x| x % 2 == 0).collect();
4040
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_set.retain(|x| x % 2 == 0)`
4141

4242
error: this expression can be written more simply using `.retain()`
43-
--> $DIR/use_retain.rs:108:5
43+
--> $DIR/manual_retain.rs:108:5
4444
|
4545
LL | hash_map = hash_map.into_iter().filter(|(k, _)| k % 2 == 0).collect();
4646
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_map.retain(|k, _| k % 2 == 0)`
4747

4848
error: this expression can be written more simply using `.retain()`
49-
--> $DIR/use_retain.rs:109:5
49+
--> $DIR/manual_retain.rs:109:5
5050
|
5151
LL | hash_map = hash_map.into_iter().filter(|(_, v)| v % 2 == 0).collect();
5252
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_map.retain(|_, &mut v| v % 2 == 0)`
5353

5454
error: this expression can be written more simply using `.retain()`
55-
--> $DIR/use_retain.rs:110:5
55+
--> $DIR/manual_retain.rs:110:5
5656
|
5757
LL | / hash_map = hash_map
5858
LL | | .into_iter()
@@ -61,61 +61,61 @@ LL | | .collect();
6161
| |__________________^ help: consider calling `.retain()` instead: `hash_map.retain(|k, &mut v| (k % 2 == 0) && (v % 2 == 0))`
6262

6363
error: this expression can be written more simply using `.retain()`
64-
--> $DIR/use_retain.rs:131:5
64+
--> $DIR/manual_retain.rs:131:5
6565
|
6666
LL | hash_set = hash_set.into_iter().filter(|x| x % 2 == 0).collect();
6767
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_set.retain(|x| x % 2 == 0)`
6868

6969
error: this expression can be written more simply using `.retain()`
70-
--> $DIR/use_retain.rs:132:5
70+
--> $DIR/manual_retain.rs:132:5
7171
|
7272
LL | hash_set = hash_set.iter().filter(|&x| x % 2 == 0).copied().collect();
7373
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_set.retain(|x| x % 2 == 0)`
7474

7575
error: this expression can be written more simply using `.retain()`
76-
--> $DIR/use_retain.rs:133:5
76+
--> $DIR/manual_retain.rs:133:5
7777
|
7878
LL | hash_set = hash_set.iter().filter(|&x| x % 2 == 0).cloned().collect();
7979
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_set.retain(|x| x % 2 == 0)`
8080

8181
error: this expression can be written more simply using `.retain()`
82-
--> $DIR/use_retain.rs:162:5
82+
--> $DIR/manual_retain.rs:162:5
8383
|
8484
LL | s = s.chars().filter(|&c| c != 'o').to_owned().collect();
8585
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `s.retain(|c| c != 'o')`
8686

8787
error: this expression can be written more simply using `.retain()`
88-
--> $DIR/use_retain.rs:174:5
88+
--> $DIR/manual_retain.rs:174:5
8989
|
9090
LL | vec = vec.iter().filter(|&x| x % 2 == 0).copied().collect();
9191
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|x| x % 2 == 0)`
9292

9393
error: this expression can be written more simply using `.retain()`
94-
--> $DIR/use_retain.rs:175:5
94+
--> $DIR/manual_retain.rs:175:5
9595
|
9696
LL | vec = vec.iter().filter(|&x| x % 2 == 0).cloned().collect();
9797
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|x| x % 2 == 0)`
9898

9999
error: this expression can be written more simply using `.retain()`
100-
--> $DIR/use_retain.rs:176:5
100+
--> $DIR/manual_retain.rs:176:5
101101
|
102102
LL | vec = vec.into_iter().filter(|x| x % 2 == 0).collect();
103103
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|x| x % 2 == 0)`
104104

105105
error: this expression can be written more simply using `.retain()`
106-
--> $DIR/use_retain.rs:198:5
106+
--> $DIR/manual_retain.rs:198:5
107107
|
108108
LL | vec_deque = vec_deque.iter().filter(|&x| x % 2 == 0).copied().collect();
109109
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec_deque.retain(|x| x % 2 == 0)`
110110

111111
error: this expression can be written more simply using `.retain()`
112-
--> $DIR/use_retain.rs:199:5
112+
--> $DIR/manual_retain.rs:199:5
113113
|
114114
LL | vec_deque = vec_deque.iter().filter(|&x| x % 2 == 0).cloned().collect();
115115
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec_deque.retain(|x| x % 2 == 0)`
116116

117117
error: this expression can be written more simply using `.retain()`
118-
--> $DIR/use_retain.rs:200:5
118+
--> $DIR/manual_retain.rs:200:5
119119
|
120120
LL | vec_deque = vec_deque.into_iter().filter(|x| x % 2 == 0).collect();
121121
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec_deque.retain(|x| x % 2 == 0)`

0 commit comments

Comments
 (0)