From 45bbd14db4f12172cfb4f00e46b1f65ced0dd224 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Fri, 19 Apr 2019 15:37:34 -0700 Subject: [PATCH 1/3] Continue evaluating after item-type checking --- src/librustc_interface/passes.rs | 3 +- src/librustc_typeck/lib.rs | 10 +-- src/test/ui/c-variadic/variadic-ffi-1.rs | 22 +++--- src/test/ui/c-variadic/variadic-ffi-1.stderr | 77 ++++++++++++++++++- .../mismatched_trait_impl.rs | 2 +- .../mismatched_trait_impl.stderr | 12 ++- .../infinite/infinite-tag-type-recursion.rs | 1 + .../infinite-tag-type-recursion.stderr | 14 +++- src/test/ui/issues/issue-16048.rs | 2 + src/test/ui/issues/issue-16048.stderr | 13 +++- .../termination-trait-test-wrong-type.rs | 2 +- .../termination-trait-test-wrong-type.stderr | 14 +++- src/test/ui/structs/struct-base-wrong-type.rs | 9 +-- .../ui/structs/struct-base-wrong-type.stderr | 20 ++++- src/test/ui/wrong-mul-method-signature.rs | 5 +- src/test/ui/wrong-mul-method-signature.stderr | 23 +++++- 16 files changed, 186 insertions(+), 43 deletions(-) diff --git a/src/librustc_interface/passes.rs b/src/librustc_interface/passes.rs index 2f01254ed5f..fddf706cc8b 100644 --- a/src/librustc_interface/passes.rs +++ b/src/librustc_interface/passes.rs @@ -966,8 +966,7 @@ fn analysis<'tcx>( time(sess, "layout testing", || layout_test::test_layout(tcx)); // Avoid overwhelming user with errors if borrow checking failed. - // I'm not sure how helpful this is, to be honest, but it avoids - // a + // I'm not sure how helpful this is, to be honest, but it avoids a // lot of annoying errors in the compile-fail tests (basically, // lint warnings and so on -- kindck used to do this abort, but // kindck is gone now). -nmatsakis diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index 9bc221fac1b..95f7c2949cb 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -357,12 +357,10 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) time(tcx.sess, "wf checking", || check::check_wf_new(tcx))?; time(tcx.sess, "item-types checking", || { - tcx.sess.track_errors(|| { - for &module in tcx.hir().krate().modules.keys() { - tcx.ensure().check_mod_item_types(tcx.hir().local_def_id(module)); - } - }) - })?; + for &module in tcx.hir().krate().modules.keys() { + tcx.ensure().check_mod_item_types(tcx.hir().local_def_id(module)); + } + }); time(tcx.sess, "item-bodies checking", || tcx.typeck_item_bodies(LOCAL_CRATE)); 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 -For more information about this error, try `rustc --explain E0045`. +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 + +Some errors have detailed explanations: E0045, E0060, E0308, E0617. +For more information about an error, try `rustc --explain E0045`. diff --git a/src/test/ui/in-band-lifetimes/mismatched_trait_impl.rs b/src/test/ui/in-band-lifetimes/mismatched_trait_impl.rs index 654d2bddfd0..f2ba81af9b6 100644 --- a/src/test/ui/in-band-lifetimes/mismatched_trait_impl.rs +++ b/src/test/ui/in-band-lifetimes/mismatched_trait_impl.rs @@ -7,7 +7,7 @@ trait Get { impl Get for i32 { fn foo(&self, x: &u32, y: &'a u32) -> &'a u32 { //~ ERROR cannot infer - x + x //~ ERROR lifetime mismatch } } diff --git a/src/test/ui/in-band-lifetimes/mismatched_trait_impl.stderr b/src/test/ui/in-band-lifetimes/mismatched_trait_impl.stderr index cd65bab2d46..80f15b7c584 100644 --- a/src/test/ui/in-band-lifetimes/mismatched_trait_impl.stderr +++ b/src/test/ui/in-band-lifetimes/mismatched_trait_impl.stderr @@ -20,5 +20,15 @@ LL | fn foo(&self, x: &u32, y: &'a u32) -> &'a u32 { expected fn(&i32, &'a u32, &u32) -> &'a u32 found fn(&i32, &u32, &u32) -> &u32 -error: aborting due to previous error +error[E0623]: lifetime mismatch + --> $DIR/mismatched_trait_impl.rs:10:9 + | +LL | fn foo(&self, x: &u32, y: &'a u32) -> &'a u32 { + | ---- ------- + | | + | this parameter and the return type are declared with different lifetimes... +LL | x + | ^ ...but data from `x` is returned here + +error: aborting due to 2 previous errors diff --git a/src/test/ui/infinite/infinite-tag-type-recursion.rs b/src/test/ui/infinite/infinite-tag-type-recursion.rs index 87a9e08dd38..bbfaaa62f0d 100644 --- a/src/test/ui/infinite/infinite-tag-type-recursion.rs +++ b/src/test/ui/infinite/infinite-tag-type-recursion.rs @@ -1,4 +1,5 @@ enum MList { Cons(isize, MList), Nil } //~^ ERROR recursive type `MList` has infinite size +//~| ERROR cycle detected when processing `MList` fn main() { let a = MList::Cons(10, MList::Cons(11, MList::Nil)); } diff --git a/src/test/ui/infinite/infinite-tag-type-recursion.stderr b/src/test/ui/infinite/infinite-tag-type-recursion.stderr index 88dad0033dd..8f6529db0be 100644 --- a/src/test/ui/infinite/infinite-tag-type-recursion.stderr +++ b/src/test/ui/infinite/infinite-tag-type-recursion.stderr @@ -8,6 +8,16 @@ LL | enum MList { Cons(isize, MList), Nil } | = help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `MList` representable -error: aborting due to previous error +error[E0391]: cycle detected when processing `MList` + --> $DIR/infinite-tag-type-recursion.rs:1:1 + | +LL | enum MList { Cons(isize, MList), Nil } + | ^^^^^^^^^^ + | + = note: ...which again requires processing `MList`, completing the cycle + = note: cycle used when computing dropck types for `Canonical { max_universe: U0, variables: [], value: ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: UserFacing, def_id: None }, value: MList } }` -For more information about this error, try `rustc --explain E0072`. +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0072, E0391. +For more information about an error, try `rustc --explain E0072`. diff --git a/src/test/ui/issues/issue-16048.rs b/src/test/ui/issues/issue-16048.rs index 5910481bf7e..7d24f3a40a7 100644 --- a/src/test/ui/issues/issue-16048.rs +++ b/src/test/ui/issues/issue-16048.rs @@ -22,6 +22,8 @@ impl<'a> NoLifetime for Foo<'a> { //~^ ERROR E0195 //~| NOTE lifetimes do not match method in trait return *self as T; + //~^ ERROR non-primitive cast: `Foo<'a>` as `T` + //~| NOTE an `as` expression can only be used to convert between primitive types. } } diff --git a/src/test/ui/issues/issue-16048.stderr b/src/test/ui/issues/issue-16048.stderr index 18e59bd2410..a137bcdf191 100644 --- a/src/test/ui/issues/issue-16048.stderr +++ b/src/test/ui/issues/issue-16048.stderr @@ -7,6 +7,15 @@ LL | fn get<'p, T : Test<'p>>(&self) -> T; LL | fn get<'p, T : Test<'a>>(&self) -> T { | ^^^^^^^^^^^^^^^^^^ lifetimes do not match method in trait -error: aborting due to previous error +error[E0605]: non-primitive cast: `Foo<'a>` as `T` + --> $DIR/issue-16048.rs:24:16 + | +LL | return *self as T; + | ^^^^^^^^^^ + | + = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait -For more information about this error, try `rustc --explain E0195`. +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0195, E0605. +For more information about an error, try `rustc --explain E0195`. diff --git a/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.rs b/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.rs index c648f542857..f49111c3fc7 100644 --- a/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.rs +++ b/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.rs @@ -4,5 +4,5 @@ use std::num::ParseIntError; #[test] fn can_parse_zero_as_f32() -> Result { //~ ERROR - "0".parse() + "0".parse() //~ ERROR type mismatch resolving } diff --git a/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr b/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr index 18115541af9..ce79c0c8089 100644 --- a/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr +++ b/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr @@ -9,6 +9,16 @@ LL | | } = help: the trait `std::process::Termination` is not implemented for `std::result::Result` = note: required by `test::assert_test_result` -error: aborting due to previous error +error[E0271]: type mismatch resolving `::Err == std::num::ParseIntError` + --> $DIR/termination-trait-test-wrong-type.rs:7:9 + | +LL | "0".parse() + | ^^^^^ expected struct `std::num::ParseFloatError`, found struct `std::num::ParseIntError` + | + = note: expected type `std::num::ParseFloatError` + found type `std::num::ParseIntError` -For more information about this error, try `rustc --explain E0277`. +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0271, E0277. +For more information about an error, try `rustc --explain E0271`. diff --git a/src/test/ui/structs/struct-base-wrong-type.rs b/src/test/ui/structs/struct-base-wrong-type.rs index 6252673c296..58aa35046d9 100644 --- a/src/test/ui/structs/struct-base-wrong-type.rs +++ b/src/test/ui/structs/struct-base-wrong-type.rs @@ -18,10 +18,7 @@ static foo_i: Foo = Foo { a: 2, ..4 }; //~ ERROR mismatched types fn main() { let b = Bar { x: 5 }; - // errors below are no longer caught since error above causes - // compilation to abort before we bother checking function bodies. - // See also struct-base-wrong-type-2.rs, which checks that we - // would catch these errors eventually. - let f = Foo { a: 2, ..b }; - let f__isize = Foo { a: 2, ..4 }; + // See also struct-base-wrong-type-2.rs, which checks these errors on isolation. + let f = Foo { a: 2, ..b }; //~ ERROR mismatched types + let f__isize = Foo { a: 2, ..4 }; //~ ERROR mismatched types } diff --git a/src/test/ui/structs/struct-base-wrong-type.stderr b/src/test/ui/structs/struct-base-wrong-type.stderr index 2491296c5ef..00c2e1e0dd5 100644 --- a/src/test/ui/structs/struct-base-wrong-type.stderr +++ b/src/test/ui/structs/struct-base-wrong-type.stderr @@ -16,6 +16,24 @@ LL | static foo_i: Foo = Foo { a: 2, ..4 }; = note: expected type `Foo` found type `{integer}` -error: aborting due to 2 previous errors +error[E0308]: mismatched types + --> $DIR/struct-base-wrong-type.rs:22:27 + | +LL | let f = Foo { a: 2, ..b }; + | ^ expected struct `Foo`, found struct `Bar` + | + = note: expected type `Foo` + found type `Bar` + +error[E0308]: mismatched types + --> $DIR/struct-base-wrong-type.rs:23:34 + | +LL | let f__isize = Foo { a: 2, ..4 }; + | ^ expected struct `Foo`, found integer + | + = note: expected type `Foo` + found type `{integer}` + +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/wrong-mul-method-signature.rs b/src/test/ui/wrong-mul-method-signature.rs index 54e2af55259..1c2f865599e 100644 --- a/src/test/ui/wrong-mul-method-signature.rs +++ b/src/test/ui/wrong-mul-method-signature.rs @@ -61,9 +61,8 @@ pub fn main() { let x: Vec1 = Vec1 { x: 1.0 } * 2.0; // this is OK let x: Vec2 = Vec2 { x: 1.0, y: 2.0 } * 2.0; // trait had reversed order - // (we no longer signal a compile error here, since the - // error in the trait signature will cause compilation to - // abort before we bother looking at function bodies.) + //~^ ERROR mismatched types + //~| ERROR mismatched types let x: i32 = Vec3 { x: 1.0, y: 2.0, z: 3.0 } * 2.0; } diff --git a/src/test/ui/wrong-mul-method-signature.stderr b/src/test/ui/wrong-mul-method-signature.stderr index 8630ebcb580..2317bf8e829 100644 --- a/src/test/ui/wrong-mul-method-signature.stderr +++ b/src/test/ui/wrong-mul-method-signature.stderr @@ -25,6 +25,25 @@ LL | fn mul(self, s: f64) -> f64 { = note: expected type `fn(Vec3, f64) -> i32` found type `fn(Vec3, f64) -> f64` -error: aborting due to 3 previous errors +error[E0308]: mismatched types + --> $DIR/wrong-mul-method-signature.rs:63:45 + | +LL | let x: Vec2 = Vec2 { x: 1.0, y: 2.0 } * 2.0; // trait had reversed order + | ^^^ expected struct `Vec2`, found floating-point number + | + = note: expected type `Vec2` + found type `{float}` -For more information about this error, try `rustc --explain E0053`. +error[E0308]: mismatched types + --> $DIR/wrong-mul-method-signature.rs:63:19 + | +LL | let x: Vec2 = Vec2 { x: 1.0, y: 2.0 } * 2.0; // trait had reversed order + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `Vec2`, found f64 + | + = note: expected type `Vec2` + found type `f64` + +error: aborting due to 5 previous errors + +Some errors have detailed explanations: E0053, E0308. +For more information about an error, try `rustc --explain E0053`. From 3a19df20daefa3ab62a356d9a2c603d0e396fdd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Mon, 22 Apr 2019 12:11:46 -0700 Subject: [PATCH 2/3] review comments: deduplicate tests --- src/test/ui/c-variadic/variadic-ffi-3.rs | 29 ------- src/test/ui/c-variadic/variadic-ffi-3.stderr | 76 ------------------- .../ui/structs/struct-base-wrong-type-2.rs | 19 ----- .../structs/struct-base-wrong-type-2.stderr | 21 ----- src/test/ui/structs/struct-base-wrong-type.rs | 10 --- .../ui/structs/struct-base-wrong-type.stderr | 8 +- 6 files changed, 4 insertions(+), 159 deletions(-) delete mode 100644 src/test/ui/c-variadic/variadic-ffi-3.rs delete mode 100644 src/test/ui/c-variadic/variadic-ffi-3.stderr delete mode 100644 src/test/ui/structs/struct-base-wrong-type-2.rs delete mode 100644 src/test/ui/structs/struct-base-wrong-type-2.stderr diff --git a/src/test/ui/c-variadic/variadic-ffi-3.rs b/src/test/ui/c-variadic/variadic-ffi-3.rs deleted file mode 100644 index c02d1f54e56..00000000000 --- a/src/test/ui/c-variadic/variadic-ffi-3.rs +++ /dev/null @@ -1,29 +0,0 @@ -extern { - fn foo(f: isize, x: u8, ...); - //~^ defined here - //~| defined here -} - -extern "C" fn bar(f: isize, x: u8) {} - -fn main() { - unsafe { - 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; - //~^ ERROR: mismatched types - //~| expected type `unsafe extern "C" fn(isize, u8)` - - let y: extern "C" fn(f: isize, x: u8, ...) = bar; - //~^ ERROR: mismatched types - //~| expected type `for<'r> extern "C" fn(isize, u8, std::ffi::VaList<'r>, ...)` - - foo(1, 2, 3f32); //~ ERROR can't pass `f32` to variadic function - foo(1, 2, true); //~ ERROR can't pass `bool` to variadic function - foo(1, 2, 1i8); //~ ERROR can't pass `i8` to variadic function - foo(1, 2, 1u8); //~ ERROR can't pass `u8` to variadic function - foo(1, 2, 1i16); //~ ERROR can't pass `i16` to variadic function - foo(1, 2, 1u16); //~ ERROR can't pass `u16` to variadic function - } -} diff --git a/src/test/ui/c-variadic/variadic-ffi-3.stderr b/src/test/ui/c-variadic/variadic-ffi-3.stderr deleted file mode 100644 index 28762252572..00000000000 --- a/src/test/ui/c-variadic/variadic-ffi-3.stderr +++ /dev/null @@ -1,76 +0,0 @@ -error[E0060]: this function takes at least 2 parameters but 0 parameters were supplied - --> $DIR/variadic-ffi-3.rs:11: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-3.rs:12: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-3.rs:14: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-3.rs:18: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-3.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-3.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-3.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-3.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-3.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-3.rs:27:19 - | -LL | foo(1, 2, 1u16); - | ^^^^ help: cast the value to `c_uint`: `1u16 as c_uint` - -error: aborting due to 10 previous errors - -Some errors have detailed explanations: E0060, E0308, E0617. -For more information about an error, try `rustc --explain E0060`. diff --git a/src/test/ui/structs/struct-base-wrong-type-2.rs b/src/test/ui/structs/struct-base-wrong-type-2.rs deleted file mode 100644 index 562f75b8e85..00000000000 --- a/src/test/ui/structs/struct-base-wrong-type-2.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Check that `base` in `Fru { field: expr, ..base }` must have right type. -// -// See also struct-base-wrong-type.rs, which tests same condition -// within a const expression. - -struct Foo { a: isize, b: isize } -struct Bar { x: isize } - -fn main() { - let b = Bar { x: 5 }; - let f = Foo { a: 2, ..b }; //~ ERROR mismatched types - //~| expected type `Foo` - //~| found type `Bar` - //~| expected struct `Foo`, found struct `Bar` - let f__isize = Foo { a: 2, ..4 }; //~ ERROR mismatched types - //~| expected type `Foo` - //~| found type `{integer}` - //~| expected struct `Foo`, found integer -} diff --git a/src/test/ui/structs/struct-base-wrong-type-2.stderr b/src/test/ui/structs/struct-base-wrong-type-2.stderr deleted file mode 100644 index d02ed205e92..00000000000 --- a/src/test/ui/structs/struct-base-wrong-type-2.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/struct-base-wrong-type-2.rs:11:27 - | -LL | let f = Foo { a: 2, ..b }; - | ^ expected struct `Foo`, found struct `Bar` - | - = note: expected type `Foo` - found type `Bar` - -error[E0308]: mismatched types - --> $DIR/struct-base-wrong-type-2.rs:15:34 - | -LL | let f__isize = Foo { a: 2, ..4 }; - | ^ expected struct `Foo`, found integer - | - = note: expected type `Foo` - found type `{integer}` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/structs/struct-base-wrong-type.rs b/src/test/ui/structs/struct-base-wrong-type.rs index 58aa35046d9..b64c6b49936 100644 --- a/src/test/ui/structs/struct-base-wrong-type.rs +++ b/src/test/ui/structs/struct-base-wrong-type.rs @@ -1,24 +1,14 @@ // Check that `base` in `Fru { field: expr, ..base }` must have right type. -// -// See also struct-base-wrong-type-2.rs, which tests same condition -// within a function body. struct Foo { a: isize, b: isize } struct Bar { x: isize } static bar: Bar = Bar { x: 5 }; static foo: Foo = Foo { a: 2, ..bar }; //~ ERROR mismatched types - //~| expected type `Foo` - //~| found type `Bar` - //~| expected struct `Foo`, found struct `Bar` static foo_i: Foo = Foo { a: 2, ..4 }; //~ ERROR mismatched types - //~| expected type `Foo` - //~| found type `{integer}` - //~| expected struct `Foo`, found integer fn main() { let b = Bar { x: 5 }; - // See also struct-base-wrong-type-2.rs, which checks these errors on isolation. let f = Foo { a: 2, ..b }; //~ ERROR mismatched types let f__isize = Foo { a: 2, ..4 }; //~ ERROR mismatched types } diff --git a/src/test/ui/structs/struct-base-wrong-type.stderr b/src/test/ui/structs/struct-base-wrong-type.stderr index 00c2e1e0dd5..a0216305f31 100644 --- a/src/test/ui/structs/struct-base-wrong-type.stderr +++ b/src/test/ui/structs/struct-base-wrong-type.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/struct-base-wrong-type.rs:10:33 + --> $DIR/struct-base-wrong-type.rs:7:33 | LL | static foo: Foo = Foo { a: 2, ..bar }; | ^^^ expected struct `Foo`, found struct `Bar` @@ -8,7 +8,7 @@ LL | static foo: Foo = Foo { a: 2, ..bar }; found type `Bar` error[E0308]: mismatched types - --> $DIR/struct-base-wrong-type.rs:14:35 + --> $DIR/struct-base-wrong-type.rs:8:35 | LL | static foo_i: Foo = Foo { a: 2, ..4 }; | ^ expected struct `Foo`, found integer @@ -17,7 +17,7 @@ LL | static foo_i: Foo = Foo { a: 2, ..4 }; found type `{integer}` error[E0308]: mismatched types - --> $DIR/struct-base-wrong-type.rs:22:27 + --> $DIR/struct-base-wrong-type.rs:12:27 | LL | let f = Foo { a: 2, ..b }; | ^ expected struct `Foo`, found struct `Bar` @@ -26,7 +26,7 @@ LL | let f = Foo { a: 2, ..b }; found type `Bar` error[E0308]: mismatched types - --> $DIR/struct-base-wrong-type.rs:23:34 + --> $DIR/struct-base-wrong-type.rs:13:34 | LL | let f__isize = Foo { a: 2, ..4 }; | ^ expected struct `Foo`, found integer From 2dc5d52a0414e6b65e060b98b767e95e55569a3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Mon, 22 Apr 2019 12:19:07 -0700 Subject: [PATCH 3/3] Remove needless error in test --- .../termination-trait-test-wrong-type.rs | 6 +++--- .../termination-trait-test-wrong-type.stderr | 20 +++++-------------- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.rs b/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.rs index f49111c3fc7..193a523aed2 100644 --- a/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.rs +++ b/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.rs @@ -1,8 +1,8 @@ // compile-flags: --test -use std::num::ParseIntError; +use std::num::ParseFloatError; #[test] -fn can_parse_zero_as_f32() -> Result { //~ ERROR - "0".parse() //~ ERROR type mismatch resolving +fn can_parse_zero_as_f32() -> Result { //~ ERROR + "0".parse() } diff --git a/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr b/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr index ce79c0c8089..f253b67a019 100644 --- a/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr +++ b/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr @@ -1,24 +1,14 @@ -error[E0277]: `main` has invalid return type `std::result::Result` +error[E0277]: `main` has invalid return type `std::result::Result` --> $DIR/termination-trait-test-wrong-type.rs:6:1 | -LL | / fn can_parse_zero_as_f32() -> Result { +LL | / fn can_parse_zero_as_f32() -> Result { LL | | "0".parse() LL | | } | |_^ `main` can only return types that implement `std::process::Termination` | - = help: the trait `std::process::Termination` is not implemented for `std::result::Result` + = help: the trait `std::process::Termination` is not implemented for `std::result::Result` = note: required by `test::assert_test_result` -error[E0271]: type mismatch resolving `::Err == std::num::ParseIntError` - --> $DIR/termination-trait-test-wrong-type.rs:7:9 - | -LL | "0".parse() - | ^^^^^ expected struct `std::num::ParseFloatError`, found struct `std::num::ParseIntError` - | - = note: expected type `std::num::ParseFloatError` - found type `std::num::ParseIntError` +error: aborting due to previous error -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0271, E0277. -For more information about an error, try `rustc --explain E0271`. +For more information about this error, try `rustc --explain E0277`.