Skip to content

Commit a4b53c9

Browse files
committed
manual_let_else: Add test with expanded macros
1 parent bbcc260 commit a4b53c9

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

tests/ui/manual_let_else.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,4 +234,18 @@ fn not_fire() {
234234
// If a type annotation is present, don't lint as
235235
// expressing the type might be too hard
236236
let v: () = if let Some(v_some) = g() { v_some } else { panic!() };
237+
238+
// Issue 9940
239+
// Suggestion should not expand macros
240+
macro_rules! macro_call {
241+
() => {
242+
return ()
243+
};
244+
}
245+
246+
let ff = Some(1);
247+
let _ = match ff {
248+
Some(value) => value,
249+
_ => macro_call!(),
250+
};
237251
}

tests/ui/manual_let_else.stderr

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,5 +259,14 @@ LL | create_binding_if_some!(w, g());
259259
|
260260
= note: this error originates in the macro `create_binding_if_some` (in Nightly builds, run with -Z macro-backtrace for more info)
261261

262-
error: aborting due to 17 previous errors
262+
error: this could be rewritten as `let...else`
263+
--> $DIR/manual_let_else.rs:247:5
264+
|
265+
LL | / let _ = match ff {
266+
LL | | Some(value) => value,
267+
LL | | _ => macro_call!(),
268+
LL | | };
269+
| |______^ help: consider writing: `let Some(value) = ff else { macro_call!() };`
270+
271+
error: aborting due to 18 previous errors
263272

0 commit comments

Comments
 (0)