Skip to content

Commit 3db2203

Browse files
committed
Remove this check for object-safety during selection of trait object candidates
I don't really understand what it's for, but see the comment here: rust-lang#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
1 parent eb997d7 commit 3db2203

File tree

1 file changed

+0
-11
lines changed

1 file changed

+0
-11
lines changed

src/librustc/traits/select.rs

-11
Original file line numberDiff line numberDiff line change
@@ -2111,17 +2111,6 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
21112111
data.principal().with_self_ty(this.tcx(), self_ty)
21122112
}
21132113
ty::Infer(ty::TyVar(_)) => {
2114-
// Object-safety candidates are only applicable to object-safe
2115-
// traits. Including this check is useful because it helps
2116-
// inference in cases of traits like `BorrowFrom`, which are
2117-
// not object-safe, and which rely on being able to infer the
2118-
// self-type from one of the other inputs. Without this check,
2119-
// these cases wind up being considered ambiguous due to a
2120-
// (spurious) ambiguity introduced here.
2121-
let predicate_trait_ref = obligation.predicate.to_poly_trait_ref();
2122-
if !this.tcx().is_object_safe(predicate_trait_ref.def_id()) {
2123-
return;
2124-
}
21252114
debug!("assemble_candidates_from_object_ty: ambiguous");
21262115
candidates.ambiguous = true; // could wind up being an object type
21272116
return;

0 commit comments

Comments
 (0)