@@ -374,13 +374,16 @@ fn to_pretty_impl_header(tcx: TyCtxt, impl_def_id: DefId) -> Option<String> {
374
374
375
375
let substs = Substs :: identity_for_item ( tcx, impl_def_id) ;
376
376
377
- // FIXME: Currently only handles ?Sized.
378
- // Needs to support ?Move and ?DynSized when they are implemented.
379
- let mut types_without_default_bounds = FxHashSet :: default ( ) ;
377
+ // FIXME: Currently only handles ?Sized and ?DynSized.
378
+ // Needs to support ?Move when it is implemented.
379
+ let mut types_without_sized = FxHashSet :: default ( ) ;
380
+ let mut types_without_dynsized = FxHashSet :: default ( ) ;
380
381
let sized_trait = tcx. lang_items ( ) . sized_trait ( ) ;
382
+ let dynsized_trait = tcx. lang_items ( ) . dynsized_trait ( ) ;
381
383
382
384
if !substs. is_noop ( ) {
383
- types_without_default_bounds. extend ( substs. types ( ) ) ;
385
+ types_without_sized. extend ( substs. types ( ) ) ;
386
+ types_without_dynsized. extend ( substs. types ( ) ) ;
384
387
w. push ( '<' ) ;
385
388
w. push_str ( & substs. iter ( ) . map ( |k| k. to_string ( ) ) . collect :: < Vec < _ > > ( ) . join ( ", " ) ) ;
386
389
w. push ( '>' ) ;
@@ -395,14 +398,22 @@ fn to_pretty_impl_header(tcx: TyCtxt, impl_def_id: DefId) -> Option<String> {
395
398
for p in predicates {
396
399
if let Some ( poly_trait_ref) = p. to_opt_poly_trait_ref ( ) {
397
400
if Some ( poly_trait_ref. def_id ( ) ) == sized_trait {
398
- types_without_default_bounds. remove ( poly_trait_ref. self_ty ( ) ) ;
401
+ types_without_sized. remove ( poly_trait_ref. self_ty ( ) ) ;
402
+ continue ;
403
+ }
404
+ if Some ( poly_trait_ref. def_id ( ) ) == dynsized_trait {
405
+ types_without_dynsized. remove ( poly_trait_ref. self_ty ( ) ) ;
399
406
continue ;
400
407
}
401
408
}
402
409
pretty_predicates. push ( p. to_string ( ) ) ;
403
410
}
404
- for ty in types_without_default_bounds {
405
- pretty_predicates. push ( format ! ( "{}: ?Sized" , ty) ) ;
411
+ for ty in types_without_sized {
412
+ if types_without_dynsized. contains ( & ty) {
413
+ pretty_predicates. push ( format ! ( "{}: ?DynSized" , ty) ) ;
414
+ } else {
415
+ pretty_predicates. push ( format ! ( "{}: ?Sized" , ty) ) ;
416
+ }
406
417
}
407
418
if !pretty_predicates. is_empty ( ) {
408
419
write ! ( w, "\n where {}" , pretty_predicates. join( ", " ) ) . unwrap ( ) ;
0 commit comments