Skip to content

Commit 63fb294

Browse files
committed
Add help for matches for if let in arm guard
1 parent 23bcea4 commit 63fb294

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

compiler/rustc_ast_passes/src/feature_gate.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,11 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session) {
638638
}
639639
};
640640
}
641-
gate_all!(if_let_guard, "`if let` guards are experimental");
641+
gate_all!(
642+
if_let_guard,
643+
"`if let` guards are experimental",
644+
"you can write `if matches!(<expr>, <pattern>)` instead of `if let <pattern> = <expr>`"
645+
);
642646
gate_all!(
643647
let_chains,
644648
"`let` expressions in this position are experimental",

src/test/ui/rfc-2294-if-let-guard/feature-gate.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ LL | () if let 0 = 1 => {}
1515
|
1616
= note: see issue #51114 <https://github.com/rust-lang/rust/issues/51114> for more information
1717
= help: add `#![feature(if_let_guard)]` to the crate attributes to enable
18+
= help: you can write `if matches!(<expr>, <pattern>)` instead of `if let <pattern> = <expr>`
1819

1920
error[E0658]: `if let` guards are experimental
2021
--> $DIR/feature-gate.rs:76:12
@@ -24,6 +25,7 @@ LL | () if let 0 = 1 => {}
2425
|
2526
= note: see issue #51114 <https://github.com/rust-lang/rust/issues/51114> for more information
2627
= help: add `#![feature(if_let_guard)]` to the crate attributes to enable
28+
= help: you can write `if matches!(<expr>, <pattern>)` instead of `if let <pattern> = <expr>`
2729

2830
error[E0658]: `let` expressions in this position are experimental
2931
--> $DIR/feature-gate.rs:10:16

0 commit comments

Comments
 (0)