@@ -1086,21 +1086,17 @@ fn get_mut_span_in_struct_field<'tcx>(
1086
1086
field : & mir:: Field ,
1087
1087
) -> Option < Span > {
1088
1088
// Expect our local to be a reference to a struct of some kind.
1089
- if let ty:: Ref ( _, ty, _) = ty. kind ( ) {
1090
- if let ty:: Adt ( def, _) = ty. kind ( ) {
1091
- let field = def. all_fields ( ) . nth ( field. index ( ) ) ?;
1092
- // Use the HIR types to construct the diagnostic message.
1093
- let node = tcx. hir ( ) . find_by_def_id ( field. did . as_local ( ) ?) ?;
1094
- // Now we're dealing with the actual struct that we're going to suggest a change to,
1095
- // we can expect a field that is an immutable reference to a type.
1096
- if let hir:: Node :: Field ( field) = node {
1097
- if let hir:: TyKind :: Rptr ( lifetime, hir:: MutTy { mutbl : hir:: Mutability :: Not , ty } ) =
1098
- field. ty . kind
1099
- {
1100
- return Some ( lifetime. span . between ( ty. span ) ) ;
1101
- }
1102
- }
1103
- }
1089
+ if let ty:: Ref ( _, ty, _) = ty. kind ( )
1090
+ && let ty:: Adt ( def, _) = ty. kind ( )
1091
+ && let field = def. all_fields ( ) . nth ( field. index ( ) ) ?
1092
+ // Use the HIR types to construct the diagnostic message.
1093
+ && let node = tcx. hir ( ) . find_by_def_id ( field. did . as_local ( ) ?) ?
1094
+ // Now we're dealing with the actual struct that we're going to suggest a change to,
1095
+ // we can expect a field that is an immutable reference to a type.
1096
+ && let hir:: Node :: Field ( field) = node
1097
+ && let hir:: TyKind :: Rptr ( lt, hir:: MutTy { mutbl : hir:: Mutability :: Not , ty } ) = field. ty . kind
1098
+ {
1099
+ return Some ( lt. span . between ( ty. span ) ) ;
1104
1100
}
1105
1101
1106
1102
None
0 commit comments