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 17:56:42 -05:00
|
|
|
// Tests that the trait matching code takes lifetime parameters into account.
|
|
|
|
// (Issue #15517.)
|
|
|
|
|
|
|
|
struct Foo<'a,'b> {
|
2015-01-08 04:54:35 -06: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 17:56:42 -05:00
|
|
|
}
|
|
|
|
|
2014-12-19 05:54:09 -06: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 17:56:42 -05: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(){}
|