-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when appliedL-suggestionLint: Improving, adding or fixing lint suggestionsLint: Improving, adding or fixing lint suggestions
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
})
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when appliedL-suggestionLint: Improving, adding or fixing lint suggestionsLint: Improving, adding or fixing lint suggestions
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
ThibsG commentedon Mar 21, 2020
Thanks for reporting this, I will work on a fix
Auto merge of #5350 - ThibsG:FixSingleBindingClosure, r=flip1995
Auto merge of #5350 - ThibsG:FixSingleBindingClosure, r=flip1995
Auto merge of #5350 - ThibsG:FixSingleBindingClosure, r=flip1995