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