]> git.lizzy.rs Git - rust.git/blob - src/test/ui/nll/issue-52534-1.rs
Rollup merge of #60685 - dtolnay:spdx, r=nikomatsakis
[rust.git] / src / test / ui / nll / issue-52534-1.rs
1 #![feature(nll)]
2 #![allow(warnings)]
3
4 struct Test;
5
6 impl Test {
7     fn bar(&self, x: &u32) -> &u32 {
8         let x = 22;
9         &x
10 //~^ ERROR cannot return reference to local variable
11     }
12 }
13
14 fn foo(x: &u32) -> &u32 {
15     let x = 22;
16     &x
17 //~^ ERROR cannot return reference to local variable
18 }
19
20 fn baz(x: &u32) -> &&u32 {
21     let x = 22;
22     &&x
23 //~^ ERROR cannot return value referencing local variable
24 //~| ERROR cannot return reference to temporary value
25 }
26
27 fn foobazbar<'a>(x: u32, y: &'a u32) -> &'a u32 {
28     let x = 22;
29     &x
30 //~^ ERROR cannot return reference to local variable
31 }
32
33 fn foobar<'a>(x: &'a u32) -> &'a u32 {
34     let x = 22;
35     &x
36 //~^ ERROR cannot return reference to local variable
37 }
38
39 fn foobaz<'a, 'b>(x: &'a u32, y: &'b u32) -> &'a u32 {
40     let x = 22;
41     &x
42 //~^ ERROR cannot return reference to local variable
43 }
44
45 fn foobarbaz<'a, 'b>(x: &'a u32, y: &'b u32, z: &'a u32) -> &'a u32 {
46     let x = 22;
47     &x
48 //~^ ERROR cannot return reference to local variable
49 }
50
51 fn main() { }