about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2015-02-05 16:24:12 -0500
committerNiko Matsakis <niko@alum.mit.edu>2015-02-05 16:34:54 -0500
commitfab32b41676c6c9d75733ce78d8d5f455a4f27fc (patch)
treeff69f979c0d4d171e26bcfa1b578f72ec090ca37 /src
parent8d9bb17204c0b3b9c8ade3569ac4501fac18b885 (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/librustc/middle/traits/select.rs19
-rw-r--r--src/test/compile-fail/issue-21974.rs28
2 files changed, 28 insertions, 19 deletions
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 <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() { }