Sitelet https://github.com/dtolnay/syn/commit/376f371977161a37fbf576ab482c284b54c127de
Skip to content

Commit 376f371

Browse files
committed
Resolve manual_let_else pedantic clippy lint in dump-syntax
warning: this could be rewritten as `let...else` --> examples/dump-syntax/src/main.rs:101:5 | 101 | / let code_line = match start.line.checked_sub(1).and_then(|n| code.lines().nth(n)) { 102 | | Some(line) => line, 103 | | None => return render_fallback(formatter, err), 104 | | }; | |______^ help: consider writing: `let Some(code_line) = start.line.checked_sub(1).and_then(|n| code.lines().nth(n)) else { return render_fallback(formatter, err) };` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else = note: `-W clippy::manual-let-else` implied by `-W clippy::pedantic` = help: to override `-W clippy::pedantic` add `#[allow(clippy::manual_let_else)]`
1 parent b4c6c8f commit 376f371

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

‎examples/dump-syntax/src/main.rs‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,8 @@ fn render_location(
9898
let start = err.span().start();
9999
let mut end = err.span().end();
100100

101-
let code_line = match start.line.checked_sub(1).and_then(|n| code.lines().nth(n)) {
102-
Some(line) => line,
103-
None => return render_fallback(formatter, err),
101+
let Some(code_line) = start.line.checked_sub(1).and_then(|n| code.lines().nth(n)) else {
102+
return render_fallback(formatter, err);
104103
};
105104

106105
if end.line > start.line {

0 commit comments

Comments
 (0)