@@ -1066,26 +1066,19 @@ impl<'a, 'tcx> CastCheck<'tcx> {
10661066 if let Some ( ( deref_ty, _) ) = derefed {
10671067 // Give a note about what the expr derefs to.
10681068 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+ } ) ;
10761073 }
10771074
10781075 // Create a multipart suggestion: add `!` and `.is_empty()` in
10791076 // 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+ } ) ;
10891082 }
10901083 }
10911084 }
0 commit comments