@@ -1066,26 +1066,19 @@ impl<'a, 'tcx> CastCheck<'tcx> {
1066
1066
if let Some ( ( deref_ty, _) ) = derefed {
1067
1067
// Give a note about what the expr derefs to.
1068
1068
if deref_ty != self . expr_ty . peel_refs ( ) {
1069
- err. span_note (
1070
- self . expr_span ,
1071
- format ! (
1072
- "this expression `Deref`s to `{}` which implements `is_empty`" ,
1073
- fcx. ty_to_string( deref_ty)
1074
- ) ,
1075
- ) ;
1069
+ err. subdiagnostic ( errors:: DerefImplsIsEmpty {
1070
+ span : self . expr_span ,
1071
+ deref_ty : fcx. ty_to_string ( deref_ty) ,
1072
+ } ) ;
1076
1073
}
1077
1074
1078
1075
// Create a multipart suggestion: add `!` and `.is_empty()` in
1079
1076
// place of the cast.
1080
- let suggestion = vec ! [
1081
- ( self . expr_span. shrink_to_lo( ) , "!" . to_string( ) ) ,
1082
- ( self . span. with_lo( self . expr_span. hi( ) ) , ".is_empty()" . to_string( ) ) ,
1083
- ] ;
1084
-
1085
- err. multipart_suggestion_verbose ( format ! (
1086
- "consider using the `is_empty` method on `{}` to determine if it contains anything" ,
1087
- fcx. ty_to_string( self . expr_ty) ,
1088
- ) , suggestion, Applicability :: MaybeIncorrect ) ;
1077
+ err. subdiagnostic ( errors:: UseIsEmpty {
1078
+ lo : self . expr_span . shrink_to_lo ( ) ,
1079
+ hi : self . span . with_lo ( self . expr_span . hi ( ) ) ,
1080
+ expr_ty : fcx. ty_to_string ( self . expr_ty ) ,
1081
+ } ) ;
1089
1082
}
1090
1083
}
1091
1084
}
0 commit comments