Now that the elaboration mechanism is suppressing defaults, we can remove this overeager code that was pruning out ambig where-clause matches in trait selection. cc #21974.

This commit is contained in:
Niko Matsakis 2015-02-05 16:24:12 -05:00
parent 8d9bb17204
commit fab32b4167
2 changed files with 28 additions and 19 deletions

View File

@ -1335,25 +1335,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
// the where clauses are in scope.
true
}
(&ParamCandidate(ref bound1), &ParamCandidate(ref bound2)) => {
self.infcx.probe(|_| {
let bound1 =
project::normalize_with_depth(self,
stack.obligation.cause.clone(),
stack.obligation.recursion_depth+1,
bound1);
let bound2 =
project::normalize_with_depth(self,
stack.obligation.cause.clone(),
stack.obligation.recursion_depth+1,
bound2);
let origin =
infer::RelateOutputImplTypes(stack.obligation.cause.span);
self.infcx
.sub_poly_trait_refs(false, origin, bound1.value, bound2.value)
.is_ok()
})
}
_ => {
false
}

View File

@ -0,0 +1,28 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Test that (for now) we report an ambiguity error here, because
// specific trait relationships are ignored for the purposes of trait
// matching. This behavior should likely be improved such that this
// test passes. See #21974 for more details.
trait Foo {
fn foo(self);
}
fn foo<'a,'b,T>(x: &'a T, y: &'b T)
where &'a T : Foo,
&'b T : Foo
{
x.foo(); //~ ERROR type annotations required
y.foo();
}
fn main() { }