about summary refs log tree commit diff
path: root/src/test/ui/c-variadic
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2019-04-19 15:37:34 -0700
committerEsteban Küber <esteban@kuber.com.ar>2019-04-22 11:31:35 -0700
commit45bbd14db4f12172cfb4f00e46b1f65ced0dd224 (patch)
tree0ae8bac8b1f507007af5d1dc5502d4d77dd37e05 /src/test/ui/c-variadic
parentc21fbfe7e310b9055ed6b7c46b7d37b831a516e3 (diff)
downloadrust-45bbd14db4f12172cfb4f00e46b1f65ced0dd224.tar.gz
rust-45bbd14db4f12172cfb4f00e46b1f65ced0dd224.zip
Continue evaluating after item-type checking
Diffstat (limited to 'src/test/ui/c-variadic')
-rw-r--r--src/test/ui/c-variadic/variadic-ffi-1.rs22
-rw-r--r--src/test/ui/c-variadic/variadic-ffi-1.stderr77
2 files changed, 85 insertions, 14 deletions
diff --git a/src/test/ui/c-variadic/variadic-ffi-1.rs b/src/test/ui/c-variadic/variadic-ffi-1.rs
index 61b2ad4bed5..6a3ff24b674 100644
--- a/src/test/ui/c-variadic/variadic-ffi-1.rs
+++ b/src/test/ui/c-variadic/variadic-ffi-1.rs
@@ -12,20 +12,18 @@ extern {
 extern "C" fn bar(f: isize, x: u8) {}
 
 fn main() {
-    // errors below are no longer checked because error above aborts
-    // compilation; see variadic-ffi-3.rs for corresponding test.
     unsafe {
-        foo();
-        foo(1);
+        foo();  //~ ERROR this function takes at least 2 parameters but 0 parameters were supplied
+        foo(1); //~ ERROR this function takes at least 2 parameters but 1 parameter was supplied
 
-        let x: unsafe extern "C" fn(f: isize, x: u8) = foo;
-        let y: extern "C" fn(f: isize, x: u8, ...) = bar;
+        let x: unsafe extern "C" fn(f: isize, x: u8) = foo; //~ ERROR mismatched types
+        let y: extern "C" fn(f: isize, x: u8, ...) = bar; //~ ERROR mismatched types
 
-        foo(1, 2, 3f32);
-        foo(1, 2, true);
-        foo(1, 2, 1i8);
-        foo(1, 2, 1u8);
-        foo(1, 2, 1i16);
-        foo(1, 2, 1u16);
+        foo(1, 2, 3f32); //~ ERROR can't pass
+        foo(1, 2, true); //~ ERROR can't pass
+        foo(1, 2, 1i8);  //~ ERROR can't pass
+        foo(1, 2, 1u8);  //~ ERROR can't pass
+        foo(1, 2, 1i16); //~ ERROR can't pass
+        foo(1, 2, 1u16); //~ ERROR can't pass
     }
 }
diff --git a/src/test/ui/c-variadic/variadic-ffi-1.stderr b/src/test/ui/c-variadic/variadic-ffi-1.stderr
index 1a2bb4419b5..e16d15a98bf 100644
--- a/src/test/ui/c-variadic/variadic-ffi-1.stderr
+++ b/src/test/ui/c-variadic/variadic-ffi-1.stderr
@@ -4,6 +4,79 @@ error[E0045]: C-variadic function must have C or cdecl calling convention
 LL |     fn printf(_: *const u8, ...);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadics require C or cdecl calling convention
 
-error: aborting due to previous error
+error[E0060]: this function takes at least 2 parameters but 0 parameters were supplied
+  --> $DIR/variadic-ffi-1.rs:16:9
+   |
+LL |     fn foo(f: isize, x: u8, ...);
+   |     ----------------------------- defined here
+...
+LL |         foo();
+   |         ^^^^^ expected at least 2 parameters
+
+error[E0060]: this function takes at least 2 parameters but 1 parameter was supplied
+  --> $DIR/variadic-ffi-1.rs:17:9
+   |
+LL |     fn foo(f: isize, x: u8, ...);
+   |     ----------------------------- defined here
+...
+LL |         foo(1);
+   |         ^^^^^^ expected at least 2 parameters
+
+error[E0308]: mismatched types
+  --> $DIR/variadic-ffi-1.rs:19:56
+   |
+LL |         let x: unsafe extern "C" fn(f: isize, x: u8) = foo;
+   |                                                        ^^^ expected non-variadic fn, found variadic function
+   |
+   = note: expected type `unsafe extern "C" fn(isize, u8)`
+              found type `for<'r> unsafe extern "C" fn(isize, u8, std::ffi::VaList<'r>, ...) {foo}`
+
+error[E0308]: mismatched types
+  --> $DIR/variadic-ffi-1.rs:20:54
+   |
+LL |         let y: extern "C" fn(f: isize, x: u8, ...) = bar;
+   |                                                      ^^^ expected variadic fn, found non-variadic function
+   |
+   = note: expected type `for<'r> extern "C" fn(isize, u8, std::ffi::VaList<'r>, ...)`
+              found type `extern "C" fn(isize, u8) {bar}`
+
+error[E0617]: can't pass `f32` to variadic function
+  --> $DIR/variadic-ffi-1.rs:22:19
+   |
+LL |         foo(1, 2, 3f32);
+   |                   ^^^^ help: cast the value to `c_double`: `3f32 as c_double`
+
+error[E0617]: can't pass `bool` to variadic function
+  --> $DIR/variadic-ffi-1.rs:23:19
+   |
+LL |         foo(1, 2, true);
+   |                   ^^^^ help: cast the value to `c_int`: `true as c_int`
+
+error[E0617]: can't pass `i8` to variadic function
+  --> $DIR/variadic-ffi-1.rs:24:19
+   |
+LL |         foo(1, 2, 1i8);
+   |                   ^^^ help: cast the value to `c_int`: `1i8 as c_int`
+
+error[E0617]: can't pass `u8` to variadic function
+  --> $DIR/variadic-ffi-1.rs:25:19
+   |
+LL |         foo(1, 2, 1u8);
+   |                   ^^^ help: cast the value to `c_uint`: `1u8 as c_uint`
+
+error[E0617]: can't pass `i16` to variadic function
+  --> $DIR/variadic-ffi-1.rs:26:19
+   |
+LL |         foo(1, 2, 1i16);
+   |                   ^^^^ help: cast the value to `c_int`: `1i16 as c_int`
+
+error[E0617]: can't pass `u16` to variadic function
+  --> $DIR/variadic-ffi-1.rs:27:19
+   |
+LL |         foo(1, 2, 1u16);
+   |                   ^^^^ help: cast the value to `c_uint`: `1u16 as c_uint`
+
+error: aborting due to 11 previous errors
 
-For more information about this error, try `rustc --explain E0045`.
+Some errors have detailed explanations: E0045, E0060, E0308, E0617.
+For more information about an error, try `rustc --explain E0045`.