Skip to content

Commit

Permalink
Resolve single_match_else pedantic clippy lint in code generator
Browse files Browse the repository at this point in the history
    warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
       --> src/parse.rs:146:33
        |
    146 |                       let punct = match introspect_type(last_arg(&last.arguments), lookup) {
        |  _________________________________^
    147 | |                         types::Type::Token(s) => s,
    148 | |                         _ => panic!(),
    149 | |                     };
        | |_____________________^ help: try: `if let types::Type::Token(s) = introspect_type(last_arg(&last.arguments), lookup) { s } else { panic!() }`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match_else
        = note: `-W clippy::single-match-else` implied by `-W clippy::pedantic`
        = help: to override `-W clippy::pedantic` add `#[allow(clippy::single_match_else)]`
  • Loading branch information
dtolnay committed Oct 2, 2023
1 parent 67ab64f commit 7313d24
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions codegen/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ fn introspect_type(item: &syn::Type, lookup: &Lookup) -> types::Type {
}
"Punctuated" => {
let nested = introspect_type(first_arg(&last.arguments), lookup);
let punct = match introspect_type(last_arg(&last.arguments), lookup) {
types::Type::Token(s) => s,
_ => panic!(),
let types::Type::Token(punct) =
introspect_type(last_arg(&last.arguments), lookup)
else {
panic!()
};

types::Type::Punctuated(types::Punctuated {
element: Box::new(nested),
punct,
Expand Down

0 comments on commit 7313d24

Please sign in to comment.