|
| 1 | +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT |
| 2 | +// file at the top-level directory of this distribution and at |
| 3 | +// http://rust-lang.org/COPYRIGHT. |
| 4 | +// |
| 5 | +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or |
| 6 | +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license |
| 7 | +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your |
| 8 | +// option. This file may not be copied, modified, or distributed |
| 9 | +// except according to those terms. |
| 10 | + |
| 11 | +// revisions: ast mir |
| 12 | +//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir |
| 13 | + |
| 14 | +struct S<X, Y> { |
| 15 | + x: X, |
| 16 | + y: Y, |
| 17 | +} |
| 18 | + |
| 19 | +fn main() { |
| 20 | + let x: &&Box<i32>; |
| 21 | + let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381] |
| 22 | + //[mir]~^ (Ast) [E0381] |
| 23 | + //[mir]~| (Mir) [E0381] |
| 24 | + |
| 25 | + let x: &&S<i32, i32>; |
| 26 | + let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381] |
| 27 | + //[mir]~^ (Ast) [E0381] |
| 28 | + //[mir]~| (Mir) [E0381] |
| 29 | + |
| 30 | + let x: &&i32; |
| 31 | + let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381] |
| 32 | + //[mir]~^ (Ast) [E0381] |
| 33 | + //[mir]~| (Mir) [E0381] |
| 34 | + |
| 35 | + |
| 36 | + let mut a: S<i32, i32>; |
| 37 | + a.x = 0; |
| 38 | + let _b = &a.x; //[ast]~ ERROR use of possibly uninitialized variable: `a.x` [E0381] |
| 39 | + //[mir]~^ ERROR (Ast) [E0381] |
| 40 | + // (deliberately *not* an error under MIR-borrowck) |
| 41 | + |
| 42 | + let mut a: S<&&i32, &&i32>; |
| 43 | + a.x = &&0; |
| 44 | + let _b = &**a.x; //[ast]~ ERROR use of possibly uninitialized variable: `**a.x` [E0381] |
| 45 | + //[mir]~^ ERROR (Ast) [E0381] |
| 46 | + // (deliberately *not* an error under MIR-borrowck) |
| 47 | + |
| 48 | + |
| 49 | + let mut a: S<i32, i32>; |
| 50 | + a.x = 0; |
| 51 | + let _b = &a.y; //[ast]~ ERROR use of possibly uninitialized variable: `a.y` [E0381] |
| 52 | + //[mir]~^ ERROR (Ast) [E0381] |
| 53 | + //[mir]~| ERROR (Mir) [E0381] |
| 54 | + |
| 55 | + let mut a: S<&&i32, &&i32>; |
| 56 | + a.x = &&0; |
| 57 | + let _b = &**a.y; //[ast]~ ERROR use of possibly uninitialized variable: `**a.y` [E0381] |
| 58 | + //[mir]~^ ERROR (Ast) [E0381] |
| 59 | + //[mir]~| ERROR (Mir) [E0381] |
| 60 | +} |
0 commit comments