]> git.lizzy.rs Git - rust.git/commitdiff
Update UI tests to be platform independent
authorMark Simulacrum <mark.simulacrum@gmail.com>
Sun, 4 Jun 2017 13:02:05 +0000 (07:02 -0600)
committerMark Simulacrum <mark.simulacrum@gmail.com>
Sun, 18 Jun 2017 17:35:37 +0000 (11:35 -0600)
src/librustc/middle/intrinsicck.rs
src/test/ui/transmute/main.rs
src/test/ui/transmute/main.stderr
src/test/ui/transmute/transmute-from-fn-item-types-error.rs
src/test/ui/transmute/transmute-from-fn-item-types-error.stderr
src/test/ui/transmute/transmute-type-parameters.rs
src/test/ui/transmute/transmute-type-parameters.stderr

index de92395ac6955b316ec88640d16f01af490baf42..f180ae53b8ae1926868ad9794595f772c8e31f85 100644 (file)
@@ -87,7 +87,7 @@ fn check_transmute(&self, span: Span, from: Ty<'tcx>, to: Ty<'tcx>) {
             // `Option<typeof(function)>` to present a clearer error.
             let from = unpack_option_like(self.tcx.global_tcx(), from);
             if let (&ty::TyFnDef(..), SizeSkeleton::Known(size_to)) = (&from.sty, sk_to) {
-                if size_to == Pointer.size(self.tcx) => {
+                if size_to == Pointer.size(self.tcx) {
                     struct_span_err!(self.tcx.sess, span, E0591,
                                      "can't transmute zero-sized type")
                         .note(&format!("source type: {}", from))
index 28cac90c69d9b8e363536e6da2245b500a130541..d5968a388dc1d933ea5e7b54876928e8b9eaf6ba 100644 (file)
@@ -7,6 +7,12 @@
 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
+
+// ignore-x86
+// ignore-arm
+// ignore-emscripten
+// ignore 32-bit platforms (test output is different)
+
 #![feature(untagged_unions)]
 use std::mem::transmute;
 
index 2ae4252cfa2b776a72f83bfe7581e3a86df4381e..c5d5a4ed8a6239631d2985df674f9002414779c4 100644 (file)
@@ -1,34 +1,34 @@
 error[E0512]: transmute called with types of different sizes
-  --> $DIR/main.rs:20:5
+  --> $DIR/main.rs:26:5
    |
-20 |     transmute(x) //~ ERROR transmute called with types of different sizes
+26 |     transmute(x) //~ ERROR transmute called with types of different sizes
    |     ^^^^^^^^^
    |
    = note: source type: <C as TypeConstructor<'a>>::T (size can vary because of <C as TypeConstructor>::T)
    = note: target type: <C as TypeConstructor<'b>>::T (size can vary because of <C as TypeConstructor>::T)
 
 error[E0512]: transmute called with types of different sizes
-  --> $DIR/main.rs:24:17
+  --> $DIR/main.rs:30:17
    |
-24 |     let x: u8 = transmute(10u16); //~ ERROR transmute called with types of different sizes
+30 |     let x: u8 = transmute(10u16); //~ ERROR transmute called with types of different sizes
    |                 ^^^^^^^^^
    |
    = note: source type: u16 (16 bits)
    = note: target type: u8 (8 bits)
 
 error[E0512]: transmute called with types of different sizes
-  --> $DIR/main.rs:28:17
+  --> $DIR/main.rs:34:17
    |
-28 |     let x: u8 = transmute("test"); //~ ERROR transmute called with types of different sizes
+34 |     let x: u8 = transmute("test"); //~ ERROR transmute called with types of different sizes
    |                 ^^^^^^^^^
    |
    = note: source type: &str (128 bits)
    = note: target type: u8 (8 bits)
 
 error[E0512]: transmute called with types of different sizes
-  --> $DIR/main.rs:33:18
+  --> $DIR/main.rs:39:18
    |
-33 |     let x: Foo = transmute(10); //~ ERROR transmute called with types of different sizes
+39 |     let x: Foo = transmute(10); //~ ERROR transmute called with types of different sizes
    |                  ^^^^^^^^^
    |
    = note: source type: i32 (32 bits)
index 808be8beede928362187cd4c51f74d427f27fd04..98d2e1e3628f280f6847abdc6c31dba484f22bf7 100644 (file)
@@ -8,9 +8,14 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-x86
+// ignore-arm
+// ignore-emscripten
+// ignore 32-bit platforms (test output is different)
+
 use std::mem;
 
-unsafe fn foo() -> (isize, *const (), Option<fn()>) {
+unsafe fn foo() -> (i32, *const (), Option<fn()>) {
     let i = mem::transmute(bar);
     //~^ ERROR is zero-sized and can't be transmuted
     //~^^ NOTE cast with `as` to a pointer instead
@@ -41,7 +46,7 @@ unsafe fn bar() {
     //~^^ NOTE cast with `as` to a pointer instead
 
     // No error if a coercion would otherwise occur.
-    mem::transmute::<fn(), usize>(main);
+    mem::transmute::<fn(), u32>(main);
 }
 
 unsafe fn baz() {
@@ -58,7 +63,7 @@ unsafe fn baz() {
     //~^^ NOTE cast with `as` to a pointer instead
 
     // No error if a coercion would otherwise occur.
-    mem::transmute::<Option<fn()>, usize>(Some(main));
+    mem::transmute::<Option<fn()>, u32>(Some(main));
 }
 
 fn main() {
index efd60630aa26503279659abd357acf1f6c3c027d..61ee5cf61283fa2937b16ad0307a40b46d72a679 100644 (file)
@@ -1,27 +1,26 @@
-error[E0591]: can't transmute zero-sized type
-  --> $DIR/transmute-from-fn-item-types-error.rs:14:13
+error[E0512]: transmute called with types of different sizes
+  --> $DIR/transmute-from-fn-item-types-error.rs:19:13
    |
-14 |     let i = mem::transmute(bar);
+19 |     let i = mem::transmute(bar);
    |             ^^^^^^^^^^^^^^
    |
-   = note: source type: unsafe fn() {bar}
-   = note: target type: isize
-   = help: cast with `as` to a pointer instead
+   = note: source type: unsafe fn() {bar} (0 bits)
+   = note: target type: i32 (32 bits)
 
 error[E0591]: can't transmute zero-sized type
-  --> $DIR/transmute-from-fn-item-types-error.rs:18:13
+  --> $DIR/transmute-from-fn-item-types-error.rs:23:13
    |
-18 |     let p = mem::transmute(foo);
+23 |     let p = mem::transmute(foo);
    |             ^^^^^^^^^^^^^^
    |
-   = note: source type: unsafe fn() -> (isize, *const (), std::option::Option<fn()>) {foo}
+   = note: source type: unsafe fn() -> (i32, *const (), std::option::Option<fn()>) {foo}
    = note: target type: *const ()
    = help: cast with `as` to a pointer instead
 
 error[E0591]: can't transmute zero-sized type
-  --> $DIR/transmute-from-fn-item-types-error.rs:22:14
+  --> $DIR/transmute-from-fn-item-types-error.rs:27:14
    |
-22 |     let of = mem::transmute(main);
+27 |     let of = mem::transmute(main);
    |              ^^^^^^^^^^^^^^
    |
    = note: source type: fn() {main}
@@ -29,48 +28,57 @@ error[E0591]: can't transmute zero-sized type
    = help: cast with `as` to a pointer instead
 
 error[E0512]: transmute called with types of different sizes
-  --> $DIR/transmute-from-fn-item-types-error.rs:31:5
+  --> $DIR/transmute-from-fn-item-types-error.rs:36:5
    |
-31 |     mem::transmute::<_, u8>(main);
+36 |     mem::transmute::<_, u8>(main);
    |     ^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: source type: fn() {main} (0 bits)
    = note: target type: u8 (8 bits)
 
 error[E0591]: can't transmute zero-sized type
-  --> $DIR/transmute-from-fn-item-types-error.rs:35:5
+  --> $DIR/transmute-from-fn-item-types-error.rs:40:5
    |
-35 |     mem::transmute::<_, *mut ()>(foo);
+40 |     mem::transmute::<_, *mut ()>(foo);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = note: source type: unsafe fn() -> (isize, *const (), std::option::Option<fn()>) {foo}
+   = note: source type: unsafe fn() -> (i32, *const (), std::option::Option<fn()>) {foo}
    = note: target type: *mut ()
    = help: cast with `as` to a pointer instead
 
 error[E0591]: can't transmute zero-sized type
-  --> $DIR/transmute-from-fn-item-types-error.rs:39:5
+  --> $DIR/transmute-from-fn-item-types-error.rs:44:5
    |
-39 |     mem::transmute::<_, fn()>(bar);
+44 |     mem::transmute::<_, fn()>(bar);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: source type: unsafe fn() {bar}
    = note: target type: fn()
    = help: cast with `as` to a pointer instead
 
+error[E0512]: transmute called with types of different sizes
+  --> $DIR/transmute-from-fn-item-types-error.rs:49:5
+   |
+49 |     mem::transmute::<fn(), u32>(main);
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: source type: fn() (64 bits)
+   = note: target type: u32 (32 bits)
+
 error[E0591]: can't transmute zero-sized type
-  --> $DIR/transmute-from-fn-item-types-error.rs:48:5
+  --> $DIR/transmute-from-fn-item-types-error.rs:53:5
    |
-48 |     mem::transmute::<_, *mut ()>(Some(foo));
+53 |     mem::transmute::<_, *mut ()>(Some(foo));
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = note: source type: unsafe fn() -> (isize, *const (), std::option::Option<fn()>) {foo}
+   = note: source type: unsafe fn() -> (i32, *const (), std::option::Option<fn()>) {foo}
    = note: target type: *mut ()
    = help: cast with `as` to a pointer instead
 
 error[E0591]: can't transmute zero-sized type
-  --> $DIR/transmute-from-fn-item-types-error.rs:52:5
+  --> $DIR/transmute-from-fn-item-types-error.rs:57:5
    |
-52 |     mem::transmute::<_, fn()>(Some(bar));
+57 |     mem::transmute::<_, fn()>(Some(bar));
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: source type: unsafe fn() {bar}
@@ -78,14 +86,23 @@ error[E0591]: can't transmute zero-sized type
    = help: cast with `as` to a pointer instead
 
 error[E0591]: can't transmute zero-sized type
-  --> $DIR/transmute-from-fn-item-types-error.rs:56:5
+  --> $DIR/transmute-from-fn-item-types-error.rs:61:5
    |
-56 |     mem::transmute::<_, Option<fn()>>(Some(baz));
+61 |     mem::transmute::<_, Option<fn()>>(Some(baz));
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: source type: unsafe fn() {baz}
    = note: target type: std::option::Option<fn()>
    = help: cast with `as` to a pointer instead
 
+error[E0512]: transmute called with types of different sizes
+  --> $DIR/transmute-from-fn-item-types-error.rs:66:5
+   |
+66 |     mem::transmute::<Option<fn()>, u32>(Some(main));
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: source type: std::option::Option<fn()> (64 bits)
+   = note: target type: u32 (32 bits)
+
 error: aborting due to previous error(s)
 
index b6e7e32663ec122669b3bd2e50cf257f9903afe7..fa83a10dc48e88da1512ba3db41a2ba2bdad22ea 100644 (file)
@@ -8,23 +8,28 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-x86
+// ignore-arm
+// ignore-emscripten
+// ignore 32-bit platforms (test output is different)
+
 // Tests that `transmute` cannot be called on type parameters.
 
 use std::mem::transmute;
 
 unsafe fn f<T>(x: T) {
-    let _: isize = transmute(x);
-//~^ ERROR differently sized types: T (size can vary) to isize
+    let _: i32 = transmute(x);
+//~^ ERROR differently sized types: T (size can vary) to i32
 }
 
-unsafe fn g<T>(x: (T, isize)) {
-    let _: isize = transmute(x);
-//~^ ERROR differently sized types: (T, isize) (size can vary because of T) to isize
+unsafe fn g<T>(x: (T, i32)) {
+    let _: i32 = transmute(x);
+//~^ ERROR differently sized types: (T, i32) (size can vary because of T) to i32
 }
 
 unsafe fn h<T>(x: [T; 10]) {
-    let _: isize = transmute(x);
-//~^ ERROR differently sized types: [T; 10] (size can vary because of T) to isize
+    let _: i32 = transmute(x);
+//~^ ERROR differently sized types: [T; 10] (size can vary because of T) to i32
 }
 
 struct Bad<T> {
@@ -32,8 +37,8 @@ struct Bad<T> {
 }
 
 unsafe fn i<T>(x: Bad<T>) {
-    let _: isize = transmute(x);
-//~^ ERROR differently sized types: Bad<T> (size can vary because of T) to isize
+    let _: i32 = transmute(x);
+//~^ ERROR differently sized types: Bad<T> (size can vary because of T) to i32
 }
 
 enum Worse<T> {
@@ -42,13 +47,13 @@ enum Worse<T> {
 }
 
 unsafe fn j<T>(x: Worse<T>) {
-    let _: isize = transmute(x);
-//~^ ERROR differently sized types: Worse<T> (size can vary because of T) to isize
+    let _: i32 = transmute(x);
+//~^ ERROR differently sized types: Worse<T> (size can vary because of T) to i32
 }
 
 unsafe fn k<T>(x: Option<T>) {
-    let _: isize = transmute(x);
-//~^ ERROR differently sized types: std::option::Option<T> (size can vary because of T) to isize
+    let _: i32 = transmute(x);
+//~^ ERROR differently sized types: std::option::Option<T> (size can vary because of T) to i32
 }
 
 fn main() {}
index 39f18efe97a84d88a9b90aa235fbea5d236aa3db..bb21cfd3e4c9d462adc5b1e731f22a13a86c2982 100644 (file)
@@ -1,56 +1,56 @@
 error[E0512]: transmute called with types of different sizes
-  --> $DIR/transmute-type-parameters.rs:16:20
+  --> $DIR/transmute-type-parameters.rs:21:18
    |
-16 |     let _: isize = transmute(x);
-   |                    ^^^^^^^^^
+21 |     let _: i32 = transmute(x);
+   |                  ^^^^^^^^^
    |
    = note: source type: T (this type's size can vary)
-   = note: target type: isize (64 bits)
+   = note: target type: i32 (32 bits)
 
 error[E0512]: transmute called with types of different sizes
-  --> $DIR/transmute-type-parameters.rs:21:20
+  --> $DIR/transmute-type-parameters.rs:26:18
    |
-21 |     let _: isize = transmute(x);
-   |                    ^^^^^^^^^
+26 |     let _: i32 = transmute(x);
+   |                  ^^^^^^^^^
    |
-   = note: source type: (T, isize) (size can vary because of T)
-   = note: target type: isize (64 bits)
+   = note: source type: (T, i32) (size can vary because of T)
+   = note: target type: i32 (32 bits)
 
 error[E0512]: transmute called with types of different sizes
-  --> $DIR/transmute-type-parameters.rs:26:20
+  --> $DIR/transmute-type-parameters.rs:31:18
    |
-26 |     let _: isize = transmute(x);
-   |                    ^^^^^^^^^
+31 |     let _: i32 = transmute(x);
+   |                  ^^^^^^^^^
    |
    = note: source type: [T; 10] (size can vary because of T)
-   = note: target type: isize (64 bits)
+   = note: target type: i32 (32 bits)
 
 error[E0512]: transmute called with types of different sizes
-  --> $DIR/transmute-type-parameters.rs:35:20
+  --> $DIR/transmute-type-parameters.rs:40:18
    |
-35 |     let _: isize = transmute(x);
-   |                    ^^^^^^^^^
+40 |     let _: i32 = transmute(x);
+   |                  ^^^^^^^^^
    |
    = note: source type: Bad<T> (size can vary because of T)
-   = note: target type: isize (64 bits)
+   = note: target type: i32 (32 bits)
 
 error[E0512]: transmute called with types of different sizes
-  --> $DIR/transmute-type-parameters.rs:45:20
+  --> $DIR/transmute-type-parameters.rs:50:18
    |
-45 |     let _: isize = transmute(x);
-   |                    ^^^^^^^^^
+50 |     let _: i32 = transmute(x);
+   |                  ^^^^^^^^^
    |
    = note: source type: Worse<T> (size can vary because of T)
-   = note: target type: isize (64 bits)
+   = note: target type: i32 (32 bits)
 
 error[E0512]: transmute called with types of different sizes
-  --> $DIR/transmute-type-parameters.rs:50:20
+  --> $DIR/transmute-type-parameters.rs:55:18
    |
-50 |     let _: isize = transmute(x);
-   |                    ^^^^^^^^^
+55 |     let _: i32 = transmute(x);
+   |                  ^^^^^^^^^
    |
    = note: source type: std::option::Option<T> (size can vary because of T)
-   = note: target type: isize (64 bits)
+   = note: target type: i32 (32 bits)
 
 error: aborting due to previous error(s)