Visit type parameter in lifetime suggestion

Previously, Rebuilder did not visit type parameters when rebuilding
generics and path, so in some cases the suggestion turns out to be
erroneous.
This commit is contained in:
Kiet Tran
2014-03-24 19:11:44 -04:00
parent 533a526327
commit 1d99d37f87
3 changed files with 157 additions and 24 deletions

View File

@@ -54,5 +54,16 @@ fn bar2<'a, 'b, 'c>(x: &Bar<'a, 'b, 'c>) -> (&int, &int, &int) {
//~^^ ERROR: cannot infer
}
struct Cat<'x, T> { cat: &'x int, t: T }
struct Dog<'y> { dog: &'y int }
fn cat<'x>(x: Cat<'x, Dog>) -> &int {
//~^ NOTE: consider using an explicit lifetime parameter as shown: fn cat<'a, 'x>(x: Cat<'x, Dog<'a>>) -> &'a int
x.t.dog //~ ERROR: mismatched types
}
fn cat2<'x, 'y>(x: Cat<'x, Dog<'y>>) -> &int {
//~^ NOTE: consider using an explicit lifetime parameter as shown: fn cat2<'a, 'x>(x: Cat<'x, Dog<'a>>) -> &'a int
x.t.dog //~ ERROR: mismatched types
}
fn main() {}