Skip to content

Commit

Permalink
Remove this check for object-safety during selection of trait object …
Browse files Browse the repository at this point in the history
…candidates

I don't really understand what it's for, but see the comment here:
#50173 (comment)

where arielb1 said

> Does this check do anything these days? I think `$0: Trait` is always considered ambiguous

and nikomatsakis agreed we may be able to get rid of it
  • Loading branch information
mikeyhew committed Nov 1, 2018
1 parent eb997d7 commit 3db2203
Showing 1 changed file with 0 additions and 11 deletions.
11 changes: 0 additions & 11 deletions src/librustc/traits/select.rs
Expand Up @@ -2111,17 +2111,6 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
data.principal().with_self_ty(this.tcx(), self_ty)
}
ty::Infer(ty::TyVar(_)) => {
// Object-safety candidates are only applicable to object-safe
// traits. Including this check is useful because it helps
// inference in cases of traits like `BorrowFrom`, which are
// not object-safe, and which rely on being able to infer the
// self-type from one of the other inputs. Without this check,
// these cases wind up being considered ambiguous due to a
// (spurious) ambiguity introduced here.
let predicate_trait_ref = obligation.predicate.to_poly_trait_ref();
if !this.tcx().is_object_safe(predicate_trait_ref.def_id()) {
return;
}
debug!("assemble_candidates_from_object_ty: ambiguous");
candidates.ambiguous = true; // could wind up being an object type
return;
Expand Down

0 comments on commit 3db2203

Please sign in to comment.