]> git.proxmox.com Git - rustc.git/blame - src/test/ui/shadowed/shadowed-lifetime.rs
New upstream version 1.67.1+dfsg1
[rustc.git] / src / test / ui / shadowed / shadowed-lifetime.rs
CommitLineData
1a4d82fc
JJ
1// Test that shadowed lifetimes generate an error.
2
3struct Foo<'a>(&'a isize);
4
5impl<'a> Foo<'a> {
1a4d82fc 6 fn shadow_in_method<'a>(&'a self) -> &'a isize {
9346a6ac 7 //~^ ERROR lifetime name `'a` shadows a lifetime name that is already in scope
1a4d82fc
JJ
8 self.0
9 }
10
11 fn shadow_in_type<'b>(&'b self) -> &'b isize {
1a4d82fc 12 let x: for<'b> fn(&'b isize) = panic!();
9346a6ac 13 //~^ ERROR lifetime name `'b` shadows a lifetime name that is already in scope
1a4d82fc
JJ
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
23fn main() {
1a4d82fc 24}