Skip to content

Commit d481e08

Browse files
committed
Auto merge of #1338 - RalfJung:test-cleanup, r=RalfJung
Cleanup some run-pass tests
2 parents 5c823a1 + 3e3613f commit d481e08

22 files changed

+154
-142
lines changed

tests/run-pass/bitop-beyond-alignment.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![allow(dead_code)]
12-
1311
use std::mem;
1412

1513
enum Tag<A> {
1614
Tag2(A)
1715
}
1816

17+
#[allow(dead_code)]
1918
struct Rec {
2019
c8: u8,
2120
t: Tag<u64>

tests/run-pass/dst-field-align.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#![allow(dead_code)]
2-
1+
#[allow(dead_code)]
32
struct Foo<T: ?Sized> {
43
a: u16,
54
b: T
@@ -17,6 +16,7 @@ struct Baz<T: ?Sized> {
1716
a: T
1817
}
1918

19+
#[allow(dead_code)]
2020
struct HasDrop<T: ?Sized> {
2121
ptr: Box<usize>,
2222
data: T

tests/run-pass/foreign-fn-linkname.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
//ignore-windows: Uses POSIX APIs
2-
32
#![feature(rustc_private)]
4-
#![allow(unused_extern_crates)] // rustc bug https://github.com/rust-lang/rust/issues/56098
53

64
extern crate libc;
75

tests/run-pass/issue-15063.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#![allow(dead_code)]
2-
1+
#[allow(dead_code)]
32
enum Two { A, B }
43
impl Drop for Two {
54
fn drop(&mut self) {

tests/run-pass/issue-35815.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
#![allow(dead_code)]
2-
31
use std::mem;
42

3+
#[allow(dead_code)]
54
struct Foo<T: ?Sized> {
65
a: i64,
76
b: bool,

tests/run-pass/issue-53728.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
#![allow(dead_code)]
2-
31
#[repr(u16)]
2+
#[allow(dead_code)]
43
enum DeviceKind {
54
Nil = 0,
65
}
6+
77
#[repr(packed)]
8+
#[allow(dead_code)]
89
struct DeviceInfo {
910
endianness: u8,
1011
device_kind: DeviceKind,
1112
}
13+
1214
fn main() {
1315
let _x = None::<(DeviceInfo, u8)>;
1416
let _y = None::<(DeviceInfo, u16)>;

tests/run-pass/libc.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@
22
// compile-flags: -Zmiri-disable-isolation
33

44
#![feature(rustc_private)]
5-
#![allow(unused)] // necessary on macos due to conditional compilation
6-
7-
use std::path::PathBuf;
85

96
extern crate libc;
107

11-
fn tmp() -> PathBuf {
12-
std::env::var("MIRI_TEMP").map(PathBuf::from).unwrap_or_else(|_| std::env::temp_dir())
8+
#[cfg(target_os = "linux")]
9+
fn tmp() -> std::path::PathBuf {
10+
std::env::var("MIRI_TEMP").map(std::path::PathBuf::from).unwrap_or_else(|_| std::env::temp_dir())
1311
}
1412

1513
#[cfg(target_os = "linux")]

tests/run-pass/packed_static.rs

Lines changed: 0 additions & 10 deletions
This file was deleted.

tests/run-pass/packed_struct.rs

Lines changed: 52 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,53 @@
1-
#![allow(dead_code)]
21
#![feature(unsize, coerce_unsized)]
32

4-
#[repr(packed)]
5-
struct S {
6-
a: i32,
7-
b: i64,
8-
}
93

10-
#[repr(packed)]
11-
struct Test1<'a> {
12-
x: u8,
13-
other: &'a u32,
14-
}
4+
fn test_basic() {
5+
#[repr(packed)]
6+
struct S {
7+
a: i32,
8+
b: i64,
9+
}
1510

16-
#[repr(packed)]
17-
struct Test2<'a> {
18-
x: u8,
19-
other: &'a Test1<'a>,
20-
}
11+
#[repr(packed)]
12+
#[allow(dead_code)]
13+
struct Test1<'a> {
14+
x: u8,
15+
other: &'a u32,
16+
}
17+
18+
#[repr(packed)]
19+
#[allow(dead_code)]
20+
struct Test2<'a> {
21+
x: u8,
22+
other: &'a Test1<'a>,
23+
}
24+
25+
fn test(t: Test2) {
26+
let x = *t.other.other;
27+
assert_eq!(x, 42);
28+
}
29+
30+
let mut x = S {
31+
a: 42,
32+
b: 99,
33+
};
34+
let a = x.a;
35+
let b = x.b;
36+
assert_eq!(a, 42);
37+
assert_eq!(b, 99);
38+
// can't do `assert_eq!(x.a, 42)`, because `assert_eq!` takes a reference
39+
assert_eq!({x.a}, 42);
40+
assert_eq!({x.b}, 99);
2141

22-
fn test(t: Test2) {
23-
let x = *t.other.other;
24-
assert_eq!(x, 42);
42+
x.b = 77;
43+
assert_eq!({x.b}, 77);
44+
45+
test(Test2 { x: 0, other: &Test1 { x: 0, other: &42 }});
2546
}
2647

2748
fn test_unsizing() {
2849
#[repr(packed)]
50+
#[allow(dead_code)]
2951
struct UnalignedPtr<'a, T: ?Sized>
3052
where T: 'a,
3153
{
@@ -81,25 +103,21 @@ fn test_inner_packed() {
81103
let _o2 = o.clone();
82104
}
83105

84-
fn main() {
85-
let mut x = S {
86-
a: 42,
87-
b: 99,
88-
};
89-
let a = x.a;
90-
let b = x.b;
91-
assert_eq!(a, 42);
92-
assert_eq!(b, 99);
93-
// can't do `assert_eq!(x.a, 42)`, because `assert_eq!` takes a reference
94-
assert_eq!({x.a}, 42);
95-
assert_eq!({x.b}, 99);
106+
fn test_static() {
107+
#[repr(packed)]
108+
struct Foo {
109+
i: i32
110+
}
96111

97-
x.b = 77;
98-
assert_eq!({x.b}, 77);
112+
static FOO: Foo = Foo { i: 42 };
99113

100-
test(Test2 { x: 0, other: &Test1 { x: 0, other: &42 }});
114+
assert_eq!({FOO.i}, 42);
115+
}
101116

117+
fn main() {
118+
test_basic();
102119
test_unsizing();
103120
test_drop();
104121
test_inner_packed();
122+
test_static();
105123
}

tests/run-pass/ptr_arith_offset.rs

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)