Skip to content

Commit 0f7a86b

Browse files
committed
cleaned up some tests
1 parent 7f2e37f commit 0f7a86b

12 files changed

+36
-22
lines changed

tests/ui/binop/compound-assign-by-ref.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1+
//! Test compound assignment operators with reference right-hand side.
2+
13
//@ run-pass
24

35
fn main() {
4-
// test compound assignment operators with ref as right-hand side,
5-
// for each operator, with various types as operands.
6-
76
// test AddAssign
87
{
98
let mut x = 3i8;

tests/ui/closures/fnonce-call-twice-error.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
// Testing guarantees provided by once functions.
2-
// This program would segfault if it were legal.
1+
//! Test that `FnOnce` closures cannot be called twice.
32
43
use std::sync::Arc;
54

6-
fn foo<F:FnOnce()>(blk: F) {
5+
fn foo<F: FnOnce()>(blk: F) {
76
blk();
87
blk(); //~ ERROR use of moved value
98
}
109

1110
fn main() {
1211
let x = Arc::new(true);
13-
foo(move|| {
12+
foo(move || {
1413
assert!(*x);
1514
drop(x);
1615
});

tests/ui/closures/fnonce-call-twice-error.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
error[E0382]: use of moved value: `blk`
2-
--> $DIR/once-cant-call-twice-on-heap.rs:8:5
2+
--> $DIR/fnonce-call-twice-error.rs:7:5
33
|
4-
LL | fn foo<F:FnOnce()>(blk: F) {
5-
| --- move occurs because `blk` has type `F`, which does not implement the `Copy` trait
4+
LL | fn foo<F: FnOnce()>(blk: F) {
5+
| --- move occurs because `blk` has type `F`, which does not implement the `Copy` trait
66
LL | blk();
77
| ----- `blk` moved due to this call
88
LL | blk();
99
| ^^^ value used here after move
1010
|
1111
note: `FnOnce` closures can only be called once
12-
--> $DIR/once-cant-call-twice-on-heap.rs:6:10
12+
--> $DIR/fnonce-call-twice-error.rs:5:11
1313
|
14-
LL | fn foo<F:FnOnce()>(blk: F) {
15-
| ^^^^^^^^ `F` is made to be an `FnOnce` closure here
14+
LL | fn foo<F: FnOnce()>(blk: F) {
15+
| ^^^^^^^^ `F` is made to be an `FnOnce` closure here
1616
LL | blk();
1717
| ----- this value implements `FnOnce`, which causes it to be moved when called
1818

tests/ui/panics/oom-panic-unwind.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Test that out-of-memory conditions trigger catchable panics with `-Z oom=panic`.
2+
13
//@ compile-flags: -Z oom=panic
24
//@ run-pass
35
//@ no-prefer-dynamic

tests/ui/traits/copy-requires-all-fields-copy.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Test that `Copy` cannot be implemented if any field doesn't implement `Copy`.
2+
13
struct CantCopyThis;
24

35
struct IWantToCopyThis {

tests/ui/traits/copy-requires-all-fields-copy.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0204]: the trait `Copy` cannot be implemented for this type
2-
--> $DIR/opt-in-copy.rs:7:15
2+
--> $DIR/copy-requires-all-fields-copy.rs:9:15
33
|
44
LL | but_i_cant: CantCopyThis,
55
| ------------------------ this field does not implement `Copy`
@@ -8,7 +8,7 @@ LL | impl Copy for IWantToCopyThis {}
88
| ^^^^^^^^^^^^^^^
99

1010
error[E0204]: the trait `Copy` cannot be implemented for this type
11-
--> $DIR/opt-in-copy.rs:19:15
11+
--> $DIR/copy-requires-all-fields-copy.rs:21:15
1212
|
1313
LL | ButICant(CantCopyThisEither),
1414
| ------------------ this field does not implement `Copy`

tests/ui/type-inference/direct-self-reference-occurs-check.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
//! Test that occurs check prevents direct self-reference in variable assignment.
2+
//!
3+
//! Regression test for <https://github.com/rust-lang/rust/issues/768>.
4+
15
fn main() {
26
let f;
37
f = Box::new(f);

tests/ui/type-inference/direct-self-reference-occurs-check.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0275]: overflow assigning `Box<_>` to `_`
2-
--> $DIR/occurs-check.rs:3:18
2+
--> $DIR/direct-self-reference-occurs-check.rs:7:18
33
|
44
LL | f = Box::new(f);
55
| ^
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1-
// From Issue #778
1+
//! Test that occurs check prevents infinite types with enum self-references.
2+
//!
3+
//! Regression test for <https://github.com/rust-lang/rust/issues/778>.
4+
5+
enum Clam<T> {
6+
A(T),
7+
}
28

3-
enum Clam<T> { A(T) }
49
fn main() {
510
let c;
611
c = Clam::A(c);
712
//~^ ERROR overflow assigning `Clam<_>` to `_`
813
match c {
9-
Clam::A::<isize>(_) => { }
14+
Clam::A::<isize>(_) => {}
1015
}
1116
}

tests/ui/type-inference/enum-self-reference-occurs-check.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0275]: overflow assigning `Clam<_>` to `_`
2-
--> $DIR/occurs-check-3.rs:6:17
2+
--> $DIR/enum-self-reference-occurs-check.rs:11:17
33
|
44
LL | c = Clam::A(c);
55
| ^

0 commit comments

Comments
 (0)