Skip to content

Commit b28806d

Browse files
committed
cleaned up some tests
1 parent 986f1c9 commit b28806d

19 files changed

+168
-108
lines changed

tests/ui/allocator/allocator-reallocate-overflow.rs renamed to tests/ui/allocator/alloc-shrink-oob-read.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1+
//! Sanity check for out-of-bounds read caused by copying the entire original buffer on shrink.
2+
//!
3+
//! Regression test for: <https://github.com/rust-lang/rust/issues/16687>
4+
15
//@ run-pass
2-
// alloc::heap::reallocate test.
3-
//
4-
// Ideally this would be revised to use no_std, but for now it serves
5-
// well enough to reproduce (and illustrate) the bug from #16687.
66

77
#![feature(allocator_api)]
88
#![feature(slice_ptr_get)]
99

10-
use std::alloc::{handle_alloc_error, Allocator, Global, Layout};
10+
use std::alloc::{Allocator, Global, Layout, handle_alloc_error};
1111
use std::ptr::{self, NonNull};
1212

1313
fn main() {

tests/ui/auto-traits/auto-trait-phantom-data-bounds.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
// Ensure that auto trait checks `T` when it encounters a `PhantomData<T>` field, instead of
2-
// checking the `PhantomData<T>` type itself (which almost always implements an auto trait).
1+
//! Ensure that auto trait checks `T` when it encounters a `PhantomData<T>` field, instead of
2+
//! checking the `PhantomData<T>` type itself (which almost always implements an auto trait).
33
44
#![feature(auto_traits)]
55

6-
use std::marker::{PhantomData};
6+
use std::marker::PhantomData;
77

88
unsafe auto trait Zen {}
99

tests/ui/auto-traits/auto-trait-phantom-data-bounds.stderr

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
error[E0277]: `T` cannot be shared between threads safely
2-
--> $DIR/phantom-auto-trait.rs:21:12
2+
--> $DIR/auto-trait-phantom-data-bounds.rs:21:12
33
|
44
LL | is_zen(x)
55
| ------ ^ `T` cannot be shared between threads safely
66
| |
77
| required by a bound introduced by this call
88
|
99
note: required for `&T` to implement `Zen`
10-
--> $DIR/phantom-auto-trait.rs:10:24
10+
--> $DIR/auto-trait-phantom-data-bounds.rs:10:24
1111
|
1212
LL | unsafe impl<'a, T: 'a> Zen for &'a T where T: Sync {}
1313
| ^^^ ^^^^^ ---- unsatisfied trait bound introduced here
1414
note: required because it appears within the type `PhantomData<&T>`
1515
--> $SRC_DIR/core/src/marker.rs:LL:COL
1616
note: required because it appears within the type `Guard<'_, T>`
17-
--> $DIR/phantom-auto-trait.rs:12:8
17+
--> $DIR/auto-trait-phantom-data-bounds.rs:12:8
1818
|
1919
LL | struct Guard<'a, T: 'a> {
2020
| ^^^^^
2121
note: required by a bound in `is_zen`
22-
--> $DIR/phantom-auto-trait.rs:18:14
22+
--> $DIR/auto-trait-phantom-data-bounds.rs:18:14
2323
|
2424
LL | fn is_zen<T: Zen>(_: T) {}
2525
| ^^^ required by this bound in `is_zen`
@@ -29,32 +29,32 @@ LL | fn not_sync<T: std::marker::Sync>(x: Guard<T>) {
2929
| +++++++++++++++++++
3030

3131
error[E0277]: `T` cannot be shared between threads safely
32-
--> $DIR/phantom-auto-trait.rs:26:12
32+
--> $DIR/auto-trait-phantom-data-bounds.rs:26:12
3333
|
3434
LL | is_zen(x)
3535
| ------ ^ `T` cannot be shared between threads safely
3636
| |
3737
| required by a bound introduced by this call
3838
|
3939
note: required for `&T` to implement `Zen`
40-
--> $DIR/phantom-auto-trait.rs:10:24
40+
--> $DIR/auto-trait-phantom-data-bounds.rs:10:24
4141
|
4242
LL | unsafe impl<'a, T: 'a> Zen for &'a T where T: Sync {}
4343
| ^^^ ^^^^^ ---- unsatisfied trait bound introduced here
4444
note: required because it appears within the type `PhantomData<&T>`
4545
--> $SRC_DIR/core/src/marker.rs:LL:COL
4646
note: required because it appears within the type `Guard<'_, T>`
47-
--> $DIR/phantom-auto-trait.rs:12:8
47+
--> $DIR/auto-trait-phantom-data-bounds.rs:12:8
4848
|
4949
LL | struct Guard<'a, T: 'a> {
5050
| ^^^^^
5151
note: required because it appears within the type `Nested<Guard<'_, T>>`
52-
--> $DIR/phantom-auto-trait.rs:16:8
52+
--> $DIR/auto-trait-phantom-data-bounds.rs:16:8
5353
|
5454
LL | struct Nested<T>(T);
5555
| ^^^^^^
5656
note: required by a bound in `is_zen`
57-
--> $DIR/phantom-auto-trait.rs:18:14
57+
--> $DIR/auto-trait-phantom-data-bounds.rs:18:14
5858
|
5959
LL | fn is_zen<T: Zen>(_: T) {}
6060
| ^^^ required by this bound in `is_zen`
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
1+
//! Test evaluation order in binary operations with primitive types.
2+
13
//@ run-pass
24

35
fn main() {
46
let x = Box::new(0);
5-
assert_eq!(0, *x + { drop(x); let _ = Box::new(main); 0 });
7+
assert_eq!(
8+
0,
9+
*x + {
10+
drop(x);
11+
let _ = Box::new(main);
12+
0
13+
}
14+
);
615
}
Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,24 @@
1-
//@ run-pass
2-
3-
#![allow(unused_variables)]
4-
// Test coercions between pointers which don't do anything fancy like unsizing.
1+
//! Tests basic pointer coercions
52
3+
//@ run-pass
64

75
pub fn main() {
86
// &mut -> &
97
let x: &mut isize = &mut 42;
10-
let x: &isize = x;
11-
12-
let x: &isize = &mut 42;
8+
let _x: &isize = x;
9+
let _x: &isize = &mut 42;
1310

1411
// & -> *const
1512
let x: &isize = &42;
16-
let x: *const isize = x;
17-
18-
let x: *const isize = &42;
13+
let _x: *const isize = x;
14+
let _x: *const isize = &42;
1915

2016
// &mut -> *const
2117
let x: &mut isize = &mut 42;
22-
let x: *const isize = x;
23-
24-
let x: *const isize = &mut 42;
18+
let _x: *const isize = x;
19+
let _x: *const isize = &mut 42;
2520

2621
// *mut -> *const
27-
let x: *mut isize = &mut 42;
28-
let x: *const isize = x;
22+
let _x: *mut isize = &mut 42;
23+
let _x: *const isize = x;
2924
}

tests/ui/coercion/ptr-mutability-errors.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// Test coercions between pointers which don't do anything fancy like unsizing.
2-
// These are testing that we don't lose mutability when converting to raw pointers.
1+
//! Tests that pointer coercions preserving mutability are enforced:
32
43
//@ dont-require-annotations: NOTE
54

tests/ui/coercion/ptr-mutability-errors.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0308]: mismatched types
2-
--> $DIR/ptr-coercion.rs:9:25
2+
--> $DIR/ptr-mutability-errors.rs:8:25
33
|
44
LL | let x: *mut isize = x;
55
| ---------- ^ types differ in mutability
@@ -10,7 +10,7 @@ LL | let x: *mut isize = x;
1010
found raw pointer `*const isize`
1111

1212
error[E0308]: mismatched types
13-
--> $DIR/ptr-coercion.rs:15:25
13+
--> $DIR/ptr-mutability-errors.rs:14:25
1414
|
1515
LL | let x: *mut isize = &42;
1616
| ---------- ^^^ types differ in mutability
@@ -21,7 +21,7 @@ LL | let x: *mut isize = &42;
2121
found reference `&isize`
2222

2323
error[E0308]: mismatched types
24-
--> $DIR/ptr-coercion.rs:21:25
24+
--> $DIR/ptr-mutability-errors.rs:20:25
2525
|
2626
LL | let x: *mut isize = x;
2727
| ---------- ^ types differ in mutability

tests/ui/io-checks/stdout-stderr-separation.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//! Test that print!/println! output to stdout and eprint!/eprintln!
2+
//! output to stderr correctly.
3+
14
//@ run-pass
25
//@ needs-subprocess
36

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
1+
//! Test closure parameter type inference and type mismatch errors.
2+
//!
3+
//! Related to <https://github.com/rust-lang/rust/issues/2093>.
4+
15
//@ dont-require-annotations: NOTE
26

3-
fn let_in<T, F>(x: T, f: F) where F: FnOnce(T) {}
7+
fn let_in<T, F>(x: T, f: F)
8+
where
9+
F: FnOnce(T),
10+
{
11+
}
412

513
fn main() {
6-
let_in(3u32, |i| { assert!(i == 3i32); });
7-
//~^ ERROR mismatched types
8-
//~| NOTE expected `u32`, found `i32`
14+
let_in(3u32, |i| {
15+
assert!(i == 3i32);
16+
//~^ ERROR mismatched types
17+
//~| NOTE expected `u32`, found `i32`
18+
});
919

10-
let_in(3i32, |i| { assert!(i == 3u32); });
11-
//~^ ERROR mismatched types
12-
//~| NOTE expected `i32`, found `u32`
20+
let_in(3i32, |i| {
21+
assert!(i == 3u32);
22+
//~^ ERROR mismatched types
23+
//~| NOTE expected `i32`, found `u32`
24+
});
1325
}

tests/ui/mismatched_types/closure-parameter-type-inference-mismatch.stderr

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
error[E0308]: mismatched types
2-
--> $DIR/pptypedef.rs:6:37
2+
--> $DIR/closure-parameter-type-inference-mismatch.rs:15:22
33
|
4-
LL | let_in(3u32, |i| { assert!(i == 3i32); });
5-
| - ^^^^ expected `u32`, found `i32`
6-
| |
7-
| expected because this is `u32`
4+
LL | assert!(i == 3i32);
5+
| - ^^^^ expected `u32`, found `i32`
6+
| |
7+
| expected because this is `u32`
88
|
99
help: change the type of the numeric literal from `i32` to `u32`
1010
|
11-
LL - let_in(3u32, |i| { assert!(i == 3i32); });
12-
LL + let_in(3u32, |i| { assert!(i == 3u32); });
11+
LL - assert!(i == 3i32);
12+
LL + assert!(i == 3u32);
1313
|
1414

1515
error[E0308]: mismatched types
16-
--> $DIR/pptypedef.rs:10:37
16+
--> $DIR/closure-parameter-type-inference-mismatch.rs:21:22
1717
|
18-
LL | let_in(3i32, |i| { assert!(i == 3u32); });
19-
| - ^^^^ expected `i32`, found `u32`
20-
| |
21-
| expected because this is `i32`
18+
LL | assert!(i == 3u32);
19+
| - ^^^^ expected `i32`, found `u32`
20+
| |
21+
| expected because this is `i32`
2222
|
2323
help: change the type of the numeric literal from `u32` to `i32`
2424
|
25-
LL - let_in(3i32, |i| { assert!(i == 3u32); });
26-
LL + let_in(3i32, |i| { assert!(i == 3i32); });
25+
LL - assert!(i == 3u32);
26+
LL + assert!(i == 3i32);
2727
|
2828

2929
error: aborting due to 2 previous errors

0 commit comments

Comments
 (0)