Skip to content

Commit

Permalink
Added revisions: ast mir template to tests that this PR sync'ed ast…
Browse files Browse the repository at this point in the history
…+mir borrowcks.

(There are other tests that this PR also improves, but were not
completely synchronized. I chose to wait until later to pull those
into the `revisions: ast mir` testing pattern; later being either when
they *are* synchronized, or in some PR where we migrate all borrowck
tests, regardless of whether MIR-borrowck is "finished" for them or
not.)
  • Loading branch information
pnkfelix committed Oct 11, 2017
1 parent b62b67a commit d6caf73
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
8 changes: 7 additions & 1 deletion src/test/compile-fail/borrowck/borrowck-init-in-fru.rs
Expand Up @@ -8,6 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// revisions: ast mir
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir

#[derive(Clone)]
struct point {
x: isize,
Expand All @@ -16,6 +19,9 @@ struct point {

fn main() {
let mut origin: point;
origin = point {x: 10,.. origin}; //~ ERROR use of possibly uninitialized variable: `origin.y`
origin = point {x: 10,.. origin};
//[ast]~^ ERROR use of possibly uninitialized variable: `origin.y` [E0381]
//[mir]~^^ ERROR (Ast) [E0381]
//[mir]~| ERROR (Mir) [E0381]
origin.clone();
}
11 changes: 9 additions & 2 deletions src/test/compile-fail/borrowck/borrowck-use-in-index-lvalue.rs
Expand Up @@ -8,12 +8,19 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// revisions: ast mir
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir

fn test() {
let w: &mut [isize];
w[5] = 0; //~ ERROR use of possibly uninitialized variable: `*w`
w[5] = 0; //[ast]~ ERROR use of possibly uninitialized variable: `*w` [E0381]
//[mir]~^ ERROR (Ast) [E0381]
//[mir]~| ERROR (Mir) [E0381]

let mut w: &mut [isize];
w[5] = 0; //~ ERROR use of possibly uninitialized variable: `*w`
w[5] = 0; //[ast]~ ERROR use of possibly uninitialized variable: `*w` [E0381]
//[mir]~^ ERROR (Ast) [E0381]
//[mir]~| ERROR (Mir) [E0381]
}

fn main() { test(); }
Expand Up @@ -8,6 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// revisions: ast mir
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir

// Variation on `borrowck-use-uninitialized-in-cast` in which we do a
// trait cast from an uninitialized source. Issue #20791.

Expand All @@ -16,5 +19,7 @@ impl Foo for i32 { }

fn main() {
let x: &i32;
let y = x as *const Foo; //~ ERROR use of possibly uninitialized variable: `*x`
let y = x as *const Foo; //[ast]~ ERROR use of possibly uninitialized variable: `*x`
//[mir]~^ ERROR (Ast) [E0381]
//[mir]~| ERROR (Mir) [E0381]
}
Expand Up @@ -8,11 +8,16 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// revisions: ast mir
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir

// Check that we detect unused values that are cast to other things.
// The problem was specified to casting to `*`, as creating unsafe
// pointers was not being fully checked. Issue #20791.

fn main() {
let x: &i32;
let y = x as *const i32; //~ ERROR use of possibly uninitialized variable: `*x`
let y = x as *const i32; //[ast]~ ERROR use of possibly uninitialized variable: `*x` [E0381]
//[mir]~^ ERROR (Ast) [E0381]
//[mir]~| ERROR (Mir) [E0381]
}

0 comments on commit d6caf73

Please sign in to comment.