@@ -223,7 +223,7 @@ macro_rules! always_pat {
223223/// Focus on `focus_idx` in `alternatives`,
224224/// attempting to extend it with elements of the same constructor `C`
225225/// in `alternatives[focus_idx + 1..]`.
226- fn transform_with_focus_on_idx ( alternatives : & mut ThinVec < Box < Pat > > , focus_idx : usize ) -> bool {
226+ fn transform_with_focus_on_idx ( alternatives : & mut ThinVec < Pat > , focus_idx : usize ) -> bool {
227227 // Extract the kind; we'll need to make some changes in it.
228228 let mut focus_kind = mem:: replace ( & mut alternatives[ focus_idx] . kind , Wild ) ;
229229 // We'll focus on `alternatives[focus_idx]`,
@@ -251,20 +251,20 @@ fn transform_with_focus_on_idx(alternatives: &mut ThinVec<Box<Pat>>, focus_idx:
251251 Box ( target) => extend_with_matching (
252252 target, start, alternatives,
253253 |k| matches ! ( k, Box ( _) ) ,
254- |k| always_pat ! ( k, Box ( p) => p) ,
254+ |k| always_pat ! ( k, Box ( p) => * p) ,
255255 ) ,
256256 // Transform `&mut x | ... | &mut y` into `&mut (x | y)`.
257257 Ref ( target, Mutability :: Mut ) => extend_with_matching (
258258 target, start, alternatives,
259259 |k| matches ! ( k, Ref ( _, Mutability :: Mut ) ) ,
260- |k| always_pat ! ( k, Ref ( p, _) => p) ,
260+ |k| always_pat ! ( k, Ref ( p, _) => * p) ,
261261 ) ,
262262 // Transform `b @ p0 | ... b @ p1` into `b @ (p0 | p1)`.
263263 Ident ( b1, i1, Some ( target) ) => extend_with_matching (
264264 target, start, alternatives,
265265 // Binding names must match.
266266 |k| matches ! ( k, Ident ( b2, i2, Some ( _) ) if b1 == b2 && eq_id( * i1, * i2) ) ,
267- |k| always_pat ! ( k, Ident ( _, _, Some ( p) ) => p) ,
267+ |k| always_pat ! ( k, Ident ( _, _, Some ( p) ) => * p) ,
268268 ) ,
269269 // Transform `[pre, x, post] | ... | [pre, y, post]` into `[pre, x | y, post]`.
270270 Slice ( ps1) => extend_with_matching_product (
@@ -309,7 +309,7 @@ fn extend_with_struct_pat(
309309 fps1 : & mut [ ast:: PatField ] ,
310310 rest1 : ast:: PatFieldsRest ,
311311 start : usize ,
312- alternatives : & mut ThinVec < Box < Pat > > ,
312+ alternatives : & mut ThinVec < Pat > ,
313313) -> bool {
314314 ( 0 ..fps1. len ( ) ) . any ( |idx| {
315315 let pos_in_2 = Cell :: new ( None ) ; // The element `k`.
@@ -339,7 +339,7 @@ fn extend_with_struct_pat(
339339 } ) )
340340 } ,
341341 // Extract `p2_k`.
342- |k| always_pat ! ( k, Struct ( _, _, mut fps, _) => fps. swap_remove( pos_in_2. take( ) . unwrap( ) ) . pat) ,
342+ |k| always_pat ! ( k, Struct ( _, _, mut fps, _) => * fps. swap_remove( pos_in_2. take( ) . unwrap( ) ) . pat) ,
343343 ) ;
344344 extend_with_tail_or ( & mut fps1[ idx] . pat , tail_or)
345345 } )
@@ -351,11 +351,11 @@ fn extend_with_struct_pat(
351351/// while also requiring `ps1[..n] ~ ps2[..n]` (pre) and `ps1[n + 1..] ~ ps2[n + 1..]` (post),
352352/// where `~` denotes semantic equality.
353353fn extend_with_matching_product (
354- targets : & mut [ Box < Pat > ] ,
354+ targets : & mut [ Pat ] ,
355355 start : usize ,
356- alternatives : & mut ThinVec < Box < Pat > > ,
357- predicate : impl Fn ( & PatKind , & [ Box < Pat > ] , usize ) -> bool ,
358- extract : impl Fn ( PatKind ) -> ThinVec < Box < Pat > > ,
356+ alternatives : & mut ThinVec < Pat > ,
357+ predicate : impl Fn ( & PatKind , & [ Pat ] , usize ) -> bool ,
358+ extract : impl Fn ( PatKind ) -> ThinVec < Pat > ,
359359) -> bool {
360360 ( 0 ..targets. len ( ) ) . any ( |idx| {
361361 let tail_or = drain_matching (
@@ -382,14 +382,14 @@ fn take_pat(from: &mut Pat) -> Pat {
382382
383383/// Extend `target` as an or-pattern with the alternatives
384384/// in `tail_or` if there are any and return if there were.
385- fn extend_with_tail_or ( target : & mut Pat , tail_or : ThinVec < Box < Pat > > ) -> bool {
386- fn extend ( target : & mut Pat , mut tail_or : ThinVec < Box < Pat > > ) {
385+ fn extend_with_tail_or ( target : & mut Pat , tail_or : ThinVec < Pat > ) -> bool {
386+ fn extend ( target : & mut Pat , mut tail_or : ThinVec < Pat > ) {
387387 match target {
388388 // On an existing or-pattern in the target, append to it.
389389 Pat { kind : Or ( ps) , .. } => ps. append ( & mut tail_or) ,
390390 // Otherwise convert the target to an or-pattern.
391391 target => {
392- let mut init_or = thin_vec ! [ Box :: new ( take_pat( target) ) ] ;
392+ let mut init_or = thin_vec ! [ take_pat( target) ] ;
393393 init_or. append ( & mut tail_or) ;
394394 target. kind = Or ( init_or) ;
395395 } ,
@@ -408,10 +408,10 @@ fn extend_with_tail_or(target: &mut Pat, tail_or: ThinVec<Box<Pat>>) -> bool {
408408// Only elements beginning with `start` are considered for extraction.
409409fn drain_matching (
410410 start : usize ,
411- alternatives : & mut ThinVec < Box < Pat > > ,
411+ alternatives : & mut ThinVec < Pat > ,
412412 predicate : impl Fn ( & PatKind ) -> bool ,
413- extract : impl Fn ( PatKind ) -> Box < Pat > ,
414- ) -> ThinVec < Box < Pat > > {
413+ extract : impl Fn ( PatKind ) -> Pat ,
414+ ) -> ThinVec < Pat > {
415415 let mut tail_or = ThinVec :: new ( ) ;
416416 let mut idx = 0 ;
417417
@@ -443,15 +443,15 @@ fn drain_matching(
443443fn extend_with_matching (
444444 target : & mut Pat ,
445445 start : usize ,
446- alternatives : & mut ThinVec < Box < Pat > > ,
446+ alternatives : & mut ThinVec < Pat > ,
447447 predicate : impl Fn ( & PatKind ) -> bool ,
448- extract : impl Fn ( PatKind ) -> Box < Pat > ,
448+ extract : impl Fn ( PatKind ) -> Pat ,
449449) -> bool {
450450 extend_with_tail_or ( target, drain_matching ( start, alternatives, predicate, extract) )
451451}
452452
453453/// Are the patterns in `ps1` and `ps2` equal save for `ps1[idx]` compared to `ps2[idx]`?
454- fn eq_pre_post ( ps1 : & [ Box < Pat > ] , ps2 : & [ Box < Pat > ] , idx : usize ) -> bool {
454+ fn eq_pre_post ( ps1 : & [ Pat ] , ps2 : & [ Pat ] , idx : usize ) -> bool {
455455 ps1. len ( ) == ps2. len ( )
456456 && ps1[ idx] . is_rest ( ) == ps2[ idx] . is_rest ( ) // Avoid `[x, ..] | [x, 0]` => `[x, .. | 0]`.
457457 && over ( & ps1[ ..idx] , & ps2[ ..idx] , |l, r| eq_pat ( l, r) )
0 commit comments