about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMichael Hewson <michael@michaelhewson.ca>2018-10-17 18:54:13 -0400
committerMichael Hewson <michael@michaelhewson.ca>2018-11-01 18:16:59 -0400
commit3db22039dceb36fc15e770c24ec99e2db1ca586d (patch)
tree5430589e94a240df77a7bc391d481810041cfcf4 /src
parenteb997d76d5a1c0ed933ab76459233e3650d2771d (diff)
downloadrust-3db22039dceb36fc15e770c24ec99e2db1ca586d.tar.gz
rust-3db22039dceb36fc15e770c24ec99e2db1ca586d.zip
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:
https://github.com/rust-lang/rust/pull/50173#discussion_r204222336

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
Diffstat (limited to 'src')
-rw-r--r--src/librustc/traits/select.rs11
1 files changed, 0 insertions, 11 deletions
diff --git a/src/librustc/traits/select.rs b/src/librustc/traits/select.rs
index 0742f377f18..126c158f846 100644
--- a/src/librustc/traits/select.rs
+++ b/src/librustc/traits/select.rs
@@ -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;