Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit ac194ca

Browse files
committed
map_clone: make lint adhere to lint message convention
1 parent c0a9d64 commit ac194ca

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

clippy_lints/src/map_clone.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ fn lint_needless_cloning(cx: &LateContext<'_>, root: Span, receiver: Span) {
111111
cx,
112112
MAP_CLONE,
113113
root.trim_start(receiver).unwrap(),
114-
"You are needlessly cloning iterator elements",
115-
"Remove the `map` call",
114+
"you are needlessly cloning iterator elements",
115+
"remove the `map` call",
116116
String::new(),
117117
Applicability::MachineApplicable,
118118
)
@@ -125,8 +125,8 @@ fn lint(cx: &LateContext<'_>, replace: Span, root: Span, copied: bool) {
125125
cx,
126126
MAP_CLONE,
127127
replace,
128-
"You are using an explicit closure for copying elements",
129-
"Consider calling the dedicated `copied` method",
128+
"you are using an explicit closure for copying elements",
129+
"consider calling the dedicated `copied` method",
130130
format!(
131131
"{}.copied()",
132132
snippet_with_applicability(cx, root, "..", &mut applicability)
@@ -138,8 +138,8 @@ fn lint(cx: &LateContext<'_>, replace: Span, root: Span, copied: bool) {
138138
cx,
139139
MAP_CLONE,
140140
replace,
141-
"You are using an explicit closure for cloning elements",
142-
"Consider calling the dedicated `cloned` method",
141+
"you are using an explicit closure for cloning elements",
142+
"consider calling the dedicated `cloned` method",
143143
format!(
144144
"{}.cloned()",
145145
snippet_with_applicability(cx, root, "..", &mut applicability)

tests/ui/map_clone.stderr

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
1-
error: You are using an explicit closure for copying elements
1+
error: you are using an explicit closure for copying elements
22
--> $DIR/map_clone.rs:10:22
33
|
44
LL | let _: Vec<i8> = vec![5_i8; 6].iter().map(|x| *x).collect();
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: Consider calling the dedicated `copied` method: `vec![5_i8; 6].iter().copied()`
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `copied` method: `vec![5_i8; 6].iter().copied()`
66
|
77
= note: `-D clippy::map-clone` implied by `-D warnings`
88

9-
error: You are using an explicit closure for cloning elements
9+
error: you are using an explicit closure for cloning elements
1010
--> $DIR/map_clone.rs:11:26
1111
|
1212
LL | let _: Vec<String> = vec![String::new()].iter().map(|x| x.clone()).collect();
13-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: Consider calling the dedicated `cloned` method: `vec![String::new()].iter().cloned()`
13+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `cloned` method: `vec![String::new()].iter().cloned()`
1414

15-
error: You are using an explicit closure for copying elements
15+
error: you are using an explicit closure for copying elements
1616
--> $DIR/map_clone.rs:12:23
1717
|
1818
LL | let _: Vec<u32> = vec![42, 43].iter().map(|&x| x).collect();
19-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: Consider calling the dedicated `copied` method: `vec![42, 43].iter().copied()`
19+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `copied` method: `vec![42, 43].iter().copied()`
2020

21-
error: You are using an explicit closure for copying elements
21+
error: you are using an explicit closure for copying elements
2222
--> $DIR/map_clone.rs:14:26
2323
|
2424
LL | let _: Option<u64> = Some(&16).map(|b| *b);
25-
| ^^^^^^^^^^^^^^^^^^^^^ help: Consider calling the dedicated `copied` method: `Some(&16).copied()`
25+
| ^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `copied` method: `Some(&16).copied()`
2626

27-
error: You are using an explicit closure for copying elements
27+
error: you are using an explicit closure for copying elements
2828
--> $DIR/map_clone.rs:15:25
2929
|
3030
LL | let _: Option<u8> = Some(&1).map(|x| x.clone());
31-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: Consider calling the dedicated `copied` method: `Some(&1).copied()`
31+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `copied` method: `Some(&1).copied()`
3232

33-
error: You are needlessly cloning iterator elements
33+
error: you are needlessly cloning iterator elements
3434
--> $DIR/map_clone.rs:26:29
3535
|
3636
LL | let _ = std::env::args().map(|v| v.clone());
37-
| ^^^^^^^^^^^^^^^^^^^ help: Remove the `map` call
37+
| ^^^^^^^^^^^^^^^^^^^ help: remove the `map` call
3838

3939
error: aborting due to 6 previous errors
4040

0 commit comments

Comments
 (0)