Skip to content

Commit 2e0d4c5

Browse files
committed
misc
1 parent 7fd0b9e commit 2e0d4c5

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

clippy_lints/src/significant_drop_tightening.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -275,13 +275,7 @@ impl<'tcx> Visitor<'tcx> for StmtsChecker<'_, '_, '_, '_, 'tcx> {
275275
if let hir::StmtKind::Let(local) = self.ap.curr_stmt.kind
276276
&& let hir::PatKind::Binding(_, hir_id, ident, _) = local.pat.kind
277277
&& !self.ap.apas.contains_key(&hir_id)
278-
&& {
279-
if let Some(local_hir_id) = path_to_local(expr) {
280-
local_hir_id == hir_id
281-
} else {
282-
true
283-
}
284-
}
278+
&& path_to_local(expr).is_none_or(|local_hir_id| local_hir_id == hir_id)
285279
{
286280
let mut apa = AuxParamsAttr {
287281
first_block_hir_id: self.ap.curr_block_hir_id,
@@ -417,15 +411,15 @@ fn dummy_stmt_expr<'any>(expr: &'any hir::Expr<'any>) -> hir::Stmt<'any> {
417411
}
418412

419413
fn has_drop(expr: &hir::Expr<'_>, first_bind_ident: Option<Ident>, lcx: &LateContext<'_>) -> bool {
420-
if let hir::ExprKind::Call(fun, [first_arg]) = expr.kind
414+
if let Some(first_bind_ident) = first_bind_ident
415+
&& let hir::ExprKind::Call(fun, [first_arg]) = expr.kind
421416
&& let hir::ExprKind::Path(hir::QPath::Resolved(_, fun_path)) = &fun.kind
422417
&& let Res::Def(DefKind::Fn, did) = fun_path.res
423418
&& lcx.tcx.is_diagnostic_item(sym::mem_drop, did)
424419
{
425420
let has_ident = |local_expr: &hir::Expr<'_>| {
426421
if let hir::ExprKind::Path(hir::QPath::Resolved(_, arg_path)) = &local_expr.kind
427422
&& let [first_arg_ps, ..] = arg_path.segments
428-
&& let Some(first_bind_ident) = first_bind_ident
429423
&& first_arg_ps.ident == first_bind_ident
430424
{
431425
true
@@ -447,7 +441,5 @@ fn has_drop(expr: &hir::Expr<'_>, first_bind_ident: Option<Ident>, lcx: &LateCon
447441

448442
fn is_inexpensive_expr(expr: &hir::Expr<'_>) -> bool {
449443
let actual = peel_hir_expr_unary(expr).0;
450-
let is_path = matches!(actual.kind, hir::ExprKind::Path(_));
451-
let is_lit = matches!(actual.kind, hir::ExprKind::Lit(_));
452-
is_path || is_lit
444+
matches!(actual.kind, hir::ExprKind::Path(_) | hir::ExprKind::Lit(_))
453445
}

0 commit comments

Comments
 (0)