Skip to content

Commit 21c3518

Browse files
committed
Auto merge of #6032 - matthiaskrgr:move_consume, r=flip1995
into_iter_on_ref: rephrase lint message: will not move the x -> will not consume the x imo that's a bit clearer. changelog: none
2 parents c057621 + 2487f8f commit 21c3518

File tree

2 files changed

+28
-28
lines changed

2 files changed

+28
-28
lines changed

clippy_lints/src/methods/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3374,7 +3374,7 @@ fn lint_into_iter(cx: &LateContext<'_>, expr: &hir::Expr<'_>, self_ref_ty: Ty<'_
33743374
INTO_ITER_ON_REF,
33753375
method_span,
33763376
&format!(
3377-
"this `.into_iter()` call is equivalent to `.{}()` and will not move the `{}`",
3377+
"this `.into_iter()` call is equivalent to `.{}()` and will not consume the `{}`",
33783378
method_name, kind,
33793379
),
33803380
"call directly",

tests/ui/into_iter_on_ref.stderr

+27-27
Original file line numberDiff line numberDiff line change
@@ -1,162 +1,162 @@
1-
error: this `.into_iter()` call is equivalent to `.iter()` and will not move the `Vec`
1+
error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `Vec`
22
--> $DIR/into_iter_on_ref.rs:14:30
33
|
44
LL | let _ = (&vec![1, 2, 3]).into_iter(); //~ WARN equivalent to .iter()
55
| ^^^^^^^^^ help: call directly: `iter`
66
|
77
= note: `-D clippy::into-iter-on-ref` implied by `-D warnings`
88

9-
error: this `.into_iter()` call is equivalent to `.iter()` and will not move the `slice`
9+
error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `slice`
1010
--> $DIR/into_iter_on_ref.rs:15:46
1111
|
1212
LL | let _ = vec![1, 2, 3].into_boxed_slice().into_iter(); //~ WARN equivalent to .iter()
1313
| ^^^^^^^^^ help: call directly: `iter`
1414

15-
error: this `.into_iter()` call is equivalent to `.iter()` and will not move the `slice`
15+
error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `slice`
1616
--> $DIR/into_iter_on_ref.rs:16:41
1717
|
1818
LL | let _ = std::rc::Rc::from(&[X][..]).into_iter(); //~ WARN equivalent to .iter()
1919
| ^^^^^^^^^ help: call directly: `iter`
2020

21-
error: this `.into_iter()` call is equivalent to `.iter()` and will not move the `slice`
21+
error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `slice`
2222
--> $DIR/into_iter_on_ref.rs:17:44
2323
|
2424
LL | let _ = std::sync::Arc::from(&[X][..]).into_iter(); //~ WARN equivalent to .iter()
2525
| ^^^^^^^^^ help: call directly: `iter`
2626

27-
error: this `.into_iter()` call is equivalent to `.iter()` and will not move the `array`
27+
error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `array`
2828
--> $DIR/into_iter_on_ref.rs:19:32
2929
|
3030
LL | let _ = (&&&&&&&[1, 2, 3]).into_iter(); //~ ERROR equivalent to .iter()
3131
| ^^^^^^^^^ help: call directly: `iter`
3232

33-
error: this `.into_iter()` call is equivalent to `.iter()` and will not move the `array`
33+
error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `array`
3434
--> $DIR/into_iter_on_ref.rs:20:36
3535
|
3636
LL | let _ = (&&&&mut &&&[1, 2, 3]).into_iter(); //~ ERROR equivalent to .iter()
3737
| ^^^^^^^^^ help: call directly: `iter`
3838

39-
error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not move the `array`
39+
error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not consume the `array`
4040
--> $DIR/into_iter_on_ref.rs:21:40
4141
|
4242
LL | let _ = (&mut &mut &mut [1, 2, 3]).into_iter(); //~ ERROR equivalent to .iter_mut()
4343
| ^^^^^^^^^ help: call directly: `iter_mut`
4444

45-
error: this `.into_iter()` call is equivalent to `.iter()` and will not move the `Option`
45+
error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `Option`
4646
--> $DIR/into_iter_on_ref.rs:23:24
4747
|
4848
LL | let _ = (&Some(4)).into_iter(); //~ WARN equivalent to .iter()
4949
| ^^^^^^^^^ help: call directly: `iter`
5050

51-
error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not move the `Option`
51+
error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not consume the `Option`
5252
--> $DIR/into_iter_on_ref.rs:24:28
5353
|
5454
LL | let _ = (&mut Some(5)).into_iter(); //~ WARN equivalent to .iter_mut()
5555
| ^^^^^^^^^ help: call directly: `iter_mut`
5656

57-
error: this `.into_iter()` call is equivalent to `.iter()` and will not move the `Result`
57+
error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `Result`
5858
--> $DIR/into_iter_on_ref.rs:25:32
5959
|
6060
LL | let _ = (&Ok::<_, i32>(6)).into_iter(); //~ WARN equivalent to .iter()
6161
| ^^^^^^^^^ help: call directly: `iter`
6262

63-
error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not move the `Result`
63+
error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not consume the `Result`
6464
--> $DIR/into_iter_on_ref.rs:26:37
6565
|
6666
LL | let _ = (&mut Err::<i32, _>(7)).into_iter(); //~ WARN equivalent to .iter_mut()
6767
| ^^^^^^^^^ help: call directly: `iter_mut`
6868

69-
error: this `.into_iter()` call is equivalent to `.iter()` and will not move the `Vec`
69+
error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `Vec`
7070
--> $DIR/into_iter_on_ref.rs:27:34
7171
|
7272
LL | let _ = (&Vec::<i32>::new()).into_iter(); //~ WARN equivalent to .iter()
7373
| ^^^^^^^^^ help: call directly: `iter`
7474

75-
error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not move the `Vec`
75+
error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not consume the `Vec`
7676
--> $DIR/into_iter_on_ref.rs:28:38
7777
|
7878
LL | let _ = (&mut Vec::<i32>::new()).into_iter(); //~ WARN equivalent to .iter_mut()
7979
| ^^^^^^^^^ help: call directly: `iter_mut`
8080

81-
error: this `.into_iter()` call is equivalent to `.iter()` and will not move the `BTreeMap`
81+
error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `BTreeMap`
8282
--> $DIR/into_iter_on_ref.rs:29:44
8383
|
8484
LL | let _ = (&BTreeMap::<i32, u64>::new()).into_iter(); //~ WARN equivalent to .iter()
8585
| ^^^^^^^^^ help: call directly: `iter`
8686

87-
error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not move the `BTreeMap`
87+
error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not consume the `BTreeMap`
8888
--> $DIR/into_iter_on_ref.rs:30:48
8989
|
9090
LL | let _ = (&mut BTreeMap::<i32, u64>::new()).into_iter(); //~ WARN equivalent to .iter_mut()
9191
| ^^^^^^^^^ help: call directly: `iter_mut`
9292

93-
error: this `.into_iter()` call is equivalent to `.iter()` and will not move the `VecDeque`
93+
error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `VecDeque`
9494
--> $DIR/into_iter_on_ref.rs:31:39
9595
|
9696
LL | let _ = (&VecDeque::<i32>::new()).into_iter(); //~ WARN equivalent to .iter()
9797
| ^^^^^^^^^ help: call directly: `iter`
9898

99-
error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not move the `VecDeque`
99+
error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not consume the `VecDeque`
100100
--> $DIR/into_iter_on_ref.rs:32:43
101101
|
102102
LL | let _ = (&mut VecDeque::<i32>::new()).into_iter(); //~ WARN equivalent to .iter_mut()
103103
| ^^^^^^^^^ help: call directly: `iter_mut`
104104

105-
error: this `.into_iter()` call is equivalent to `.iter()` and will not move the `LinkedList`
105+
error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `LinkedList`
106106
--> $DIR/into_iter_on_ref.rs:33:41
107107
|
108108
LL | let _ = (&LinkedList::<i32>::new()).into_iter(); //~ WARN equivalent to .iter()
109109
| ^^^^^^^^^ help: call directly: `iter`
110110

111-
error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not move the `LinkedList`
111+
error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not consume the `LinkedList`
112112
--> $DIR/into_iter_on_ref.rs:34:45
113113
|
114114
LL | let _ = (&mut LinkedList::<i32>::new()).into_iter(); //~ WARN equivalent to .iter_mut()
115115
| ^^^^^^^^^ help: call directly: `iter_mut`
116116

117-
error: this `.into_iter()` call is equivalent to `.iter()` and will not move the `HashMap`
117+
error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `HashMap`
118118
--> $DIR/into_iter_on_ref.rs:35:43
119119
|
120120
LL | let _ = (&HashMap::<i32, u64>::new()).into_iter(); //~ WARN equivalent to .iter()
121121
| ^^^^^^^^^ help: call directly: `iter`
122122

123-
error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not move the `HashMap`
123+
error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not consume the `HashMap`
124124
--> $DIR/into_iter_on_ref.rs:36:47
125125
|
126126
LL | let _ = (&mut HashMap::<i32, u64>::new()).into_iter(); //~ WARN equivalent to .iter_mut()
127127
| ^^^^^^^^^ help: call directly: `iter_mut`
128128

129-
error: this `.into_iter()` call is equivalent to `.iter()` and will not move the `BTreeSet`
129+
error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `BTreeSet`
130130
--> $DIR/into_iter_on_ref.rs:38:39
131131
|
132132
LL | let _ = (&BTreeSet::<i32>::new()).into_iter(); //~ WARN equivalent to .iter()
133133
| ^^^^^^^^^ help: call directly: `iter`
134134

135-
error: this `.into_iter()` call is equivalent to `.iter()` and will not move the `BinaryHeap`
135+
error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `BinaryHeap`
136136
--> $DIR/into_iter_on_ref.rs:39:41
137137
|
138138
LL | let _ = (&BinaryHeap::<i32>::new()).into_iter(); //~ WARN equivalent to .iter()
139139
| ^^^^^^^^^ help: call directly: `iter`
140140

141-
error: this `.into_iter()` call is equivalent to `.iter()` and will not move the `HashSet`
141+
error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `HashSet`
142142
--> $DIR/into_iter_on_ref.rs:40:38
143143
|
144144
LL | let _ = (&HashSet::<i32>::new()).into_iter(); //~ WARN equivalent to .iter()
145145
| ^^^^^^^^^ help: call directly: `iter`
146146

147-
error: this `.into_iter()` call is equivalent to `.iter()` and will not move the `Path`
147+
error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `Path`
148148
--> $DIR/into_iter_on_ref.rs:41:43
149149
|
150150
LL | let _ = std::path::Path::new("12/34").into_iter(); //~ WARN equivalent to .iter()
151151
| ^^^^^^^^^ help: call directly: `iter`
152152

153-
error: this `.into_iter()` call is equivalent to `.iter()` and will not move the `PathBuf`
153+
error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `PathBuf`
154154
--> $DIR/into_iter_on_ref.rs:42:47
155155
|
156156
LL | let _ = std::path::PathBuf::from("12/34").into_iter(); //~ ERROR equivalent to .iter()
157157
| ^^^^^^^^^ help: call directly: `iter`
158158

159-
error: this `.into_iter()` call is equivalent to `.iter()` and will not move the `array`
159+
error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `array`
160160
--> $DIR/into_iter_on_ref.rs:44:26
161161
|
162162
LL | let _ = (&[1, 2, 3]).into_iter().next(); //~ WARN equivalent to .iter()

0 commit comments

Comments
 (0)