@@ -295,18 +295,19 @@ fn place_projection_conflict<'tcx>(
295
295
pi2_elem : PlaceElem < ' tcx > ,
296
296
bias : PlaceConflictBias ,
297
297
) -> Overlap {
298
+ use ProjectionElem :: * ;
298
299
match ( pi1_elem, pi2_elem) {
299
- ( ProjectionElem :: Deref , ProjectionElem :: Deref ) => {
300
+ ( Deref , Deref ) => {
300
301
// derefs (e.g., `*x` vs. `*x`) - recur.
301
302
debug ! ( "place_element_conflict: DISJOINT-OR-EQ-DEREF" ) ;
302
303
Overlap :: EqualOrDisjoint
303
304
}
304
- ( ProjectionElem :: OpaqueCast ( _) , ProjectionElem :: OpaqueCast ( _) ) => {
305
+ ( OpaqueCast ( _) , OpaqueCast ( _) ) => {
305
306
// casts to other types may always conflict irrespective of the type being cast to.
306
307
debug ! ( "place_element_conflict: DISJOINT-OR-EQ-OPAQUE" ) ;
307
308
Overlap :: EqualOrDisjoint
308
309
}
309
- ( ProjectionElem :: Field ( f1, _) , ProjectionElem :: Field ( f2, _) ) => {
310
+ ( Field ( f1, _) , Field ( f2, _) ) => {
310
311
if f1 == f2 {
311
312
// same field (e.g., `a.y` vs. `a.y`) - recur.
312
313
debug ! ( "place_element_conflict: DISJOINT-OR-EQ-FIELD" ) ;
@@ -324,7 +325,7 @@ fn place_projection_conflict<'tcx>(
324
325
}
325
326
}
326
327
}
327
- ( ProjectionElem :: Downcast ( _, v1) , ProjectionElem :: Downcast ( _, v2) ) => {
328
+ ( Downcast ( _, v1) , Downcast ( _, v2) ) => {
328
329
// different variants are treated as having disjoint fields,
329
330
// even if they occupy the same "space", because it's
330
331
// impossible for 2 variants of the same enum to exist
@@ -357,16 +358,8 @@ fn place_projection_conflict<'tcx>(
357
358
Overlap :: Disjoint
358
359
}
359
360
}
360
- (
361
- ProjectionElem :: Index ( ..) ,
362
- ProjectionElem :: Index ( ..)
363
- | ProjectionElem :: ConstantIndex { .. }
364
- | ProjectionElem :: Subslice { .. } ,
365
- )
366
- | (
367
- ProjectionElem :: ConstantIndex { .. } | ProjectionElem :: Subslice { .. } ,
368
- ProjectionElem :: Index ( ..) ,
369
- ) => {
361
+ ( Index ( ..) , Index ( ..) | ConstantIndex { .. } | Subslice { .. } )
362
+ | ( ConstantIndex { .. } | Subslice { .. } , Index ( ..) ) => {
370
363
// Array indexes (`a[0]` vs. `a[i]`). These can either be disjoint
371
364
// (if the indexes differ) or equal (if they are the same).
372
365
match bias {
@@ -384,12 +377,12 @@ fn place_projection_conflict<'tcx>(
384
377
}
385
378
}
386
379
(
387
- ProjectionElem :: ConstantIndex { offset : o1, min_length : _, from_end : false } ,
388
- ProjectionElem :: ConstantIndex { offset : o2, min_length : _, from_end : false } ,
380
+ ConstantIndex { offset : o1, min_length : _, from_end : false } ,
381
+ ConstantIndex { offset : o2, min_length : _, from_end : false } ,
389
382
)
390
383
| (
391
- ProjectionElem :: ConstantIndex { offset : o1, min_length : _, from_end : true } ,
392
- ProjectionElem :: ConstantIndex { offset : o2, min_length : _, from_end : true } ,
384
+ ConstantIndex { offset : o1, min_length : _, from_end : true } ,
385
+ ConstantIndex { offset : o2, min_length : _, from_end : true } ,
393
386
) => {
394
387
if o1 == o2 {
395
388
debug ! ( "place_element_conflict: DISJOINT-OR-EQ-ARRAY-CONSTANT-INDEX" ) ;
@@ -400,28 +393,12 @@ fn place_projection_conflict<'tcx>(
400
393
}
401
394
}
402
395
(
403
- ProjectionElem :: ConstantIndex {
404
- offset : offset_from_begin,
405
- min_length : min_length1,
406
- from_end : false ,
407
- } ,
408
- ProjectionElem :: ConstantIndex {
409
- offset : offset_from_end,
410
- min_length : min_length2,
411
- from_end : true ,
412
- } ,
396
+ ConstantIndex { offset : offset_from_begin, min_length : min_length1, from_end : false } ,
397
+ ConstantIndex { offset : offset_from_end, min_length : min_length2, from_end : true } ,
413
398
)
414
399
| (
415
- ProjectionElem :: ConstantIndex {
416
- offset : offset_from_end,
417
- min_length : min_length1,
418
- from_end : true ,
419
- } ,
420
- ProjectionElem :: ConstantIndex {
421
- offset : offset_from_begin,
422
- min_length : min_length2,
423
- from_end : false ,
424
- } ,
400
+ ConstantIndex { offset : offset_from_end, min_length : min_length1, from_end : true } ,
401
+ ConstantIndex { offset : offset_from_begin, min_length : min_length2, from_end : false } ,
425
402
) => {
426
403
// both patterns matched so it must be at least the greater of the two
427
404
let min_length = max ( min_length1, min_length2) ;
@@ -438,12 +415,12 @@ fn place_projection_conflict<'tcx>(
438
415
}
439
416
}
440
417
(
441
- ProjectionElem :: ConstantIndex { offset, min_length : _, from_end : false } ,
442
- ProjectionElem :: Subslice { from, to, from_end : false } ,
418
+ ConstantIndex { offset, min_length : _, from_end : false } ,
419
+ Subslice { from, to, from_end : false } ,
443
420
)
444
421
| (
445
- ProjectionElem :: Subslice { from, to, from_end : false } ,
446
- ProjectionElem :: ConstantIndex { offset, min_length : _, from_end : false } ,
422
+ Subslice { from, to, from_end : false } ,
423
+ ConstantIndex { offset, min_length : _, from_end : false } ,
447
424
) => {
448
425
if ( from..to) . contains ( & offset) {
449
426
debug ! ( "place_element_conflict: DISJOINT-OR-EQ-ARRAY-CONSTANT-INDEX-SUBSLICE" ) ;
@@ -453,14 +430,8 @@ fn place_projection_conflict<'tcx>(
453
430
Overlap :: Disjoint
454
431
}
455
432
}
456
- (
457
- ProjectionElem :: ConstantIndex { offset, min_length : _, from_end : false } ,
458
- ProjectionElem :: Subslice { from, .. } ,
459
- )
460
- | (
461
- ProjectionElem :: Subslice { from, .. } ,
462
- ProjectionElem :: ConstantIndex { offset, min_length : _, from_end : false } ,
463
- ) => {
433
+ ( ConstantIndex { offset, min_length : _, from_end : false } , Subslice { from, .. } )
434
+ | ( Subslice { from, .. } , ConstantIndex { offset, min_length : _, from_end : false } ) => {
464
435
if offset >= from {
465
436
debug ! ( "place_element_conflict: DISJOINT-OR-EQ-SLICE-CONSTANT-INDEX-SUBSLICE" ) ;
466
437
Overlap :: EqualOrDisjoint
@@ -470,12 +441,12 @@ fn place_projection_conflict<'tcx>(
470
441
}
471
442
}
472
443
(
473
- ProjectionElem :: ConstantIndex { offset, min_length : _, from_end : true } ,
474
- ProjectionElem :: Subslice { to, from_end : true , .. } ,
444
+ ConstantIndex { offset, min_length : _, from_end : true } ,
445
+ Subslice { to, from_end : true , .. } ,
475
446
)
476
447
| (
477
- ProjectionElem :: Subslice { to, from_end : true , .. } ,
478
- ProjectionElem :: ConstantIndex { offset, min_length : _, from_end : true } ,
448
+ Subslice { to, from_end : true , .. } ,
449
+ ConstantIndex { offset, min_length : _, from_end : true } ,
479
450
) => {
480
451
if offset > to {
481
452
debug ! (
@@ -489,8 +460,8 @@ fn place_projection_conflict<'tcx>(
489
460
}
490
461
}
491
462
(
492
- ProjectionElem :: Subslice { from : f1, to : t1, from_end : false } ,
493
- ProjectionElem :: Subslice { from : f2, to : t2, from_end : false } ,
463
+ Subslice { from : f1, to : t1, from_end : false } ,
464
+ Subslice { from : f2, to : t2, from_end : false } ,
494
465
) => {
495
466
if f2 >= t1 || f1 >= t2 {
496
467
debug ! ( "place_element_conflict: DISJOINT-ARRAY-SUBSLICES" ) ;
@@ -500,19 +471,19 @@ fn place_projection_conflict<'tcx>(
500
471
Overlap :: EqualOrDisjoint
501
472
}
502
473
}
503
- ( ProjectionElem :: Subslice { .. } , ProjectionElem :: Subslice { .. } ) => {
474
+ ( Subslice { .. } , Subslice { .. } ) => {
504
475
debug ! ( "place_element_conflict: DISJOINT-OR-EQ-SLICE-SUBSLICES" ) ;
505
476
Overlap :: EqualOrDisjoint
506
477
}
507
478
(
508
- ProjectionElem :: Deref
509
- | ProjectionElem :: Field ( ..)
510
- | ProjectionElem :: Index ( ..)
511
- | ProjectionElem :: ConstantIndex { .. }
512
- | ProjectionElem :: Subtype ( _)
513
- | ProjectionElem :: OpaqueCast { .. }
514
- | ProjectionElem :: Subslice { .. }
515
- | ProjectionElem :: Downcast ( ..) ,
479
+ Deref
480
+ | Field ( ..)
481
+ | Index ( ..)
482
+ | ConstantIndex { .. }
483
+ | Subtype ( _)
484
+ | OpaqueCast { .. }
485
+ | Subslice { .. }
486
+ | Downcast ( ..) ,
516
487
_,
517
488
) => bug ! (
518
489
"mismatched projections in place_element_conflict: {:?} and {:?}" ,
0 commit comments