Skip to content

Commit

Permalink
Resolve single_match_else pedantic clippy lint
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/path.rs:175:21
        |
    175 |           let qself = match qself {
        |  _____________________^
    176 | |             Some(qself) => qself,
    177 | |             None => {
    178 | |                 self.path(path, kind);
    179 | |                 return;
    180 | |             }
    181 | |         };
        | |_________^
        |
        = 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)]`
    help: try
        |
    175 ~         let qself = if let Some(qself) = qself { qself } else {
    176 +             self.path(path, kind);
    177 +             return;
    178 ~         };
        |
  • Loading branch information
dtolnay committed Aug 10, 2024
1 parent 93f2078 commit 8584223
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,11 @@ impl Printer {
}

pub fn qpath(&mut self, qself: &Option<QSelf>, path: &Path, kind: PathKind) {
let qself = match qself {
Some(qself) => qself,
None => {
self.path(path, kind);
return;
}
let qself = if let Some(qself) = qself {
qself
} else {
self.path(path, kind);
return;
};

assert!(qself.position < path.segments.len());
Expand Down

0 comments on commit 8584223

Please sign in to comment.