]> git.lizzy.rs Git - rust.git/blob - src/test/ui/borrowck/borrowck-uninit-ref-chain.rs
Rollup merge of #57132 - daxpedda:master, r=steveklabnik
[rust.git] / src / test / ui / borrowck / borrowck-uninit-ref-chain.rs
1 // revisions: ast mir
2 //[mir]compile-flags: -Z borrowck=mir
3
4 struct S<X, Y> {
5     x: X,
6     y: Y,
7 }
8
9 fn main() {
10     let x: &&Box<i32>;
11     let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381]
12                    //[mir]~^ [E0381]
13
14     let x: &&S<i32, i32>;
15     let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381]
16                    //[mir]~^ [E0381]
17
18     let x: &&i32;
19     let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381]
20                    //[mir]~^ [E0381]
21
22
23     let mut a: S<i32, i32>;
24     a.x = 0;       //[mir]~ ERROR assign to part of possibly uninitialized variable: `a` [E0381]
25     let _b = &a.x; //[ast]~ ERROR use of possibly uninitialized variable: `a.x` [E0381]
26
27
28     let mut a: S<&&i32, &&i32>;
29     a.x = &&0;       //[mir]~ ERROR assign to part of possibly uninitialized variable: `a` [E0381]
30     let _b = &**a.x; //[ast]~ ERROR use of possibly uninitialized variable: `**a.x` [E0381]
31
32
33
34     let mut a: S<i32, i32>;
35     a.x = 0;       //[mir]~ ERROR assign to part of possibly uninitialized variable: `a` [E0381]
36     let _b = &a.y; //[ast]~ ERROR use of possibly uninitialized variable: `a.y` [E0381]
37
38
39     let mut a: S<&&i32, &&i32>;
40     a.x = &&0;       //[mir]~ assign to part of possibly uninitialized variable: `a` [E0381]
41     let _b = &**a.y; //[ast]~ ERROR use of possibly uninitialized variable: `**a.y` [E0381]
42
43 }