rust-lang/rust — pull request #15325 by pcwalton (2014-07-02 05:05:54+00:00)
Title: librustc: Properly compare implementation method type parameter bounds

with the corresponding trait parameter bounds.

This is a version of the patch in PR #12611 by Florian Hahn, modified to
address Niko's feedback.

It does not address the issue of duplicate type parameter bounds, nor
does it address the issue of implementation-defined methods that contain
*fewer* bounds than the trait, because Niko's review indicates that this
should not be necessary (and indeed I believe it is not). A test has
been added to ensure that this works.

This will break code like:

trait Foo {
fn bar();
}

impl Foo for Boo {
fn bar() { ... }
// ^~~~ ERROR
}

This will be rejected because the implementation requires *more* bounds
than the trait. It can be fixed by either adding the missing bound to
the trait:

trait Foo {
fn bar();
// ^~~~
}

impl Foo for Boo {
fn bar() { ... } // OK
}

Or by removing the bound from the impl:

trait Foo {
fn bar();
}

impl Foo for Boo {
fn bar() { ... } // OK
// ^ remove Quux
}

This patch imports the relevant tests from #2687, as well as the test
case in #5886, which is fixed as well by this patch.

Closes #2687.
Closes #5886.

[breaking-change]

r? @pnkfelix