From fab32b41676c6c9d75733ce78d8d5f455a4f27fc Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Thu, 5 Feb 2015 16:24:12 -0500 Subject: [PATCH] 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. --- src/librustc/middle/traits/select.rs | 19 ------------------- src/test/compile-fail/issue-21974.rs | 28 ++++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 19 deletions(-) create mode 100644 src/test/compile-fail/issue-21974.rs diff --git a/src/librustc/middle/traits/select.rs b/src/librustc/middle/traits/select.rs index b8af91add9e..e9909cc512c 100644 --- a/src/librustc/middle/traits/select.rs +++ b/src/librustc/middle/traits/select.rs @@ -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 } diff --git a/src/test/compile-fail/issue-21974.rs b/src/test/compile-fail/issue-21974.rs new file mode 100644 index 00000000000..f768d6c00ec --- /dev/null +++ b/src/test/compile-fail/issue-21974.rs @@ -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 or the MIT license +// , 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() { }