]> git.lizzy.rs Git - rust.git/blob - src/test/ui/regions/regions-addr-of-arg.rs
Rollup merge of #105955 - Nilstrieb:no-trivial-opt-wrappers-we-have-field-accesses...
[rust.git] / src / test / ui / regions / regions-addr-of-arg.rs
1 // Check that taking the address of an argument yields a lifetime
2 // bounded by the current function call.
3
4 fn foo(a: isize) {
5     let _p: &'static isize = &a; //~ ERROR `a` does not live long enough
6 }
7
8 fn bar(a: isize) {
9     let _q: &isize = &a;
10 }
11
12 fn zed<'a>(a: isize) -> &'a isize {
13     &a //~ ERROR cannot return reference to function parameter `a`
14 }
15
16 fn main() {
17 }