forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't check impl ty params for equality with trait ty params
This was too restrictive. We need to check the number of ty params, and that the bounds are equal, but otherwise require_same_types does the job. Closes rust-lang#2611
- Loading branch information
1 parent
c6b5154
commit ac1f84c
Showing
7 changed files
with
115 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Tests that impl methods are matched to traits exactly: | ||
// we might be tempted to think matching is contravariant, but if | ||
// we let an impl method can have more permissive bounds than the trait | ||
// method it's implementing, the return type might be less specific than | ||
// needed. Just punt and make it invariant. | ||
import iter; | ||
import iter::BaseIter; | ||
|
||
trait A { | ||
fn b<C:copy const, D>(x: C) -> C; | ||
} | ||
|
||
struct E { | ||
f: int; | ||
} | ||
|
||
impl E: A { | ||
fn b<F:copy, G>(_x: F) -> F { fail } //~ ERROR in method `b`, type parameter 0 has 1 bound, but | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Tests that an impl method's bounds aren't *more* restrictive | ||
// than the trait method it's implementing | ||
import iter; | ||
import iter::BaseIter; | ||
|
||
trait A { | ||
fn b<C:copy, D>(x: C) -> C; | ||
} | ||
|
||
struct E { | ||
f: int; | ||
} | ||
|
||
impl E: A { | ||
fn b<F:copy const, G>(_x: F) -> F { fail } //~ ERROR in method `b`, type parameter 0 has 2 bounds, but | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Tests that ty params get matched correctly when comparing | ||
// an impl against a trait | ||
import iter; | ||
import iter::BaseIter; | ||
|
||
trait A { | ||
fn b<C:copy, D>(x: C) -> C; | ||
} | ||
|
||
struct E { | ||
f: int; | ||
} | ||
|
||
impl E: A { | ||
// n.b. The error message is awful -- see #3404 | ||
fn b<F:copy, G>(_x: G) -> G { fail } //~ ERROR method `b` has an incompatible type | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters