manual_let_else: Add test with expanded macros

This commit is contained in:
dswij 2022-11-25 18:04:31 +08:00
parent bbcc260b6f
commit a4b53c9c14
2 changed files with 24 additions and 1 deletions

View File

@ -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!(),
};
}

View File

@ -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