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