Skip to content

Commit 7898f41

Browse files
Update UI tests to be platform independent
1 parent 8c005e9 commit 7898f41

5 files changed

+86
-67
lines changed

src/librustc/middle/intrinsicck.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl<'a, 'tcx> ExprVisitor<'a, 'tcx> {
8787
// `Option<typeof(function)>` to present a clearer error.
8888
let from = unpack_option_like(self.tcx.global_tcx(), from);
8989
if let (&ty::TyFnDef(..), SizeSkeleton::Known(size_to)) = (&from.sty, sk_to) {
90-
if size_to == Pointer.size(self.tcx) => {
90+
if size_to == Pointer.size(self.tcx) {
9191
struct_span_err!(self.tcx.sess, span, E0591,
9292
"can't transmute zero-sized type")
9393
.note(&format!("source type: {}", from))

src/test/ui/transmute/transmute-from-fn-item-types-error.rs

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

11+
// ignore-x86 fn() has different sizes dependent on platform
12+
1113
use std::mem;
1214

13-
unsafe fn foo() -> (isize, *const (), Option<fn()>) {
15+
unsafe fn foo() -> (i32, *const (), Option<fn()>) {
1416
let i = mem::transmute(bar);
1517
//~^ ERROR is zero-sized and can't be transmuted
1618
//~^^ NOTE cast with `as` to a pointer instead
@@ -41,7 +43,7 @@ unsafe fn bar() {
4143
//~^^ NOTE cast with `as` to a pointer instead
4244

4345
// No error if a coercion would otherwise occur.
44-
mem::transmute::<fn(), usize>(main);
46+
mem::transmute::<fn(), u32>(main);
4547
}
4648

4749
unsafe fn baz() {
@@ -58,7 +60,7 @@ unsafe fn baz() {
5860
//~^^ NOTE cast with `as` to a pointer instead
5961

6062
// No error if a coercion would otherwise occur.
61-
mem::transmute::<Option<fn()>, usize>(Some(main));
63+
mem::transmute::<Option<fn()>, u32>(Some(main));
6264
}
6365

6466
fn main() {
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,108 @@
1-
error[E0591]: can't transmute zero-sized type
2-
--> $DIR/transmute-from-fn-item-types-error.rs:14:13
1+
error[E0512]: transmute called with types of different sizes
2+
--> $DIR/transmute-from-fn-item-types-error.rs:16:13
33
|
4-
14 | let i = mem::transmute(bar);
4+
16 | let i = mem::transmute(bar);
55
| ^^^^^^^^^^^^^^
66
|
7-
= note: source type: unsafe fn() {bar}
8-
= note: target type: isize
9-
= help: cast with `as` to a pointer instead
7+
= note: source type: unsafe fn() {bar} (0 bits)
8+
= note: target type: i32 (32 bits)
109

1110
error[E0591]: can't transmute zero-sized type
12-
--> $DIR/transmute-from-fn-item-types-error.rs:18:13
11+
--> $DIR/transmute-from-fn-item-types-error.rs:20:13
1312
|
14-
18 | let p = mem::transmute(foo);
13+
20 | let p = mem::transmute(foo);
1514
| ^^^^^^^^^^^^^^
1615
|
17-
= note: source type: unsafe fn() -> (isize, *const (), std::option::Option<fn()>) {foo}
16+
= note: source type: unsafe fn() -> (i32, *const (), std::option::Option<fn()>) {foo}
1817
= note: target type: *const ()
1918
= help: cast with `as` to a pointer instead
2019

2120
error[E0591]: can't transmute zero-sized type
22-
--> $DIR/transmute-from-fn-item-types-error.rs:22:14
21+
--> $DIR/transmute-from-fn-item-types-error.rs:24:14
2322
|
24-
22 | let of = mem::transmute(main);
23+
24 | let of = mem::transmute(main);
2524
| ^^^^^^^^^^^^^^
2625
|
2726
= note: source type: fn() {main}
2827
= note: target type: std::option::Option<fn()>
2928
= help: cast with `as` to a pointer instead
3029

3130
error[E0512]: transmute called with types of different sizes
32-
--> $DIR/transmute-from-fn-item-types-error.rs:31:5
31+
--> $DIR/transmute-from-fn-item-types-error.rs:33:5
3332
|
34-
31 | mem::transmute::<_, u8>(main);
33+
33 | mem::transmute::<_, u8>(main);
3534
| ^^^^^^^^^^^^^^^^^^^^^^^
3635
|
3736
= note: source type: fn() {main} (0 bits)
3837
= note: target type: u8 (8 bits)
3938

4039
error[E0591]: can't transmute zero-sized type
41-
--> $DIR/transmute-from-fn-item-types-error.rs:35:5
40+
--> $DIR/transmute-from-fn-item-types-error.rs:37:5
4241
|
43-
35 | mem::transmute::<_, *mut ()>(foo);
42+
37 | mem::transmute::<_, *mut ()>(foo);
4443
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4544
|
46-
= note: source type: unsafe fn() -> (isize, *const (), std::option::Option<fn()>) {foo}
45+
= note: source type: unsafe fn() -> (i32, *const (), std::option::Option<fn()>) {foo}
4746
= note: target type: *mut ()
4847
= help: cast with `as` to a pointer instead
4948

5049
error[E0591]: can't transmute zero-sized type
51-
--> $DIR/transmute-from-fn-item-types-error.rs:39:5
50+
--> $DIR/transmute-from-fn-item-types-error.rs:41:5
5251
|
53-
39 | mem::transmute::<_, fn()>(bar);
52+
41 | mem::transmute::<_, fn()>(bar);
5453
| ^^^^^^^^^^^^^^^^^^^^^^^^^
5554
|
5655
= note: source type: unsafe fn() {bar}
5756
= note: target type: fn()
5857
= help: cast with `as` to a pointer instead
5958

59+
error[E0512]: transmute called with types of different sizes
60+
--> $DIR/transmute-from-fn-item-types-error.rs:46:5
61+
|
62+
46 | mem::transmute::<fn(), u32>(main);
63+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
64+
|
65+
= note: source type: fn() (64 bits)
66+
= note: target type: u32 (32 bits)
67+
6068
error[E0591]: can't transmute zero-sized type
61-
--> $DIR/transmute-from-fn-item-types-error.rs:48:5
69+
--> $DIR/transmute-from-fn-item-types-error.rs:50:5
6270
|
63-
48 | mem::transmute::<_, *mut ()>(Some(foo));
71+
50 | mem::transmute::<_, *mut ()>(Some(foo));
6472
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6573
|
66-
= note: source type: unsafe fn() -> (isize, *const (), std::option::Option<fn()>) {foo}
74+
= note: source type: unsafe fn() -> (i32, *const (), std::option::Option<fn()>) {foo}
6775
= note: target type: *mut ()
6876
= help: cast with `as` to a pointer instead
6977

7078
error[E0591]: can't transmute zero-sized type
71-
--> $DIR/transmute-from-fn-item-types-error.rs:52:5
79+
--> $DIR/transmute-from-fn-item-types-error.rs:54:5
7280
|
73-
52 | mem::transmute::<_, fn()>(Some(bar));
81+
54 | mem::transmute::<_, fn()>(Some(bar));
7482
| ^^^^^^^^^^^^^^^^^^^^^^^^^
7583
|
7684
= note: source type: unsafe fn() {bar}
7785
= note: target type: fn()
7886
= help: cast with `as` to a pointer instead
7987

8088
error[E0591]: can't transmute zero-sized type
81-
--> $DIR/transmute-from-fn-item-types-error.rs:56:5
89+
--> $DIR/transmute-from-fn-item-types-error.rs:58:5
8290
|
83-
56 | mem::transmute::<_, Option<fn()>>(Some(baz));
91+
58 | mem::transmute::<_, Option<fn()>>(Some(baz));
8492
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8593
|
8694
= note: source type: unsafe fn() {baz}
8795
= note: target type: std::option::Option<fn()>
8896
= help: cast with `as` to a pointer instead
8997

98+
error[E0512]: transmute called with types of different sizes
99+
--> $DIR/transmute-from-fn-item-types-error.rs:63:5
100+
|
101+
63 | mem::transmute::<Option<fn()>, u32>(Some(main));
102+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
103+
|
104+
= note: source type: std::option::Option<fn()> (64 bits)
105+
= note: target type: u32 (32 bits)
106+
90107
error: aborting due to previous error(s)
91108

src/test/ui/transmute/transmute-type-parameters.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,27 @@
1313
use std::mem::transmute;
1414

1515
unsafe fn f<T>(x: T) {
16-
let _: isize = transmute(x);
17-
//~^ ERROR differently sized types: T (size can vary) to isize
16+
let _: i32 = transmute(x);
17+
//~^ ERROR differently sized types: T (size can vary) to i32
1818
}
1919

20-
unsafe fn g<T>(x: (T, isize)) {
21-
let _: isize = transmute(x);
22-
//~^ ERROR differently sized types: (T, isize) (size can vary because of T) to isize
20+
unsafe fn g<T>(x: (T, i32)) {
21+
let _: i32 = transmute(x);
22+
//~^ ERROR differently sized types: (T, i32) (size can vary because of T) to i32
2323
}
2424

2525
unsafe fn h<T>(x: [T; 10]) {
26-
let _: isize = transmute(x);
27-
//~^ ERROR differently sized types: [T; 10] (size can vary because of T) to isize
26+
let _: i32 = transmute(x);
27+
//~^ ERROR differently sized types: [T; 10] (size can vary because of T) to i32
2828
}
2929

3030
struct Bad<T> {
3131
f: T,
3232
}
3333

3434
unsafe fn i<T>(x: Bad<T>) {
35-
let _: isize = transmute(x);
36-
//~^ ERROR differently sized types: Bad<T> (size can vary because of T) to isize
35+
let _: i32 = transmute(x);
36+
//~^ ERROR differently sized types: Bad<T> (size can vary because of T) to i32
3737
}
3838

3939
enum Worse<T> {
@@ -42,13 +42,13 @@ enum Worse<T> {
4242
}
4343

4444
unsafe fn j<T>(x: Worse<T>) {
45-
let _: isize = transmute(x);
46-
//~^ ERROR differently sized types: Worse<T> (size can vary because of T) to isize
45+
let _: i32 = transmute(x);
46+
//~^ ERROR differently sized types: Worse<T> (size can vary because of T) to i32
4747
}
4848

4949
unsafe fn k<T>(x: Option<T>) {
50-
let _: isize = transmute(x);
51-
//~^ ERROR differently sized types: std::option::Option<T> (size can vary because of T) to isize
50+
let _: i32 = transmute(x);
51+
//~^ ERROR differently sized types: std::option::Option<T> (size can vary because of T) to i32
5252
}
5353

5454
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,56 @@
11
error[E0512]: transmute called with types of different sizes
2-
--> $DIR/transmute-type-parameters.rs:16:20
2+
--> $DIR/transmute-type-parameters.rs:16:18
33
|
4-
16 | let _: isize = transmute(x);
5-
| ^^^^^^^^^
4+
16 | let _: i32 = transmute(x);
5+
| ^^^^^^^^^
66
|
77
= note: source type: T (this type's size can vary)
8-
= note: target type: isize (64 bits)
8+
= note: target type: i32 (32 bits)
99

1010
error[E0512]: transmute called with types of different sizes
11-
--> $DIR/transmute-type-parameters.rs:21:20
11+
--> $DIR/transmute-type-parameters.rs:21:18
1212
|
13-
21 | let _: isize = transmute(x);
14-
| ^^^^^^^^^
13+
21 | let _: i32 = transmute(x);
14+
| ^^^^^^^^^
1515
|
16-
= note: source type: (T, isize) (size can vary because of T)
17-
= note: target type: isize (64 bits)
16+
= note: source type: (T, i32) (size can vary because of T)
17+
= note: target type: i32 (32 bits)
1818

1919
error[E0512]: transmute called with types of different sizes
20-
--> $DIR/transmute-type-parameters.rs:26:20
20+
--> $DIR/transmute-type-parameters.rs:26:18
2121
|
22-
26 | let _: isize = transmute(x);
23-
| ^^^^^^^^^
22+
26 | let _: i32 = transmute(x);
23+
| ^^^^^^^^^
2424
|
2525
= note: source type: [T; 10] (size can vary because of T)
26-
= note: target type: isize (64 bits)
26+
= note: target type: i32 (32 bits)
2727

2828
error[E0512]: transmute called with types of different sizes
29-
--> $DIR/transmute-type-parameters.rs:35:20
29+
--> $DIR/transmute-type-parameters.rs:35:18
3030
|
31-
35 | let _: isize = transmute(x);
32-
| ^^^^^^^^^
31+
35 | let _: i32 = transmute(x);
32+
| ^^^^^^^^^
3333
|
3434
= note: source type: Bad<T> (size can vary because of T)
35-
= note: target type: isize (64 bits)
35+
= note: target type: i32 (32 bits)
3636

3737
error[E0512]: transmute called with types of different sizes
38-
--> $DIR/transmute-type-parameters.rs:45:20
38+
--> $DIR/transmute-type-parameters.rs:45:18
3939
|
40-
45 | let _: isize = transmute(x);
41-
| ^^^^^^^^^
40+
45 | let _: i32 = transmute(x);
41+
| ^^^^^^^^^
4242
|
4343
= note: source type: Worse<T> (size can vary because of T)
44-
= note: target type: isize (64 bits)
44+
= note: target type: i32 (32 bits)
4545

4646
error[E0512]: transmute called with types of different sizes
47-
--> $DIR/transmute-type-parameters.rs:50:20
47+
--> $DIR/transmute-type-parameters.rs:50:18
4848
|
49-
50 | let _: isize = transmute(x);
50-
| ^^^^^^^^^
49+
50 | let _: i32 = transmute(x);
50+
| ^^^^^^^^^
5151
|
5252
= note: source type: std::option::Option<T> (size can vary because of T)
53-
= note: target type: isize (64 bits)
53+
= note: target type: i32 (32 bits)
5454

5555
error: aborting due to previous error(s)
5656

0 commit comments

Comments
 (0)