Closed
Description
warning: this match could be written as a `let` statement
--> src/librustc_builtin_macros/deriving/generic/mod.rs:1059:34
|
1059 | .map(|l| match l.next().unwrap() {
| __________________________________^
1060 | | (.., ex, _) => ex,
1061 | | })
| |_________________________^
|
= note: `#[warn(clippy::match_single_binding)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_single_binding
help: consider using `let` statement
|
1059 | .map(|l| let (.., ex, _) = l.next().unwrap();
1060 | ex)
|
The suggested code does not compile,
error: expected one of `)`, `,`, `.`, `?`, or an operator, found `;`
--> src/librustc_builtin_macros/deriving/generic/mod.rs:1060:64
|
1060 | ... let (.., ex, _) = l.next().unwrap();
| ^
| |
| expected one of `)`, `,`, `.`, `?`, or an operator
| help: missing `,`
error[E0425]: cannot find value `ex` in this scope
--> src/librustc_builtin_macros/deriving/generic/mod.rs:1061:29
|
1061 | ... ex
| ^^ help: a local variable with a similar name exists: `cx`
error[E0658]: `let` expressions in this position are experimental
--> src/librustc_builtin_macros/deriving/generic/mod.rs:1060:29
|
1060 | ... let (.., ex, _) = l.next().unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= 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
we need curly braces around the let + return statement like this:
.map(|l| {
let (.., ex, _) = l.next().unwrap();
ex
})