Skip to content

Commit

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

error[E0658]: `let` expressions in this position are experimental
--> $DIR/feature-gate.rs:14:18
Expand All @@ -42,6 +43,7 @@ LL | () if (((let 0 = 1))) => {}
|
= note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
= help: add `#![feature(let_chains)]` to the crate attributes to enable
= help: you can write `matches!(<expr>, <pattern>)` instead of `let <pattern> = <expr>`

error[E0658]: `let` expressions in this position are experimental
--> $DIR/feature-gate.rs:18:23
Expand All @@ -51,6 +53,7 @@ LL | () if true && let 0 = 1 => {}
|
= note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
= help: add `#![feature(let_chains)]` to the crate attributes to enable
= help: you can write `matches!(<expr>, <pattern>)` instead of `let <pattern> = <expr>`

error[E0658]: `let` expressions in this position are experimental
--> $DIR/feature-gate.rs:22:15
Expand All @@ -60,6 +63,7 @@ LL | () if let 0 = 1 && true => {}
|
= note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
= help: add `#![feature(let_chains)]` to the crate attributes to enable
= help: you can write `matches!(<expr>, <pattern>)` instead of `let <pattern> = <expr>`

error[E0658]: `let` expressions in this position are experimental
--> $DIR/feature-gate.rs:26:16
Expand All @@ -69,6 +73,7 @@ LL | () if (let 0 = 1) && true => {}
|
= note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
= help: add `#![feature(let_chains)]` to the crate attributes to enable
= help: you can write `matches!(<expr>, <pattern>)` instead of `let <pattern> = <expr>`

error[E0658]: `let` expressions in this position are experimental
--> $DIR/feature-gate.rs:30:24
Expand All @@ -78,6 +83,7 @@ LL | () if true && (let 0 = 1) => {}
|
= note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
= help: add `#![feature(let_chains)]` to the crate attributes to enable
= help: you can write `matches!(<expr>, <pattern>)` instead of `let <pattern> = <expr>`

error[E0658]: `let` expressions in this position are experimental
--> $DIR/feature-gate.rs:34:16
Expand All @@ -87,6 +93,7 @@ LL | () if (let 0 = 1) && (let 0 = 1) => {}
|
= note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
= help: add `#![feature(let_chains)]` to the crate attributes to enable
= help: you can write `matches!(<expr>, <pattern>)` instead of `let <pattern> = <expr>`

error[E0658]: `let` expressions in this position are experimental
--> $DIR/feature-gate.rs:34:31
Expand All @@ -96,6 +103,7 @@ LL | () if (let 0 = 1) && (let 0 = 1) => {}
|
= note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
= help: add `#![feature(let_chains)]` to the crate attributes to enable
= help: you can write `matches!(<expr>, <pattern>)` instead of `let <pattern> = <expr>`

error[E0658]: `let` expressions in this position are experimental
--> $DIR/feature-gate.rs:40:15
Expand All @@ -105,6 +113,7 @@ LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 =
|
= note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
= help: add `#![feature(let_chains)]` to the crate attributes to enable
= help: you can write `matches!(<expr>, <pattern>)` instead of `let <pattern> = <expr>`

error[E0658]: `let` expressions in this position are experimental
--> $DIR/feature-gate.rs:40:28
Expand All @@ -114,6 +123,7 @@ LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 =
|
= note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
= help: add `#![feature(let_chains)]` to the crate attributes to enable
= help: you can write `matches!(<expr>, <pattern>)` instead of `let <pattern> = <expr>`

error[E0658]: `let` expressions in this position are experimental
--> $DIR/feature-gate.rs:40:42
Expand All @@ -123,6 +133,7 @@ LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 =
|
= note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
= help: add `#![feature(let_chains)]` to the crate attributes to enable
= help: you can write `matches!(<expr>, <pattern>)` instead of `let <pattern> = <expr>`

error[E0658]: `let` expressions in this position are experimental
--> $DIR/feature-gate.rs:40:55
Expand All @@ -132,6 +143,7 @@ LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 =
|
= note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
= help: add `#![feature(let_chains)]` to the crate attributes to enable
= help: you can write `matches!(<expr>, <pattern>)` instead of `let <pattern> = <expr>`

error[E0658]: `let` expressions in this position are experimental
--> $DIR/feature-gate.rs:40:68
Expand All @@ -141,6 +153,7 @@ LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 =
|
= note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
= help: add `#![feature(let_chains)]` to the crate attributes to enable
= help: you can write `matches!(<expr>, <pattern>)` instead of `let <pattern> = <expr>`

error[E0658]: `let` expressions in this position are experimental
--> $DIR/feature-gate.rs:52:15
Expand All @@ -150,6 +163,7 @@ LL | () if let Range { start: _, end: _ } = (true..true) && false => {}
|
= note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
= help: add `#![feature(let_chains)]` to the crate attributes to enable
= help: you can write `matches!(<expr>, <pattern>)` instead of `let <pattern> = <expr>`

error[E0658]: `let` expressions in this position are experimental
--> $DIR/feature-gate.rs:68:16
Expand All @@ -159,6 +173,7 @@ LL | use_expr!((let 0 = 1 && 0 == 0));
|
= note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
= help: add `#![feature(let_chains)]` to the crate attributes to enable
= help: you can write `matches!(<expr>, <pattern>)` instead of `let <pattern> = <expr>`

error[E0658]: `let` expressions in this position are experimental
--> $DIR/feature-gate.rs:71:16
Expand All @@ -168,6 +183,7 @@ LL | use_expr!((let 0 = 1));
|
= note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
= help: add `#![feature(let_chains)]` to the crate attributes to enable
= help: you can write `matches!(<expr>, <pattern>)` instead of `let <pattern> = <expr>`

error: `let` expressions are not supported here
--> $DIR/feature-gate.rs:10:16
Expand Down

0 comments on commit 23bcea4

Please sign in to comment.