2014-12-12 16:09:24 +00:00
|
|
|
// Test that shadowed lifetimes generate an error.
|
|
|
|
|
2015-01-08 10:54:35 +00:00
|
|
|
struct Foo<'a>(&'a isize);
|
2014-12-12 16:09:24 +00:00
|
|
|
|
|
|
|
impl<'a> Foo<'a> {
|
2015-01-08 10:54:35 +00:00
|
|
|
fn shadow_in_method<'a>(&'a self) -> &'a isize {
|
2015-04-08 16:37:47 +00:00
|
|
|
//~^ ERROR lifetime name `'a` shadows a lifetime name that is already in scope
|
2014-12-12 16:09:24 +00:00
|
|
|
self.0
|
|
|
|
}
|
|
|
|
|
2015-01-08 10:54:35 +00:00
|
|
|
fn shadow_in_type<'b>(&'b self) -> &'b isize {
|
|
|
|
let x: for<'b> fn(&'b isize) = panic!();
|
2015-04-08 16:37:47 +00:00
|
|
|
//~^ ERROR lifetime name `'b` shadows a lifetime name that is already in scope
|
2014-12-12 16:09:24 +00:00
|
|
|
self.0
|
|
|
|
}
|
|
|
|
|
|
|
|
fn not_shadow_in_item<'b>(&'b self) {
|
2015-01-08 10:54:35 +00:00
|
|
|
struct Bar<'a, 'b>(&'a isize, &'b isize); // not a shadow, separate item
|
|
|
|
fn foo<'a, 'b>(x: &'a isize, y: &'b isize) { } // same
|
2014-12-12 16:09:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
}
|