Skip to content

Commit

Permalink
Some new tests I added.
Browse files Browse the repository at this point in the history
  • Loading branch information
pnkfelix committed Oct 17, 2018
1 parent 5b74843 commit 233fdb4
Show file tree
Hide file tree
Showing 16 changed files with 1,308 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
error[E0381]: use of possibly uninitialized variable: `t.0`
--> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:25:31
|
LL | println!("{:?} {:?}", t.0, t.1);
| ^^^ use of possibly uninitialized `t.0`

error[E0381]: use of possibly uninitialized variable: `t.1`
--> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:25:36
|
LL | println!("{:?} {:?}", t.0, t.1);
| ^^^ use of possibly uninitialized `t.1`

error[E0381]: use of possibly uninitialized variable: `u.0`
--> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:35:31
|
LL | println!("{:?} {:?}", u.0, u.1);
| ^^^ use of possibly uninitialized `u.0`

error[E0381]: use of possibly uninitialized variable: `u.1`
--> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:35:36
|
LL | println!("{:?} {:?}", u.0, u.1);
| ^^^ use of possibly uninitialized `u.1`

error[E0381]: use of possibly uninitialized variable: `v.x`
--> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:45:31
|
LL | println!("{:?} {:?}", v.x, v.y);
| ^^^ use of possibly uninitialized `v.x`

error[E0381]: use of possibly uninitialized variable: `v.y`
--> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:45:36
|
LL | println!("{:?} {:?}", v.x, v.y);
| ^^^ use of possibly uninitialized `v.y`

error: aborting due to 6 previous errors

For more information about this error, try `rustc --explain E0381`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
error[E0381]: assign to part of possibly uninitialized variable: `t`
--> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:22:9
|
LL | t.0 = S(1);
| ^^^^^^^^^^ use of possibly uninitialized `t`

error[E0381]: assign to part of possibly uninitialized variable: `u`
--> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:32:9
|
LL | u.0 = S(1);
| ^^^^^^^^^^ use of possibly uninitialized `u`

error[E0381]: assign to part of possibly uninitialized variable: `v`
--> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:42:9
|
LL | v.x = S(1);
| ^^^^^^^^^^ use of possibly uninitialized `v`

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0381`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// revisions: ast nll

// Since we are testing nll migration explicitly as a separate
// revision, don't worry about the --compare-mode=nll on this test.

// ignore-compare-mode-nll

//[ast]compile-flags: -Z borrowck=ast
//[nll]compile-flags: -Z borrowck=migrate -Z two-phase-borrows

#![warn(unused)]
#[derive(Debug)]
struct S(i32);

type Tuple = (S, i32);
struct Tpair(S, i32);
struct Spair { x: S, y: i32 }

fn main() {
{
let mut t: Tuple;
t.0 = S(1);
//[nll]~^ ERROR assign to part of possibly uninitialized variable: `t` [E0381]
t.1 = 2;
println!("{:?} {:?}", t.0, t.1);
//[ast]~^ ERROR use of possibly uninitialized variable: `t.0` [E0381]
//[ast]~| ERROR use of possibly uninitialized variable: `t.1` [E0381]
}

{
let mut u: Tpair;
u.0 = S(1);
//[nll]~^ ERROR assign to part of possibly uninitialized variable: `u` [E0381]
u.1 = 2;
println!("{:?} {:?}", u.0, u.1);
//[ast]~^ ERROR use of possibly uninitialized variable: `u.0` [E0381]
//[ast]~| ERROR use of possibly uninitialized variable: `u.1` [E0381]
}

{
let mut v: Spair;
v.x = S(1);
//[nll]~^ ERROR assign to part of possibly uninitialized variable: `v` [E0381]
v.y = 2;
println!("{:?} {:?}", v.x, v.y);
//[ast]~^ ERROR use of possibly uninitialized variable: `v.x` [E0381]
//[ast]~| ERROR use of possibly uninitialized variable: `v.y` [E0381]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
error[E0382]: use of moved value: `t.0`
--> $DIR/issue-54499-field-mutation-of-moved-out-with-mut.rs:25:31
|
LL | drop(t);
| - value moved here
...
LL | println!("{:?} {:?}", t.0, t.1);
| ^^^ value used here after move
|
= note: move occurs because `t` has type `(S, i32)`, which does not implement the `Copy` trait

error[E0382]: use of moved value: `t.1`
--> $DIR/issue-54499-field-mutation-of-moved-out-with-mut.rs:25:36
|
LL | drop(t);
| - value moved here
...
LL | println!("{:?} {:?}", t.0, t.1);
| ^^^ value used here after move
|
= note: move occurs because `t` has type `(S, i32)`, which does not implement the `Copy` trait

error[E0382]: use of moved value: `u.0`
--> $DIR/issue-54499-field-mutation-of-moved-out-with-mut.rs:33:31
|
LL | drop(u);
| - value moved here
...
LL | println!("{:?} {:?}", u.0, u.1);
| ^^^ value used here after move
|
= note: move occurs because `u` has type `Tpair`, which does not implement the `Copy` trait

error[E0382]: use of moved value: `u.1`
--> $DIR/issue-54499-field-mutation-of-moved-out-with-mut.rs:33:36
|
LL | drop(u);
| - value moved here
...
LL | println!("{:?} {:?}", u.0, u.1);
| ^^^ value used here after move
|
= note: move occurs because `u` has type `Tpair`, which does not implement the `Copy` trait

error[E0382]: use of moved value: `v.x`
--> $DIR/issue-54499-field-mutation-of-moved-out-with-mut.rs:41:31
|
LL | drop(v);
| - value moved here
...
LL | println!("{:?} {:?}", v.x, v.y);
| ^^^ value used here after move
|
= note: move occurs because `v` has type `Spair`, which does not implement the `Copy` trait

error[E0382]: use of moved value: `v.y`
--> $DIR/issue-54499-field-mutation-of-moved-out-with-mut.rs:41:36
|
LL | drop(v);
| - value moved here
...
LL | println!("{:?} {:?}", v.x, v.y);
| ^^^ value used here after move
|
= note: move occurs because `v` has type `Spair`, which does not implement the `Copy` trait

error: aborting due to 6 previous errors

For more information about this error, try `rustc --explain E0382`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
error[E0382]: assign to part of moved value: `t`
--> $DIR/issue-54499-field-mutation-of-moved-out-with-mut.rs:23:9
|
LL | drop(t);
| - value moved here
LL | t.0 = S(1);
| ^^^^^^^^^^ value partially assigned here after move
|
= note: move occurs because `t` has type `(S, i32)`, which does not implement the `Copy` trait

error[E0382]: assign to part of moved value: `u`
--> $DIR/issue-54499-field-mutation-of-moved-out-with-mut.rs:31:9
|
LL | drop(u);
| - value moved here
LL | u.0 = S(1);
| ^^^^^^^^^^ value partially assigned here after move
|
= note: move occurs because `u` has type `Tpair`, which does not implement the `Copy` trait

error[E0382]: assign to part of moved value: `v`
--> $DIR/issue-54499-field-mutation-of-moved-out-with-mut.rs:39:9
|
LL | drop(v);
| - value moved here
LL | v.x = S(1);
| ^^^^^^^^^^ value partially assigned here after move
|
= note: move occurs because `v` has type `Spair`, which does not implement the `Copy` trait

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0382`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// revisions: ast nll

// Since we are testing nll migration explicitly as a separate
// revision, don't worry about the --compare-mode=nll on this test.

// ignore-compare-mode-nll

//[ast]compile-flags: -Z borrowck=ast
//[nll]compile-flags: -Z borrowck=migrate -Z two-phase-borrows

#![warn(unused)]
#[derive(Debug)]
struct S(i32);

type Tuple = (S, i32);
struct Tpair(S, i32);
struct Spair { x: S, y: i32 }

fn main() {
{
let mut t: Tuple = (S(0), 0);
drop(t);
t.0 = S(1);
t.1 = 2;
println!("{:?} {:?}", t.0, t.1);
}

{
let mut u: Tpair = Tpair(S(0), 0);
drop(u);
u.0 = S(1);
u.1 = 2;
println!("{:?} {:?}", u.0, u.1);
}

{
let mut v: Spair = Spair { x: S(0), y: 0 };
drop(v);
v.x = S(1);
v.y = 2;
println!("{:?} {:?}", v.x, v.y);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
error[E0594]: cannot assign to field `t.0` of immutable binding
--> $DIR/issue-54499-field-mutation-of-moved-out.rs:23:9
|
LL | let t: Tuple = (S(0), 0);
| - help: make this binding mutable: `mut t`
LL | drop(t);
LL | t.0 = S(1);
| ^^^^^^^^^^ cannot mutably borrow field of immutable binding

error[E0594]: cannot assign to field `t.1` of immutable binding
--> $DIR/issue-54499-field-mutation-of-moved-out.rs:27:9
|
LL | let t: Tuple = (S(0), 0);
| - help: make this binding mutable: `mut t`
...
LL | t.1 = 2;
| ^^^^^^^ cannot mutably borrow field of immutable binding

error[E0594]: cannot assign to field `u.0` of immutable binding
--> $DIR/issue-54499-field-mutation-of-moved-out.rs:38:9
|
LL | let u: Tpair = Tpair(S(0), 0);
| - help: make this binding mutable: `mut u`
LL | drop(u);
LL | u.0 = S(1);
| ^^^^^^^^^^ cannot mutably borrow field of immutable binding

error[E0594]: cannot assign to field `u.1` of immutable binding
--> $DIR/issue-54499-field-mutation-of-moved-out.rs:42:9
|
LL | let u: Tpair = Tpair(S(0), 0);
| - help: make this binding mutable: `mut u`
...
LL | u.1 = 2;
| ^^^^^^^ cannot mutably borrow field of immutable binding

error[E0594]: cannot assign to field `v.x` of immutable binding
--> $DIR/issue-54499-field-mutation-of-moved-out.rs:53:9
|
LL | let v: Spair = Spair { x: S(0), y: 0 };
| - help: make this binding mutable: `mut v`
LL | drop(v);
LL | v.x = S(1);
| ^^^^^^^^^^ cannot mutably borrow field of immutable binding

error[E0594]: cannot assign to field `v.y` of immutable binding
--> $DIR/issue-54499-field-mutation-of-moved-out.rs:57:9
|
LL | let v: Spair = Spair { x: S(0), y: 0 };
| - help: make this binding mutable: `mut v`
...
LL | v.y = 2;
| ^^^^^^^ cannot mutably borrow field of immutable binding

error[E0382]: use of moved value: `t.0`
--> $DIR/issue-54499-field-mutation-of-moved-out.rs:30:31
|
LL | drop(t);
| - value moved here
...
LL | println!("{:?} {:?}", t.0, t.1);
| ^^^ value used here after move
|
= note: move occurs because `t` has type `(S, i32)`, which does not implement the `Copy` trait

error[E0382]: use of moved value: `t.1`
--> $DIR/issue-54499-field-mutation-of-moved-out.rs:30:36
|
LL | drop(t);
| - value moved here
...
LL | println!("{:?} {:?}", t.0, t.1);
| ^^^ value used here after move
|
= note: move occurs because `t` has type `(S, i32)`, which does not implement the `Copy` trait

error[E0382]: use of moved value: `u.0`
--> $DIR/issue-54499-field-mutation-of-moved-out.rs:45:31
|
LL | drop(u);
| - value moved here
...
LL | println!("{:?} {:?}", u.0, u.1);
| ^^^ value used here after move
|
= note: move occurs because `u` has type `Tpair`, which does not implement the `Copy` trait

error[E0382]: use of moved value: `u.1`
--> $DIR/issue-54499-field-mutation-of-moved-out.rs:45:36
|
LL | drop(u);
| - value moved here
...
LL | println!("{:?} {:?}", u.0, u.1);
| ^^^ value used here after move
|
= note: move occurs because `u` has type `Tpair`, which does not implement the `Copy` trait

error[E0382]: use of moved value: `v.x`
--> $DIR/issue-54499-field-mutation-of-moved-out.rs:60:31
|
LL | drop(v);
| - value moved here
...
LL | println!("{:?} {:?}", v.x, v.y);
| ^^^ value used here after move
|
= note: move occurs because `v` has type `Spair`, which does not implement the `Copy` trait

error[E0382]: use of moved value: `v.y`
--> $DIR/issue-54499-field-mutation-of-moved-out.rs:60:36
|
LL | drop(v);
| - value moved here
...
LL | println!("{:?} {:?}", v.x, v.y);
| ^^^ value used here after move
|
= note: move occurs because `v` has type `Spair`, which does not implement the `Copy` trait

error: aborting due to 12 previous errors

Some errors occurred: E0382, E0594.
For more information about an error, try `rustc --explain E0382`.

0 comments on commit 233fdb4

Please sign in to comment.