librustc: Resolve regions and report errors in trait/impl method
matching.
This breaks code like:
struct Foo<'a,'b> {
x: &'a int,
y: &'b int,
}
trait Tr {
fn foo(x: Self) {}
}
impl<'a,'b> Tr for Foo<'a,'b> {
fn foo(x: Foo<'b,'a>) {} // <-- bad
}
Change this code to not contain a lifetime mismatch error. For example:
struct Foo<'a,'b> {
x: &'a int,
y: &'b int,
}
trait Tr {
fn foo(x: Self) {}
}
impl<'a,'b> Tr for Foo<'a,'b> {
fn foo(x: Foo<'a,'b>) {} // OK
}
Closes #15517.
[breaking-change]
2014-07-25 22:56:42 +00:00
|
|
|
// Tests that the trait matching code takes lifetime parameters into account.
|
|
|
|
// (Issue #15517.)
|
|
|
|
|
|
|
|
struct Foo<'a,'b> {
|
2015-01-08 10:54:35 +00:00
|
|
|
x: &'a isize,
|
|
|
|
y: &'b isize,
|
librustc: Resolve regions and report errors in trait/impl method
matching.
This breaks code like:
struct Foo<'a,'b> {
x: &'a int,
y: &'b int,
}
trait Tr {
fn foo(x: Self) {}
}
impl<'a,'b> Tr for Foo<'a,'b> {
fn foo(x: Foo<'b,'a>) {} // <-- bad
}
Change this code to not contain a lifetime mismatch error. For example:
struct Foo<'a,'b> {
x: &'a int,
y: &'b int,
}
trait Tr {
fn foo(x: Self) {}
}
impl<'a,'b> Tr for Foo<'a,'b> {
fn foo(x: Foo<'a,'b>) {} // OK
}
Closes #15517.
[breaking-change]
2014-07-25 22:56:42 +00:00
|
|
|
}
|
|
|
|
|
2014-12-19 11:54:09 +00:00
|
|
|
trait Tr : Sized {
|
librustc: Resolve regions and report errors in trait/impl method
matching.
This breaks code like:
struct Foo<'a,'b> {
x: &'a int,
y: &'b int,
}
trait Tr {
fn foo(x: Self) {}
}
impl<'a,'b> Tr for Foo<'a,'b> {
fn foo(x: Foo<'b,'a>) {} // <-- bad
}
Change this code to not contain a lifetime mismatch error. For example:
struct Foo<'a,'b> {
x: &'a int,
y: &'b int,
}
trait Tr {
fn foo(x: Self) {}
}
impl<'a,'b> Tr for Foo<'a,'b> {
fn foo(x: Foo<'a,'b>) {} // OK
}
Closes #15517.
[breaking-change]
2014-07-25 22:56:42 +00:00
|
|
|
fn foo(x: Self) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a,'b> Tr for Foo<'a,'b> {
|
|
|
|
fn foo(x: Foo<'b,'a>) {
|
|
|
|
//~^ ERROR method not compatible with trait
|
|
|
|
//~^^ ERROR method not compatible with trait
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main(){}
|