@@ -288,8 +288,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
288288 let mode = no_match_data. mode ;
289289 let tcx = self . tcx ;
290290 let rcvr_ty = self . resolve_vars_if_possible ( rcvr_ty) ;
291- let ( ty_str, ty_file) = tcx. short_ty_string ( rcvr_ty) ;
292- let short_ty_str = with_forced_trimmed_paths ! ( rcvr_ty. to_string( ) ) ;
291+ let ( ( mut ty_str, ty_file) , short_ty_str) = if trait_missing_method
292+ && let ty:: Dynamic ( predicates, _, _) = rcvr_ty. kind ( ) {
293+ ( ( predicates. to_string ( ) , None ) , with_forced_trimmed_paths ! ( predicates. to_string( ) ) )
294+ } else {
295+ ( tcx. short_ty_string ( rcvr_ty) , with_forced_trimmed_paths ! ( rcvr_ty. to_string( ) ) )
296+ } ;
293297 let is_method = mode == Mode :: MethodCall ;
294298 let unsatisfied_predicates = & no_match_data. unsatisfied_predicates ;
295299 let similar_candidate = no_match_data. similar_candidate ;
@@ -329,12 +333,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
329333 span = item_name. span ;
330334
331335 // Don't show generic arguments when the method can't be found in any implementation (#81576).
332- let mut ty_str_reported = if trait_missing_method {
333- ty_str. strip_prefix ( "dyn " ) . expect ( "Failed to remove the prefix dyn" ) . to_owned ( )
334- } else {
335- ty_str. clone ( )
336- } ;
337-
336+ let mut ty_str_reported = ty_str. clone ( ) ;
338337 if let ty:: Adt ( _, generics) = rcvr_ty. kind ( ) {
339338 if generics. len ( ) > 0 {
340339 let mut autoderef = self . autoderef ( span, rcvr_ty) ;
@@ -383,14 +382,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
383382 if tcx. sess . source_map ( ) . is_multiline ( sugg_span) {
384383 err. span_label ( sugg_span. with_hi ( span. lo ( ) ) , "" ) ;
385384 }
386- let mut ty_str = if short_ty_str. len ( ) < ty_str. len ( ) && ty_str. len ( ) > 10 {
387- short_ty_str
388- } else {
389- ty_str
390- } ;
391- if trait_missing_method {
392- ty_str =
393- ty_str. strip_prefix ( "dyn " ) . expect ( "Failed to remove the prefix dyn" ) . to_owned ( ) ;
385+
386+ if short_ty_str. len ( ) < ty_str. len ( ) && ty_str. len ( ) > 10 {
387+ ty_str = short_ty_str;
394388 }
395389
396390 if let Some ( file) = ty_file {
0 commit comments