Skip to content

Commit edbf7a0

Browse files
committed
also add a test to map_identity
1 parent 94c959a commit edbf7a0

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

tests/ui/map_identity.fixed

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,15 @@ fn issue13904() {
8787
let _ = { it }.next();
8888
//~^ map_identity
8989
}
90+
91+
// same as `issue11764`, but for arrays
92+
fn issue15198() {
93+
let x = [[1, 2], [3, 4]];
94+
// don't lint: `&[i32; 2]` becomes `[&i32; 2]`
95+
let _ = x.iter().map(|[x, y]| [x, y]);
96+
let _ = x.iter().map(|x| [x[0]]).map(|[x]| x);
97+
98+
// no match ergonomics for `[i32, i32]`
99+
let _ = x.iter().copied();
100+
//~^ map_identity
101+
}

tests/ui/map_identity.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,15 @@ fn issue13904() {
9393
let _ = { it }.map(|x| x).next();
9494
//~^ map_identity
9595
}
96+
97+
// same as `issue11764`, but for arrays
98+
fn issue15198() {
99+
let x = [[1, 2], [3, 4]];
100+
// don't lint: `&[i32; 2]` becomes `[&i32; 2]`
101+
let _ = x.iter().map(|[x, y]| [x, y]);
102+
let _ = x.iter().map(|x| [x[0]]).map(|[x]| x);
103+
104+
// no match ergonomics for `[i32, i32]`
105+
let _ = x.iter().copied().map(|[x, y]| [x, y]);
106+
//~^ map_identity
107+
}

tests/ui/map_identity.stderr

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,5 +87,11 @@ error: unnecessary map of the identity function
8787
LL | let _ = { it }.map(|x| x).next();
8888
| ^^^^^^^^^^^ help: remove the call to `map`
8989

90-
error: aborting due to 13 previous errors
90+
error: unnecessary map of the identity function
91+
--> tests/ui/map_identity.rs:105:30
92+
|
93+
LL | let _ = x.iter().copied().map(|[x, y]| [x, y]);
94+
| ^^^^^^^^^^^^^^^^^^^^^ help: remove the call to `map`
95+
96+
error: aborting due to 14 previous errors
9197

0 commit comments

Comments
 (0)