@@ -442,7 +442,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
442
442
443
443
self . super_rvalue ( rvalue, location) ;
444
444
445
- match * rvalue {
445
+ match rvalue {
446
446
Rvalue :: ThreadLocalRef ( _) => self . check_op ( ops:: ThreadLocalAccess ) ,
447
447
448
448
Rvalue :: Use ( _)
@@ -451,18 +451,15 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
451
451
| Rvalue :: Discriminant ( ..)
452
452
| Rvalue :: Len ( _) => { }
453
453
454
- Rvalue :: Aggregate ( ref kind, ..) => {
455
- if let AggregateKind :: Generator ( def_id, ..) = kind. as_ref ( ) {
456
- if let Some ( generator_kind) = self . tcx . generator_kind ( def_id. to_def_id ( ) ) {
457
- if matches ! ( generator_kind, hir:: GeneratorKind :: Async ( ..) ) {
458
- self . check_op ( ops:: Generator ( generator_kind) ) ;
459
- }
460
- }
454
+ Rvalue :: Aggregate ( kind, ..) => {
455
+ if let AggregateKind :: Generator ( def_id, ..) = kind. as_ref ( )
456
+ && let Some ( generator_kind @ hir:: GeneratorKind :: Async ( ..) ) = self . tcx . generator_kind ( def_id. to_def_id ( ) )
457
+ {
458
+ self . check_op ( ops:: Generator ( generator_kind) ) ;
461
459
}
462
460
}
463
461
464
- Rvalue :: Ref ( _, kind @ BorrowKind :: Mut { .. } , ref place)
465
- | Rvalue :: Ref ( _, kind @ BorrowKind :: Unique , ref place) => {
462
+ Rvalue :: Ref ( _, kind @ ( BorrowKind :: Mut { .. } | BorrowKind :: Unique ) , place) => {
466
463
let ty = place. ty ( self . body , self . tcx ) . ty ;
467
464
let is_allowed = match ty. kind ( ) {
468
465
// Inside a `static mut`, `&mut [...]` is allowed.
@@ -491,12 +488,12 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
491
488
}
492
489
}
493
490
494
- Rvalue :: AddressOf ( Mutability :: Mut , ref place) => {
491
+ Rvalue :: AddressOf ( Mutability :: Mut , place) => {
495
492
self . check_mut_borrow ( place. local , hir:: BorrowKind :: Raw )
496
493
}
497
494
498
- Rvalue :: Ref ( _, BorrowKind :: Shared | BorrowKind :: Shallow , ref place)
499
- | Rvalue :: AddressOf ( Mutability :: Not , ref place) => {
495
+ Rvalue :: Ref ( _, BorrowKind :: Shared | BorrowKind :: Shallow , place)
496
+ | Rvalue :: AddressOf ( Mutability :: Not , place) => {
500
497
let borrowed_place_has_mut_interior = qualifs:: in_place :: < HasMutInterior , _ > (
501
498
& self . ccx ,
502
499
& mut |local| self . qualifs . has_mut_interior ( self . ccx , local, location) ,
@@ -564,7 +561,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
564
561
Rvalue :: NullaryOp ( NullOp :: SizeOf | NullOp :: AlignOf , _) => { }
565
562
Rvalue :: ShallowInitBox ( _, _) => { }
566
563
567
- Rvalue :: UnaryOp ( _, ref operand) => {
564
+ Rvalue :: UnaryOp ( _, operand) => {
568
565
let ty = operand. ty ( self . body , self . tcx ) ;
569
566
if is_int_bool_or_char ( ty) {
570
567
// Int, bool, and char operations are fine.
@@ -575,8 +572,8 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
575
572
}
576
573
}
577
574
578
- Rvalue :: BinaryOp ( op, box ( ref lhs, ref rhs) )
579
- | Rvalue :: CheckedBinaryOp ( op, box ( ref lhs, ref rhs) ) => {
575
+ Rvalue :: BinaryOp ( op, box ( lhs, rhs) )
576
+ | Rvalue :: CheckedBinaryOp ( op, box ( lhs, rhs) ) => {
580
577
let lhs_ty = lhs. ty ( self . body , self . tcx ) ;
581
578
let rhs_ty = rhs. ty ( self . body , self . tcx ) ;
582
579
@@ -585,13 +582,16 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
585
582
} else if lhs_ty. is_fn_ptr ( ) || lhs_ty. is_unsafe_ptr ( ) {
586
583
assert_eq ! ( lhs_ty, rhs_ty) ;
587
584
assert ! (
588
- op == BinOp :: Eq
589
- || op == BinOp :: Ne
590
- || op == BinOp :: Le
591
- || op == BinOp :: Lt
592
- || op == BinOp :: Ge
593
- || op == BinOp :: Gt
594
- || op == BinOp :: Offset
585
+ matches!(
586
+ op,
587
+ BinOp :: Eq
588
+ | BinOp :: Ne
589
+ | BinOp :: Le
590
+ | BinOp :: Lt
591
+ | BinOp :: Ge
592
+ | BinOp :: Gt
593
+ | BinOp :: Offset
594
+ )
595
595
) ;
596
596
597
597
self . check_op ( ops:: RawPtrComparison ) ;
0 commit comments