@@ -291,10 +291,13 @@ impl<'tcx> LateLintPass<'tcx> for Dereferencing<'tcx> {
291
291
&& let Some ( ty) = use_node. defined_ty ( cx)
292
292
&& TyCoercionStability :: for_defined_ty ( cx, ty, use_node. is_return ( ) ) . is_deref_stable ( )
293
293
{
294
- self . state = Some ( ( State :: ExplicitDeref { mutability : None } , StateData {
295
- first_expr : expr,
296
- adjusted_ty,
297
- } ) ) ;
294
+ self . state = Some ( (
295
+ State :: ExplicitDeref { mutability : None } ,
296
+ StateData {
297
+ first_expr : expr,
298
+ adjusted_ty,
299
+ } ,
300
+ ) ) ;
298
301
}
299
302
} ,
300
303
RefOp :: Method { mutbl, is_ufcs }
@@ -456,10 +459,13 @@ impl<'tcx> LateLintPass<'tcx> for Dereferencing<'tcx> {
456
459
&& next_adjust. is_none_or ( |a| matches ! ( a. kind, Adjust :: Deref ( _) | Adjust :: Borrow ( _) ) )
457
460
&& iter. all ( |a| matches ! ( a. kind, Adjust :: Deref ( _) | Adjust :: Borrow ( _) ) )
458
461
{
459
- self . state = Some ( ( State :: Borrow { mutability } , StateData {
460
- first_expr : expr,
461
- adjusted_ty,
462
- } ) ) ;
462
+ self . state = Some ( (
463
+ State :: Borrow { mutability } ,
464
+ StateData {
465
+ first_expr : expr,
466
+ adjusted_ty,
467
+ } ,
468
+ ) ) ;
463
469
}
464
470
} ,
465
471
_ => { } ,
@@ -503,10 +509,13 @@ impl<'tcx> LateLintPass<'tcx> for Dereferencing<'tcx> {
503
509
let stability = state. stability ;
504
510
report ( cx, expr, State :: DerefedBorrow ( state) , data, typeck) ;
505
511
if stability. is_deref_stable ( ) {
506
- self . state = Some ( ( State :: Borrow { mutability } , StateData {
507
- first_expr : expr,
508
- adjusted_ty,
509
- } ) ) ;
512
+ self . state = Some ( (
513
+ State :: Borrow { mutability } ,
514
+ StateData {
515
+ first_expr : expr,
516
+ adjusted_ty,
517
+ } ,
518
+ ) ) ;
510
519
}
511
520
} ,
512
521
( Some ( ( State :: DerefedBorrow ( state) , data) ) , RefOp :: Deref ) => {
@@ -531,10 +540,13 @@ impl<'tcx> LateLintPass<'tcx> for Dereferencing<'tcx> {
531
540
} else if stability. is_deref_stable ( )
532
541
&& let Some ( parent) = get_parent_expr ( cx, expr)
533
542
{
534
- self . state = Some ( ( State :: ExplicitDeref { mutability : None } , StateData {
535
- first_expr : parent,
536
- adjusted_ty,
537
- } ) ) ;
543
+ self . state = Some ( (
544
+ State :: ExplicitDeref { mutability : None } ,
545
+ StateData {
546
+ first_expr : parent,
547
+ adjusted_ty,
548
+ } ,
549
+ ) ) ;
538
550
}
539
551
} ,
540
552
@@ -1124,17 +1136,20 @@ impl<'tcx> Dereferencing<'tcx> {
1124
1136
if let Some ( outer_pat) = self . ref_locals . get_mut ( & local) {
1125
1137
if let Some ( pat) = outer_pat {
1126
1138
// Check for auto-deref
1127
- if !matches ! ( cx. typeck_results( ) . expr_adjustments( e) , [
1128
- Adjustment {
1129
- kind: Adjust :: Deref ( _) ,
1130
- ..
1131
- } ,
1132
- Adjustment {
1133
- kind: Adjust :: Deref ( _) ,
1139
+ if !matches ! (
1140
+ cx. typeck_results( ) . expr_adjustments( e) ,
1141
+ [
1142
+ Adjustment {
1143
+ kind: Adjust :: Deref ( _) ,
1144
+ ..
1145
+ } ,
1146
+ Adjustment {
1147
+ kind: Adjust :: Deref ( _) ,
1148
+ ..
1149
+ } ,
1134
1150
..
1135
- } ,
1136
- ..
1137
- ] ) {
1151
+ ]
1152
+ ) {
1138
1153
match get_parent_expr ( cx, e) {
1139
1154
// Field accesses are the same no matter the number of references.
1140
1155
Some ( Expr {
0 commit comments