about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-11-30 21:23:10 +0000
committerbors <bors@rust-lang.org>2022-11-30 21:23:10 +0000
commitee12b12be538900d9b21cde6643ee78144a14445 (patch)
treedd424a66a3c8324729d47a48aac5241a24555a7c /tests
parent1cdb06d406181e15a943dab926273013fdefd516 (diff)
parentc502dee41ec38e6e0096abaa50a48e792e4c9d40 (diff)
downloadrust-ee12b12be538900d9b21cde6643ee78144a14445.tar.gz
rust-ee12b12be538900d9b21cde6643ee78144a14445.zip
Auto merge of #9943 - dswij:pr-9940, r=Jarcho
manual_let_else: keep macro call on suggestion blocks

Closes #9940

changelog: [`manual_let_else`]: Do not expand macro calls on suggestions
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/manual_let_else.rs14
-rw-r--r--tests/ui/manual_let_else.stderr11
2 files changed, 24 insertions, 1 deletions
diff --git a/tests/ui/manual_let_else.rs b/tests/ui/manual_let_else.rs
index 2ef40e5911a..48a162c1360 100644
--- a/tests/ui/manual_let_else.rs
+++ b/tests/ui/manual_let_else.rs
@@ -234,4 +234,18 @@ fn not_fire() {
     // If a type annotation is present, don't lint as
     // expressing the type might be too hard
     let v: () = if let Some(v_some) = g() { v_some } else { panic!() };
+
+    // Issue 9940
+    // Suggestion should not expand macros
+    macro_rules! macro_call {
+        () => {
+            return ()
+        };
+    }
+
+    let ff = Some(1);
+    let _ = match ff {
+        Some(value) => value,
+        _ => macro_call!(),
+    };
 }
diff --git a/tests/ui/manual_let_else.stderr b/tests/ui/manual_let_else.stderr
index 453b68b8bd0..52aac6bc673 100644
--- a/tests/ui/manual_let_else.stderr
+++ b/tests/ui/manual_let_else.stderr
@@ -259,5 +259,14 @@ LL |     create_binding_if_some!(w, g());
    |
    = note: this error originates in the macro `create_binding_if_some` (in Nightly builds, run with -Z macro-backtrace for more info)
 
-error: aborting due to 17 previous errors
+error: this could be rewritten as `let...else`
+  --> $DIR/manual_let_else.rs:247:5
+   |
+LL | /     let _ = match ff {
+LL | |         Some(value) => value,
+LL | |         _ => macro_call!(),
+LL | |     };
+   | |______^ help: consider writing: `let Some(value) = ff else { macro_call!() };`
+
+error: aborting due to 18 previous errors