From c53ceba56f0b0ec5d3ee20a19f0f6aace6d26228 Mon Sep 17 00:00:00 2001 From: disco07 Date: Thu, 11 May 2023 07:20:02 +0200 Subject: [PATCH] update tests --- .../redundant_pattern_matching_option.fixed | 14 +++++++---- tests/ui/redundant_pattern_matching_option.rs | 14 +++++++---- .../redundant_pattern_matching_option.stderr | 24 +++++++++---------- 3 files changed, 30 insertions(+), 22 deletions(-) diff --git a/tests/ui/redundant_pattern_matching_option.fixed b/tests/ui/redundant_pattern_matching_option.fixed index 2f907f7ae3dd..94c89049189e 100644 --- a/tests/ui/redundant_pattern_matching_option.fixed +++ b/tests/ui/redundant_pattern_matching_option.fixed @@ -91,15 +91,19 @@ fn issue7921() { } fn issue10726() { - Some(42).is_some(); + let x = Some(42); + let y = None::<()>; - Some(42).is_none(); + x.is_some(); - None::<()>.is_some(); + x.is_none(); - None::<()>.is_none(); + y.is_some(); - match Some(42) { + y.is_none(); + + // Don't lint + match x { Some(21) => true, _ => false, }; diff --git a/tests/ui/redundant_pattern_matching_option.rs b/tests/ui/redundant_pattern_matching_option.rs index 5e80a2b384b7..303a0280e9d9 100644 --- a/tests/ui/redundant_pattern_matching_option.rs +++ b/tests/ui/redundant_pattern_matching_option.rs @@ -106,27 +106,31 @@ fn issue7921() { } fn issue10726() { - match Some(42) { + let x = Some(42); + let y = None::<()>; + + match x { Some(_) => true, _ => false, }; - match Some(42) { + match x { None => true, _ => false, }; - match None::<()> { + match y { Some(_) => true, _ => false, }; - match None::<()> { + match y { None => true, _ => false, }; - match Some(42) { + // Don't lint + match x { Some(21) => true, _ => false, }; diff --git a/tests/ui/redundant_pattern_matching_option.stderr b/tests/ui/redundant_pattern_matching_option.stderr index 97de2f1c86f2..eb4d87ba2b5e 100644 --- a/tests/ui/redundant_pattern_matching_option.stderr +++ b/tests/ui/redundant_pattern_matching_option.stderr @@ -149,40 +149,40 @@ LL | if let None = *&None::<()> {} | -------^^^^--------------- help: try this: `if (&None::<()>).is_none()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching_option.rs:109:5 + --> $DIR/redundant_pattern_matching_option.rs:112:5 | -LL | / match Some(42) { +LL | / match x { LL | | Some(_) => true, LL | | _ => false, LL | | }; - | |_____^ help: try this: `Some(42).is_some()` + | |_____^ help: try this: `x.is_some()` error: redundant pattern matching, consider using `is_none()` - --> $DIR/redundant_pattern_matching_option.rs:114:5 + --> $DIR/redundant_pattern_matching_option.rs:117:5 | -LL | / match Some(42) { +LL | / match x { LL | | None => true, LL | | _ => false, LL | | }; - | |_____^ help: try this: `Some(42).is_none()` + | |_____^ help: try this: `x.is_none()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching_option.rs:119:5 + --> $DIR/redundant_pattern_matching_option.rs:122:5 | -LL | / match None::<()> { +LL | / match y { LL | | Some(_) => true, LL | | _ => false, LL | | }; - | |_____^ help: try this: `None::<()>.is_some()` + | |_____^ help: try this: `y.is_some()` error: redundant pattern matching, consider using `is_none()` - --> $DIR/redundant_pattern_matching_option.rs:124:5 + --> $DIR/redundant_pattern_matching_option.rs:127:5 | -LL | / match None::<()> { +LL | / match y { LL | | None => true, LL | | _ => false, LL | | }; - | |_____^ help: try this: `None::<()>.is_none()` + | |_____^ help: try this: `y.is_none()` error: aborting due to 26 previous errors