check msrv
This commit is contained in:
parent
14212115c4
commit
4decfdec76
6 changed files with 123 additions and 45 deletions
|
|
@ -1,4 +1,5 @@
|
|||
// run-rustfix
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::use_retain)]
|
||||
#![allow(unused)]
|
||||
use std::collections::BTreeMap;
|
||||
|
|
@ -15,12 +16,16 @@ fn main() {
|
|||
hash_set_retain();
|
||||
hash_map_retain();
|
||||
string_retain();
|
||||
vec_queue_retain();
|
||||
vec_deque_retain();
|
||||
vec_retain();
|
||||
_msrv_153();
|
||||
_msrv_126();
|
||||
_msrv_118();
|
||||
}
|
||||
|
||||
fn binary_heap_retain() {
|
||||
// NOTE: Do not lint now, because binary_heap_retain is nighyly API.
|
||||
// And we need to add a test case for msrv if we update this implmention.
|
||||
// https://github.com/rust-lang/rust/issues/71503
|
||||
let mut heap = BinaryHeap::from([1, 2, 3]);
|
||||
heap = heap.into_iter().filter(|x| x % 2 == 0).collect();
|
||||
|
|
@ -179,7 +184,7 @@ fn vec_retain() {
|
|||
bar = foobar.into_iter().filter(|x| x % 2 == 0).collect();
|
||||
}
|
||||
|
||||
fn vec_queue_retain() {
|
||||
fn vec_deque_retain() {
|
||||
let mut vec_deque = VecDeque::new();
|
||||
vec_deque.extend(1..5);
|
||||
|
||||
|
|
@ -210,3 +215,26 @@ fn vec_queue_retain() {
|
|||
bar = foobar.iter().filter(|&x| x % 2 == 0).cloned().collect();
|
||||
bar = foobar.into_iter().filter(|x| x % 2 == 0).collect();
|
||||
}
|
||||
|
||||
fn _msrv_153() {
|
||||
#![clippy::msrv = "1.52"]
|
||||
let mut btree_map: BTreeMap<i8, i8> = (0..8).map(|x| (x, x * 10)).collect();
|
||||
btree_map = btree_map.into_iter().filter(|(k, _)| k % 2 == 0).collect();
|
||||
|
||||
let mut btree_set = BTreeSet::from([1, 2, 3, 4, 5, 6]);
|
||||
btree_set = btree_set.iter().filter(|&x| x % 2 == 0).copied().collect();
|
||||
}
|
||||
|
||||
fn _msrv_126() {
|
||||
#![clippy::msrv = "1.25"]
|
||||
let mut s = String::from("foobar");
|
||||
s = s.chars().filter(|&c| c != 'o').to_owned().collect();
|
||||
}
|
||||
|
||||
fn _msrv_118() {
|
||||
#![clippy::msrv = "1.17"]
|
||||
let mut hash_set = HashSet::from([1, 2, 3, 4, 5, 6]);
|
||||
hash_set = hash_set.into_iter().filter(|x| x % 2 == 0).collect();
|
||||
let mut hash_map: HashMap<i8, i8> = (0..8).map(|x| (x, x * 10)).collect();
|
||||
hash_map = hash_map.into_iter().filter(|(k, _)| k % 2 == 0).collect();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
// run-rustfix
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::use_retain)]
|
||||
#![allow(unused)]
|
||||
use std::collections::BTreeMap;
|
||||
|
|
@ -15,12 +16,16 @@ fn main() {
|
|||
hash_set_retain();
|
||||
hash_map_retain();
|
||||
string_retain();
|
||||
vec_queue_retain();
|
||||
vec_deque_retain();
|
||||
vec_retain();
|
||||
_msrv_153();
|
||||
_msrv_126();
|
||||
_msrv_118();
|
||||
}
|
||||
|
||||
fn binary_heap_retain() {
|
||||
// NOTE: Do not lint now, because binary_heap_retain is nighyly API.
|
||||
// And we need to add a test case for msrv if we update this implmention.
|
||||
// https://github.com/rust-lang/rust/issues/71503
|
||||
let mut heap = BinaryHeap::from([1, 2, 3]);
|
||||
heap = heap.into_iter().filter(|x| x % 2 == 0).collect();
|
||||
|
|
@ -185,7 +190,7 @@ fn vec_retain() {
|
|||
bar = foobar.into_iter().filter(|x| x % 2 == 0).collect();
|
||||
}
|
||||
|
||||
fn vec_queue_retain() {
|
||||
fn vec_deque_retain() {
|
||||
let mut vec_deque = VecDeque::new();
|
||||
vec_deque.extend(1..5);
|
||||
|
||||
|
|
@ -216,3 +221,26 @@ fn vec_queue_retain() {
|
|||
bar = foobar.iter().filter(|&x| x % 2 == 0).cloned().collect();
|
||||
bar = foobar.into_iter().filter(|x| x % 2 == 0).collect();
|
||||
}
|
||||
|
||||
fn _msrv_153() {
|
||||
#![clippy::msrv = "1.52"]
|
||||
let mut btree_map: BTreeMap<i8, i8> = (0..8).map(|x| (x, x * 10)).collect();
|
||||
btree_map = btree_map.into_iter().filter(|(k, _)| k % 2 == 0).collect();
|
||||
|
||||
let mut btree_set = BTreeSet::from([1, 2, 3, 4, 5, 6]);
|
||||
btree_set = btree_set.iter().filter(|&x| x % 2 == 0).copied().collect();
|
||||
}
|
||||
|
||||
fn _msrv_126() {
|
||||
#![clippy::msrv = "1.25"]
|
||||
let mut s = String::from("foobar");
|
||||
s = s.chars().filter(|&c| c != 'o').to_owned().collect();
|
||||
}
|
||||
|
||||
fn _msrv_118() {
|
||||
#![clippy::msrv = "1.17"]
|
||||
let mut hash_set = HashSet::from([1, 2, 3, 4, 5, 6]);
|
||||
hash_set = hash_set.into_iter().filter(|x| x % 2 == 0).collect();
|
||||
let mut hash_map: HashMap<i8, i8> = (0..8).map(|x| (x, x * 10)).collect();
|
||||
hash_map = hash_map.into_iter().filter(|(k, _)| k % 2 == 0).collect();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/use_retain.rs:47:5
|
||||
--> $DIR/use_retain.rs:52:5
|
||||
|
|
||||
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)`
|
||||
|
|
@ -7,13 +7,13 @@ LL | btree_map = btree_map.into_iter().filter(|(k, _)| k % 2 == 0).collect()
|
|||
= note: `-D clippy::use-retain` implied by `-D warnings`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/use_retain.rs:48:5
|
||||
--> $DIR/use_retain.rs:53:5
|
||||
|
|
||||
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)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/use_retain.rs:49:5
|
||||
--> $DIR/use_retain.rs:54:5
|
||||
|
|
||||
LL | / btree_map = btree_map
|
||||
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))`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/use_retain.rs:71:5
|
||||
--> $DIR/use_retain.rs:76:5
|
||||
|
|
||||
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)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/use_retain.rs:72:5
|
||||
--> $DIR/use_retain.rs:77:5
|
||||
|
|
||||
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)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/use_retain.rs:73:5
|
||||
--> $DIR/use_retain.rs:78:5
|
||||
|
|
||||
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)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/use_retain.rs:103:5
|
||||
--> $DIR/use_retain.rs:108:5
|
||||
|
|
||||
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)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/use_retain.rs:104:5
|
||||
--> $DIR/use_retain.rs:109:5
|
||||
|
|
||||
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)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/use_retain.rs:105:5
|
||||
--> $DIR/use_retain.rs:110:5
|
||||
|
|
||||
LL | / hash_map = hash_map
|
||||
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))`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/use_retain.rs:126:5
|
||||
--> $DIR/use_retain.rs:131:5
|
||||
|
|
||||
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)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/use_retain.rs:127:5
|
||||
--> $DIR/use_retain.rs:132:5
|
||||
|
|
||||
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)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/use_retain.rs:128:5
|
||||
--> $DIR/use_retain.rs:133:5
|
||||
|
|
||||
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)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/use_retain.rs:157:5
|
||||
--> $DIR/use_retain.rs:162:5
|
||||
|
|
||||
LL | s = s.chars().filter(|&c| c != 'o').to_owned().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `s.retain(|c| c != 'o')`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/use_retain.rs:169:5
|
||||
--> $DIR/use_retain.rs:174:5
|
||||
|
|
||||
LL | vec = vec.iter().filter(|&x| x % 2 == 0).copied().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|x| x % 2 == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/use_retain.rs:170:5
|
||||
--> $DIR/use_retain.rs:175:5
|
||||
|
|
||||
LL | vec = vec.iter().filter(|&x| x % 2 == 0).cloned().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|x| x % 2 == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/use_retain.rs:171:5
|
||||
--> $DIR/use_retain.rs:176:5
|
||||
|
|
||||
LL | vec = vec.into_iter().filter(|x| x % 2 == 0).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|x| x % 2 == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/use_retain.rs:193:5
|
||||
--> $DIR/use_retain.rs:198:5
|
||||
|
|
||||
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)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/use_retain.rs:194:5
|
||||
--> $DIR/use_retain.rs:199:5
|
||||
|
|
||||
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)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/use_retain.rs:195:5
|
||||
--> $DIR/use_retain.rs:200:5
|
||||
|
|
||||
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)`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue