Skip to content

Commit d64a318

Browse files
committed
Update tests involving E0384 for mir-borrowck
1 parent 6853b34 commit d64a318

5 files changed

+60
-11
lines changed

src/test/compile-fail/assign-imm-local-twice.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,18 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// revisions: ast mir
12+
//[mir]compile-flags: -Zborrowck=mir
13+
1114
fn test() {
1215
let v: isize;
13-
v = 1; //~ NOTE first assignment
16+
v = 1; //[ast]~ NOTE first assignment
17+
//[mir]~^ NOTE first assignment
1418
println!("v={}", v);
15-
v = 2; //~ ERROR cannot assign twice to immutable variable
16-
//~| NOTE cannot assign twice to immutable
19+
v = 2; //[ast]~ ERROR cannot assign twice to immutable variable
20+
//[mir]~^ ERROR cannot assign twice to immutable variable `v`
21+
//[ast]~| NOTE cannot assign twice to immutable
22+
//[mir]~| NOTE cannot assign twice to immutable
1723
println!("v={}", v);
1824
}
1925

src/test/compile-fail/liveness-assign-imm-local-in-loop.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,16 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// revisions: ast mir
12+
//[mir]compile-flags: -Zborrowck=mir
13+
1114
fn test() {
1215
let v: isize;
1316
loop {
14-
v = 1; //~ ERROR cannot assign twice to immutable variable
15-
//~^ NOTE cannot assign twice to immutable variable
17+
v = 1; //[ast]~ ERROR cannot assign twice to immutable variable
18+
//[mir]~^ ERROR cannot assign twice to immutable variable `v`
19+
//[ast]~| NOTE cannot assign twice to immutable variable
20+
//[mir]~| NOTE cannot assign twice to immutable variable
1621
v.clone(); // just to prevent liveness warnings
1722
}
1823
}

src/test/compile-fail/liveness-assign-imm-local-in-op-eq.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,17 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// revisions: ast mir
12+
//[mir]compile-flags: -Zborrowck=mir
13+
1114
fn test() {
1215
let v: isize;
13-
v = 2; //~ NOTE first assignment
14-
v += 1; //~ ERROR cannot assign twice to immutable variable
15-
//~| NOTE cannot assign twice to immutable
16+
v = 2; //[ast]~ NOTE first assignment
17+
//[mir]~^ NOTE first assignment
18+
v += 1; //[ast]~ ERROR cannot assign twice to immutable variable
19+
//[mir]~^ ERROR cannot assign twice to immutable variable `v`
20+
//[ast]~| NOTE cannot assign twice to immutable
21+
//[mir]~| NOTE cannot assign twice to immutable
1622
v.clone();
1723
}
1824

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2012 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: -Zborrowck=mir
13+
14+
fn test() {
15+
let b = Box::new(1); //[ast]~ NOTE first assignment
16+
//[mir]~^ NOTE first assignment
17+
drop(b);
18+
b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable
19+
//[mir]~^ ERROR cannot assign twice to immutable variable `b`
20+
//[ast]~| NOTE cannot assign twice to immutable
21+
//[mir]~| NOTE cannot assign twice to immutable
22+
drop(b);
23+
}
24+
25+
fn main() {
26+
}

src/test/compile-fail/liveness-assign-imm-local-with-init.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,17 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// revisions: ast mir
12+
//[mir]compile-flags: -Zborrowck=mir
13+
1114
fn test() {
12-
let v: isize = 1; //~ NOTE first assignment
15+
let v: isize = 1; //[ast]~ NOTE first assignment
16+
//[mir]~^ NOTE first assignment
1317
v.clone();
14-
v = 2; //~ ERROR cannot assign twice to immutable variable
15-
//~| NOTE cannot assign twice to immutable
18+
v = 2; //[ast]~ ERROR cannot assign twice to immutable variable
19+
//[mir]~^ ERROR cannot assign twice to immutable variable `v`
20+
//[ast]~| NOTE cannot assign twice to immutable
21+
//[mir]~| NOTE cannot assign twice to immutable
1622
v.clone();
1723
}
1824

0 commit comments

Comments
 (0)