Skip to content

Commit

Permalink
Resolve let_and_return clippy lint
Browse files Browse the repository at this point in the history
    warning: returning the result of a `let` binding from a block
      --> impl/src/fmt.rs:67:21
       |
    63 | /                     let member = match int.parse::<u32>() {
    64 | |                         Ok(index) => MemberUnraw::Unnamed(Index { index, span }),
    65 | |                         Err(_) => return Ok(()),
    66 | |                     };
       | |______________________- unnecessary `let` binding
    67 |                       member
       |                       ^^^^^^
       |
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_and_return
       = note: `-W clippy::let-and-return` implied by `-W clippy::all`
       = help: to override `-W clippy::all` add `#[allow(clippy::let_and_return)]`
    help: return the expression directly
       |
    63 ~
    64 ~                     match int.parse::<u32>() {
    65 +                         Ok(index) => MemberUnraw::Unnamed(Index { index, span }),
    66 +                         Err(_) => return Ok(()),
    67 +                     }
       |
  • Loading branch information
dtolnay committed Nov 8, 2024
1 parent 3ee0a4d commit fb59da6
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions impl/src/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,10 @@ impl Display<'_> {
return Err(Error::new_spanned(first_unnamed, msg));
}
}
let member = match int.parse::<u32>() {
match int.parse::<u32>() {
Ok(index) => MemberUnraw::Unnamed(Index { index, span }),
Err(_) => return Ok(()),
};
member
}
}
'a'..='z' | 'A'..='Z' | '_' => {
if read.starts_with("r#") {
Expand Down

0 comments on commit fb59da6

Please sign in to comment.