From a78c53add26e69d145b881a822cd8cc94cb29ca0 Mon Sep 17 00:00:00 2001 From: y21 <30553356+y21@users.noreply.github.com> Date: Wed, 14 Jun 2023 13:30:53 +0200 Subject: [PATCH] add some tests for tuples with type annotations --- tests/ui/map_identity.fixed | 5 +++++ tests/ui/map_identity.rs | 6 ++++++ tests/ui/map_identity.stderr | 10 +++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/tests/ui/map_identity.fixed b/tests/ui/map_identity.fixed index 999e8b455dec..e2064825af7c 100644 --- a/tests/ui/map_identity.fixed +++ b/tests/ui/map_identity.fixed @@ -30,6 +30,8 @@ fn issue7189() { let y = [(1, 2, (3, (4,))), (5, 6, (7, (8,)))]; let _ = y.iter(); + let _ = y + .iter(); // should not lint let _ = x.iter().map(|(x, y)| (x, y, y)); @@ -37,6 +39,9 @@ fn issue7189() { let _ = x.iter().map(|(x, _)| (x,)); let _ = x.iter().map(|(x, ..)| (x,)); let _ = y.iter().map(|(x, y, (z, _))| (x, y, (z, z))); + let _ = y + .iter() + .map(|(x, y, (z, _)): &(i32, i32, (i32, (i32,)))| (x, y, (z, z))); } fn not_identity(x: &u16) -> u16 { diff --git a/tests/ui/map_identity.rs b/tests/ui/map_identity.rs index 33896721f682..897ad4870990 100644 --- a/tests/ui/map_identity.rs +++ b/tests/ui/map_identity.rs @@ -34,6 +34,9 @@ fn issue7189() { let y = [(1, 2, (3, (4,))), (5, 6, (7, (8,)))]; let _ = y.iter().map(|(x, y, (z, (w,)))| (x, y, (z, (w,)))); + let _ = y + .iter() + .map(|(x, y, (z, (w,))): &(i32, i32, (i32, (i32,)))| (x, y, (z, (w,)))); // should not lint let _ = x.iter().map(|(x, y)| (x, y, y)); @@ -41,6 +44,9 @@ fn issue7189() { let _ = x.iter().map(|(x, _)| (x,)); let _ = x.iter().map(|(x, ..)| (x,)); let _ = y.iter().map(|(x, y, (z, _))| (x, y, (z, z))); + let _ = y + .iter() + .map(|(x, y, (z, _)): &(i32, i32, (i32, (i32,)))| (x, y, (z, z))); } fn not_identity(x: &u16) -> u16 { diff --git a/tests/ui/map_identity.stderr b/tests/ui/map_identity.stderr index 90ef150297e2..2e996907bbbd 100644 --- a/tests/ui/map_identity.stderr +++ b/tests/ui/map_identity.stderr @@ -66,5 +66,13 @@ error: unnecessary map of the identity function LL | let _ = y.iter().map(|(x, y, (z, (w,)))| (x, y, (z, (w,)))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove the call to `map` -error: aborting due to 10 previous errors +error: unnecessary map of the identity function + --> $DIR/map_identity.rs:38:16 + | +LL | .iter() + | ________________^ +LL | | .map(|(x, y, (z, (w,))): &(i32, i32, (i32, (i32,)))| (x, y, (z, (w,)))); + | |_______________________________________________________________________________^ help: remove the call to `map` + +error: aborting due to 11 previous errors