diff --git a/clippy_lints/src/assigning_clones.rs b/clippy_lints/src/assigning_clones.rs index 60bc9b2b5b85..85a3cd8bd327 100644 --- a/clippy_lints/src/assigning_clones.rs +++ b/clippy_lints/src/assigning_clones.rs @@ -189,7 +189,7 @@ fn clone_source_borrows_from_dest(cx: &LateContext<'_>, lhs: &Expr<'_>, call_spa .find(|stmt| { !matches!(stmt.kind, mir::StatementKind::StorageDead(_) | mir::StatementKind::StorageLive(_)) }) - && let mir::StatementKind::Assign(box (borrowed, _)) = &assignment.kind + && let mir::StatementKind::Assign((borrowed, _)) = &assignment.kind && let Some(borrowers) = borrow_map.get(&borrowed.local) { borrowers.contains(source.local) diff --git a/clippy_lints/src/double_parens.rs b/clippy_lints/src/double_parens.rs index acc3e4936e44..e2c3f00ce03f 100644 --- a/clippy_lints/src/double_parens.rs +++ b/clippy_lints/src/double_parens.rs @@ -74,7 +74,7 @@ impl EarlyLintPass for DoubleParens { // ^^^^^^^^^ expr // ^^^ arg // ^ inner - ExprKind::Call(_, args) | ExprKind::MethodCall(box MethodCall { args, .. }) + ExprKind::Call(_, args) | ExprKind::MethodCall(MethodCall { args, .. }) if let [arg] = &**args && let ExprKind::Paren(inner) = &arg.kind && expr.span.eq_ctxt(arg.span) diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index af25b1f7f1aa..0d1118b62fb1 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -1,5 +1,5 @@ -#![feature(box_patterns)] #![feature(control_flow_into_value)] +#![feature(deref_patterns)] #![feature(exact_div)] #![feature(f128)] #![feature(f16)] diff --git a/clippy_lints/src/needless_borrows_for_generic_args.rs b/clippy_lints/src/needless_borrows_for_generic_args.rs index 40db810c1284..48691006a74e 100644 --- a/clippy_lints/src/needless_borrows_for_generic_args.rs +++ b/clippy_lints/src/needless_borrows_for_generic_args.rs @@ -371,7 +371,7 @@ fn referent_used_exactly_once<'tcx>( && let [location] = *local_assignments(mir, local).as_slice() && let block_data = &mir.basic_blocks[location.block] && let Some(statement) = block_data.statements.get(location.statement_index) - && let StatementKind::Assign(box (_, Rvalue::Ref(_, _, place))) = statement.kind + && let StatementKind::Assign((_, Rvalue::Ref(_, _, place))) = statement.kind && !place.is_indirect_first_projection() { let body_owner_local_def_id = cx.tcx.hir_enclosing_body_owner(reference.hir_id); diff --git a/clippy_lints/src/non_expressive_names.rs b/clippy_lints/src/non_expressive_names.rs index 21ddefb249ca..56f35931a685 100644 --- a/clippy_lints/src/non_expressive_names.rs +++ b/clippy_lints/src/non_expressive_names.rs @@ -404,7 +404,7 @@ impl EarlyLintPass for NonExpressiveNames { return; } - if let ItemKind::Fn(box ast::Fn { + if let ItemKind::Fn(ast::Fn { ref sig, body: Some(ref blk), .. @@ -419,7 +419,7 @@ impl EarlyLintPass for NonExpressiveNames { return; } - if let AssocItemKind::Fn(box ast::Fn { + if let AssocItemKind::Fn(ast::Fn { ref sig, body: Some(ref blk), .. diff --git a/clippy_lints/src/option_env_unwrap.rs b/clippy_lints/src/option_env_unwrap.rs index 64ad92b1ebb5..c5410feee971 100644 --- a/clippy_lints/src/option_env_unwrap.rs +++ b/clippy_lints/src/option_env_unwrap.rs @@ -35,7 +35,7 @@ declare_lint_pass!(OptionEnvUnwrap => [OPTION_ENV_UNWRAP]); impl EarlyLintPass for OptionEnvUnwrap { fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &Expr) { - if let ExprKind::MethodCall(box MethodCall { seg, receiver, .. }) = &expr.kind + if let ExprKind::MethodCall(MethodCall { seg, receiver, .. }) = &expr.kind && matches!(seg.ident.name, sym::expect | sym::unwrap) && is_direct_expn_of(receiver.span, sym::option_env).is_some() { diff --git a/clippy_lints/src/redundant_clone.rs b/clippy_lints/src/redundant_clone.rs index bfb704dd2171..8909f781dfdd 100644 --- a/clippy_lints/src/redundant_clone.rs +++ b/clippy_lints/src/redundant_clone.rs @@ -285,7 +285,7 @@ fn find_stmt_assigns_to<'tcx>( bb: mir::BasicBlock, ) -> Option<(mir::Local, CannotMoveOut)> { let rvalue = mir.basic_blocks[bb].statements.iter().rev().find_map(|stmt| { - if let mir::StatementKind::Assign(box (mir::Place { local, .. }, v)) = &stmt.kind { + if let mir::StatementKind::Assign((mir::Place { local, .. }, v)) = &stmt.kind { return if *local == to_local { Some(v) } else { None }; } diff --git a/clippy_lints/src/redundant_static_lifetimes.rs b/clippy_lints/src/redundant_static_lifetimes.rs index 35cfc37b133b..75c1a36d9dca 100644 --- a/clippy_lints/src/redundant_static_lifetimes.rs +++ b/clippy_lints/src/redundant_static_lifetimes.rs @@ -97,13 +97,13 @@ impl EarlyLintPass for RedundantStaticLifetimes { } if !item.span.from_expansion() { - if let ItemKind::Const(box ConstItem { ty: ref var_type, .. }) = item.kind { + if let ItemKind::Const(ConstItem { ty: ref var_type, .. }) = item.kind { Self::visit_type(var_type, cx, "constants have by default a `'static` lifetime"); // Don't check associated consts because `'static` cannot be elided on those (issue // #2438) } - if let ItemKind::Static(box StaticItem { ty: ref var_type, .. }) = item.kind { + if let ItemKind::Static(StaticItem { ty: ref var_type, .. }) = item.kind { Self::visit_type(var_type, cx, "statics have by default a `'static` lifetime"); } } diff --git a/clippy_lints/src/unused_rounding.rs b/clippy_lints/src/unused_rounding.rs index a8af8eafe8dc..4cdf4201139f 100644 --- a/clippy_lints/src/unused_rounding.rs +++ b/clippy_lints/src/unused_rounding.rs @@ -34,7 +34,7 @@ declare_clippy_lint! { declare_lint_pass!(UnusedRounding => [UNUSED_ROUNDING]); fn is_useless_rounding(cx: &EarlyContext<'_>, expr: &Expr) -> Option<(Symbol, String)> { - if let ExprKind::MethodCall(box MethodCall { + if let ExprKind::MethodCall(MethodCall { seg: name_ident, receiver, .. diff --git a/clippy_utils/src/ast_utils/mod.rs b/clippy_utils/src/ast_utils/mod.rs index e0a182523f67..a2a227594d28 100644 --- a/clippy_utils/src/ast_utils/mod.rs +++ b/clippy_utils/src/ast_utils/mod.rs @@ -158,13 +158,13 @@ fn eq_expr(l: &Expr, r: &Expr) -> bool { (Repeat(le, ls), Repeat(re, rs)) => eq_expr(le, re) && eq_expr(&ls.value, &rs.value), (Call(lc, la), Call(rc, ra)) => eq_expr(lc, rc) && over(la, ra, |l, r| eq_expr(l, r)), ( - MethodCall(box ast::MethodCall { + MethodCall(ast::MethodCall { seg: ls, receiver: lr, args: la, .. }), - MethodCall(box ast::MethodCall { + MethodCall(ast::MethodCall { seg: rs, receiver: rr, args: ra, @@ -214,7 +214,7 @@ fn eq_expr(l: &Expr, r: &Expr) -> bool { (Field(lp, lf), Field(rp, rf)) => eq_id(*lf, *rf) && eq_expr(lp, rp), (Match(ls, la, lkind), Match(rs, ra, rkind)) => (lkind == rkind) && eq_expr(ls, rs) && over(la, ra, eq_arm), ( - Closure(box ast::Closure { + Closure(ast::Closure { binder: lb, capture_clause: lc, coroutine_kind: la, @@ -223,7 +223,7 @@ fn eq_expr(l: &Expr, r: &Expr) -> bool { body: le, .. }), - Closure(box ast::Closure { + Closure(ast::Closure { binder: rb, capture_clause: rc, coroutine_kind: ra, @@ -333,7 +333,7 @@ fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool { (ExternCrate(ls, li), ExternCrate(rs, ri)) => ls == rs && eq_id(*li, *ri), (Use(l), Use(r)) => eq_use_tree(l, r), ( - Static(box StaticItem { + Static(StaticItem { ident: li, ty: lt, mutability: lm, @@ -342,7 +342,7 @@ fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool { define_opaque: _, eii_impls: _, }), - Static(box StaticItem { + Static(StaticItem { ident: ri, ty: rt, mutability: rm, @@ -353,7 +353,7 @@ fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool { }), ) => eq_id(*li, *ri) && lm == rm && ls == rs && eq_ty(lt, rt) && eq_expr_opt(le.as_deref(), re.as_deref()), ( - Const(box ConstItem { + Const(ConstItem { defaultness: ld, ident: li, generics: lg, @@ -361,7 +361,7 @@ fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool { rhs_kind: lb, define_opaque: _, }), - Const(box ConstItem { + Const(ConstItem { defaultness: rd, ident: ri, generics: rg, @@ -377,7 +377,7 @@ fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool { && both(Some(lb), Some(rb), eq_const_item_rhs) }, ( - Fn(box ast::Fn { + Fn(ast::Fn { defaultness: ld, sig: lf, ident: li, @@ -387,7 +387,7 @@ fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool { define_opaque: _, eii_impls: _, }), - Fn(box ast::Fn { + Fn(ast::Fn { defaultness: rd, sig: rf, ident: ri, @@ -421,14 +421,14 @@ fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool { && over(&l.items, &r.items, |l, r| eq_item(l, r, eq_foreign_item_kind)) }, ( - TyAlias(box ast::TyAlias { + TyAlias(ast::TyAlias { defaultness: ld, generics: lg, bounds: lb, ty: lt, .. }), - TyAlias(box ast::TyAlias { + TyAlias(ast::TyAlias { defaultness: rd, generics: rg, bounds: rb, @@ -448,7 +448,7 @@ fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool { eq_id(*li, *ri) && eq_generics(lg, rg) && eq_variant_data(lv, rv) }, ( - Trait(box ast::Trait { + Trait(ast::Trait { impl_restriction: liprt, constness: lc, is_auto: la, @@ -458,7 +458,7 @@ fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool { bounds: lb, items: lis, }), - Trait(box ast::Trait { + Trait(ast::Trait { impl_restriction: riprt, constness: rc, is_auto: ra, @@ -479,13 +479,13 @@ fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool { && over(lis, ris, |l, r| eq_item(l, r, eq_assoc_item_kind)) }, ( - TraitAlias(box ast::TraitAlias { + TraitAlias(ast::TraitAlias { ident: li, generics: lg, bounds: lb, constness: lc, }), - TraitAlias(box ast::TraitAlias { + TraitAlias(ast::TraitAlias { ident: ri, generics: rg, bounds: rb, @@ -536,7 +536,7 @@ fn eq_foreign_item_kind(l: &ForeignItemKind, r: &ForeignItemKind) -> bool { use ForeignItemKind::*; match (l, r) { ( - Static(box StaticItem { + Static(StaticItem { ident: li, ty: lt, mutability: lm, @@ -545,7 +545,7 @@ fn eq_foreign_item_kind(l: &ForeignItemKind, r: &ForeignItemKind) -> bool { define_opaque: _, eii_impls: _, }), - Static(box StaticItem { + Static(StaticItem { ident: ri, ty: rt, mutability: rm, @@ -556,7 +556,7 @@ fn eq_foreign_item_kind(l: &ForeignItemKind, r: &ForeignItemKind) -> bool { }), ) => eq_id(*li, *ri) && eq_ty(lt, rt) && lm == rm && eq_expr_opt(le.as_deref(), re.as_deref()) && ls == rs, ( - Fn(box ast::Fn { + Fn(ast::Fn { defaultness: ld, sig: lf, ident: li, @@ -566,7 +566,7 @@ fn eq_foreign_item_kind(l: &ForeignItemKind, r: &ForeignItemKind) -> bool { define_opaque: _, eii_impls: _, }), - Fn(box ast::Fn { + Fn(ast::Fn { defaultness: rd, sig: rf, ident: ri, @@ -585,7 +585,7 @@ fn eq_foreign_item_kind(l: &ForeignItemKind, r: &ForeignItemKind) -> bool { && both(lb.as_ref(), rb.as_ref(), |l, r| eq_block(l, r)) }, ( - TyAlias(box ast::TyAlias { + TyAlias(ast::TyAlias { defaultness: ld, ident: li, generics: lg, @@ -593,7 +593,7 @@ fn eq_foreign_item_kind(l: &ForeignItemKind, r: &ForeignItemKind) -> bool { bounds: lb, ty: lt, }), - TyAlias(box ast::TyAlias { + TyAlias(ast::TyAlias { defaultness: rd, ident: ri, generics: rg, @@ -618,7 +618,7 @@ fn eq_assoc_item_kind(l: &AssocItemKind, r: &AssocItemKind) -> bool { use AssocItemKind::*; match (l, r) { ( - Const(box ConstItem { + Const(ConstItem { defaultness: ld, ident: li, generics: lg, @@ -626,7 +626,7 @@ fn eq_assoc_item_kind(l: &AssocItemKind, r: &AssocItemKind) -> bool { rhs_kind: lb, define_opaque: _, }), - Const(box ConstItem { + Const(ConstItem { defaultness: rd, ident: ri, generics: rg, @@ -642,7 +642,7 @@ fn eq_assoc_item_kind(l: &AssocItemKind, r: &AssocItemKind) -> bool { && both(Some(lb), Some(rb), eq_const_item_rhs) }, ( - Fn(box ast::Fn { + Fn(ast::Fn { defaultness: ld, sig: lf, ident: li, @@ -652,7 +652,7 @@ fn eq_assoc_item_kind(l: &AssocItemKind, r: &AssocItemKind) -> bool { define_opaque: _, eii_impls: _, }), - Fn(box ast::Fn { + Fn(ast::Fn { defaultness: rd, sig: rf, ident: ri, @@ -671,7 +671,7 @@ fn eq_assoc_item_kind(l: &AssocItemKind, r: &AssocItemKind) -> bool { && both(lb.as_ref(), rb.as_ref(), |l, r| eq_block(l, r)) }, ( - Type(box TyAlias { + Type(TyAlias { defaultness: ld, ident: li, generics: lg, @@ -679,7 +679,7 @@ fn eq_assoc_item_kind(l: &AssocItemKind, r: &AssocItemKind) -> bool { bounds: lb, ty: lt, }), - Type(box TyAlias { + Type(TyAlias { defaultness: rd, ident: ri, generics: rg, diff --git a/clippy_utils/src/lib.rs b/clippy_utils/src/lib.rs index 1ad12da6e62c..492f66e47d12 100644 --- a/clippy_utils/src/lib.rs +++ b/clippy_utils/src/lib.rs @@ -1,4 +1,4 @@ -#![feature(box_patterns)] +#![feature(deref_patterns)] #![feature(macro_metavar_expr)] #![feature(rustc_private)] #![feature(unwrap_infallible)] diff --git a/clippy_utils/src/mir/mod.rs b/clippy_utils/src/mir/mod.rs index 40c553d1c9e6..56fcaa637cb8 100644 --- a/clippy_utils/src/mir/mod.rs +++ b/clippy_utils/src/mir/mod.rs @@ -183,7 +183,7 @@ pub fn local_assignments(mir: &Body<'_>, local: Local) -> Vec { fn is_local_assignment(mir: &Body<'_>, local: Local, location: Location) -> bool { match mir.stmt_at(location) { Either::Left(statement) => { - if let StatementKind::Assign(box (place, _)) = statement.kind { + if let StatementKind::Assign((place, _)) = statement.kind { place.as_local() == Some(local) } else { false diff --git a/clippy_utils/src/mir/possible_borrower.rs b/clippy_utils/src/mir/possible_borrower.rs index cbd55ce9b435..fd0bde4b9ddc 100644 --- a/clippy_utils/src/mir/possible_borrower.rs +++ b/clippy_utils/src/mir/possible_borrower.rs @@ -157,7 +157,7 @@ fn rvalue_locals(rvalue: &mir::Rvalue<'_>, mut visit: impl FnMut(mir::Local)) { match rvalue { Use(op, _) | Repeat(op, _) | Cast(_, op, _) | UnaryOp(_, op) => visit_op(op), Aggregate(_, ops) => ops.iter().for_each(visit_op), - BinaryOp(_, box (lhs, rhs)) => { + BinaryOp(_, (lhs, rhs)) => { visit_op(lhs); visit_op(rhs); }, diff --git a/clippy_utils/src/qualify_min_const_fn.rs b/clippy_utils/src/qualify_min_const_fn.rs index 900534dcbf51..d9dcd73bd7db 100644 --- a/clippy_utils/src/qualify_min_const_fn.rs +++ b/clippy_utils/src/qualify_min_const_fn.rs @@ -190,7 +190,7 @@ fn check_rvalue<'tcx>( "transmute can attempt to turn pointers into integers, so is unstable in const fn".into(), )), // binops are fine on integers - Rvalue::BinaryOp(_, box (lhs, rhs)) => { + Rvalue::BinaryOp(_, (lhs, rhs)) => { check_operand(cx, lhs, span, body, msrv)?; check_operand(cx, rhs, span, body, msrv)?; let ty = lhs.ty(body, cx.tcx); @@ -229,18 +229,18 @@ fn check_statement<'tcx>( ) -> McfResult { let span = statement.source_info.span; match &statement.kind { - StatementKind::Assign(box (place, rval)) => { + StatementKind::Assign((place, rval)) => { check_place(cx, *place, span, body, msrv)?; check_rvalue(cx, body, def_id, rval, span, msrv) }, - StatementKind::FakeRead(box (_, place)) => check_place(cx, *place, span, body, msrv), + StatementKind::FakeRead((_, place)) => check_place(cx, *place, span, body, msrv), // just an assignment StatementKind::SetDiscriminant { place, .. } => check_place(cx, **place, span, body, msrv), - StatementKind::Intrinsic(box NonDivergingIntrinsic::Assume(op)) => check_operand(cx, op, span, body, msrv), + StatementKind::Intrinsic(NonDivergingIntrinsic::Assume(op)) => check_operand(cx, op, span, body, msrv), - StatementKind::Intrinsic(box NonDivergingIntrinsic::CopyNonOverlapping( + StatementKind::Intrinsic(NonDivergingIntrinsic::CopyNonOverlapping( rustc_middle::mir::CopyNonOverlapping { dst, src, count }, )) => { check_operand(cx, dst, span, body, msrv)?; diff --git a/tests/ui/auxiliary/proc_macro_attr.rs b/tests/ui/auxiliary/proc_macro_attr.rs index ddee6e5566fa..f176a4ee3c5c 100644 --- a/tests/ui/auxiliary/proc_macro_attr.rs +++ b/tests/ui/auxiliary/proc_macro_attr.rs @@ -1,4 +1,4 @@ -#![feature(proc_macro_hygiene, proc_macro_quote, box_patterns)] +#![feature(proc_macro_hygiene, proc_macro_quote, deref_patterns)] #![allow(clippy::uninlined_format_args, clippy::useless_conversion)] extern crate proc_macro; @@ -67,7 +67,7 @@ pub fn rename_my_lifetimes(_args: TokenStream, input: TokenStream) -> TokenStrea for inner in &mut item.items { if let ImplItem::Fn(method) = inner && let Some(FnArg::Typed(pat_type)) = mut_receiver_of(&mut method.sig) - && let box Type::Reference(reference) = &mut pat_type.ty + && let Type::Reference(reference) = &mut pat_type.ty { // Target only unnamed lifetimes let name = match &reference.lifetime {