diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index 5de93c5202922..5579479c5e5ac 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -966,6 +966,16 @@ fn check_expected_errors(expected_errors: Vec , line.starts_with( prefix ) } + // A multi-line error will have followup lines which will always + // start with one of these strings. + fn continuation( line: &str) -> bool { + line.starts_with(" expected") || + line.starts_with(" found") || + // 1234 + // Should have 4 spaces: see issue 18946 + line.starts_with("(") + } + // Scan and extract our error/warning messages, // which look like: // filename:line1:col1: line2:col2: *error:* msg @@ -981,7 +991,7 @@ fn check_expected_errors(expected_errors: Vec , ee.kind, ee.msg, line); - if prefix_matches(line, prefixes[i].as_slice()) && + if (prefix_matches(line, prefixes[i].as_slice()) || continuation(line)) && line.contains(ee.kind.as_slice()) && line.contains(ee.msg.as_slice()) { found_flags[i] = true; diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index fb7c5296d020e..eb6c49f6ad001 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -35,6 +35,7 @@ extern crate flate; extern crate getopts; extern crate graphviz; extern crate libc; +extern crate regex; extern crate rustc_llvm; extern crate rustc_back; extern crate serialize; diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 0089fd08c51b0..cf30969ebefcc 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -4702,7 +4702,7 @@ pub fn ty_sort_string<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> String { } ty_tup(ref tys) if tys.is_empty() => ::util::ppaux::ty_to_string(cx, ty), - ty_enum(id, _) => format!("enum {}", item_path_str(cx, id)), + ty_enum(id, _) => format!("enum `{}`", item_path_str(cx, id)), ty_uniq(_) => "box".to_string(), ty_vec(_, Some(n)) => format!("array of {} elements", n), ty_vec(_, None) => "slice".to_string(), @@ -4714,7 +4714,7 @@ pub fn ty_sort_string<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> String { format!("trait {}", item_path_str(cx, inner.principal_def_id())) } ty_struct(id, _) => { - format!("struct {}", item_path_str(cx, id)) + format!("struct `{}`", item_path_str(cx, id)) } ty_unboxed_closure(..) => "closure".to_string(), ty_tup(_) => "tuple".to_string(), diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index 26d5a9daf89b0..27acc39c77863 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -15,6 +15,8 @@ use metadata::filesearch; use session::search_paths::PathKind; use util::nodemap::NodeMap; +use regex::Regex; + use syntax::ast::NodeId; use syntax::codemap::Span; use syntax::diagnostic::{self, Emitter}; @@ -71,7 +73,58 @@ impl Session { self.diagnostic().handler().fatal(msg) } pub fn span_err(&self, sp: Span, msg: &str) { - self.diagnostic().span_err(sp, msg) + // Conditions for enabling multi-line errors: + if !msg.contains("mismatched types") && + !msg.contains("type mismatch resolving") && + !msg.contains("if and else have incompatible types") && + !msg.contains("if may be missing an else clause") && + !msg.contains("match arms have incompatible types") && + !msg.contains("structure constructor specifies a structure of type") { + return self.diagnostic().span_err(sp, msg); + } + + let first = Regex::new(r"[( ]expected").unwrap(); + let second = Regex::new(r" found").unwrap(); + let third = Regex::new( + r"\((values differ|lifetime|cyclic type of infinite size)").unwrap(); + + let mut new_msg = String::new(); + let mut head = 0u; + + // Insert `\n` before expected and found. + for (pos1, pos2) in first.find_iter(msg).zip( + second.find_iter(msg)) { + new_msg = new_msg + + // A `(` may be preceded by a space and it should be trimmed + msg[head..pos1.0].trim_right() + // prefix + "\n" + // insert before first + &msg[pos1.0..pos1.1] + // insert what first matched + &msg[pos1.1..pos2.0] + // between matches + "\n " + // insert before second + // 123 + // `expected` is 3 char longer than `found`. To align the types, `found` gets + // 3 spaces prepended. + &msg[pos2.0..pos2.1]; // insert what second matched + + head = pos2.1; + } + + let mut tail = &msg[head..]; + // Insert `\n` before any remaining messages which match. + for pos in third.find_iter(tail).take(1) { + // The end of the message may just be wrapped in `()` without `expected`/`found`. + // Push this also to a new line and add the final tail after. + new_msg = new_msg + + // `(` is usually preceded by a space and should be trimmed. + tail[..pos.0].trim_right() + // prefix + "\n" + // insert before paren + &tail[pos.0..]; // append the tail + + tail = ""; + } + + new_msg.push_str(tail); + self.diagnostic().span_err(sp, &new_msg[]) } pub fn span_err_with_code(&self, sp: Span, msg: &str, code: &str) { self.diagnostic().span_err_with_code(sp, msg, code) diff --git a/src/test/compile-fail/array-not-vector.rs b/src/test/compile-fail/array-not-vector.rs index 6581019fdd520..2415288a3eb73 100644 --- a/src/test/compile-fail/array-not-vector.rs +++ b/src/test/compile-fail/array-not-vector.rs @@ -9,8 +9,18 @@ // except according to those terms. fn main() { - let _x: isize = [1is, 2, 3]; //~ ERROR expected isize, found array of 3 elements + let _x: isize = [1is, 2, 3]; + //~^ ERROR mismatched types + //~| expected `isize` + //~| found `[isize; 3]` + //~| expected isize + //~| found array of 3 elements let x: &[isize] = &[1, 2, 3]; - let _y: &isize = x; //~ ERROR expected isize, found slice + let _y: &isize = x; + //~^ ERROR mismatched types + //~| expected `&isize` + //~| found `&[isize]` + //~| expected isize + //~| found slice } diff --git a/src/test/compile-fail/associated-types-eq-3.rs b/src/test/compile-fail/associated-types-eq-3.rs index ed81c0fccbc85..fdfff559086f3 100644 --- a/src/test/compile-fail/associated-types-eq-3.rs +++ b/src/test/compile-fail/associated-types-eq-3.rs @@ -30,7 +30,12 @@ fn foo1>(x: I) { } fn foo2(x: I) { - let _: Bar = x.boo(); //~ERROR mismatched types + let _: Bar = x.boo(); + //~^ ERROR mismatched types + //~| expected `Bar` + //~| found `::A` + //~| expected struct `Bar` + //~| found associated type } @@ -41,6 +46,12 @@ pub fn baz(x: &Foo) { pub fn main() { let a = 42is; - foo1(a); //~ERROR expected usize, found struct Bar - baz(&a); //~ERROR expected usize, found struct Bar + foo1(a); + //~^ ERROR type mismatch resolving + //~| expected usize + //~| found struct `Bar` + baz(&a); + //~^ ERROR type mismatch resolving + //~| expected usize + //~| found struct `Bar` } diff --git a/src/test/compile-fail/associated-types-path-2.rs b/src/test/compile-fail/associated-types-path-2.rs index 74c8dffced5cf..5cb9aca8bebd0 100644 --- a/src/test/compile-fail/associated-types-path-2.rs +++ b/src/test/compile-fail/associated-types-path-2.rs @@ -25,7 +25,9 @@ pub fn f2(a: T) -> T::A { pub fn f1_int_int() { f1(2is, 4is); - //~^ ERROR expected usize, found isize + //~^ ERROR type mismatch resolving + //~| expected usize + //~| found isize } pub fn f1_int_uint() { @@ -46,7 +48,11 @@ pub fn f1_uint_int() { pub fn f2_int() { let _: isize = f2(2is); - //~^ ERROR expected `isize`, found `usize` + //~^ ERROR mismatched types + //~| expected `isize` + //~| found `usize` + //~| expected isize + //~| found usize } pub fn main() { } diff --git a/src/test/compile-fail/bad-const-type.rs b/src/test/compile-fail/bad-const-type.rs index 2450f22669a51..ed62506420a7c 100644 --- a/src/test/compile-fail/bad-const-type.rs +++ b/src/test/compile-fail/bad-const-type.rs @@ -8,7 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:expected `collections::string::String`, found `isize` - static i: String = 10is; +//~^ ERROR mismatched types +//~| expected `collections::string::String` +//~| found `isize` +//~| expected struct `collections::string::String` +//~| found isize fn main() { println!("{}", i); } diff --git a/src/test/compile-fail/block-must-not-have-result-do.rs b/src/test/compile-fail/block-must-not-have-result-do.rs index 687171f8c1f9b..30039a1c54c3a 100644 --- a/src/test/compile-fail/block-must-not-have-result-do.rs +++ b/src/test/compile-fail/block-must-not-have-result-do.rs @@ -8,10 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:mismatched types: expected `()`, found `bool` - fn main() { loop { - true + true //~ ERROR mismatched types + //~| expected () + //~| found bool + //~| expected () + //~| found bool } } diff --git a/src/test/compile-fail/block-must-not-have-result-res.rs b/src/test/compile-fail/block-must-not-have-result-res.rs index 328c032325e09..6161660ddf7b3 100644 --- a/src/test/compile-fail/block-must-not-have-result-res.rs +++ b/src/test/compile-fail/block-must-not-have-result-res.rs @@ -8,13 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:mismatched types: expected `()`, found `bool` - struct r; impl Drop for r { fn drop(&mut self) { - true + true //~ ERROR mismatched types + //~| expected () + //~| found bool + //~| expected () + //~| found bool } } diff --git a/src/test/compile-fail/block-must-not-have-result-while.rs b/src/test/compile-fail/block-must-not-have-result-while.rs index ed903f3fd6551..ba6340ed395ee 100644 --- a/src/test/compile-fail/block-must-not-have-result-while.rs +++ b/src/test/compile-fail/block-must-not-have-result-while.rs @@ -8,10 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:mismatched types: expected `()`, found `bool` - fn main() { while true { - true + true //~ ERROR mismatched types + //~| expected `()` + //~| found `bool` + //~| expected () + //~| found bool } } diff --git a/src/test/compile-fail/coercion-slice.rs b/src/test/compile-fail/coercion-slice.rs index 8d48ede0e1543..d7a37d2699186 100644 --- a/src/test/compile-fail/coercion-slice.rs +++ b/src/test/compile-fail/coercion-slice.rs @@ -11,5 +11,10 @@ // Tests that we forbid coercion from `[T; n]` to `&[T]` fn main() { - let _: &[isize] = [0is]; //~ERROR: mismatched types: expected `&[isize]`, found `[isize; 1]` + let _: &[isize] = [0is]; + //~^ ERROR mismatched types + //~| expected `&[isize]` + //~| found `[isize; 1]` + //~| expected &-ptr + //~| found array of 1 elements } diff --git a/src/test/compile-fail/const-cast-different-types.rs b/src/test/compile-fail/const-cast-different-types.rs index 6b8e126db7790..6e3732908ac06 100644 --- a/src/test/compile-fail/const-cast-different-types.rs +++ b/src/test/compile-fail/const-cast-different-types.rs @@ -10,9 +10,17 @@ static a: &'static str = "foo"; static b: *const u8 = a as *const u8; -//~^ ERROR mismatched types: expected `*const u8`, found `&'static str` +//~^ ERROR mismatched types +//~| expected *const u8 +//~| found &'static str +//~| expected u8 +//~| found str static c: *const u8 = &a as *const u8; -//~^ ERROR mismatched types: expected `*const u8`, found `&&'static str` +//~^ ERROR mismatched types +//~| expected *const u8 +//~| found &&'static str +//~| expected u8 +//~| found &-ptr fn main() { } diff --git a/src/test/compile-fail/cross-borrow-trait.rs b/src/test/compile-fail/cross-borrow-trait.rs index ff96ea93184e6..86b7a8c89184a 100644 --- a/src/test/compile-fail/cross-borrow-trait.rs +++ b/src/test/compile-fail/cross-borrow-trait.rs @@ -19,6 +19,10 @@ impl Trait for Foo {} pub fn main() { let x: Box = box Foo; - let _y: &Trait = x; //~ ERROR mismatched types: expected `&Trait`, found `Box` + let _y: &Trait = x; //~ ERROR mismatched types + //~| expected `&Trait` + //~| found `Box` + //~| expected &-ptr + //~| found box } diff --git a/src/test/compile-fail/destructure-trait-ref.rs b/src/test/compile-fail/destructure-trait-ref.rs index 5166ef8f72f8b..5cc0d6a143ae2 100644 --- a/src/test/compile-fail/destructure-trait-ref.rs +++ b/src/test/compile-fail/destructure-trait-ref.rs @@ -37,7 +37,22 @@ fn main() { let box x = box 1is as Box; //~ ERROR type `Box` cannot be dereferenced // n > m - let &&x = &1is as &T; //~ ERROR found &-ptr - let &&&x = &(&1is as &T); //~ ERROR found &-ptr - let box box x = box 1is as Box; //~ ERROR found box + let &&x = &1is as &T; + //~^ ERROR mismatched types + //~| expected `T` + //~| found `&_` + //~| expected trait T + //~| found &-ptr + let &&&x = &(&1is as &T); + //~^ ERROR mismatched types + //~| expected `T` + //~| found `&_` + //~| expected trait T + //~| found &-ptr + let box box x = box 1is as Box; + //~^ ERROR mismatched types + //~| expected `T` + //~| found `Box<_>` + //~| expected trait T + //~| found box } diff --git a/src/test/compile-fail/dst-bad-assign.rs b/src/test/compile-fail/dst-bad-assign.rs index 634b5999e9ef2..152864b601c20 100644 --- a/src/test/compile-fail/dst-bad-assign.rs +++ b/src/test/compile-fail/dst-bad-assign.rs @@ -44,6 +44,11 @@ pub fn main() { // Assignment. let f5: &mut Fat = &mut Fat { f1: 5, f2: "some str", ptr: Bar1 {f :42} }; let z: Box = box Bar1 {f: 36}; - f5.ptr = Bar1 {f: 36}; //~ ERROR mismatched types: expected `ToBar`, found `Bar1` - //~^ ERROR the trait `core::marker::Sized` is not implemented for the type `ToBar` + f5.ptr = Bar1 {f: 36}; + //~^ ERROR mismatched types + //~| expected `ToBar` + //~| found `Bar1` + //~| expected trait ToBar + //~| found struct `Bar1` + //~| ERROR the trait `core::marker::Sized` is not implemented for the type `ToBar` } diff --git a/src/test/compile-fail/dst-bad-coerce1.rs b/src/test/compile-fail/dst-bad-coerce1.rs index e70db87a39a41..2b96c5ebe1284 100644 --- a/src/test/compile-fail/dst-bad-coerce1.rs +++ b/src/test/compile-fail/dst-bad-coerce1.rs @@ -22,7 +22,11 @@ pub fn main() { let f1 = Fat { ptr: [1, 2, 3] }; let f2: &Fat<[isize; 3]> = &f1; let f3: &Fat<[usize]> = f2; - //~^ ERROR mismatched types: expected `&Fat<[usize]>`, found `&Fat<[isize; 3]>` + //~^ ERROR mismatched types + //~| expected `&Fat<[usize]>` + //~| found `&Fat<[isize; 3]>` + //~| expected usize + //~| found isize // With a trait. let f1 = Fat { ptr: Foo }; diff --git a/src/test/compile-fail/dst-bad-coerce4.rs b/src/test/compile-fail/dst-bad-coerce4.rs index 8e81eacae921e..c1443bdbb309d 100644 --- a/src/test/compile-fail/dst-bad-coerce4.rs +++ b/src/test/compile-fail/dst-bad-coerce4.rs @@ -18,5 +18,9 @@ pub fn main() { // With a vec of isizes. let f1: &Fat<[isize]> = &Fat { ptr: [1, 2, 3] }; let f2: &Fat<[isize; 3]> = f1; - //~^ ERROR mismatched types: expected `&Fat<[isize; 3]>`, found `&Fat<[isize]>` + //~^ ERROR mismatched types + //~| expected `&Fat<[isize; 3]>` + //~| found `&Fat<[isize]>` + //~| expected array of 3 elements + //~| found slice } diff --git a/src/test/compile-fail/explicit-self-lifetime-mismatch.rs b/src/test/compile-fail/explicit-self-lifetime-mismatch.rs index fbc5263d82d10..92542ab3bcb81 100644 --- a/src/test/compile-fail/explicit-self-lifetime-mismatch.rs +++ b/src/test/compile-fail/explicit-self-lifetime-mismatch.rs @@ -15,8 +15,14 @@ struct Foo<'a,'b> { impl<'a,'b> Foo<'a,'b> { fn bar(self: Foo<'b,'a>) {} - //~^ ERROR mismatched types: expected `Foo<'a, 'b>`, found `Foo<'b, 'a>` - //~^^ ERROR mismatched types: expected `Foo<'a, 'b>`, found `Foo<'b, 'a>` + //~^ ERROR mismatched types + //~| expected `Foo<'a, 'b>` + //~| found `Foo<'b, 'a>` + //~| lifetime mismatch + //~| ERROR mismatched types + //~| expected `Foo<'a, 'b>` + //~| found `Foo<'b, 'a>` + //~| lifetime mismatch } fn main() {} diff --git a/src/test/compile-fail/fn-item-type.rs b/src/test/compile-fail/fn-item-type.rs index b2394a29899e7..5015810ff4774 100644 --- a/src/test/compile-fail/fn-item-type.rs +++ b/src/test/compile-fail/fn-item-type.rs @@ -18,8 +18,16 @@ fn eq(x: T, y: T) { } fn main() { let f = if true { foo } else { bar }; - //~^ ERROR expected fn item, found a different fn item + //~^ ERROR if and else have incompatible types + //~| expected `fn(isize) -> isize {foo}` + //~| found `fn(isize) -> isize {bar}` + //~| expected fn item, + //~| found a different fn item eq(foo, bar); - //~^ ERROR expected fn item, found a different fn item + //~^ ERROR mismatched types + //~| expected `fn(isize) -> isize {foo}` + //~| found `fn(isize) -> isize {bar}` + //~| expected fn item + //~| found a different fn item } diff --git a/src/test/compile-fail/fn-trait-formatting.rs b/src/test/compile-fail/fn-trait-formatting.rs index 3f5a92605b7e9..f19e27640cbc7 100644 --- a/src/test/compile-fail/fn-trait-formatting.rs +++ b/src/test/compile-fail/fn-trait-formatting.rs @@ -14,12 +14,25 @@ fn needs_fn(x: F) where F: Fn(isize) -> isize {} fn main() { - let _: () = (box |:_: isize| {}) as Box; //~ ERROR object-safe - //~^ ERROR Box + let _: () = (box |:_: isize| {}) as Box; + //~^ ERROR object-safe + //~| ERROR mismatched types + //~| expected `()` + //~| found `Box` + //~| expected () + //~| found box let _: () = (box |&:_: isize, isize| {}) as Box; - //~^ ERROR Box + //~^ ERROR mismatched types + //~| expected `()` + //~| found `Box` + //~| expected () + //~| found box let _: () = (box |&mut:| -> isize unimplemented!()) as Box isize>; - //~^ ERROR Box isize> + //~^ ERROR mismatched types + //~| expected `()` + //~| found `Box isize>` + //~| expected () + //~| found box needs_fn(1is); //~ ERROR `core::ops::Fn(isize) -> isize` } diff --git a/src/test/compile-fail/fully-qualified-type-name1.rs b/src/test/compile-fail/fully-qualified-type-name1.rs index 5ab946a53e5cc..029acbff9c333 100644 --- a/src/test/compile-fail/fully-qualified-type-name1.rs +++ b/src/test/compile-fail/fully-qualified-type-name1.rs @@ -13,5 +13,9 @@ fn main() { let x: Option; x = 5; - //~^ ERROR mismatched types: expected `core::option::Option` + //~^ ERROR mismatched types + //~| expected `core::option::Option` + //~| found `_` + //~| expected enum `core::option::Option` + //~| found integral variable } diff --git a/src/test/compile-fail/fully-qualified-type-name2.rs b/src/test/compile-fail/fully-qualified-type-name2.rs index 94af50dac0ea5..ab542d90800b2 100644 --- a/src/test/compile-fail/fully-qualified-type-name2.rs +++ b/src/test/compile-fail/fully-qualified-type-name2.rs @@ -20,7 +20,11 @@ mod y { fn bar(x: x::foo) -> y::foo { return x; - //~^ ERROR mismatched types: expected `y::foo`, found `x::foo` + //~^ ERROR mismatched types + //~| expected `y::foo` + //~| found `x::foo` + //~| expected enum `y::foo` + //~| found enum `x::foo` } fn main() { diff --git a/src/test/compile-fail/fully-qualified-type-name4.rs b/src/test/compile-fail/fully-qualified-type-name4.rs index 9250444c3e6cd..d6d668b366aa3 100644 --- a/src/test/compile-fail/fully-qualified-type-name4.rs +++ b/src/test/compile-fail/fully-qualified-type-name4.rs @@ -14,7 +14,11 @@ use std::option::Option; fn bar(x: usize) -> Option { return x; - //~^ ERROR mismatched types: expected `core::option::Option` + //~^ ERROR mismatched types + //~| expected `core::option::Option` + //~| found `usize` + //~| expected enum `core::option::Option` + //~| found usize } fn main() { diff --git a/src/test/compile-fail/generic-type-params-name-repr.rs b/src/test/compile-fail/generic-type-params-name-repr.rs index 5769b9d7932c0..3e34344d78b9d 100644 --- a/src/test/compile-fail/generic-type-params-name-repr.rs +++ b/src/test/compile-fail/generic-type-params-name-repr.rs @@ -19,23 +19,47 @@ struct HashMap>; fn main() { // Ensure that the printed type doesn't include the default type params... let _: Foo = (); - //~^ ERROR mismatched types: expected `Foo`, found `()` + //~^ ERROR mismatched types + //~| expected `Foo` + //~| found `()` + //~| expected struct `Foo` + //~| found () // ...even when they're present, but the same types as the defaults. let _: Foo = (); - //~^ ERROR mismatched types: expected `Foo`, found `()` + //~^ ERROR mismatched types + //~| expected `Foo` + //~| found `()` + //~| expected struct `Foo` + //~| found () // Including cases where the default is using previous type params. let _: HashMap = (); - //~^ ERROR mismatched types: expected `HashMap`, found `()` + //~^ ERROR mismatched types + //~| expected `HashMap` + //~| found `()` + //~| expected struct `HashMap` + //~| found () let _: HashMap> = (); - //~^ ERROR mismatched types: expected `HashMap`, found `()` + //~^ ERROR mismatched types + //~| expected `HashMap` + //~| found `()` + //~| expected struct `HashMap` + //~| found () // But not when there's a different type in between. let _: Foo = (); - //~^ ERROR mismatched types: expected `Foo`, found `()` + //~^ ERROR mismatched types + //~| expected `Foo` + //~| found `()` + //~| expected struct `Foo` + //~| found () // And don't print <> at all when there's just defaults. let _: Foo = (); - //~^ ERROR mismatched types: expected `Foo`, found `()` + //~^ ERROR mismatched types + //~| expected `Foo` + //~| found `()` + //~| expected struct `Foo` + //~| found () } diff --git a/src/test/compile-fail/if-branch-types.rs b/src/test/compile-fail/if-branch-types.rs index be54554a3c02f..2209a02c63918 100644 --- a/src/test/compile-fail/if-branch-types.rs +++ b/src/test/compile-fail/if-branch-types.rs @@ -10,5 +10,9 @@ fn main() { let x = if true { 10is } else { 10us }; - //~^ ERROR if and else have incompatible types: expected `isize`, found `usize` + //~^ ERROR if and else have incompatible types + //~| expected `isize` + //~| found `usize` + //~| expected isize + //~| found usize } diff --git a/src/test/compile-fail/if-without-else-result.rs b/src/test/compile-fail/if-without-else-result.rs index 89beb9a31601b..a9567f4272f50 100644 --- a/src/test/compile-fail/if-without-else-result.rs +++ b/src/test/compile-fail/if-without-else-result.rs @@ -10,6 +10,10 @@ fn main() { let a = if true { true }; -//~^ ERROR if may be missing an else clause: expected `()`, found `bool` (expected (), found bool) + //~^ ERROR if may be missing an else clause + //~| expected `()` + //~| found `bool` + //~| expected () + //~| found bool println!("{}", a); } diff --git a/src/test/compile-fail/integer-literal-suffix-inference.rs b/src/test/compile-fail/integer-literal-suffix-inference.rs index 1e42a9447f67a..5d9314faef982 100644 --- a/src/test/compile-fail/integer-literal-suffix-inference.rs +++ b/src/test/compile-fail/integer-literal-suffix-inference.rs @@ -39,62 +39,242 @@ fn main() { fn id_u64(n: u64) -> u64 { n } id_i8(a8); // ok - id_i8(a16); //~ ERROR mismatched types: expected `i8`, found `i16` - id_i8(a32); //~ ERROR mismatched types: expected `i8`, found `i32` - id_i8(a64); //~ ERROR mismatched types: expected `i8`, found `i64` + id_i8(a16); + //~^ ERROR mismatched types + //~| expected `i8` + //~| found `i16` + //~| expected i8 + //~| found i16 + id_i8(a32); + //~^ ERROR mismatched types + //~| expected `i8` + //~| found `i32` + //~| expected i8 + //~| found i32 + id_i8(a64); + //~^ ERROR mismatched types + //~| expected `i8` + //~| found `i64` + //~| expected i8 + //~| found i64 - id_i16(a8); //~ ERROR mismatched types: expected `i16`, found `i8` + id_i16(a8); + //~^ ERROR mismatched types + //~| expected `i16` + //~| found `i8` + //~| expected i16 + //~| found i8 id_i16(a16); // ok - id_i16(a32); //~ ERROR mismatched types: expected `i16`, found `i32` - id_i16(a64); //~ ERROR mismatched types: expected `i16`, found `i64` + id_i16(a32); + //~^ ERROR mismatched types + //~| expected `i16` + //~| found `i32` + //~| expected i16 + //~| found i32 + id_i16(a64); + //~^ ERROR mismatched types + //~| expected `i16` + //~| found `i64` + //~| expected i16 + //~| found i64 - id_i32(a8); //~ ERROR mismatched types: expected `i32`, found `i8` - id_i32(a16); //~ ERROR mismatched types: expected `i32`, found `i16` + id_i32(a8); + //~^ ERROR mismatched types + //~| expected `i32` + //~| found `i8` + //~| expected i32 + //~| found i8 + id_i32(a16); + //~^ ERROR mismatched types + //~| expected `i32` + //~| found `i16` + //~| expected i32 + //~| found i16 id_i32(a32); // ok - id_i32(a64); //~ ERROR mismatched types: expected `i32`, found `i64` + id_i32(a64); + //~^ ERROR mismatched types + //~| expected `i32` + //~| found `i64` + //~| expected i32 + //~| found i64 - id_i64(a8); //~ ERROR mismatched types: expected `i64`, found `i8` - id_i64(a16); //~ ERROR mismatched types: expected `i64`, found `i16` - id_i64(a32); //~ ERROR mismatched types: expected `i64`, found `i32` + id_i64(a8); + //~^ ERROR mismatched types + //~| expected `i64` + //~| found `i8` + //~| expected i64 + //~| found i8 + id_i64(a16); + //~^ ERROR mismatched types + //~| expected `i64` + //~| found `i16` + //~| expected i64 + //~| found i16 + id_i64(a32); + //~^ ERROR mismatched types + //~| expected `i64` + //~| found `i32` + //~| expected i64 + //~| found i32 id_i64(a64); // ok id_i8(c8); // ok - id_i8(c16); //~ ERROR mismatched types: expected `i8`, found `i16` - id_i8(c32); //~ ERROR mismatched types: expected `i8`, found `i32` - id_i8(c64); //~ ERROR mismatched types: expected `i8`, found `i64` + id_i8(c16); + //~^ ERROR mismatched types + //~| expected `i8` + //~| found `i16` + //~| expected i8 + //~| found i16 + id_i8(c32); + //~^ ERROR mismatched types + //~| expected `i8` + //~| found `i32` + //~| expected i8 + //~| found i32 + id_i8(c64); + //~^ ERROR mismatched types + //~| expected `i8` + //~| found `i64` + //~| expected i8 + //~| found i64 - id_i16(c8); //~ ERROR mismatched types: expected `i16`, found `i8` + id_i16(c8); + //~^ ERROR mismatched types + //~| expected `i16` + //~| found `i8` + //~| expected i16 + //~| found i8 id_i16(c16); // ok - id_i16(c32); //~ ERROR mismatched types: expected `i16`, found `i32` - id_i16(c64); //~ ERROR mismatched types: expected `i16`, found `i64` + id_i16(c32); + //~^ ERROR mismatched types + //~| expected `i16` + //~| found `i32` + //~| expected i16 + //~| found i32 + id_i16(c64); + //~^ ERROR mismatched types + //~| expected `i16` + //~| found `i64` + //~| expected i16 + //~| found i64 - id_i32(c8); //~ ERROR mismatched types: expected `i32`, found `i8` - id_i32(c16); //~ ERROR mismatched types: expected `i32`, found `i16` + id_i32(c8); + //~^ ERROR mismatched types + //~| expected `i32` + //~| found `i8` + //~| expected i32 + //~| found i8 + id_i32(c16); + //~^ ERROR mismatched types + //~| expected `i32` + //~| found `i16` + //~| expected i32 + //~| found i16 id_i32(c32); // ok - id_i32(c64); //~ ERROR mismatched types: expected `i32`, found `i64` + id_i32(c64); + //~^ ERROR mismatched types + //~| expected `i32` + //~| found `i64` + //~| expected i32 + //~| found i64 - id_i64(a8); //~ ERROR mismatched types: expected `i64`, found `i8` - id_i64(a16); //~ ERROR mismatched types: expected `i64`, found `i16` - id_i64(a32); //~ ERROR mismatched types: expected `i64`, found `i32` + id_i64(a8); + //~^ ERROR mismatched types + //~| expected `i64` + //~| found `i8` + //~| expected i64 + //~| found i8 + id_i64(a16); + //~^ ERROR mismatched types + //~| expected `i64` + //~| found `i16` + //~| expected i64 + //~| found i16 + id_i64(a32); + //~^ ERROR mismatched types + //~| expected `i64` + //~| found `i32` + //~| expected i64 + //~| found i32 id_i64(a64); // ok id_u8(b8); // ok - id_u8(b16); //~ ERROR mismatched types: expected `u8`, found `u16` - id_u8(b32); //~ ERROR mismatched types: expected `u8`, found `u32` - id_u8(b64); //~ ERROR mismatched types: expected `u8`, found `u64` + id_u8(b16); + //~^ ERROR mismatched types + //~| expected `u8` + //~| found `u16` + //~| expected u8 + //~| found u16 + id_u8(b32); + //~^ ERROR mismatched types + //~| expected `u8` + //~| found `u32` + //~| expected u8 + //~| found u32 + id_u8(b64); + //~^ ERROR mismatched types + //~| expected `u8` + //~| found `u64` + //~| expected u8 + //~| found u64 - id_u16(b8); //~ ERROR mismatched types: expected `u16`, found `u8` + id_u16(b8); + //~^ ERROR mismatched types + //~| expected `u16` + //~| found `u8` + //~| expected u16 + //~| found u8 id_u16(b16); // ok - id_u16(b32); //~ ERROR mismatched types: expected `u16`, found `u32` - id_u16(b64); //~ ERROR mismatched types: expected `u16`, found `u64` + id_u16(b32); + //~^ ERROR mismatched types + //~| expected `u16` + //~| found `u32` + //~| expected u16 + //~| found u32 + id_u16(b64); + //~^ ERROR mismatched types + //~| expected `u16` + //~| found `u64` + //~| expected u16 + //~| found u64 - id_u32(b8); //~ ERROR mismatched types: expected `u32`, found `u8` - id_u32(b16); //~ ERROR mismatched types: expected `u32`, found `u16` + id_u32(b8); + //~^ ERROR mismatched types + //~| expected `u32` + //~| found `u8` + //~| expected u32 + //~| found u8 + id_u32(b16); + //~^ ERROR mismatched types + //~| expected `u32` + //~| found `u16` + //~| expected u32 + //~| found u16 id_u32(b32); // ok - id_u32(b64); //~ ERROR mismatched types: expected `u32`, found `u64` + id_u32(b64); + //~^ ERROR mismatched types + //~| expected `u32` + //~| found `u64` + //~| expected u32 + //~| found u64 - id_u64(b8); //~ ERROR mismatched types: expected `u64`, found `u8` - id_u64(b16); //~ ERROR mismatched types: expected `u64`, found `u16` - id_u64(b32); //~ ERROR mismatched types: expected `u64`, found `u32` + id_u64(b8); + //~^ ERROR mismatched types + //~| expected `u64` + //~| found `u8` + //~| expected u64 + //~| found u8 + id_u64(b16); + //~^ ERROR mismatched types + //~| expected `u64` + //~| found `u16` + //~| expected u64 + //~| found u16 + id_u64(b32); + //~^ ERROR mismatched types + //~| expected `u64` + //~| found `u32` + //~| expected u64 + //~| found u32 id_u64(b64); // ok } diff --git a/src/test/compile-fail/integral-variable-unification-error.rs b/src/test/compile-fail/integral-variable-unification-error.rs index fbbe4cf8dbc4b..3374f715917c2 100644 --- a/src/test/compile-fail/integral-variable-unification-error.rs +++ b/src/test/compile-fail/integral-variable-unification-error.rs @@ -11,5 +11,9 @@ fn main() { let mut x = 2; x = 5.0; -//~^ ERROR expected `_`, found `_` (expected integral variable, found floating-point variable) + //~^ ERROR mismatched types + //~| expected `_` + //~| found `_` + //~| expected integral variable + //~| found floating-point variable } diff --git a/src/test/compile-fail/issue-10176.rs b/src/test/compile-fail/issue-10176.rs index 832cc57bd24df..6e84e777898b6 100644 --- a/src/test/compile-fail/issue-10176.rs +++ b/src/test/compile-fail/issue-10176.rs @@ -10,7 +10,11 @@ fn f() -> isize { (return 1, return 2) -//~^ ERROR mismatched types: expected `isize`, found `(_, _)` (expected isize, found tuple) +//~^ ERROR mismatched types +//~| expected `isize` +//~| found `(_, _)` +//~| expected isize +//~| found tuple } fn main() {} diff --git a/src/test/compile-fail/issue-11319.rs b/src/test/compile-fail/issue-11319.rs index c818b3bb26ce6..d3e44b71b1c89 100644 --- a/src/test/compile-fail/issue-11319.rs +++ b/src/test/compile-fail/issue-11319.rs @@ -10,7 +10,11 @@ fn main() { match Some(10) { - //~^ ERROR match arms have incompatible types: expected `bool`, found `()` + //~^ ERROR match arms have incompatible types: + //~| expected `bool` + //~| found `()` + //~| expected bool + //~| found () Some(5) => false, Some(2) => true, None => (), //~ NOTE match arm with an incompatible type diff --git a/src/test/compile-fail/issue-11771.rs b/src/test/compile-fail/issue-11771.rs index 7ce23e1f6ac79..2de86e527ef59 100644 --- a/src/test/compile-fail/issue-11771.rs +++ b/src/test/compile-fail/issue-11771.rs @@ -11,11 +11,19 @@ fn main() { let x = (); 1 + - x //~ ERROR mismatched types: expected `_`, found `()` (expected integral variable, found ()) + x //~ ERROR mismatched types + //~| expected `_` + //~| found `()` + //~| expected integral variable + //~| found () ; let x: () = (); 1 + - x //~ ERROR mismatched types: expected `_`, found `()` (expected integral variable, found ()) + x //~ ERROR mismatched types + //~| expected `_` + //~| found `()` + //~| expected integral variable + //~| found () ; } diff --git a/src/test/compile-fail/issue-12997-2.rs b/src/test/compile-fail/issue-12997-2.rs index 39957a242268f..1cf534e7e419d 100644 --- a/src/test/compile-fail/issue-12997-2.rs +++ b/src/test/compile-fail/issue-12997-2.rs @@ -12,6 +12,10 @@ //! Test that makes sure wrongly-typed bench functions are rejected -// error-pattern:expected &-ptr, found isize #[bench] fn bar(x: isize) { } +//~^ ERROR mismatched types +//~| expected `fn(&mut test::Bencher)` +//~| found `fn(isize) {bar}` +//~| expected &-ptr +//~| found isize diff --git a/src/test/compile-fail/issue-13058.rs b/src/test/compile-fail/issue-13058.rs index eee82483cae1d..61b50ef705f6a 100644 --- a/src/test/compile-fail/issue-13058.rs +++ b/src/test/compile-fail/issue-13058.rs @@ -35,5 +35,9 @@ fn check<'r, I: Iterator, T: Itble<'r, usize, I>>(cont: &T) -> bool fn main() { check((3us, 5us)); -//~^ ERROR mismatched types: expected `&_`, found `(usize, usize)` (expected &-ptr, found tuple) +//~^ ERROR mismatched types +//~| expected `&_` +//~| found `(usize, usize)` +//~| expected &-ptr +//~| found tuple } diff --git a/src/test/compile-fail/issue-13359.rs b/src/test/compile-fail/issue-13359.rs index 2e33886037708..c53e5760941f1 100644 --- a/src/test/compile-fail/issue-13359.rs +++ b/src/test/compile-fail/issue-13359.rs @@ -14,8 +14,16 @@ fn bar(_s: u32) { } fn main() { foo(1*(1 as isize)); - //~^ ERROR: mismatched types: expected `i16`, found `isize` (expected i16, found isize) + //~^ ERROR mismatched types + //~| expected `i16` + //~| found `isize` + //~| expected i16 + //~| found isize bar(1*(1 as usize)); - //~^ ERROR: mismatched types: expected `u32`, found `usize` (expected u32, found usize) + //~^ ERROR mismatched types + //~| expected `u32` + //~| found `usize` + //~| expected u32 + //~| found usize } diff --git a/src/test/compile-fail/issue-13466.rs b/src/test/compile-fail/issue-13466.rs index 7d554545b5ed2..09e2905dc401b 100644 --- a/src/test/compile-fail/issue-13466.rs +++ b/src/test/compile-fail/issue-13466.rs @@ -15,7 +15,18 @@ pub fn main() { // the actual arm `Result` has two. typeck should not be // tricked into looking up a non-existing second type parameter. let _x: usize = match Some(1us) { - Ok(u) => u, //~ ERROR mismatched types: expected `core::option::Option` - Err(e) => panic!(e) //~ ERROR mismatched types: expected `core::option::Option` + Ok(u) => u, + //~^ ERROR mismatched types + //~| expected `core::option::Option` + //~| found `core::result::Result<_, _>` + //~| expected enum `core::option::Option` + //~| found enum `core::result::Result` + + Err(e) => panic!(e) + //~^ ERROR mismatched types + //~| expected `core::option::Option` + //~| found `core::result::Result<_, _>` + //~| expected enum `core::option::Option` + //~| found enum `core::result::Result` }; } diff --git a/src/test/compile-fail/issue-13482-2.rs b/src/test/compile-fail/issue-13482-2.rs index ef7d3d4d158d9..86a79416c77bc 100644 --- a/src/test/compile-fail/issue-13482-2.rs +++ b/src/test/compile-fail/issue-13482-2.rs @@ -14,8 +14,11 @@ fn main() { let x = [1,2]; let y = match x { [] => None, - //~^ ERROR types: expected `[_#0i; 2]`, found `[_#7t; 0]` - // (expected array of 2 elements, found array of 0 elements) +//~^ ERROR mismatched types +//~| expected `[_#0i; 2]` +//~| found `[_#7t; 0]` +//~| expected an array with a fixed size of 2 elements +//~| found one with 0 elements [a,_] => Some(a) }; } diff --git a/src/test/compile-fail/issue-13482.rs b/src/test/compile-fail/issue-13482.rs index 157280b1719ad..a345ce79612cc 100644 --- a/src/test/compile-fail/issue-13482.rs +++ b/src/test/compile-fail/issue-13482.rs @@ -12,8 +12,10 @@ fn main() { let x = [1,2]; let y = match x { [] => None, -//~^ ERROR types: expected `[_; 2]`, found `[_; 0]` -// (expected array of 2 elements, found array of 0 elements) + //~^ ERROR mismatched types + //~| expected `[_; 2]` + //~| found `[_; 0]` + //~| expected array with a fixed size of 2 elements [a,_] => Some(a) }; } diff --git a/src/test/compile-fail/issue-13624.rs b/src/test/compile-fail/issue-13624.rs index 83612823c591a..2a5805790a742 100644 --- a/src/test/compile-fail/issue-13624.rs +++ b/src/test/compile-fail/issue-13624.rs @@ -15,7 +15,11 @@ mod a { pub fn get_enum_struct_variant() -> () { Enum::EnumStructVariant { x: 1, y: 2, z: 3 } -//~^ ERROR mismatched types: expected `()`, found `a::Enum` (expected (), found enum a::Enum) + //~^ ERROR mismatched types + //~| expected `()` + //~| found `a::Enum` + //~| expected () + //~| found enum `a::Enum` } } @@ -27,8 +31,11 @@ mod b { let enum_struct_variant = ::a::get_enum_struct_variant(); match enum_struct_variant { a::Enum::EnumStructVariant { x, y, z } => { - //~^ ERROR mismatched types: expected `()`, found `a::Enum` - // (expected (), found enum a::Enum) + //~^ ERROR mismatched types + //~| expected `()` + //~| found `a::Enum` + //~| expected () + // found enum `a::Enum` } } } diff --git a/src/test/compile-fail/issue-14091.rs b/src/test/compile-fail/issue-14091.rs index c2ad09f5cb4b1..3ceb465cb4b23 100644 --- a/src/test/compile-fail/issue-14091.rs +++ b/src/test/compile-fail/issue-14091.rs @@ -8,6 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern: expected `bool`, found `_` (expected bool, found integral variable) +// error-pattern:mismatched types +// error-pattern:expected `bool` +// error-pattern:found `_` +// error-pattern:expected bool +// error-pattern:found integral variable fn main(){assert!(1,1);} diff --git a/src/test/compile-fail/issue-14541.rs b/src/test/compile-fail/issue-14541.rs index ac49f8b99cf2d..deb8f00cd01c9 100644 --- a/src/test/compile-fail/issue-14541.rs +++ b/src/test/compile-fail/issue-14541.rs @@ -13,8 +13,11 @@ struct vec3 { y: f32, z: f32 } fn make(v: vec2) { let vec3 { y: _, z: _ } = v; - //~^ ERROR mismatched types: expected `vec2`, found `vec3` - // (expected struct vec2, found struct vec3) + //~^ ERROR mismatched types + //~| expected `vec2` + //~| found `vec3` + //~| expected struct `vec2` + //~| found struct `vec3` } fn main() { } diff --git a/src/test/compile-fail/issue-14845.rs b/src/test/compile-fail/issue-14845.rs index 5166d84a02543..d7ff6f2fe63ce 100644 --- a/src/test/compile-fail/issue-14845.rs +++ b/src/test/compile-fail/issue-14845.rs @@ -16,9 +16,17 @@ struct X { fn main() { let x = X { a: [0] }; let _f = &x.a as *mut u8; - //~^ ERROR mismatched types: expected `*mut u8`, found `&[u8; 1]` + //~^ ERROR mismatched types + //~| expected `*mut u8` + //~| found `&[u8; 1]` + //~| expected u8 + //~| found array of 1 elements let local = [0u8]; let _v = &local as *mut u8; - //~^ ERROR mismatched types: expected `*mut u8`, found `&[u8; 1]` + //~^ ERROR mismatched types + //~| expected `*mut u8` + //~| found `&[u8; 1]` + //~| expected u8, + //~| found array of 1 elements } diff --git a/src/test/compile-fail/issue-15783.rs b/src/test/compile-fail/issue-15783.rs index d363f2f834bb6..7080db23d42e5 100644 --- a/src/test/compile-fail/issue-15783.rs +++ b/src/test/compile-fail/issue-15783.rs @@ -16,6 +16,10 @@ fn main() { let name = "Foo"; let x = Some(&[name.as_slice()]); let msg = foo(x); -//~^ ERROR mismatched types: expected `core::option::Option<&[&str]>` +//~^ ERROR mismatched types +//~| expected `core::option::Option<&[&str]>` +//~| found `core::option::Option<&[&str; 1]>` +//~| expected slice +//~| found array of 1 elements assert_eq!(msg, 3); } diff --git a/src/test/compile-fail/issue-15896.rs b/src/test/compile-fail/issue-15896.rs index c4373ba335157..7381ade263b20 100644 --- a/src/test/compile-fail/issue-15896.rs +++ b/src/test/compile-fail/issue-15896.rs @@ -19,8 +19,11 @@ fn main() { let u = match e { E::B( Tau{t: x}, - //~^ ERROR mismatched types: expected `main::R`, found `main::Tau` - // (expected enum main::R, found struct main::Tau) + //~^ ERROR mismatched types + //~| expected `main::R` + //~| found `main::Tau` + //~| expected enum `main::R` + //~| found struct `main::Tau` _) => x, }; } diff --git a/src/test/compile-fail/issue-16338.rs b/src/test/compile-fail/issue-16338.rs index f62bccb22f359..ba936561ae53d 100644 --- a/src/test/compile-fail/issue-16338.rs +++ b/src/test/compile-fail/issue-16338.rs @@ -12,7 +12,10 @@ use std::raw::Slice; fn main() { let Slice { data: data, len: len } = "foo"; - //~^ ERROR mismatched types: expected `&str`, found `core::raw::Slice<_>` - // (expected &-ptr, found struct core::raw::Slice) + //~^ ERROR mismatched types + //~| expected `&str` + //~| found `core::raw::Slice<_>` + //~| expected &-ptr + //~| found struct `core::raw::Slice` } diff --git a/src/test/compile-fail/issue-16401.rs b/src/test/compile-fail/issue-16401.rs index 4890cc52c0005..b943ef510da28 100644 --- a/src/test/compile-fail/issue-16401.rs +++ b/src/test/compile-fail/issue-16401.rs @@ -13,8 +13,11 @@ use std::raw::Slice; fn main() { match () { Slice { data: data, len: len } => (), - //~^ ERROR mismatched types: expected `()`, found `core::raw::Slice<_>` - // (expected (), found struct core::raw::Slice) + //~^ ERROR mismatched types + //~| expected `()` + //~| found `core::raw::Slice<_>` + //~| expected () + //~| found struct `core::raw::Slice` _ => unreachable!() } } diff --git a/src/test/compile-fail/issue-17033.rs b/src/test/compile-fail/issue-17033.rs index 5048a9aa919c6..6010e206920e5 100644 --- a/src/test/compile-fail/issue-17033.rs +++ b/src/test/compile-fail/issue-17033.rs @@ -11,7 +11,11 @@ #![feature(overloaded_calls)] fn f<'r>(p: &'r mut fn(p: &mut ())) { - (*p)(()) //~ ERROR mismatched types: expected `&mut ()`, found `()` + (*p)(()) //~ ERROR mismatched types + //~| expected `&mut ()` + //~| found `()` + //~| expected &-ptr + //~| found () } fn main() {} diff --git a/src/test/compile-fail/issue-17283.rs b/src/test/compile-fail/issue-17283.rs index 0c9fd9d9486d6..4889658d083c1 100644 --- a/src/test/compile-fail/issue-17283.rs +++ b/src/test/compile-fail/issue-17283.rs @@ -21,17 +21,29 @@ fn main() { // `x { ... }` should not be interpreted as a struct literal here if x = x { - //~^ ERROR mismatched types: expected `bool`, found `()` (expected bool, found ()) + //~^ ERROR mismatched types + //~| expected `bool` + //~| found `()` + //~| expected bool + //~| found () println!("{}", x); } // Explicit parentheses on the left should match behavior of above if (x = x) { - //~^ ERROR mismatched types: expected `bool`, found `()` (expected bool, found ()) + //~^ ERROR mismatched types + //~| expected `bool` + //~| found `()` + //~| expected bool + //~| found () println!("{}", x); } // The struct literal interpretation is fine with explicit parentheses on the right if y = (Foo { foo: x }) { - //~^ ERROR mismatched types: expected `bool`, found `()` (expected bool, found ()) + //~^ ERROR mismatched types + //~| expected `bool` + //~| found `()` + //~| expected bool + //~| found () println!("{}", x); } } diff --git a/src/test/compile-fail/issue-17740.rs b/src/test/compile-fail/issue-17740.rs index 73f86fee903e5..b4791eba76e26 100644 --- a/src/test/compile-fail/issue-17740.rs +++ b/src/test/compile-fail/issue-17740.rs @@ -14,8 +14,14 @@ struct Foo<'a> { impl <'a> Foo<'a>{ fn bar(self: &mut Foo) { - //~^ mismatched types: expected `Foo<'a>`, found `Foo<'_>` (lifetime mismatch) - //~| mismatched types: expected `Foo<'a>`, found `Foo<'_>` (lifetime mismatch) + //~^ mismatched types + //~| expected `Foo<'a>` + //~| found `Foo<'_>` + //~| lifetime mismatch + //~| mismatched types + //~| expected `Foo<'a>` + //~| found `Foo<'_>` + //~| lifetime mismatch } } diff --git a/src/test/compile-fail/issue-17905.rs b/src/test/compile-fail/issue-17905.rs index 1418cdf403993..9d1047f68e6c7 100644 --- a/src/test/compile-fail/issue-17905.rs +++ b/src/test/compile-fail/issue-17905.rs @@ -16,7 +16,10 @@ impl Pair< isize > { fn say(self: &Pair<&str, isize>) { -//~^ ERROR mismatched types: expected `Pair<&'static str, isize>`, found `Pair<&str, isize>` +//~^ ERROR mismatched types +//~| expected `Pair<&'static str, isize>` +//~| found `Pair<&str, isize>` +//~| lifetime mismatch println!("{}", self); } } diff --git a/src/test/compile-fail/issue-19991.rs b/src/test/compile-fail/issue-19991.rs index 0f1dbfa349277..2d73b98ec1e60 100644 --- a/src/test/compile-fail/issue-19991.rs +++ b/src/test/compile-fail/issue-19991.rs @@ -12,7 +12,11 @@ // clause does not exist, instead of the unsympathetic "match arms have incompatible types" fn main() { - if let Some(homura) = Some("madoka") { //~ ERROR missing an else clause: expected `()` + if let Some(homura) = Some("madoka") { //~ ERROR missing an else clause + //~| expected `()` + //~| found `i32` + //~| expected () + //~| found i32 765i32 }; } diff --git a/src/test/compile-fail/issue-2951.rs b/src/test/compile-fail/issue-2951.rs index 694bf05b21035..d0781b5658087 100644 --- a/src/test/compile-fail/issue-2951.rs +++ b/src/test/compile-fail/issue-2951.rs @@ -10,7 +10,12 @@ fn foo(x: T, y: U) { let mut xx = x; - xx = y; //~ ERROR expected `T`, found `U` + xx = y; + //~^ ERROR mismatched types + //~| expected `T` + //~| found `U` + //~| expected type parameter + //~| found a different type parameter } fn main() { diff --git a/src/test/compile-fail/issue-3477.rs b/src/test/compile-fail/issue-3477.rs index 798a8cfec9a6e..5e7c23164cbbb 100644 --- a/src/test/compile-fail/issue-3477.rs +++ b/src/test/compile-fail/issue-3477.rs @@ -9,5 +9,10 @@ // except according to those terms. fn main() { - let _p: char = 100; //~ ERROR mismatched types: expected `char`, found + let _p: char = 100; + //~^ ERROR mismatched types + //~| expected `char` + //~| found `u8` + //~| expected char + //~| found u8 } diff --git a/src/test/compile-fail/issue-3563.rs b/src/test/compile-fail/issue-3563.rs index 86ab9be77fc68..7ebc5b7a5b96b 100644 --- a/src/test/compile-fail/issue-3563.rs +++ b/src/test/compile-fail/issue-3563.rs @@ -10,8 +10,13 @@ trait A { fn a(&self) { - |&:| self.b() //~ ERROR type `&Self` does not implement any method in scope named `b` - //~^ ERROR expected (), found closure + |&:| self.b() + //~^ ERROR type `&Self` does not implement any method in scope named `b` + //~| ERROR mismatched types + //~| expected `()` + //~| found closure + //~| expected () + //~| found closure } } fn main() {} diff --git a/src/test/compile-fail/issue-3680.rs b/src/test/compile-fail/issue-3680.rs index f018a02a945a9..4aff95b57decb 100644 --- a/src/test/compile-fail/issue-3680.rs +++ b/src/test/compile-fail/issue-3680.rs @@ -11,7 +11,10 @@ fn main() { match None { Err(_) => () - //~^ ERROR mismatched types: expected `core::option::Option<_>` - // , found `core::result::Result<_, _>` + //~^ ERROR mismatched types + //~| expected `core::option::Option<_>` + //~| found `core::result::Result<_, _>` + //~| expected enum `core::option::Option` + //~| found enum `core::result::Result` } } diff --git a/src/test/compile-fail/issue-4201.rs b/src/test/compile-fail/issue-4201.rs index 0391c73d90a6c..b5af1f03b635b 100644 --- a/src/test/compile-fail/issue-4201.rs +++ b/src/test/compile-fail/issue-4201.rs @@ -12,7 +12,11 @@ fn main() { let a = if true { 0 } else if false { -//~^ ERROR if may be missing an else clause: expected `()`, found `_` +//~^ ERROR if may be missing an else clause +//~| expected `()` +//~| found `_` +//~| expected () +//~| found integral variable 1 }; } diff --git a/src/test/compile-fail/issue-4517.rs b/src/test/compile-fail/issue-4517.rs index 1943f1e5a1954..881e124fd6892 100644 --- a/src/test/compile-fail/issue-4517.rs +++ b/src/test/compile-fail/issue-4517.rs @@ -13,6 +13,9 @@ fn bar(int_param: usize) {} fn main() { let foo: [u8; 4] = [1u8; 4us]; bar(foo); - //~^ ERROR mismatched types: expected `usize`, found `[u8; 4]` - // (expected usize, found vector) + //~^ ERROR mismatched types + //~| expected `usize` + //~| found `[u8; 4]` + //~| expected usize + //~| found array of 4 elements } diff --git a/src/test/compile-fail/issue-4968.rs b/src/test/compile-fail/issue-4968.rs index 88933c0add929..e7cd20f38a1d2 100644 --- a/src/test/compile-fail/issue-4968.rs +++ b/src/test/compile-fail/issue-4968.rs @@ -13,6 +13,9 @@ const A: (isize,isize) = (4,2); fn main() { match 42 { A => () } - //~^ ERROR mismatched types: expected `_`, found `(isize, isize)` - // (expected integral variable, found tuple) + //~^ ERROR mismatched types + //~| expected `_` + //~| found `(isize, isize)` + //~| expected integral variable + //~| found tuple } diff --git a/src/test/compile-fail/issue-5100.rs b/src/test/compile-fail/issue-5100.rs index ca7f87ff61ae3..b051abbc7ff50 100644 --- a/src/test/compile-fail/issue-5100.rs +++ b/src/test/compile-fail/issue-5100.rs @@ -15,28 +15,48 @@ enum A { B, C } fn main() { match (true, false) { A::B => (), -//~^ ERROR mismatched types: expected `(bool, bool)`, found `A` (expected tuple, found enum A) +//~^ ERROR mismatched types: +//~| expected `(bool, bool)` +//~| found `A` +//~| expected tuple +//~| found enum `A` _ => () } match (true, false) { (true, false, false) => () -//~^ ERROR mismatched types: expected `(bool, bool)`, found `(_, _, _)` +//~^ ERROR mismatched types +//~| expected `(bool, bool)` +//~| found `(_, _, _)` +//~| expected a tuple with 2 elements +//~| found one with 3 elements } match (true, false) { (true, false, false) => () -//~^ ERROR (expected a tuple with 2 elements, found one with 3 elements) +//~^ ERROR mismatched types +//~| expected `(bool, bool)` +//~| found `(_, _, _)` +//~| expected a tuple with 2 elements +//~| found one with 3 elements } match (true, false) { box (true, false) => () -//~^ ERROR mismatched types: expected `(bool, bool)`, found `Box<_>` (expected tuple, found box) +//~^ ERROR mismatched types +//~| expected `(bool, bool)` +//~| found `Box<_>` +//~| expected tuple +//~| found box } match (true, false) { &(true, false) => () -//~^ ERROR mismatched types: expected `(bool, bool)`, found `&_` (expected tuple, found &-ptr) +//~^ ERROR mismatched types +//~| expected `(bool, bool)` +//~| found `&_` +//~| expected tuple +//~| found &-ptr } @@ -47,5 +67,9 @@ fn main() { for &(x,y) in v.iter() {} // should be OK // Make sure none of the errors above were fatal - let x: char = true; //~ ERROR expected `char`, found `bool` + let x: char = true; //~ ERROR mismatched types + //~| expected `char` + //~| found `bool` + //~| expected char + //~| found bool } diff --git a/src/test/compile-fail/issue-5358-1.rs b/src/test/compile-fail/issue-5358-1.rs index 96bad3a6a4455..32702d3e2f6fe 100644 --- a/src/test/compile-fail/issue-5358-1.rs +++ b/src/test/compile-fail/issue-5358-1.rs @@ -13,7 +13,12 @@ struct S(Either); fn main() { match S(Either::Left(5)) { - Either::Right(_) => {} //~ ERROR mismatched types: expected `S`, found `Either + Either::Right(_) => {} + //~^ ERROR mismatched types + //~| expected `S` + //~| found `Either<_, _>` + //~| expected struct `S` + //~| found enum `Either` _ => {} } } diff --git a/src/test/compile-fail/issue-5500.rs b/src/test/compile-fail/issue-5500.rs index 56867349065a5..565634191be9a 100644 --- a/src/test/compile-fail/issue-5500.rs +++ b/src/test/compile-fail/issue-5500.rs @@ -10,5 +10,9 @@ fn main() { &panic!() - //~^ ERROR mismatched types: expected `()`, found `&_` (expected (), found &-ptr) + //~^ ERROR mismatched types + //~| expected `()` + //~| found `&_` + //~| expected () + //~| found &-ptr } diff --git a/src/test/compile-fail/issue-7061.rs b/src/test/compile-fail/issue-7061.rs index c6869c44057f9..e261249bc998e 100644 --- a/src/test/compile-fail/issue-7061.rs +++ b/src/test/compile-fail/issue-7061.rs @@ -12,7 +12,11 @@ struct BarStruct; impl<'a> BarStruct { fn foo(&'a mut self) -> Box { self } - //~^ ERROR: error: mismatched types: expected `Box`, found `&'a mut BarStruct + //~^ ERROR mismatched types + //~| expected `Box` + //~| found `&'a mut BarStruct` + //~| expected box + //~| found &-ptr } fn main() {} diff --git a/src/test/compile-fail/issue-7092.rs b/src/test/compile-fail/issue-7092.rs index 116639f49459f..eefb34fbe4c91 100644 --- a/src/test/compile-fail/issue-7092.rs +++ b/src/test/compile-fail/issue-7092.rs @@ -14,7 +14,11 @@ enum Whatever { fn foo(x: Whatever) { match x { Some(field) => -//~^ ERROR: mismatched types: expected `Whatever`, found `core::option::Option<_>` +//~^ ERROR mismatched types +//~| expected `Whatever` +//~| found `core::option::Option<_>` +//~| expected enum `Whatever` +//~| found enum `core::option::Option` field.access(), //~ ERROR the type of this value must be known in this context } } diff --git a/src/test/compile-fail/issue-7867.rs b/src/test/compile-fail/issue-7867.rs index e459a243cc8a5..0e81ec19c815a 100644 --- a/src/test/compile-fail/issue-7867.rs +++ b/src/test/compile-fail/issue-7867.rs @@ -14,14 +14,27 @@ mod foo { pub fn bar() {} } fn main() { match (true, false) { - A::B => (), //~ ERROR expected `(bool, bool)`, found `A` (expected tuple, found enum A) + A::B => (), + //~^ ERROR mismatched types + //~| expected `(bool, bool)` + //~| found `A` + //~| expected tuple + //~| found enum `A` _ => () } match &Some(42is) { - Some(x) => (), //~ ERROR expected `&core::option::Option`, - // found `core::option::Option<_>` - None => () //~ ERROR expected `&core::option::Option`, - // found `core::option::Option<_>` + Some(x) => (), + //~^ ERROR mismatched types + //~| expected `&core::option::Option` + //~| found `core::option::Option<_>` + //~| expected &-ptr + //~| found enum `core::option::Option` + None => () + //~^ ERROR mismatched types + //~| expected `&core::option::Option` + //~| found `core::option::Option<_>` + //~| expected &-ptr + //~| found enum `core::option::Option` } } diff --git a/src/test/compile-fail/issue-8761.rs b/src/test/compile-fail/issue-8761.rs index 3f9e92afba2b1..30e4ec8ad0e6d 100644 --- a/src/test/compile-fail/issue-8761.rs +++ b/src/test/compile-fail/issue-8761.rs @@ -10,9 +10,17 @@ enum Foo { A = 1i64, - //~^ ERROR mismatched types: expected `isize`, found `i64` + //~^ ERROR mismatched types + //~| expected `isize` + //~| found `i64` + //~| expected isize + //~| found i64 B = 2u8 - //~^ ERROR mismatched types: expected `isize`, found `u8` + //~^ ERROR mismatched types + //~| expected `isize` + //~| found `u8` + //~| expected isize + //~| found u8 } fn main() {} diff --git a/src/test/compile-fail/match-struct.rs b/src/test/compile-fail/match-struct.rs index e3b47372a4f40..5bda37896879b 100644 --- a/src/test/compile-fail/match-struct.rs +++ b/src/test/compile-fail/match-struct.rs @@ -14,7 +14,12 @@ enum E { C(isize) } fn main() { match (S { a: 1 }) { - E::C(_) => (), //~ ERROR mismatched types: expected `S`, found `E` + E::C(_) => (), + //~^ ERROR mismatched types + //~| expected `S` + //~| found `E` + //~| expected struct `S` + //~| found enum `E` _ => () } } diff --git a/src/test/compile-fail/match-vec-mismatch-2.rs b/src/test/compile-fail/match-vec-mismatch-2.rs index 6bb049f3ca5e8..a4abdf3ddfe94 100644 --- a/src/test/compile-fail/match-vec-mismatch-2.rs +++ b/src/test/compile-fail/match-vec-mismatch-2.rs @@ -11,6 +11,10 @@ fn main() { match () { [()] => { } -//~^ ERROR mismatched types: expected `()`, found `&[_]` (expected (), found &-ptr) + //~^ ERROR mismatched types + //~| expected `()` + //~| found `&[_]` + //~| expected () + //~| found &-ptr } } diff --git a/src/test/compile-fail/method-self-arg-1.rs b/src/test/compile-fail/method-self-arg-1.rs index 178b73199766e..4d416ed42debf 100644 --- a/src/test/compile-fail/method-self-arg-1.rs +++ b/src/test/compile-fail/method-self-arg-1.rs @@ -18,7 +18,19 @@ impl Foo { fn main() { let x = Foo; - Foo::bar(x); //~ERROR mismatched types: expected `&Foo`, found `Foo` - Foo::bar(&&x); //~ERROR mismatched types: expected `&Foo`, found `&&Foo` - Foo::bar(&42is); //~ERROR mismatched types: expected `&Foo`, found `&isize` + Foo::bar(x); //~ ERROR mismatched types + //~| expected `&Foo` + //~| found `Foo` + //~| expected &-ptr + //~| found struct `Foo` + Foo::bar(&&x); //~ ERROR mismatched types + //~| expected `&Foo` + //~| found `&&Foo` + //~| expected struct `Foo` + //~| found &-ptr + Foo::bar(&42is); //~ ERROR mismatched types + //~| expected `&Foo` + //~| found `&isize` + //~| expected struct `Foo` + //~| found isize } diff --git a/src/test/compile-fail/mut-pattern-mismatched.rs b/src/test/compile-fail/mut-pattern-mismatched.rs index 9f1d3d1fb3912..a3d016d756ffc 100644 --- a/src/test/compile-fail/mut-pattern-mismatched.rs +++ b/src/test/compile-fail/mut-pattern-mismatched.rs @@ -13,12 +13,18 @@ fn main() { // (separate lines to ensure the spans are accurate) - let &_ //~ ERROR expected `&mut isize`, found `&_` + let &_ //~ ERROR mismatched types + //~| expected `&mut isize` + //~| found `&_` + //~| values differ in mutability = foo; let &mut _ = foo; let bar = &1is; let &_ = bar; - let &mut _ //~ ERROR expected `&isize`, found `&mut _` + let &mut _ //~ ERROR mismatched types + //~| expected `&isize` + //~| found `&mut _` + //~| values differ in mutability = bar; } diff --git a/src/test/compile-fail/noexporttypeexe.rs b/src/test/compile-fail/noexporttypeexe.rs index 8fa4e81c88955..85a47492306af 100644 --- a/src/test/compile-fail/noexporttypeexe.rs +++ b/src/test/compile-fail/noexporttypeexe.rs @@ -18,5 +18,9 @@ fn main() { // because the def_id associated with the type was // not convertible to a path. let x: isize = noexporttypelib::foo(); - //~^ ERROR expected `isize`, found `core::option::Option` + //~^ ERROR mismatched types + //~| expected `isize` + //~| found `core::option::Option` + //~| expected isize + //~| found enum `core::option::Option` } diff --git a/src/test/compile-fail/occurs-check-2.rs b/src/test/compile-fail/occurs-check-2.rs index bfabcff511686..fd2903a85ddb0 100644 --- a/src/test/compile-fail/occurs-check-2.rs +++ b/src/test/compile-fail/occurs-check-2.rs @@ -14,5 +14,9 @@ fn main() { let f; let g; g = f; - f = box g; //~ ERROR cyclic type of infinite size + f = box g; + //~^ ERROR mismatched types + //~| expected `_` + //~| found `Box<_>` + //~| cyclic type of infinite size } diff --git a/src/test/compile-fail/occurs-check.rs b/src/test/compile-fail/occurs-check.rs index 417bd9b57ee0a..036fcc1b9d779 100644 --- a/src/test/compile-fail/occurs-check.rs +++ b/src/test/compile-fail/occurs-check.rs @@ -12,5 +12,9 @@ fn main() { let f; - f = box f; //~ ERROR cyclic type of infinite size + f = box f; + //~^ ERROR mismatched types + //~| expected `_` + //~| found `Box<_>` + //~| cyclic type of infinite size } diff --git a/src/test/compile-fail/pattern-error-continue.rs b/src/test/compile-fail/pattern-error-continue.rs index c288429dcda0c..aa7202574abfc 100644 --- a/src/test/compile-fail/pattern-error-continue.rs +++ b/src/test/compile-fail/pattern-error-continue.rs @@ -30,9 +30,18 @@ fn main() { } match 'c' { S { .. } => (), - //~^ ERROR mismatched types: expected `char`, found `S` (expected char, found struct S) + //~^ ERROR mismatched types + //~| expected `char` + //~| found `S` + //~| expected char + //~| found struct `S` _ => () } - f(true); //~ ERROR mismatched types: expected `char`, found `bool` + f(true); + //~^ ERROR mismatched types + //~| expected `char` + //~| found `bool` + //~| expected char + //~| found bool } diff --git a/src/test/compile-fail/pptypedef.rs b/src/test/compile-fail/pptypedef.rs index e3c440d61cec3..9e5081ed55028 100644 --- a/src/test/compile-fail/pptypedef.rs +++ b/src/test/compile-fail/pptypedef.rs @@ -12,8 +12,16 @@ fn let_in(x: T, f: F) where F: FnOnce(T) {} fn main() { let_in(3us, |i| { assert!(i == 3is); }); - //~^ ERROR expected `usize`, found `isize` + //~^ ERROR mismatched types + //~| expected `usize` + //~| found `isize` + //~| expected usize + //~| found isize let_in(3is, |i| { assert!(i == 3us); }); - //~^ ERROR expected `isize`, found `usize` + //~^ ERROR mismatched types + //~| expected `isize` + //~| found `usize` + //~| expected isize + //~| found usize } diff --git a/src/test/compile-fail/ptr-coercion.rs b/src/test/compile-fail/ptr-coercion.rs index 392a803b0dd9f..463754b29c7b4 100644 --- a/src/test/compile-fail/ptr-coercion.rs +++ b/src/test/compile-fail/ptr-coercion.rs @@ -14,11 +14,20 @@ pub fn main() { // *const -> *mut let x: *const isize = &42is; - let x: *mut isize = x; //~ERROR values differ in mutability + let x: *mut isize = x; //~ ERROR mismatched types + //~| expected `*mut isize` + //~| found `*const isize` + //~| values differ in mutability // & -> *mut - let x: *mut isize = &42; //~ERROR values differ in mutability + let x: *mut isize = &42; //~ ERROR mismatched types + //~| expected `*mut isize` + //~| found `&isize` + //~| values differ in mutability let x: *const isize = &42; - let x: *mut isize = x; //~ERROR values differ in mutability + let x: *mut isize = x; //~ ERROR mismatched types + //~| expected `*mut isize` + //~| found `*const isize` + //~| values differ in mutability } diff --git a/src/test/compile-fail/regions-bounds.rs b/src/test/compile-fail/regions-bounds.rs index c26740c9598d6..7f2889a327be0 100644 --- a/src/test/compile-fail/regions-bounds.rs +++ b/src/test/compile-fail/regions-bounds.rs @@ -16,11 +16,17 @@ struct an_enum<'a>(&'a isize); struct a_class<'a> { x:&'a isize } fn a_fn1<'a,'b>(e: an_enum<'a>) -> an_enum<'b> { - return e; //~ ERROR mismatched types: expected `an_enum<'b>`, found `an_enum<'a>` + return e; //~ ERROR mismatched types + //~| expected `an_enum<'b>` + //~| found `an_enum<'a>` + //~| lifetime mismatch } fn a_fn3<'a,'b>(e: a_class<'a>) -> a_class<'b> { - return e; //~ ERROR mismatched types: expected `a_class<'b>`, found `a_class<'a>` + return e; //~ ERROR mismatched types + //~| expected `a_class<'b>` + //~| found `a_class<'a>` + //~| lifetime mismatch } fn main() { } diff --git a/src/test/compile-fail/regions-early-bound-error-method.rs b/src/test/compile-fail/regions-early-bound-error-method.rs index c83fb09651298..4a3ca01c8496d 100644 --- a/src/test/compile-fail/regions-early-bound-error-method.rs +++ b/src/test/compile-fail/regions-early-bound-error-method.rs @@ -27,8 +27,12 @@ impl<'a> GetRef<'a> for Box<'a> { impl<'a> Box<'a> { fn or<'b,G:GetRef<'b>>(&self, g2: G) -> &'a isize { - g2.get() //~ ERROR cannot infer an appropriate lifetime for automatic coercion due to - //~^ ERROR mismatched types: expected `&'a isize`, found `&'b isize` (lifetime mismatch) + g2.get() + //~^ ERROR cannot infer an appropriate lifetime for automatic coercion due to + //~| ERROR mismatched types + //~| expected `&'a isize` + //~| found `&'b isize` + //~| lifetime mismatch } } diff --git a/src/test/compile-fail/regions-early-bound-error.rs b/src/test/compile-fail/regions-early-bound-error.rs index cc6acdca78e81..57c8e3f1170aa 100644 --- a/src/test/compile-fail/regions-early-bound-error.rs +++ b/src/test/compile-fail/regions-early-bound-error.rs @@ -26,8 +26,12 @@ impl<'a,T:Clone> GetRef<'a,T> for Box<'a,T> { } fn get<'a,'b,G:GetRef<'a, isize>>(g1: G, b: &'b isize) -> &'b isize { - g1.get() //~ ERROR cannot infer an appropriate lifetime for automatic coercion due to - //~^ ERROR mismatched types: expected `&'b isize`, found `&'a isize` (lifetime mismatch) + g1.get() + //~^ ERROR cannot infer an appropriate lifetime for automatic coercion due to + //~| ERROR mismatched types + //~| expected `&'b isize` + //~| found `&'a isize` + //~| lifetime mismatch } fn main() { diff --git a/src/test/compile-fail/regions-fn-subtyping-return-static.rs b/src/test/compile-fail/regions-fn-subtyping-return-static.rs index ac56e8ce14df6..ebf7ca289f889 100644 --- a/src/test/compile-fail/regions-fn-subtyping-return-static.rs +++ b/src/test/compile-fail/regions-fn-subtyping-return-static.rs @@ -53,7 +53,12 @@ fn supply_F() { fn supply_G() { want_G(foo); want_G(bar); - want_G(baz); //~ ERROR expected concrete lifetime + want_G(baz); + //~^ ERROR mismatched types + //~| expected `fn(&'cx S) -> &'static S` + //~| found `fn(&S) -> &S {baz}` + //~| expected concrete lifetime + //~| found bound lifetime parameter 'cx } pub fn main() { diff --git a/src/test/compile-fail/regions-infer-paramd-indirect.rs b/src/test/compile-fail/regions-infer-paramd-indirect.rs index 0d441380e8144..1d32e8fe7b250 100644 --- a/src/test/compile-fail/regions-infer-paramd-indirect.rs +++ b/src/test/compile-fail/regions-infer-paramd-indirect.rs @@ -31,7 +31,10 @@ impl<'a> set_f<'a> for c<'a> { fn set_f_bad(&mut self, b: Box) { self.f = b; - //~^ ERROR mismatched types: expected `Box>`, found `Box>` + //~^ ERROR mismatched types + //~| expected `Box>` + //~| found `Box>` + //~| lifetime mismatch } } diff --git a/src/test/compile-fail/repeat_count.rs b/src/test/compile-fail/repeat_count.rs index e94bf19955bdc..df69e13bf1e65 100644 --- a/src/test/compile-fail/repeat_count.rs +++ b/src/test/compile-fail/repeat_count.rs @@ -14,14 +14,33 @@ fn main() { let n = 1; let a = [0; n]; //~ ERROR expected constant integer for repeat count, found variable let b = [0; ()]; -//~^ ERROR expected constant integer for repeat count, found non-constant expression -//~^^ ERROR: expected `usize`, found `()` - let c = [0; true]; //~ ERROR expected positive integer for repeat count, found boolean - //~^ ERROR: expected `usize`, found `bool` - let d = [0; 0.5]; //~ ERROR expected positive integer for repeat count, found float - //~^ ERROR: expected `usize`, found `_` - let e = [0; "foo"]; //~ ERROR expected positive integer for repeat count, found string - //~^ ERROR: expected `usize`, found `&'static str` +//~^ ERROR mismatched types +//~| expected `usize` +//~| found `()` +//~| expected usize +//~| found () +//~| ERROR expected constant integer for repeat count, found non-constant expression + let c = [0; true]; + //~^ ERROR mismatched types + //~| expected `usize` + //~| found `bool` + //~| expected usize + //~| found bool + //~| ERROR expected positive integer for repeat count, found boolean + let d = [0; 0.5]; + //~^ ERROR mismatched types + //~| expected `usize` + //~| found `_` + //~| expected usize + //~| found floating-point variable + //~| ERROR expected positive integer for repeat count, found float + let e = [0; "foo"]; + //~^ ERROR mismatched types + //~| expected `usize` + //~| found `&'static str` + //~| expected usize + //~| found &-ptr + //~| ERROR expected positive integer for repeat count, found string let f = [0; -4]; //~^ ERROR expected positive integer for repeat count, found negative integer let f = [0us; -1]; diff --git a/src/test/compile-fail/shift-various-bad-types.rs b/src/test/compile-fail/shift-various-bad-types.rs index 4178858404905..66aef0ec3a1b1 100644 --- a/src/test/compile-fail/shift-various-bad-types.rs +++ b/src/test/compile-fail/shift-various-bad-types.rs @@ -36,7 +36,11 @@ fn foo(p: &Panolpy) { // Type of the result follows the LHS, not the RHS: let _: i32 = 22_i64 >> 1_i32; - //~^ ERROR mismatched types: expected `i32`, found `i64` + //~^ ERROR mismatched types + //~| expected `i32` + //~| found `i64` + //~| expected i32 + //~| found i64) } fn main() { diff --git a/src/test/compile-fail/slightly-nice-generic-literal-messages.rs b/src/test/compile-fail/slightly-nice-generic-literal-messages.rs index a655a17c037d2..1203d62234899 100644 --- a/src/test/compile-fail/slightly-nice-generic-literal-messages.rs +++ b/src/test/compile-fail/slightly-nice-generic-literal-messages.rs @@ -13,7 +13,11 @@ struct Foo(T); fn main() { match Foo(1.1) { 1 => {} - //~^ ERROR expected `Foo<_, _>`, found `_` + //~^ ERROR mismatched types + //~| expected `Foo<_, _>` + //~| found `_` + //~| expected struct `Foo` + //~| found integral variable } } diff --git a/src/test/compile-fail/struct-base-wrong-type.rs b/src/test/compile-fail/struct-base-wrong-type.rs index 2bb8d32a7e3e2..71a2b50b612d9 100644 --- a/src/test/compile-fail/struct-base-wrong-type.rs +++ b/src/test/compile-fail/struct-base-wrong-type.rs @@ -12,11 +12,27 @@ 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 `Foo`, found `Bar` -static foo_i: Foo = Foo { a: 2, ..4 }; //~ ERROR mismatched types: expected `Foo` +static foo: Foo = Foo { a: 2, ..bar }; //~ ERROR mismatched types + //~| expected `Foo` + //~| found `Bar` + //~| expected struct `Foo` + //~| found struct `Bar` +static foo_i: Foo = Foo { a: 2, ..4 }; //~ ERROR mismatched types + //~| expected `Foo` + //~| found `_` + //~| expected struct `Foo` + //~| found integral variable fn main() { let b = Bar { x: 5 }; - let f = Foo { a: 2, ..b }; //~ ERROR mismatched types: expected `Foo`, found `Bar` - let f_i = Foo { a: 2, ..4 }; //~ ERROR mismatched types: expected `Foo` + let f = Foo { a: 2, ..b }; //~ ERROR mismatched types + //~| expected `Foo` + //~| found `Bar` + //~| expected struct `Foo` + //~| found struct `Bar` + let f_i = Foo { a: 2, ..4 }; //~ ERROR mismatched types + //~| expected `Foo` + //~| found `_` + //~| expected struct `Foo` + //~| found integral variable } diff --git a/src/test/compile-fail/structure-constructor-type-mismatch.rs b/src/test/compile-fail/structure-constructor-type-mismatch.rs index fb84c1e2ebe9a..a22f390499f27 100644 --- a/src/test/compile-fail/structure-constructor-type-mismatch.rs +++ b/src/test/compile-fail/structure-constructor-type-mismatch.rs @@ -24,25 +24,33 @@ type PairF = Pair; fn main() { let pt = PointF { - //~^ ERROR expected f32, found isize + //~^ ERROR structure constructor specifies a structure of type + //~| expected f32 + //~| found isize x: 1is, y: 2is, }; let pt2 = Point:: { - //~^ ERROR expected f32, found isize + //~^ ERROR structure constructor specifies a structure of type + //~| expected f32 + //~| found isize x: 3is, y: 4is, }; let pair = PairF { - //~^ ERROR expected f32, found isize + //~^ ERROR structure constructor specifies a structure of type + //~| expected f32 + //~| found isize x: 5is, y: 6is, }; let pair2 = PairF:: { - //~^ ERROR expected f32, found isize + //~^ ERROR structure constructor specifies a structure of type + //~| expected f32 + //~| found isize x: 7is, y: 8is, }; diff --git a/src/test/compile-fail/suppressed-error.rs b/src/test/compile-fail/suppressed-error.rs index 27f50be528c56..44de5d8cfe353 100644 --- a/src/test/compile-fail/suppressed-error.rs +++ b/src/test/compile-fail/suppressed-error.rs @@ -10,6 +10,10 @@ fn main() { let (x, y) = (); -//~^ ERROR expected `()`, found `(_, _)` (expected (), found tuple) +//~^ ERROR mismatched types +//~| expected `()` +//~| found `(_, _)` +//~| expected () +//~| found tuple return x; } diff --git a/src/test/compile-fail/tag-that-dare-not-speak-its-name.rs b/src/test/compile-fail/tag-that-dare-not-speak-its-name.rs index a9df449032e6f..660c1fa9a88d8 100644 --- a/src/test/compile-fail/tag-that-dare-not-speak-its-name.rs +++ b/src/test/compile-fail/tag-that-dare-not-speak-its-name.rs @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:mismatched types: expected `char`, found // Issue #876 #![no_implicit_prelude] @@ -21,4 +20,9 @@ fn last(v: Vec<&T> ) -> std::option::Option { fn main() { let y; let x : char = last(y); + //~^ ERROR mismatched types + //~| expected `char` + //~| found `core::option::Option<_>` + //~| expected char + //~| found enum `core::option::Option` } diff --git a/src/test/compile-fail/terr-in-field.rs b/src/test/compile-fail/terr-in-field.rs index 1e5422a798e33..60db35b879f57 100644 --- a/src/test/compile-fail/terr-in-field.rs +++ b/src/test/compile-fail/terr-in-field.rs @@ -20,7 +20,11 @@ struct bar { fn want_foo(f: foo) {} fn have_bar(b: bar) { - want_foo(b); //~ ERROR (expected struct foo, found struct bar) + want_foo(b); //~ ERROR mismatched types + //~| expected `foo` + //~| found `bar` + //~| expected struct `foo` + //~| found struct `bar` } fn main() {} diff --git a/src/test/compile-fail/terr-sorts.rs b/src/test/compile-fail/terr-sorts.rs index d1a37c99c47b2..231d2366b48a8 100644 --- a/src/test/compile-fail/terr-sorts.rs +++ b/src/test/compile-fail/terr-sorts.rs @@ -18,7 +18,11 @@ type bar = Box; fn want_foo(f: foo) {} fn have_bar(b: bar) { - want_foo(b); //~ ERROR (expected struct foo, found box) + want_foo(b); //~ ERROR mismatched types + //~| expected `foo` + //~| found `Box` + //~| expected struct `foo` + //~| found box } fn main() {} diff --git a/src/test/compile-fail/trait-bounds-cant-coerce.rs b/src/test/compile-fail/trait-bounds-cant-coerce.rs index 4f405e2558d23..79174552ae09c 100644 --- a/src/test/compile-fail/trait-bounds-cant-coerce.rs +++ b/src/test/compile-fail/trait-bounds-cant-coerce.rs @@ -20,7 +20,11 @@ fn c(x: Box) { } fn d(x: Box) { - a(x); //~ ERROR found no bounds + a(x); //~ ERROR mismatched types + //~| expected `Box` + //~| found `Box` + //~| expected bounds `Send` + //~| found no bounds } fn main() { } diff --git a/src/test/compile-fail/tuple-arity-mismatch.rs b/src/test/compile-fail/tuple-arity-mismatch.rs index 7f073a7bfdbba..8ad9ca50e3042 100644 --- a/src/test/compile-fail/tuple-arity-mismatch.rs +++ b/src/test/compile-fail/tuple-arity-mismatch.rs @@ -14,8 +14,16 @@ fn first((value, _): (isize, f64)) -> isize { value } fn main() { let y = first ((1,2.0,3)); - //~^ ERROR expected a tuple with 2 elements, found one with 3 elements + //~^ ERROR mismatched types + //~| expected `(isize, f64)` + //~| found `(isize, f64, _)` + //~| expected a tuple with 2 elements + //~| found one with 3 elements let y = first ((1,)); - //~^ ERROR expected `(isize, f64)`, found `(isize,)` + //~^ ERROR mismatched types + //~| expected `(isize, f64)` + //~| found `(isize,)` + //~| expected a tuple with 2 elements + //~| found one with 1 elements } diff --git a/src/test/compile-fail/tutorial-suffix-inference-test.rs b/src/test/compile-fail/tutorial-suffix-inference-test.rs index 1b44c7e8128a2..c8c596fdb4fcc 100644 --- a/src/test/compile-fail/tutorial-suffix-inference-test.rs +++ b/src/test/compile-fail/tutorial-suffix-inference-test.rs @@ -17,9 +17,17 @@ fn main() { identity_u8(x); // after this, `x` is assumed to have type `u8` identity_u16(x); - //~^ ERROR mismatched types: expected `u16`, found `u8` + //~^ ERROR mismatched types + //~| expected `u16` + //~| found `u8` + //~| expected u16 + //~| found u8 identity_u16(y); - //~^ ERROR mismatched types: expected `u16`, found `i32` + //~^ ERROR mismatched types + //~| expected `u16` + //~| found `i32` + //~| expected u16 + //~| found i32 let a = 3is; @@ -27,6 +35,10 @@ fn main() { identity_i(a); // ok identity_u16(a); - //~^ ERROR mismatched types: expected `u16`, found `isize` + //~^ ERROR mismatched types + //~| expected `u16` + //~| found `isize` + //~| expected u16 + //~| found isize } diff --git a/src/test/compile-fail/type-mismatch-multiple.rs b/src/test/compile-fail/type-mismatch-multiple.rs index 8b0897565fb91..4ab6bd531913a 100644 --- a/src/test/compile-fail/type-mismatch-multiple.rs +++ b/src/test/compile-fail/type-mismatch-multiple.rs @@ -9,7 +9,15 @@ // except according to those terms. // Checking that the compiler reports multiple type errors at once -// error-pattern:mismatched types: expected `bool` -// error-pattern:mismatched types: expected `isize` fn main() { let a: bool = 1is; let b: isize = true; } +//~^ ERROR mismatched types +//~| expected `bool` +//~| found `isize` +//~| expected bool +//~| found isize +//~| ERROR mismatched types +//~| expected `isize` +//~| found `bool` +//~| expected isize +//~| found bool diff --git a/src/test/compile-fail/type-parameter-names.rs b/src/test/compile-fail/type-parameter-names.rs index 42691fa522903..408bf72e97c87 100644 --- a/src/test/compile-fail/type-parameter-names.rs +++ b/src/test/compile-fail/type-parameter-names.rs @@ -13,7 +13,11 @@ fn foo(x: Foo) -> Bar { x -//~^ ERROR expected `Bar`, found `Foo` (expected type parameter, found a different type parameter) +//~^ ERROR mismatched types +//~| expected `Bar` +//~| found `Foo` +//~| expected type parameter +//~| found a different type parameter } fn main() {} diff --git a/src/test/compile-fail/type-params-in-different-spaces-1.rs b/src/test/compile-fail/type-params-in-different-spaces-1.rs index 66479202e1253..de9623de7cd3a 100644 --- a/src/test/compile-fail/type-params-in-different-spaces-1.rs +++ b/src/test/compile-fail/type-params-in-different-spaces-1.rs @@ -12,7 +12,11 @@ use std::num::Int; trait BrokenAdd: Int { fn broken_add(&self, rhs: T) -> Self { - *self + rhs //~ ERROR expected `Self`, found `T` + *self + rhs //~ ERROR mismatched types + //~| expected `Self` + //~| found `T` + //~| expected Self + //~| found type parameter } } diff --git a/src/test/compile-fail/typeck_type_placeholder_mismatch.rs b/src/test/compile-fail/typeck_type_placeholder_mismatch.rs index 92740cf5082a6..a34be63ba6b3c 100644 --- a/src/test/compile-fail/typeck_type_placeholder_mismatch.rs +++ b/src/test/compile-fail/typeck_type_placeholder_mismatch.rs @@ -19,11 +19,19 @@ pub fn main() { fn test1() { let x: Foo<_> = Bar::; - //~^ ERROR mismatched types: expected `Foo<_>`, found `Bar` + //~^ ERROR mismatched types + //~| expected `Foo<_>` + //~| found `Bar` + //~| expected struct `Foo` + //~| found struct `Bar` let y: Foo = x; } fn test2() { let x: Foo<_> = Bar::; - //~^ ERROR mismatched types: expected `Foo<_>`, found `Bar` + //~^ ERROR mismatched types + //~| expected `Foo<_>` + //~| found `Bar` + //~| expected struct `Foo` + //~| found struct `Bar` } diff --git a/src/test/compile-fail/ufcs-explicit-self-bad.rs b/src/test/compile-fail/ufcs-explicit-self-bad.rs index 6c323e8c1ae50..cbcf31b5b7edb 100644 --- a/src/test/compile-fail/ufcs-explicit-self-bad.rs +++ b/src/test/compile-fail/ufcs-explicit-self-bad.rs @@ -42,8 +42,15 @@ trait SomeTrait { impl<'a, T> SomeTrait for &'a Bar { fn dummy1(self: &&'a Bar) { } fn dummy2(self: &Bar) {} //~ ERROR mismatched self type - fn dummy3(self: &&Bar) {} //~ ERROR lifetime mismatch - //~^ ERROR lifetime mismatch + fn dummy3(self: &&Bar) {} + //~^ ERROR mismatched types + //~| expected `&'a Bar` + //~| found `&Bar` + //~| lifetime mismatch + //~| ERROR mismatched types + //~| expected `&'a Bar` + //~| found `&Bar` + //~| lifetime mismatch } fn main() { diff --git a/src/test/compile-fail/variadic-ffi.rs b/src/test/compile-fail/variadic-ffi.rs index 702702990c244..86271f670ce6f 100644 --- a/src/test/compile-fail/variadic-ffi.rs +++ b/src/test/compile-fail/variadic-ffi.rs @@ -24,14 +24,18 @@ fn main() { 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 `unsafe extern "C" fn(isize, u8)` - // , found `unsafe extern "C" fn(isize, u8, ...)` - // (expected non-variadic fn, found variadic function) + //~^ ERROR: mismatched types + //~| expected `unsafe extern "C" fn(isize, u8)` + //~| found `unsafe extern "C" fn(isize, u8, ...)` + //~| expected non-variadic fn + //~| found variadic function let y: unsafe extern "C" fn(f: isize, x: u8, ...) = bar; - //~^ ERROR: mismatched types: expected `unsafe extern "C" fn(isize, u8, ...)` - // , found `extern "C" extern fn(isize, u8)` - // (expected variadic fn, found non-variadic function) + //~^ ERROR: mismatched types + //~| expected `unsafe extern "C" fn(isize, u8, ...)` + //~| found `extern "C" fn(isize, u8) {bar}` + //~| expected variadic fn + //~| found non-variadic function foo(1, 2, 3f32); //~ ERROR: can't pass an f32 to variadic function, cast to c_double foo(1, 2, true); //~ ERROR: can't pass bool to variadic function, cast to c_int diff --git a/src/test/compile-fail/wrong-mul-method-signature.rs b/src/test/compile-fail/wrong-mul-method-signature.rs index e6fbcf2d38f2b..21c249c0e1fb0 100644 --- a/src/test/compile-fail/wrong-mul-method-signature.rs +++ b/src/test/compile-fail/wrong-mul-method-signature.rs @@ -24,7 +24,7 @@ impl Mul for Vec1 { type Output = Vec1; fn mul(self, s: &f64) -> Vec1 { - //~^ ERROR: method `mul` has an incompatible type for trait: expected f64, found &-ptr + //~^ ERROR method `mul` has an incompatible type for trait Vec1 { x: self.x * *s } @@ -41,7 +41,7 @@ impl Mul for Vec2 { type Output = f64; fn mul(self, s: f64) -> Vec2 { - //~^ ERROR: method `mul` has an incompatible type for trait: expected struct Vec2, found f64 + //~^ ERROR method `mul` has an incompatible type for trait Vec2 { x: self.x * s, y: self.y * s @@ -60,7 +60,7 @@ impl Mul for Vec3 { type Output = i32; fn mul(self, s: f64) -> f64 { - //~^ ERROR: method `mul` has an incompatible type for trait: expected i32, found f64 + //~^ ERROR method `mul` has an incompatible type for trait s } } @@ -72,7 +72,15 @@ pub fn main() { let x: Vec2 = Vec2 { x: 1.0, y: 2.0 } * 2.0; // trait had reversed order //~^ ERROR mismatched types - //~^^ ERROR mismatched types + //~| expected `Vec2` + //~| found `_` + //~| expected struct `Vec2` + //~| found floating-point variable + //~| ERROR mismatched types + //~| expected `Vec2` + //~| found `f64` + //~| expected struct `Vec2` + //~| found f64 let x: i32 = Vec3 { x: 1.0, y: 2.0, z: 3.0 } * 2.0; }