]>
git.proxmox.com Git - rustc.git/blob - src/test/ui/regions/regions-name-undeclared.rs
1 // Check that lifetime resolver enforces the lifetime name scoping
2 // rules correctly in various scenarios.
10 fn m1(&self, arg
: &'a
isize) { }
12 fn m3(&self, arg
: Foo
<'a
>) { }
15 fn m4(&self, arg
: &'b
isize) { }
//~ ERROR undeclared lifetime
16 fn m5(&'b
self) { }
//~ ERROR undeclared lifetime
17 fn m6(&self, arg
: Foo
<'b
>) { }
//~ ERROR undeclared lifetime
20 fn bar
<'a
>(x
: &'a
isize) {
21 // &'a is visible to code:
24 // &'a is not visible to *items*:
25 type X
= Option
<&'a
isize>; //~ ERROR undeclared lifetime
27 E1(&'a
isize) //~ ERROR undeclared lifetime
30 f
: &'a
isize //~ ERROR undeclared lifetime
32 fn f(a
: &'a
isize) { }
//~ ERROR undeclared lifetime
34 // &'a CAN be declared on functions and used then:
35 fn g
<'a
>(a
: &'a
isize) { }
// OK
36 fn h(a
: Box
<dyn for<'a
> FnOnce(&'a
isize)>) { }
// OK
39 // Test nesting of lifetimes in fn type declarations
40 fn fn_types(a
: &'a
isize, //~ ERROR undeclared lifetime
41 b
: Box
<dyn for<'a
> FnOnce(&'a
isize,
42 &'b
isize, //~ ERROR undeclared lifetime
43 Box
<dyn for<'b
> FnOnce(&'a
isize,
45 &'b
isize)>, //~ ERROR undeclared lifetime
46 c
: &'a
isize) //~ ERROR undeclared lifetime