diff --git a/clippy_lints/src/assigning_clones.rs b/clippy_lints/src/assigning_clones.rs index d63135199aa7..a85d7093e758 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 81ad33a75e2f..49a58711ea8e 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 0f7ec0ef1b91..b7f92185ae6d 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 96b74c9f5cb4..9dcc3debe101 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 bbaf4c5c07af..fec432a210af 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 f877f12c7246..4580649a5610 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/unnested_or_patterns.rs b/clippy_lints/src/unnested_or_patterns.rs index 26b666e58b01..b114a4ca4d18 100644 --- a/clippy_lints/src/unnested_or_patterns.rs +++ b/clippy_lints/src/unnested_or_patterns.rs @@ -250,7 +250,13 @@ fn transform_with_focus_on_idx(alternatives: &mut ThinVec, focus_idx: usize // FIXME(pin_ergonomics): handle pinned patterns | Ref(_, _, Mutability::Not) // Dealt with elsewhere. - | Or(_) | Paren(_) | Deref(_) | Guard(..) => false, + | Or(_) | Paren(_) | Guard(..) => false, + // Transform `deref!(x) | ... | deref!(y)` into `deref!(x | y)`. + Deref(target) => extend_with_matching( + target, start, alternatives, + |k| matches!(k, Deref(_)), + |k| always_pat!(k, Deref(p) => *p), + ), // Transform `box x | ... | box y` into `box (x | y)`. // // The cases below until `Slice(...)` deal with *singleton* products. 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 85631d526550..dae40c4e2389 100644 --- a/clippy_utils/src/ast_utils/mod.rs +++ b/clippy_utils/src/ast_utils/mod.rs @@ -159,13 +159,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, @@ -206,7 +206,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, @@ -215,7 +215,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, @@ -325,7 +325,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, @@ -334,7 +334,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, @@ -345,7 +345,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, @@ -354,7 +354,7 @@ fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool { kind: lk, define_opaque: _, }), - Const(box ConstItem { + Const(ConstItem { defaultness: rd, ident: ri, generics: rg, @@ -373,7 +373,7 @@ fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool { && both(lb.as_deref(), rb.as_deref(), eq_expr) }, ( - Fn(box ast::Fn { + Fn(ast::Fn { defaultness: ld, sig: lf, ident: li, @@ -383,7 +383,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, @@ -417,14 +417,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, @@ -444,7 +444,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, @@ -454,7 +454,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, @@ -475,13 +475,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, @@ -532,7 +532,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, @@ -541,7 +541,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, @@ -552,7 +552,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, @@ -562,7 +562,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, @@ -581,7 +581,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, @@ -589,7 +589,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, @@ -614,7 +614,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, @@ -623,7 +623,7 @@ fn eq_assoc_item_kind(l: &AssocItemKind, r: &AssocItemKind) -> bool { kind: lk, define_opaque: _, }), - Const(box ConstItem { + Const(ConstItem { defaultness: rd, ident: ri, generics: rg, @@ -641,7 +641,7 @@ fn eq_assoc_item_kind(l: &AssocItemKind, r: &AssocItemKind) -> bool { && both(lb.as_deref(), rb.as_deref(), eq_expr) }, ( - Fn(box ast::Fn { + Fn(ast::Fn { defaultness: ld, sig: lf, ident: li, @@ -651,7 +651,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, @@ -670,7 +670,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, @@ -678,7 +678,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 b352529078f7..c546ce3dc6dd 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 dae6661c5ee1..7ed28d1846ca 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 b54c9d59a07e..0183dd54e0bc 100644 --- a/clippy_utils/src/qualify_min_const_fn.rs +++ b/clippy_utils/src/qualify_min_const_fn.rs @@ -193,7 +193,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); @@ -235,18 +235,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 { diff --git a/tests/ui/unnested_or_patterns.fixed b/tests/ui/unnested_or_patterns.fixed index f96088bd39a6..a191cbb391a2 100644 --- a/tests/ui/unnested_or_patterns.fixed +++ b/tests/ui/unnested_or_patterns.fixed @@ -1,4 +1,4 @@ -#![feature(box_patterns)] +#![feature(deref_patterns)] #![warn(clippy::unnested_or_patterns)] #![allow(clippy::manual_range_patterns)] #![expect(irrefutable_let_patterns)] @@ -12,9 +12,9 @@ fn main() { // Should be ignored by this lint, as nesting requires more characters. if let &0 | &2 = &0 {} - if let box (0 | 2) = Box::new(0) {} + if let deref!(0 | 2) = Box::new(0) {} //~^ unnested_or_patterns - if let box (0 | 1 | 2 | 3 | 4) = Box::new(0) {} + if let deref!(0 | 1 | 2 | 3 | 4) = Box::new(0) {} //~^ unnested_or_patterns const C0: Option = Some(1); if let Some(1 | 2) | C0 = None {} diff --git a/tests/ui/unnested_or_patterns.rs b/tests/ui/unnested_or_patterns.rs index 6f4ef615e9d1..8e1418f1b216 100644 --- a/tests/ui/unnested_or_patterns.rs +++ b/tests/ui/unnested_or_patterns.rs @@ -1,4 +1,4 @@ -#![feature(box_patterns)] +#![feature(deref_patterns)] #![warn(clippy::unnested_or_patterns)] #![allow(clippy::manual_range_patterns)] #![expect(irrefutable_let_patterns)] @@ -12,9 +12,9 @@ fn main() { // Should be ignored by this lint, as nesting requires more characters. if let &0 | &2 = &0 {} - if let box 0 | box 2 = Box::new(0) {} + if let deref!(0) | deref!(2) = Box::new(0) {} //~^ unnested_or_patterns - if let box ((0 | 1)) | box (2 | 3) | box 4 = Box::new(0) {} + if let deref!(0 | 1) | deref!(2 | 3) | deref!(4) = Box::new(0) {} //~^ unnested_or_patterns const C0: Option = Some(1); if let Some(1) | C0 | Some(2) = None {} diff --git a/tests/ui/unnested_or_patterns.stderr b/tests/ui/unnested_or_patterns.stderr index 7298eabaa03e..2e2ce28a6a22 100644 --- a/tests/ui/unnested_or_patterns.stderr +++ b/tests/ui/unnested_or_patterns.stderr @@ -1,27 +1,27 @@ error: unnested or-patterns --> tests/ui/unnested_or_patterns.rs:15:12 | -LL | if let box 0 | box 2 = Box::new(0) {} - | ^^^^^^^^^^^^^ +LL | if let deref!(0) | deref!(2) = Box::new(0) {} + | ^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::unnested-or-patterns` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::unnested_or_patterns)]` help: nest the patterns | -LL - if let box 0 | box 2 = Box::new(0) {} -LL + if let box (0 | 2) = Box::new(0) {} +LL - if let deref!(0) | deref!(2) = Box::new(0) {} +LL + if let deref!(0 | 2) = Box::new(0) {} | error: unnested or-patterns --> tests/ui/unnested_or_patterns.rs:17:12 | -LL | if let box ((0 | 1)) | box (2 | 3) | box 4 = Box::new(0) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | if let deref!(0 | 1) | deref!(2 | 3) | deref!(4) = Box::new(0) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: nest the patterns | -LL - if let box ((0 | 1)) | box (2 | 3) | box 4 = Box::new(0) {} -LL + if let box (0 | 1 | 2 | 3 | 4) = Box::new(0) {} +LL - if let deref!(0 | 1) | deref!(2 | 3) | deref!(4) = Box::new(0) {} +LL + if let deref!(0 | 1 | 2 | 3 | 4) = Box::new(0) {} | error: unnested or-patterns diff --git a/tests/ui/unnested_or_patterns2.fixed b/tests/ui/unnested_or_patterns2.fixed index d9625e78c246..0e75a66690e9 100644 --- a/tests/ui/unnested_or_patterns2.fixed +++ b/tests/ui/unnested_or_patterns2.fixed @@ -1,4 +1,4 @@ -#![feature(box_patterns)] +#![feature(deref_patterns)] #![warn(clippy::unnested_or_patterns)] #![allow(clippy::manual_range_patterns)] @@ -15,8 +15,8 @@ fn main() { //~^ unnested_or_patterns if let 0 | 1 | 2 = 0 {} //~^ unnested_or_patterns - if let box (0 | 1 | 2 | 3 | 4) = Box::new(0) {} + if let deref!(0 | 1 | 2 | 3 | 4) = Box::new(0) {} //~^ unnested_or_patterns - if let box (box (0 | 2 | 4)) = Box::new(Box::new(0)) {} + if let deref!(deref!(0 | 2 | 4)) = Box::new(Box::new(0)) {} //~^ unnested_or_patterns } diff --git a/tests/ui/unnested_or_patterns2.rs b/tests/ui/unnested_or_patterns2.rs index d5215966fcb1..353060f1bf26 100644 --- a/tests/ui/unnested_or_patterns2.rs +++ b/tests/ui/unnested_or_patterns2.rs @@ -1,4 +1,4 @@ -#![feature(box_patterns)] +#![feature(deref_patterns)] #![warn(clippy::unnested_or_patterns)] #![allow(clippy::manual_range_patterns)] @@ -15,8 +15,8 @@ fn main() { //~^ unnested_or_patterns if let 0 | (1 | 2) = 0 {} //~^ unnested_or_patterns - if let box (0 | 1) | (box 2 | box (3 | 4)) = Box::new(0) {} + if let deref!(0 | 1) | (deref!(2) | deref!(3 | 4)) = Box::new(0) {} //~^ unnested_or_patterns - if let box box 0 | box (box 2 | box 4) = Box::new(Box::new(0)) {} + if let deref!(deref!(0)) | deref!(deref!(2) | deref!(4)) = Box::new(Box::new(0)) {} //~^ unnested_or_patterns } diff --git a/tests/ui/unnested_or_patterns2.stderr b/tests/ui/unnested_or_patterns2.stderr index 776589e294ba..e1cd2b36b11e 100644 --- a/tests/ui/unnested_or_patterns2.stderr +++ b/tests/ui/unnested_or_patterns2.stderr @@ -75,25 +75,25 @@ LL + if let 0 | 1 | 2 = 0 {} error: unnested or-patterns --> tests/ui/unnested_or_patterns2.rs:18:12 | -LL | if let box (0 | 1) | (box 2 | box (3 | 4)) = Box::new(0) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | if let deref!(0 | 1) | (deref!(2) | deref!(3 | 4)) = Box::new(0) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: nest the patterns | -LL - if let box (0 | 1) | (box 2 | box (3 | 4)) = Box::new(0) {} -LL + if let box (0 | 1 | 2 | 3 | 4) = Box::new(0) {} +LL - if let deref!(0 | 1) | (deref!(2) | deref!(3 | 4)) = Box::new(0) {} +LL + if let deref!(0 | 1 | 2 | 3 | 4) = Box::new(0) {} | error: unnested or-patterns --> tests/ui/unnested_or_patterns2.rs:20:12 | -LL | if let box box 0 | box (box 2 | box 4) = Box::new(Box::new(0)) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | if let deref!(deref!(0)) | deref!(deref!(2) | deref!(4)) = Box::new(Box::new(0)) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: nest the patterns | -LL - if let box box 0 | box (box 2 | box 4) = Box::new(Box::new(0)) {} -LL + if let box (box (0 | 2 | 4)) = Box::new(Box::new(0)) {} +LL - if let deref!(deref!(0)) | deref!(deref!(2) | deref!(4)) = Box::new(Box::new(0)) {} +LL + if let deref!(deref!(0 | 2 | 4)) = Box::new(Box::new(0)) {} | error: aborting due to 8 previous errors