Skip to content

Commit 38efc95

Browse files
committed
don't print DynSized in conflicting trait impl error messages
This fixes a bunch of ui tests. It now either prints out `T`, `T: ?Sized`, or `T: ?DynSized`.
1 parent fe40804 commit 38efc95

File tree

1 file changed

+18
-7
lines changed
  • src/librustc/traits/specialize

1 file changed

+18
-7
lines changed

src/librustc/traits/specialize/mod.rs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -374,13 +374,16 @@ fn to_pretty_impl_header(tcx: TyCtxt, impl_def_id: DefId) -> Option<String> {
374374

375375
let substs = Substs::identity_for_item(tcx, impl_def_id);
376376

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();
380381
let sized_trait = tcx.lang_items().sized_trait();
382+
let dynsized_trait = tcx.lang_items().dynsized_trait();
381383

382384
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());
384387
w.push('<');
385388
w.push_str(&substs.iter().map(|k| k.to_string()).collect::<Vec<_>>().join(", "));
386389
w.push('>');
@@ -395,14 +398,22 @@ fn to_pretty_impl_header(tcx: TyCtxt, impl_def_id: DefId) -> Option<String> {
395398
for p in predicates {
396399
if let Some(poly_trait_ref) = p.to_opt_poly_trait_ref() {
397400
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());
399406
continue;
400407
}
401408
}
402409
pretty_predicates.push(p.to_string());
403410
}
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+
}
406417
}
407418
if !pretty_predicates.is_empty() {
408419
write!(w, "\n where {}", pretty_predicates.join(", ")).unwrap();

0 commit comments

Comments
 (0)