]>
git.proxmox.com Git - rustc.git/blob - src/test/ui/loops/loops-reject-lifetime-shadowing-label.rs
2 #![feature(label_break_value)]
3 #![allow(dead_code, unused_variables)]
5 // Issue #21633: reject duplicate loop labels and block labels in function bodies.
7 // Test rejection of lifetimes in *expressions* that shadow labels.
10 // Reusing lifetime `'a` in function item is okay.
11 fn foo
<'a
>(x
: &'a
i8) -> i8 { *x }
13 // So is reusing `'a` in struct item
14 struct S1
<'a
> { x: &'a i8 }
impl<'a
> S1
<'a
> { fn m(&self) {}
}
16 struct S2
; impl S2 { fn m<'a>(&self) {}
}
21 let b
= Box
::new(|x
: &i8| *x
) as Box
<dyn for <'a
> Fn(&'a
i8) -> i8>;
22 //~^ WARN lifetime name `'a` shadows a label name that is already in scope
23 assert_eq
!((*b
)(&z
), z
);
28 let b
= Box
::new(|x
: &()| ()) as Box
<dyn for <'b
> Fn(&'
b ())>;
29 //~^ WARN lifetime name `'b` shadows a label name that is already in scope