Skip to content

Commit

Permalink
Update tests for -Zborrowck-mir -> -Zborrowck=mode migration
Browse files Browse the repository at this point in the history
  • Loading branch information
est31 committed Nov 26, 2017
1 parent c9af68e commit 755fa9c
Show file tree
Hide file tree
Showing 57 changed files with 194 additions and 320 deletions.
5 changes: 2 additions & 3 deletions src/test/compile-fail/E0506.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// except according to those terms.

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

struct FancyNum {
num: u8,
Expand All @@ -19,8 +19,7 @@ fn main() {
let mut fancy_num = FancyNum { num: 5 };
let fancy_ref = &fancy_num;
fancy_num = FancyNum { num: 6 }; //[ast]~ ERROR E0506
//[mir]~^ ERROR (Mir) [E0506]
//[mir]~| ERROR (Ast) [E0506]
//[mir]~^ ERROR [E0506]

println!("Num: {}, Ref: {}", fancy_num.num, fancy_ref.num);
}
7 changes: 3 additions & 4 deletions src/test/compile-fail/E0508.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
// except according to those terms.

// revisions: ast mir
//[mir]compile-flags: -Zborrowck-mir
//[mir]compile-flags: -Z borrowck=mir

struct NonCopy;

fn main() {
let array = [NonCopy; 1];
let _value = array[0]; //[ast]~ ERROR E0508
//[mir]~^ ERROR (Ast) [E0508]
//[mir]~| ERROR (Mir) [E0508]
let _value = array[0]; //[ast]~ ERROR [E0508]
//[mir]~^ ERROR [E0508]
}
5 changes: 2 additions & 3 deletions src/test/compile-fail/E0594.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
// except according to those terms.

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

static NUM: i32 = 18;

fn main() {
NUM = 20; //[ast]~ ERROR E0594
//[mir]~^ ERROR cannot assign to immutable static item (Ast)
//[mir]~| ERROR cannot assign to immutable static item `NUM` (Mir)
//[mir]~^ ERROR cannot assign to immutable static item
}
5 changes: 2 additions & 3 deletions src/test/compile-fail/E0596.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@
// except according to those terms.

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

fn main() {
let x = 1;
let y = &mut x; //[ast]~ ERROR [E0596]
//[mir]~^ ERROR (Ast) [E0596]
//[mir]~| ERROR (Mir) [E0596]
//[mir]~^ ERROR [E0596]
}
22 changes: 8 additions & 14 deletions src/test/compile-fail/borrowck/borrowck-access-permissions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// except according to those terms.

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

static static_x : i32 = 1;
static mut static_x_mut : i32 = 1;
Expand All @@ -20,15 +20,13 @@ fn main() {

{ // borrow of local
let _y1 = &mut x; //[ast]~ ERROR [E0596]
//[mir]~^ ERROR (Ast) [E0596]
//[mir]~| ERROR (Mir) [E0596]
//[mir]~^ ERROR [E0596]
let _y2 = &mut x_mut; // No error
}

{ // borrow of static
let _y1 = &mut static_x; //[ast]~ ERROR [E0596]
//[mir]~^ ERROR (Ast) [E0596]
//[mir]~| ERROR (Mir) [E0596]
//[mir]~^ ERROR [E0596]
unsafe { let _y2 = &mut static_x_mut; } // No error
}

Expand All @@ -37,8 +35,7 @@ fn main() {
let mut box_x_mut = Box::new(1);

let _y1 = &mut *box_x; //[ast]~ ERROR [E0596]
//[mir]~^ ERROR (Ast) [E0596]
//[mir]~| ERROR (Mir) [E0596]
//[mir]~^ ERROR [E0596]
let _y2 = &mut *box_x_mut; // No error
}

Expand All @@ -47,8 +44,7 @@ fn main() {
let ref_x_mut = &mut x_mut;

let _y1 = &mut *ref_x; //[ast]~ ERROR [E0596]
//[mir]~^ ERROR (Ast) [E0596]
//[mir]~| ERROR (Mir) [E0596]
//[mir]~^ ERROR [E0596]
let _y2 = &mut *ref_x_mut; // No error
}

Expand All @@ -58,8 +54,7 @@ fn main() {

unsafe {
let _y1 = &mut *ptr_x; //[ast]~ ERROR [E0596]
//[mir]~^ ERROR (Ast) [E0596]
//[mir]~| ERROR (Mir) [E0596]
//[mir]~^ ERROR [E0596]
let _y2 = &mut *ptr_mut_x; // No error
}
}
Expand All @@ -69,8 +64,7 @@ fn main() {
let mut foo = Foo { f: &mut x_mut, g: &x };
let foo_ref = &foo;
let _y = &mut *foo_ref.f; //[ast]~ ERROR [E0389]
//[mir]~^ ERROR (Ast) [E0389]
//[mir]~| ERROR (Mir) [E0596]
// FIXME: Wrong error in MIR
//[mir]~^ ERROR [E0596]
// FIXME: Wrong error in MIR
}
}
11 changes: 4 additions & 7 deletions src/test/compile-fail/borrowck/borrowck-assign-comp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// except according to those terms.

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

struct point { x: isize, y: isize }

Expand All @@ -21,8 +21,7 @@ fn a() {
// inherently mutable; since `p` was made immutable, `p.x` is now
// immutable. Otherwise the type of &_q.x (&isize) would be wrong.
p.x = 5; //[ast]~ ERROR cannot assign to `p.x`
//[mir]~^ ERROR cannot assign to `p.x` because it is borrowed (Ast)
//[mir]~| ERROR cannot assign to `p.x` because it is borrowed (Mir)
//[mir]~^ ERROR cannot assign to `p.x` because it is borrowed
q.x;
}

Expand All @@ -33,8 +32,7 @@ fn c() {
let mut p = point {x: 3, y: 4};
let q = &p.y;
p = point {x: 5, y: 7};//[ast]~ ERROR cannot assign to `p`
//[mir]~^ ERROR cannot assign to `p` because it is borrowed (Ast)
//[mir]~| ERROR cannot assign to `p` because it is borrowed (Mir)
//[mir]~^ ERROR cannot assign to `p` because it is borrowed
p.x; // silence warning
*q; // stretch loan
}
Expand All @@ -46,8 +44,7 @@ fn d() {
let mut p = point {x: 3, y: 4};
let q = &p.y;
p.y = 5; //[ast]~ ERROR cannot assign to `p.y`
//[mir]~^ ERROR cannot assign to `p.y` because it is borrowed (Ast)
//[mir]~| ERROR cannot assign to `p.y` because it is borrowed (Mir)
//[mir]~^ ERROR cannot assign to `p.y` because it is borrowed
*q;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
// except according to those terms.

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

static foo: isize = 5;

fn main() {
// assigning to various global constants
foo = 6; //[ast]~ ERROR cannot assign to immutable static item
//[mir]~^ ERROR cannot assign to immutable static item (Ast)
//[mir]~| ERROR cannot assign to immutable static item `foo` (Mir)
//[mir]~^ ERROR cannot assign to immutable static item `foo`
}
28 changes: 10 additions & 18 deletions src/test/compile-fail/borrowck/borrowck-closures-mut-and-imm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

// ignore-tidy-linelength
// revisions: ast mir
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
//[mir]compile-flags: -Z borrowck=mir

#![feature(box_syntax)]

Expand All @@ -29,48 +29,42 @@ fn a() {
let mut x = 3;
let c1 = || x = 4;
let c2 = || x * 5; //[ast]~ ERROR cannot borrow `x`
//[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable (Ast)
//[mir]~| ERROR cannot borrow `x` as immutable because it is also borrowed as mutable (Mir)
//[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable
}

fn b() {
let mut x = 3;
let c1 = || set(&mut x);
let c2 = || get(&x); //[ast]~ ERROR cannot borrow `x`
//[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable (Ast)
//[mir]~| ERROR cannot borrow `x` as immutable because it is also borrowed as mutable (Mir)
//[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable
}

fn c() {
let mut x = 3;
let c1 = || set(&mut x);
let c2 = || x * 5; //[ast]~ ERROR cannot borrow `x`
//[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable (Ast)
//[mir]~| ERROR cannot borrow `x` as immutable because it is also borrowed as mutable (Mir)
//[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable
}

fn d() {
let mut x = 3;
let c2 = || x * 5;
x = 5; //[ast]~ ERROR cannot assign
//[mir]~^ ERROR cannot assign to `x` because it is borrowed (Ast)
//[mir]~| ERROR cannot assign to `x` because it is borrowed (Mir)
//[mir]~^ ERROR cannot assign to `x` because it is borrowed
}

fn e() {
let mut x = 3;
let c1 = || get(&x);
x = 5; //[ast]~ ERROR cannot assign
//[mir]~^ ERROR cannot assign to `x` because it is borrowed (Ast)
//[mir]~| ERROR cannot assign to `x` because it is borrowed (Mir)
//[mir]~^ ERROR cannot assign to `x` because it is borrowed
}

fn f() {
let mut x: Box<_> = box 3;
let c1 = || get(&*x);
*x = 5; //[ast]~ ERROR cannot assign
//[mir]~^ ERROR cannot assign to `*x` because it is borrowed (Ast)
//[mir]~| ERROR cannot assign to `*x` because it is borrowed (Mir)
*x = 5; //[ast]~ ERROR cannot assign to `*x`
//[mir]~^ ERROR cannot assign to `*x` because it is borrowed
}

fn g() {
Expand All @@ -81,8 +75,7 @@ fn g() {
let mut x: Box<_> = box Foo { f: box 3 };
let c1 = || get(&*x.f);
*x.f = 5; //[ast]~ ERROR cannot assign to `*x.f`
//[mir]~^ ERROR cannot assign to `*x.f` because it is borrowed (Ast)
//[mir]~| ERROR cannot assign to `*x.f` because it is borrowed (Mir)
//[mir]~^ ERROR cannot assign to `*x.f` because it is borrowed
}

fn h() {
Expand All @@ -93,8 +86,7 @@ fn h() {
let mut x: Box<_> = box Foo { f: box 3 };
let c1 = || get(&*x.f);
let c2 = || *x.f = 5; //[ast]~ ERROR cannot borrow `x` as mutable
//[mir]~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable (Ast)
//[mir]~| ERROR cannot borrow `x` as mutable because it is also borrowed as immutable (Mir)
//[mir]~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable
}

fn main() {
Expand Down
Loading

0 comments on commit 755fa9c

Please sign in to comment.