]> git.lizzy.rs Git - rust.git/blob - src/test/ui/shadowed/shadowed-lifetime.rs
Rollup merge of #100026 - WaffleLapkin:array-chunks, r=scottmcm
[rust.git] / src / test / ui / shadowed / shadowed-lifetime.rs
1 // Test that shadowed lifetimes generate an error.
2
3 struct Foo<'a>(&'a isize);
4
5 impl<'a> Foo<'a> {
6     fn shadow_in_method<'a>(&'a self) -> &'a isize {
7         //~^ ERROR lifetime name `'a` shadows a lifetime name that is already in scope
8         self.0
9     }
10
11     fn shadow_in_type<'b>(&'b self) -> &'b isize {
12         let x: for<'b> fn(&'b isize) = panic!();
13         //~^ ERROR lifetime name `'b` shadows a lifetime name that is already in scope
14         self.0
15     }
16
17     fn not_shadow_in_item<'b>(&'b self) {
18         struct Bar<'a, 'b>(&'a isize, &'b isize); // not a shadow, separate item
19         fn foo<'a, 'b>(x: &'a isize, y: &'b isize) { } // same
20     }
21 }
22
23 fn main() {
24 }