Skip to content

Commit a78c53a

Browse files
committed
add some tests for tuples with type annotations
1 parent e00976f commit a78c53a

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

tests/ui/map_identity.fixed

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,18 @@ fn issue7189() {
3030

3131
let y = [(1, 2, (3, (4,))), (5, 6, (7, (8,)))];
3232
let _ = y.iter();
33+
let _ = y
34+
.iter();
3335

3436
// should not lint
3537
let _ = x.iter().map(|(x, y)| (x, y, y));
3638
let _ = x.iter().map(|(x, _y)| (x,));
3739
let _ = x.iter().map(|(x, _)| (x,));
3840
let _ = x.iter().map(|(x, ..)| (x,));
3941
let _ = y.iter().map(|(x, y, (z, _))| (x, y, (z, z)));
42+
let _ = y
43+
.iter()
44+
.map(|(x, y, (z, _)): &(i32, i32, (i32, (i32,)))| (x, y, (z, z)));
4045
}
4146

4247
fn not_identity(x: &u16) -> u16 {

tests/ui/map_identity.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,19 @@ fn issue7189() {
3434

3535
let y = [(1, 2, (3, (4,))), (5, 6, (7, (8,)))];
3636
let _ = y.iter().map(|(x, y, (z, (w,)))| (x, y, (z, (w,))));
37+
let _ = y
38+
.iter()
39+
.map(|(x, y, (z, (w,))): &(i32, i32, (i32, (i32,)))| (x, y, (z, (w,))));
3740

3841
// should not lint
3942
let _ = x.iter().map(|(x, y)| (x, y, y));
4043
let _ = x.iter().map(|(x, _y)| (x,));
4144
let _ = x.iter().map(|(x, _)| (x,));
4245
let _ = x.iter().map(|(x, ..)| (x,));
4346
let _ = y.iter().map(|(x, y, (z, _))| (x, y, (z, z)));
47+
let _ = y
48+
.iter()
49+
.map(|(x, y, (z, _)): &(i32, i32, (i32, (i32,)))| (x, y, (z, z)));
4450
}
4551

4652
fn not_identity(x: &u16) -> u16 {

tests/ui/map_identity.stderr

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,13 @@ error: unnecessary map of the identity function
6666
LL | let _ = y.iter().map(|(x, y, (z, (w,)))| (x, y, (z, (w,))));
6767
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove the call to `map`
6868

69-
error: aborting due to 10 previous errors
69+
error: unnecessary map of the identity function
70+
--> $DIR/map_identity.rs:38:16
71+
|
72+
LL | .iter()
73+
| ________________^
74+
LL | | .map(|(x, y, (z, (w,))): &(i32, i32, (i32, (i32,)))| (x, y, (z, (w,))));
75+
| |_______________________________________________________________________________^ help: remove the call to `map`
76+
77+
error: aborting due to 11 previous errors
7078

0 commit comments

Comments
 (0)