Skip to content

Commit

Permalink
refactor: fix re-daclare logic
Browse files Browse the repository at this point in the history
  • Loading branch information
chansuke committed Jan 4, 2023
1 parent 9b112b2 commit 2a2e634
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
9 changes: 4 additions & 5 deletions clippy_lints/src/unnecessary_reserve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ fn check_extend_method(
struct_expr: &rustc_hir::Expr<'_>,
) -> Option<rustc_span::Span> {
let mut read_found = false;
let next_stmt_span;
let mut spanless_eq = SpanlessEq::new(cx);

let _: Option<!> = for_each_expr(block, |expr| {
Expand All @@ -117,16 +116,16 @@ fn check_extend_method(
ControlFlow::Continue(())
});

if idx == block.stmts.len() - 1 {
let next_stmt_span: rustc_span::Span = if idx == block.stmts.len() - 1 {
if let Some(e) = block.expr {
next_stmt_span = e.span;
e.span
} else {
return None;
}
} else {
let next_stmt = &block.stmts[idx + 1];
next_stmt_span = next_stmt.span;
}
return Some(next_stmt.span);
};

if read_found {
return Some(next_stmt_span);
Expand Down
6 changes: 3 additions & 3 deletions tests/ui/unnecessary_reserve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ use std::collections::VecDeque;

fn main() {
vec_reserve();
//vec_deque_reserve();
//hash_map_reserve();
//msrv_1_62();
vec_deque_reserve();
hash_map_reserve();
msrv_1_62();
}

fn vec_reserve() {
Expand Down

0 comments on commit 2a2e634

Please sign in to comment.