Skip to content

Commit

Permalink
Resolve get_first clippy lint
Browse files Browse the repository at this point in the history
    warning: accessing first element with `block.stmts.get(0)`
       --> src/expr.rs:915:20
        |
    915 |             match (block.stmts.get(0), block.stmts.get(1)) {
        |                    ^^^^^^^^^^^^^^^^^^ help: try: `block.stmts.first()`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first
        = note: `-W clippy::get-first` implied by `-W clippy::all`
        = help: to override `-W clippy::all` add `#[allow(clippy::get_first)]`
  • Loading branch information
dtolnay committed Oct 22, 2023
1 parent 1e8e67e commit 93aa5b3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -912,8 +912,8 @@ impl Printer {
if attr::has_inner(attrs) || !block.stmts.is_empty() {
self.space();
self.inner_attrs(attrs);
match (block.stmts.get(0), block.stmts.get(1)) {
(Some(Stmt::Expr(expr, None)), None) if stmt::break_after(expr) => {
match block.stmts.as_slice() {
[Stmt::Expr(expr, None)] if stmt::break_after(expr) => {
self.ibox(0);
self.expr_beginning_of_line(expr, true);
self.end();
Expand Down

0 comments on commit 93aa5b3

Please sign in to comment.