Skip to content

Commit

Permalink
Add help for matches for if let in arm guard
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed Mar 7, 2021
1 parent 23bcea4 commit 63fb294
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion compiler/rustc_ast_passes/src/feature_gate.rs
Expand Up @@ -638,7 +638,11 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session) {
}
};
}
gate_all!(if_let_guard, "`if let` guards are experimental");
gate_all!(
if_let_guard,
"`if let` guards are experimental",
"you can write `if matches!(<expr>, <pattern>)` instead of `if let <pattern> = <expr>`"
);
gate_all!(
let_chains,
"`let` expressions in this position are experimental",
Expand Down
2 changes: 2 additions & 0 deletions src/test/ui/rfc-2294-if-let-guard/feature-gate.stderr
Expand Up @@ -15,6 +15,7 @@ LL | () if let 0 = 1 => {}
|
= note: see issue #51114 <https://github.com/rust-lang/rust/issues/51114> for more information
= help: add `#![feature(if_let_guard)]` to the crate attributes to enable
= help: you can write `if matches!(<expr>, <pattern>)` instead of `if let <pattern> = <expr>`

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

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

0 comments on commit 63fb294

Please sign in to comment.