@@ -288,8 +288,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
288
288
let mode = no_match_data. mode ;
289
289
let tcx = self . tcx ;
290
290
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) = tcx. short_ty_string ( rcvr_ty) ;
292
+ let mut short_ty_str = with_forced_trimmed_paths ! ( rcvr_ty. to_string( ) ) ;
293
293
let is_method = mode == Mode :: MethodCall ;
294
294
let unsatisfied_predicates = & no_match_data. unsatisfied_predicates ;
295
295
let similar_candidate = no_match_data. similar_candidate ;
@@ -328,13 +328,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
328
328
}
329
329
span = item_name. span ;
330
330
331
- // 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
- } ;
331
+ if trait_missing_method && let ty:: Dynamic ( predicates, _, _) = rcvr_ty. kind ( ) {
332
+ ty_str = predicates. to_string ( ) ;
333
+ short_ty_str = with_forced_trimmed_paths ! ( predicates. to_string( ) ) ;
334
+ }
337
335
336
+ // Don't show generic arguments when the method can't be found in any implementation (#81576).
337
+ let mut ty_str_reported = ty_str. clone ( ) ;
338
338
if let ty:: Adt ( _, generics) = rcvr_ty. kind ( ) {
339
339
if generics. len ( ) > 0 {
340
340
let mut autoderef = self . autoderef ( span, rcvr_ty) ;
@@ -383,14 +383,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
383
383
if tcx. sess . source_map ( ) . is_multiline ( sugg_span) {
384
384
err. span_label ( sugg_span. with_hi ( span. lo ( ) ) , "" ) ;
385
385
}
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 ( ) ;
386
+
387
+ if short_ty_str. len ( ) < ty_str. len ( ) && ty_str. len ( ) > 10 {
388
+ ty_str = short_ty_str;
394
389
}
395
390
396
391
if let Some ( file) = ty_file {
0 commit comments