diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2021-03-07 14:44:21 -0800 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2021-03-07 14:44:21 -0800 |
| commit | 63fb294a7455b76ecfbef6831410e5362ee9d514 (patch) | |
| tree | fd01b88530af87a80ad232cdf516458a3be111ba | |
| parent | 23bcea4249e8c5cf72fa763c02079b35d4eb8c2d (diff) | |
| download | rust-63fb294a7455b76ecfbef6831410e5362ee9d514.tar.gz rust-63fb294a7455b76ecfbef6831410e5362ee9d514.zip | |
Add help for `matches` for `if let` in arm guard
| -rw-r--r-- | compiler/rustc_ast_passes/src/feature_gate.rs | 6 | ||||
| -rw-r--r-- | src/test/ui/rfc-2294-if-let-guard/feature-gate.stderr | 2 |
2 files changed, 7 insertions, 1 deletions
diff --git a/compiler/rustc_ast_passes/src/feature_gate.rs b/compiler/rustc_ast_passes/src/feature_gate.rs index e13e9bdf96b..053fa5b7897 100644 --- a/compiler/rustc_ast_passes/src/feature_gate.rs +++ b/compiler/rustc_ast_passes/src/feature_gate.rs @@ -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", diff --git a/src/test/ui/rfc-2294-if-let-guard/feature-gate.stderr b/src/test/ui/rfc-2294-if-let-guard/feature-gate.stderr index 2b71026dc4b..00811fe3044 100644 --- a/src/test/ui/rfc-2294-if-let-guard/feature-gate.stderr +++ b/src/test/ui/rfc-2294-if-let-guard/feature-gate.stderr @@ -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 @@ -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 |
