1
Fork 0

Fix testsuite errors

This commit is contained in:
mdinger 2015-01-12 01:01:44 -05:00
parent 5616b92e4d
commit 7b82a93be3
95 changed files with 980 additions and 221 deletions

View file

@ -9,8 +9,18 @@
// except according to those terms. // except according to those terms.
fn main() { 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 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
} }

View file

@ -30,7 +30,12 @@ fn foo1<I: Foo<A=Bar>>(x: I) {
} }
fn foo2<I: Foo>(x: I) { fn foo2<I: Foo>(x: I) {
let _: Bar = x.boo(); //~ERROR mismatched types let _: Bar = x.boo();
//~^ ERROR mismatched types
//~| expected `Bar`
//~| found `<I as Foo>::A`
//~| expected struct `Bar`
//~| found associated type
} }
@ -41,6 +46,12 @@ pub fn baz(x: &Foo<A=Bar>) {
pub fn main() { pub fn main() {
let a = 42is; let a = 42is;
foo1(a); //~ERROR expected usize, found struct Bar foo1(a);
baz(&a); //~ERROR expected usize, found struct Bar //~^ ERROR type mismatch resolving
//~| expected usize
//~| found struct `Bar`
baz(&a);
//~^ ERROR type mismatch resolving
//~| expected usize
//~| found struct `Bar`
} }

View file

@ -25,7 +25,9 @@ pub fn f2<T: Foo>(a: T) -> T::A {
pub fn f1_int_int() { pub fn f1_int_int() {
f1(2is, 4is); f1(2is, 4is);
//~^ ERROR expected usize, found isize //~^ ERROR type mismatch resolving
//~| expected usize
//~| found isize
} }
pub fn f1_int_uint() { pub fn f1_int_uint() {
@ -46,7 +48,11 @@ pub fn f1_uint_int() {
pub fn f2_int() { pub fn f2_int() {
let _: isize = f2(2is); let _: isize = f2(2is);
//~^ ERROR expected `isize`, found `usize` //~^ ERROR mismatched types
//~| expected `isize`
//~| found `usize`
//~| expected isize
//~| found usize
} }
pub fn main() { } pub fn main() { }

View file

@ -8,7 +8,10 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
// error-pattern:expected `collections::string::String`, found `isize`
static i: String = 10is; static i: String = 10is;
//~^ ERROR mismatched types
//~| expected `collections::string::String`
//~| found `isize`
//~| expected struct `collections::string::String`
//~| found isize
fn main() { println!("{}", i); } fn main() { println!("{}", i); }

View file

@ -8,10 +8,12 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
// error-pattern:mismatched types: expected `()`, found `bool`
fn main() { fn main() {
loop { loop {
true true //~ ERROR mismatched types
//~| expected ()
//~| found bool
//~| expected ()
//~| found bool
} }
} }

View file

@ -8,13 +8,15 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
// error-pattern:mismatched types: expected `()`, found `bool`
struct r; struct r;
impl Drop for r { impl Drop for r {
fn drop(&mut self) { fn drop(&mut self) {
true true //~ ERROR mismatched types
//~| expected ()
//~| found bool
//~| expected ()
//~| found bool
} }
} }

View file

@ -8,10 +8,12 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
// error-pattern:mismatched types: expected `()`, found `bool`
fn main() { fn main() {
while true { while true {
true true //~ ERROR mismatched types
//~| expected `()`
//~| found `bool`
//~| expected ()
//~| found bool
} }
} }

View file

@ -11,5 +11,10 @@
// Tests that we forbid coercion from `[T; n]` to `&[T]` // Tests that we forbid coercion from `[T; n]` to `&[T]`
fn main() { 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
} }

View file

@ -10,9 +10,17 @@
static a: &'static str = "foo"; static a: &'static str = "foo";
static b: *const u8 = a as *const u8; 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; 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() { fn main() {
} }

View file

@ -19,6 +19,10 @@ impl Trait for Foo {}
pub fn main() { pub fn main() {
let x: Box<Trait> = box Foo; let x: Box<Trait> = box Foo;
let _y: &Trait = x; //~ ERROR mismatched types: expected `&Trait`, found `Box<Trait>` let _y: &Trait = x; //~ ERROR mismatched types
//~| expected `&Trait`
//~| found `Box<Trait>`
//~| expected &-ptr
//~| found box
} }

View file

@ -37,7 +37,22 @@ fn main() {
let box x = box 1is as Box<T>; //~ ERROR type `Box<T>` cannot be dereferenced let box x = box 1is as Box<T>; //~ ERROR type `Box<T>` cannot be dereferenced
// n > m // n > m
let &&x = &1is as &T; //~ ERROR found &-ptr let &&x = &1is as &T;
let &&&x = &(&1is as &T); //~ ERROR found &-ptr //~^ ERROR mismatched types
let box box x = box 1is as Box<T>; //~ ERROR found box //~| 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<T>;
//~^ ERROR mismatched types
//~| expected `T`
//~| found `Box<_>`
//~| expected trait T
//~| found box
} }

View file

@ -44,6 +44,11 @@ pub fn main() {
// Assignment. // Assignment.
let f5: &mut Fat<ToBar> = &mut Fat { f1: 5, f2: "some str", ptr: Bar1 {f :42} }; let f5: &mut Fat<ToBar> = &mut Fat { f1: 5, f2: "some str", ptr: Bar1 {f :42} };
let z: Box<ToBar> = box Bar1 {f: 36}; let z: Box<ToBar> = box Bar1 {f: 36};
f5.ptr = Bar1 {f: 36}; //~ ERROR mismatched types: expected `ToBar`, found `Bar1` f5.ptr = Bar1 {f: 36};
//~^ ERROR the trait `core::marker::Sized` is not implemented for the type `ToBar` //~^ 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`
} }

View file

@ -22,7 +22,11 @@ pub fn main() {
let f1 = Fat { ptr: [1, 2, 3] }; let f1 = Fat { ptr: [1, 2, 3] };
let f2: &Fat<[isize; 3]> = &f1; let f2: &Fat<[isize; 3]> = &f1;
let f3: &Fat<[usize]> = f2; 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. // With a trait.
let f1 = Fat { ptr: Foo }; let f1 = Fat { ptr: Foo };

View file

@ -18,5 +18,9 @@ pub fn main() {
// With a vec of isizes. // With a vec of isizes.
let f1: &Fat<[isize]> = &Fat { ptr: [1, 2, 3] }; let f1: &Fat<[isize]> = &Fat { ptr: [1, 2, 3] };
let f2: &Fat<[isize; 3]> = f1; 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
} }

View file

@ -15,8 +15,14 @@ struct Foo<'a,'b> {
impl<'a,'b> Foo<'a,'b> { impl<'a,'b> Foo<'a,'b> {
fn bar(self: Foo<'b,'a>) {} fn bar(self: Foo<'b,'a>) {}
//~^ ERROR mismatched types: expected `Foo<'a, 'b>`, found `Foo<'b, 'a>` //~^ ERROR mismatched types
//~^^ ERROR mismatched types: expected `Foo<'a, 'b>`, found `Foo<'b, 'a>` //~| 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() {} fn main() {}

View file

@ -18,8 +18,16 @@ fn eq<T>(x: T, y: T) { }
fn main() { fn main() {
let f = if true { foo } else { bar }; 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); 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
} }

View file

@ -14,12 +14,25 @@
fn needs_fn<F>(x: F) where F: Fn(isize) -> isize {} fn needs_fn<F>(x: F) where F: Fn(isize) -> isize {}
fn main() { fn main() {
let _: () = (box |:_: isize| {}) as Box<FnOnce(isize)>; //~ ERROR object-safe let _: () = (box |:_: isize| {}) as Box<FnOnce(isize)>;
//~^ ERROR Box<core::ops::FnOnce(isize)> //~^ ERROR object-safe
//~| ERROR mismatched types
//~| expected `()`
//~| found `Box<core::ops::FnOnce(isize)>`
//~| expected ()
//~| found box
let _: () = (box |&:_: isize, isize| {}) as Box<Fn(isize, isize)>; let _: () = (box |&:_: isize, isize| {}) as Box<Fn(isize, isize)>;
//~^ ERROR Box<core::ops::Fn(isize, isize)> //~^ ERROR mismatched types
//~| expected `()`
//~| found `Box<core::ops::Fn(isize, isize)>`
//~| expected ()
//~| found box
let _: () = (box |&mut:| -> isize unimplemented!()) as Box<FnMut() -> isize>; let _: () = (box |&mut:| -> isize unimplemented!()) as Box<FnMut() -> isize>;
//~^ ERROR Box<core::ops::FnMut() -> isize> //~^ ERROR mismatched types
//~| expected `()`
//~| found `Box<core::ops::FnMut() -> isize>`
//~| expected ()
//~| found box
needs_fn(1is); //~ ERROR `core::ops::Fn(isize) -> isize` needs_fn(1is); //~ ERROR `core::ops::Fn(isize) -> isize`
} }

View file

@ -13,5 +13,9 @@
fn main() { fn main() {
let x: Option<usize>; let x: Option<usize>;
x = 5; x = 5;
//~^ ERROR mismatched types: expected `core::option::Option<usize>` //~^ ERROR mismatched types
//~| expected `core::option::Option<usize>`
//~| found `_`
//~| expected enum `core::option::Option`
//~| found integral variable
} }

View file

@ -20,7 +20,11 @@ mod y {
fn bar(x: x::foo) -> y::foo { fn bar(x: x::foo) -> y::foo {
return x; 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() { fn main() {

View file

@ -14,7 +14,11 @@ use std::option::Option;
fn bar(x: usize) -> Option<usize> { fn bar(x: usize) -> Option<usize> {
return x; return x;
//~^ ERROR mismatched types: expected `core::option::Option<usize>` //~^ ERROR mismatched types
//~| expected `core::option::Option<usize>`
//~| found `usize`
//~| expected enum `core::option::Option`
//~| found usize
} }
fn main() { fn main() {

View file

@ -19,23 +19,47 @@ struct HashMap<K, V, H = Hash<K>>;
fn main() { fn main() {
// Ensure that the printed type doesn't include the default type params... // Ensure that the printed type doesn't include the default type params...
let _: Foo<isize> = (); let _: Foo<isize> = ();
//~^ ERROR mismatched types: expected `Foo<isize>`, found `()` //~^ ERROR mismatched types
//~| expected `Foo<isize>`
//~| found `()`
//~| expected struct `Foo`
//~| found ()
// ...even when they're present, but the same types as the defaults. // ...even when they're present, but the same types as the defaults.
let _: Foo<isize, B, C> = (); let _: Foo<isize, B, C> = ();
//~^ ERROR mismatched types: expected `Foo<isize>`, found `()` //~^ ERROR mismatched types
//~| expected `Foo<isize>`
//~| found `()`
//~| expected struct `Foo`
//~| found ()
// Including cases where the default is using previous type params. // Including cases where the default is using previous type params.
let _: HashMap<String, isize> = (); let _: HashMap<String, isize> = ();
//~^ ERROR mismatched types: expected `HashMap<collections::string::String, isize>`, found `()` //~^ ERROR mismatched types
//~| expected `HashMap<collections::string::String, isize>`
//~| found `()`
//~| expected struct `HashMap`
//~| found ()
let _: HashMap<String, isize, Hash<String>> = (); let _: HashMap<String, isize, Hash<String>> = ();
//~^ ERROR mismatched types: expected `HashMap<collections::string::String, isize>`, found `()` //~^ ERROR mismatched types
//~| expected `HashMap<collections::string::String, isize>`
//~| found `()`
//~| expected struct `HashMap`
//~| found ()
// But not when there's a different type in between. // But not when there's a different type in between.
let _: Foo<A, isize, C> = (); let _: Foo<A, isize, C> = ();
//~^ ERROR mismatched types: expected `Foo<A, isize>`, found `()` //~^ ERROR mismatched types
//~| expected `Foo<A, isize>`
//~| found `()`
//~| expected struct `Foo`
//~| found ()
// And don't print <> at all when there's just defaults. // And don't print <> at all when there's just defaults.
let _: Foo<A, B, C> = (); let _: Foo<A, B, C> = ();
//~^ ERROR mismatched types: expected `Foo`, found `()` //~^ ERROR mismatched types
//~| expected `Foo`
//~| found `()`
//~| expected struct `Foo`
//~| found ()
} }

View file

@ -10,5 +10,9 @@
fn main() { fn main() {
let x = if true { 10is } else { 10us }; 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
} }

View file

@ -10,6 +10,10 @@
fn main() { fn main() {
let a = if true { true }; 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); println!("{}", a);
} }

View file

@ -39,62 +39,242 @@ fn main() {
fn id_u64(n: u64) -> u64 { n } fn id_u64(n: u64) -> u64 { n }
id_i8(a8); // ok id_i8(a8); // ok
id_i8(a16); //~ ERROR mismatched types: expected `i8`, found `i16` id_i8(a16);
id_i8(a32); //~ ERROR mismatched types: expected `i8`, found `i32` //~^ ERROR mismatched types
id_i8(a64); //~ ERROR mismatched types: expected `i8`, found `i64` //~| 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(a16); // ok
id_i16(a32); //~ ERROR mismatched types: expected `i16`, found `i32` id_i16(a32);
id_i16(a64); //~ ERROR mismatched types: expected `i16`, found `i64` //~^ 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(a8);
id_i32(a16); //~ ERROR mismatched types: expected `i32`, found `i16` //~^ 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(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(a8);
id_i64(a16); //~ ERROR mismatched types: expected `i64`, found `i16` //~^ ERROR mismatched types
id_i64(a32); //~ ERROR mismatched types: expected `i64`, found `i32` //~| 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_i64(a64); // ok
id_i8(c8); // ok id_i8(c8); // ok
id_i8(c16); //~ ERROR mismatched types: expected `i8`, found `i16` id_i8(c16);
id_i8(c32); //~ ERROR mismatched types: expected `i8`, found `i32` //~^ ERROR mismatched types
id_i8(c64); //~ ERROR mismatched types: expected `i8`, found `i64` //~| 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(c16); // ok
id_i16(c32); //~ ERROR mismatched types: expected `i16`, found `i32` id_i16(c32);
id_i16(c64); //~ ERROR mismatched types: expected `i16`, found `i64` //~^ 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(c8);
id_i32(c16); //~ ERROR mismatched types: expected `i32`, found `i16` //~^ 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(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(a8);
id_i64(a16); //~ ERROR mismatched types: expected `i64`, found `i16` //~^ ERROR mismatched types
id_i64(a32); //~ ERROR mismatched types: expected `i64`, found `i32` //~| 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_i64(a64); // ok
id_u8(b8); // ok id_u8(b8); // ok
id_u8(b16); //~ ERROR mismatched types: expected `u8`, found `u16` id_u8(b16);
id_u8(b32); //~ ERROR mismatched types: expected `u8`, found `u32` //~^ ERROR mismatched types
id_u8(b64); //~ ERROR mismatched types: expected `u8`, found `u64` //~| 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(b16); // ok
id_u16(b32); //~ ERROR mismatched types: expected `u16`, found `u32` id_u16(b32);
id_u16(b64); //~ ERROR mismatched types: expected `u16`, found `u64` //~^ 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(b8);
id_u32(b16); //~ ERROR mismatched types: expected `u32`, found `u16` //~^ 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(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(b8);
id_u64(b16); //~ ERROR mismatched types: expected `u64`, found `u16` //~^ ERROR mismatched types
id_u64(b32); //~ ERROR mismatched types: expected `u64`, found `u32` //~| 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 id_u64(b64); // ok
} }

View file

@ -11,5 +11,9 @@
fn main() { fn main() {
let mut x = 2; let mut x = 2;
x = 5.0; 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
} }

View file

@ -10,7 +10,11 @@
fn f() -> isize { fn f() -> isize {
(return 1, return 2) (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() {} fn main() {}

View file

@ -10,7 +10,11 @@
fn main() { fn main() {
match Some(10) { 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(5) => false,
Some(2) => true, Some(2) => true,
None => (), //~ NOTE match arm with an incompatible type None => (), //~ NOTE match arm with an incompatible type

View file

@ -11,11 +11,19 @@
fn main() { fn main() {
let x = (); let x = ();
1 + 1 +
x //~ ERROR mismatched types: expected `_`, found `()` (expected integral variable, found ()) x //~ ERROR mismatched types
//~| expected `_`
//~| found `()`
//~| expected integral variable
//~| found ()
; ;
let x: () = (); let x: () = ();
1 + 1 +
x //~ ERROR mismatched types: expected `_`, found `()` (expected integral variable, found ()) x //~ ERROR mismatched types
//~| expected `_`
//~| found `()`
//~| expected integral variable
//~| found ()
; ;
} }

View file

@ -12,6 +12,10 @@
//! Test that makes sure wrongly-typed bench functions are rejected //! Test that makes sure wrongly-typed bench functions are rejected
// error-pattern:expected &-ptr, found isize
#[bench] #[bench]
fn bar(x: isize) { } fn bar(x: isize) { }
//~^ ERROR mismatched types
//~| expected `fn(&mut test::Bencher)`
//~| found `fn(isize) {bar}`
//~| expected &-ptr
//~| found isize

View file

@ -35,5 +35,9 @@ fn check<'r, I: Iterator<Item=usize>, T: Itble<'r, usize, I>>(cont: &T) -> bool
fn main() { fn main() {
check((3us, 5us)); 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
} }

View file

@ -14,8 +14,16 @@ fn bar(_s: u32) { }
fn main() { fn main() {
foo(1*(1 as isize)); 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)); 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
} }

View file

@ -15,7 +15,18 @@ pub fn main() {
// the actual arm `Result<T, E>` has two. typeck should not be // the actual arm `Result<T, E>` has two. typeck should not be
// tricked into looking up a non-existing second type parameter. // tricked into looking up a non-existing second type parameter.
let _x: usize = match Some(1us) { let _x: usize = match Some(1us) {
Ok(u) => u, //~ ERROR mismatched types: expected `core::option::Option<usize>` Ok(u) => u,
Err(e) => panic!(e) //~ ERROR mismatched types: expected `core::option::Option<usize>` //~^ ERROR mismatched types
//~| expected `core::option::Option<usize>`
//~| 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<usize>`
//~| found `core::result::Result<_, _>`
//~| expected enum `core::option::Option`
//~| found enum `core::result::Result`
}; };
} }

View file

@ -14,8 +14,11 @@ fn main() {
let x = [1,2]; let x = [1,2];
let y = match x { let y = match x {
[] => None, [] => None,
//~^ ERROR types: expected `[_#0i; 2]`, found `[_#7t; 0]` //~^ ERROR mismatched types
// (expected array of 2 elements, found array of 0 elements) //~| expected `[_#0i; 2]`
//~| found `[_#7t; 0]`
//~| expected an array with a fixed size of 2 elements
//~| found one with 0 elements
[a,_] => Some(a) [a,_] => Some(a)
}; };
} }

View file

@ -12,8 +12,10 @@ fn main() {
let x = [1,2]; let x = [1,2];
let y = match x { let y = match x {
[] => None, [] => None,
//~^ ERROR types: expected `[_; 2]`, found `[_; 0]` //~^ ERROR mismatched types
// (expected array of 2 elements, found array of 0 elements) //~| expected `[_; 2]`
//~| found `[_; 0]`
//~| expected array with a fixed size of 2 elements
[a,_] => Some(a) [a,_] => Some(a)
}; };
} }

View file

@ -15,7 +15,11 @@ mod a {
pub fn get_enum_struct_variant() -> () { pub fn get_enum_struct_variant() -> () {
Enum::EnumStructVariant { x: 1, y: 2, z: 3 } 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(); let enum_struct_variant = ::a::get_enum_struct_variant();
match enum_struct_variant { match enum_struct_variant {
a::Enum::EnumStructVariant { x, y, z } => { a::Enum::EnumStructVariant { x, y, z } => {
//~^ ERROR mismatched types: expected `()`, found `a::Enum` //~^ ERROR mismatched types
// (expected (), found enum a::Enum) //~| expected `()`
//~| found `a::Enum`
//~| expected ()
// found enum `a::Enum`
} }
} }
} }

View file

@ -8,6 +8,10 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // 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);} fn main(){assert!(1,1);}

View file

@ -13,8 +13,11 @@ struct vec3 { y: f32, z: f32 }
fn make(v: vec2) { fn make(v: vec2) {
let vec3 { y: _, z: _ } = v; let vec3 { y: _, z: _ } = v;
//~^ ERROR mismatched types: expected `vec2`, found `vec3` //~^ ERROR mismatched types
// (expected struct vec2, found struct vec3) //~| expected `vec2`
//~| found `vec3`
//~| expected struct `vec2`
//~| found struct `vec3`
} }
fn main() { } fn main() { }

View file

@ -16,9 +16,17 @@ struct X {
fn main() { fn main() {
let x = X { a: [0] }; let x = X { a: [0] };
let _f = &x.a as *mut u8; 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 local = [0u8];
let _v = &local as *mut u8; 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
} }

View file

@ -16,6 +16,10 @@ fn main() {
let name = "Foo"; let name = "Foo";
let x = Some(&[name.as_slice()]); let x = Some(&[name.as_slice()]);
let msg = foo(x); 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); assert_eq!(msg, 3);
} }

View file

@ -19,8 +19,11 @@ fn main() {
let u = match e { let u = match e {
E::B( E::B(
Tau{t: x}, Tau{t: x},
//~^ ERROR mismatched types: expected `main::R`, found `main::Tau` //~^ ERROR mismatched types
// (expected enum main::R, found struct main::Tau) //~| expected `main::R`
//~| found `main::Tau`
//~| expected enum `main::R`
//~| found struct `main::Tau`
_) => x, _) => x,
}; };
} }

View file

@ -12,7 +12,10 @@ use std::raw::Slice;
fn main() { fn main() {
let Slice { data: data, len: len } = "foo"; let Slice { data: data, len: len } = "foo";
//~^ ERROR mismatched types: expected `&str`, found `core::raw::Slice<_>` //~^ ERROR mismatched types
// (expected &-ptr, found struct core::raw::Slice) //~| expected `&str`
//~| found `core::raw::Slice<_>`
//~| expected &-ptr
//~| found struct `core::raw::Slice`
} }

View file

@ -13,8 +13,11 @@ use std::raw::Slice;
fn main() { fn main() {
match () { match () {
Slice { data: data, len: len } => (), Slice { data: data, len: len } => (),
//~^ ERROR mismatched types: expected `()`, found `core::raw::Slice<_>` //~^ ERROR mismatched types
// (expected (), found struct core::raw::Slice) //~| expected `()`
//~| found `core::raw::Slice<_>`
//~| expected ()
//~| found struct `core::raw::Slice`
_ => unreachable!() _ => unreachable!()
} }
} }

View file

@ -11,7 +11,11 @@
#![feature(overloaded_calls)] #![feature(overloaded_calls)]
fn f<'r>(p: &'r mut fn(p: &mut ())) { 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() {} fn main() {}

View file

@ -21,17 +21,29 @@ fn main() {
// `x { ... }` should not be interpreted as a struct literal here // `x { ... }` should not be interpreted as a struct literal here
if x = x { if x = x {
//~^ ERROR mismatched types: expected `bool`, found `()` (expected bool, found ()) //~^ ERROR mismatched types
//~| expected `bool`
//~| found `()`
//~| expected bool
//~| found ()
println!("{}", x); println!("{}", x);
} }
// Explicit parentheses on the left should match behavior of above // Explicit parentheses on the left should match behavior of above
if (x = x) { if (x = x) {
//~^ ERROR mismatched types: expected `bool`, found `()` (expected bool, found ()) //~^ ERROR mismatched types
//~| expected `bool`
//~| found `()`
//~| expected bool
//~| found ()
println!("{}", x); println!("{}", x);
} }
// The struct literal interpretation is fine with explicit parentheses on the right // The struct literal interpretation is fine with explicit parentheses on the right
if y = (Foo { foo: x }) { 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); println!("{}", x);
} }
} }

View file

@ -14,8 +14,14 @@ struct Foo<'a> {
impl <'a> Foo<'a>{ impl <'a> Foo<'a>{
fn bar(self: &mut Foo) { fn bar(self: &mut Foo) {
//~^ mismatched types: expected `Foo<'a>`, found `Foo<'_>` (lifetime mismatch) //~^ mismatched types
//~| mismatched types: expected `Foo<'a>`, found `Foo<'_>` (lifetime mismatch) //~| expected `Foo<'a>`
//~| found `Foo<'_>`
//~| lifetime mismatch
//~| mismatched types
//~| expected `Foo<'a>`
//~| found `Foo<'_>`
//~| lifetime mismatch
} }
} }

View file

@ -16,7 +16,10 @@ impl Pair<
isize isize
> { > {
fn say(self: &Pair<&str, 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); println!("{}", self);
} }
} }

View file

@ -12,7 +12,11 @@
// clause does not exist, instead of the unsympathetic "match arms have incompatible types" // clause does not exist, instead of the unsympathetic "match arms have incompatible types"
fn main() { 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 765i32
}; };
} }

View file

@ -10,7 +10,12 @@
fn foo<T, U>(x: T, y: U) { fn foo<T, U>(x: T, y: U) {
let mut xx = x; 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() { fn main() {

View file

@ -9,5 +9,10 @@
// except according to those terms. // except according to those terms.
fn main() { 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
} }

View file

@ -10,8 +10,13 @@
trait A { trait A {
fn a(&self) { fn a(&self) {
|&:| self.b() //~ ERROR type `&Self` does not implement any method in scope named `b` |&:| self.b()
//~^ ERROR expected (), found closure //~^ ERROR type `&Self` does not implement any method in scope named `b`
//~| ERROR mismatched types
//~| expected `()`
//~| found closure
//~| expected ()
//~| found closure
} }
} }
fn main() {} fn main() {}

View file

@ -11,7 +11,10 @@
fn main() { fn main() {
match None { match None {
Err(_) => () Err(_) => ()
//~^ ERROR mismatched types: expected `core::option::Option<_>` //~^ ERROR mismatched types
// , found `core::result::Result<_, _>` //~| expected `core::option::Option<_>`
//~| found `core::result::Result<_, _>`
//~| expected enum `core::option::Option`
//~| found enum `core::result::Result`
} }
} }

View file

@ -12,7 +12,11 @@ fn main() {
let a = if true { let a = if true {
0 0
} else if false { } 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 1
}; };
} }

View file

@ -13,6 +13,9 @@ fn bar(int_param: usize) {}
fn main() { fn main() {
let foo: [u8; 4] = [1u8; 4us]; let foo: [u8; 4] = [1u8; 4us];
bar(foo); bar(foo);
//~^ ERROR mismatched types: expected `usize`, found `[u8; 4]` //~^ ERROR mismatched types
// (expected usize, found vector) //~| expected `usize`
//~| found `[u8; 4]`
//~| expected usize
//~| found array of 4 elements
} }

View file

@ -13,6 +13,9 @@
const A: (isize,isize) = (4,2); const A: (isize,isize) = (4,2);
fn main() { fn main() {
match 42 { A => () } match 42 { A => () }
//~^ ERROR mismatched types: expected `_`, found `(isize, isize)` //~^ ERROR mismatched types
// (expected integral variable, found tuple) //~| expected `_`
//~| found `(isize, isize)`
//~| expected integral variable
//~| found tuple
} }

View file

@ -15,28 +15,48 @@ enum A { B, C }
fn main() { fn main() {
match (true, false) { match (true, false) {
A::B => (), 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) { match (true, false) {
(true, false, 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) { match (true, false) {
(true, false, 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) { match (true, false) {
box (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) { match (true, false) {
&(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 for &(x,y) in v.iter() {} // should be OK
// Make sure none of the errors above were fatal // 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
} }

View file

@ -13,7 +13,12 @@ struct S(Either<usize, usize>);
fn main() { fn main() {
match S(Either::Left(5)) { 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`
_ => {} _ => {}
} }
} }

View file

@ -10,5 +10,9 @@
fn main() { fn main() {
&panic!() &panic!()
//~^ ERROR mismatched types: expected `()`, found `&_` (expected (), found &-ptr) //~^ ERROR mismatched types
//~| expected `()`
//~| found `&_`
//~| expected ()
//~| found &-ptr
} }

View file

@ -12,7 +12,11 @@ struct BarStruct;
impl<'a> BarStruct { impl<'a> BarStruct {
fn foo(&'a mut self) -> Box<BarStruct> { self } fn foo(&'a mut self) -> Box<BarStruct> { self }
//~^ ERROR: error: mismatched types: expected `Box<BarStruct>`, found `&'a mut BarStruct //~^ ERROR mismatched types
//~| expected `Box<BarStruct>`
//~| found `&'a mut BarStruct`
//~| expected box
//~| found &-ptr
} }
fn main() {} fn main() {}

View file

@ -14,7 +14,11 @@ enum Whatever {
fn foo(x: Whatever) { fn foo(x: Whatever) {
match x { match x {
Some(field) => 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 field.access(), //~ ERROR the type of this value must be known in this context
} }
} }

View file

@ -14,14 +14,27 @@ mod foo { pub fn bar() {} }
fn main() { fn main() {
match (true, false) { 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) { match &Some(42is) {
Some(x) => (), //~ ERROR expected `&core::option::Option<isize>`, Some(x) => (),
// found `core::option::Option<_>` //~^ ERROR mismatched types
None => () //~ ERROR expected `&core::option::Option<isize>`, //~| expected `&core::option::Option<isize>`
// found `core::option::Option<_>` //~| found `core::option::Option<_>`
//~| expected &-ptr
//~| found enum `core::option::Option`
None => ()
//~^ ERROR mismatched types
//~| expected `&core::option::Option<isize>`
//~| found `core::option::Option<_>`
//~| expected &-ptr
//~| found enum `core::option::Option`
} }
} }

View file

@ -10,9 +10,17 @@
enum Foo { enum Foo {
A = 1i64, A = 1i64,
//~^ ERROR mismatched types: expected `isize`, found `i64` //~^ ERROR mismatched types
//~| expected `isize`
//~| found `i64`
//~| expected isize
//~| found i64
B = 2u8 B = 2u8
//~^ ERROR mismatched types: expected `isize`, found `u8` //~^ ERROR mismatched types
//~| expected `isize`
//~| found `u8`
//~| expected isize
//~| found u8
} }
fn main() {} fn main() {}

View file

@ -14,7 +14,12 @@ enum E { C(isize) }
fn main() { fn main() {
match (S { a: 1 }) { 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`
_ => () _ => ()
} }
} }

View file

@ -11,6 +11,10 @@
fn main() { fn main() {
match () { match () {
[()] => { } [()] => { }
//~^ ERROR mismatched types: expected `()`, found `&[_]` (expected (), found &-ptr) //~^ ERROR mismatched types
//~| expected `()`
//~| found `&[_]`
//~| expected ()
//~| found &-ptr
} }
} }

View file

@ -18,7 +18,19 @@ impl Foo {
fn main() { fn main() {
let x = Foo; let x = Foo;
Foo::bar(x); //~ERROR mismatched types: expected `&Foo`, found `Foo` Foo::bar(x); //~ ERROR mismatched types
Foo::bar(&&x); //~ERROR mismatched types: expected `&Foo`, found `&&Foo` //~| expected `&Foo`
Foo::bar(&42is); //~ERROR mismatched types: expected `&Foo`, found `&isize` //~| 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
} }

View file

@ -13,12 +13,18 @@ fn main() {
// (separate lines to ensure the spans are accurate) // (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; = foo;
let &mut _ = foo; let &mut _ = foo;
let bar = &1is; let bar = &1is;
let &_ = bar; let &_ = bar;
let &mut _ //~ ERROR expected `&isize`, found `&mut _` let &mut _ //~ ERROR mismatched types
//~| expected `&isize`
//~| found `&mut _`
//~| values differ in mutability
= bar; = bar;
} }

View file

@ -18,5 +18,9 @@ fn main() {
// because the def_id associated with the type was // because the def_id associated with the type was
// not convertible to a path. // not convertible to a path.
let x: isize = noexporttypelib::foo(); let x: isize = noexporttypelib::foo();
//~^ ERROR expected `isize`, found `core::option::Option<isize>` //~^ ERROR mismatched types
//~| expected `isize`
//~| found `core::option::Option<isize>`
//~| expected isize
//~| found enum `core::option::Option`
} }

View file

@ -14,5 +14,9 @@ fn main() {
let f; let f;
let g; let g;
g = f; 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
} }

View file

@ -12,5 +12,9 @@
fn main() { fn main() {
let f; 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
} }

View file

@ -30,9 +30,18 @@ fn main() {
} }
match 'c' { match 'c' {
S { .. } => (), 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
} }

View file

@ -12,8 +12,16 @@ fn let_in<T, F>(x: T, f: F) where F: FnOnce(T) {}
fn main() { fn main() {
let_in(3us, |i| { assert!(i == 3is); }); 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); }); let_in(3is, |i| { assert!(i == 3us); });
//~^ ERROR expected `isize`, found `usize` //~^ ERROR mismatched types
//~| expected `isize`
//~| found `usize`
//~| expected isize
//~| found usize
} }

View file

@ -14,11 +14,20 @@
pub fn main() { pub fn main() {
// *const -> *mut // *const -> *mut
let x: *const isize = &42is; 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 // & -> *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: *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
} }

View file

@ -16,11 +16,17 @@ struct an_enum<'a>(&'a isize);
struct a_class<'a> { x:&'a isize } struct a_class<'a> { x:&'a isize }
fn a_fn1<'a,'b>(e: an_enum<'a>) -> an_enum<'b> { 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> { 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() { } fn main() { }

View file

@ -27,8 +27,12 @@ impl<'a> GetRef<'a> for Box<'a> {
impl<'a> Box<'a> { impl<'a> Box<'a> {
fn or<'b,G:GetRef<'b>>(&self, g2: G) -> &'a isize { fn or<'b,G:GetRef<'b>>(&self, g2: G) -> &'a isize {
g2.get() //~ ERROR cannot infer an appropriate lifetime for automatic coercion due to g2.get()
//~^ ERROR mismatched types: expected `&'a isize`, found `&'b isize` (lifetime mismatch) //~^ ERROR cannot infer an appropriate lifetime for automatic coercion due to
//~| ERROR mismatched types
//~| expected `&'a isize`
//~| found `&'b isize`
//~| lifetime mismatch
} }
} }

View file

@ -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 { 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 g1.get()
//~^ ERROR mismatched types: expected `&'b isize`, found `&'a isize` (lifetime mismatch) //~^ ERROR cannot infer an appropriate lifetime for automatic coercion due to
//~| ERROR mismatched types
//~| expected `&'b isize`
//~| found `&'a isize`
//~| lifetime mismatch
} }
fn main() { fn main() {

View file

@ -53,7 +53,12 @@ fn supply_F() {
fn supply_G() { fn supply_G() {
want_G(foo); want_G(foo);
want_G(bar); 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() { pub fn main() {

View file

@ -31,7 +31,10 @@ impl<'a> set_f<'a> for c<'a> {
fn set_f_bad(&mut self, b: Box<b>) { fn set_f_bad(&mut self, b: Box<b>) {
self.f = b; self.f = b;
//~^ ERROR mismatched types: expected `Box<Box<&'a isize>>`, found `Box<Box<&isize>>` //~^ ERROR mismatched types
//~| expected `Box<Box<&'a isize>>`
//~| found `Box<Box<&isize>>`
//~| lifetime mismatch
} }
} }

View file

@ -14,14 +14,33 @@ fn main() {
let n = 1; let n = 1;
let a = [0; n]; //~ ERROR expected constant integer for repeat count, found variable let a = [0; n]; //~ ERROR expected constant integer for repeat count, found variable
let b = [0; ()]; let b = [0; ()];
//~^ ERROR expected constant integer for repeat count, found non-constant expression //~^ ERROR mismatched types
//~^^ ERROR: expected `usize`, found `()` //~| expected `usize`
let c = [0; true]; //~ ERROR expected positive integer for repeat count, found boolean //~| found `()`
//~^ ERROR: expected `usize`, found `bool` //~| expected usize
let d = [0; 0.5]; //~ ERROR expected positive integer for repeat count, found float //~| found ()
//~^ ERROR: expected `usize`, found `_` //~| ERROR expected constant integer for repeat count, found non-constant expression
let e = [0; "foo"]; //~ ERROR expected positive integer for repeat count, found string let c = [0; true];
//~^ ERROR: expected `usize`, found `&'static str` //~^ 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]; let f = [0; -4];
//~^ ERROR expected positive integer for repeat count, found negative integer //~^ ERROR expected positive integer for repeat count, found negative integer
let f = [0us; -1]; let f = [0us; -1];

View file

@ -36,7 +36,11 @@ fn foo(p: &Panolpy) {
// Type of the result follows the LHS, not the RHS: // Type of the result follows the LHS, not the RHS:
let _: i32 = 22_i64 >> 1_i32; 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() { fn main() {

View file

@ -13,7 +13,11 @@ struct Foo<T,U>(T);
fn main() { fn main() {
match Foo(1.1) { match Foo(1.1) {
1 => {} 1 => {}
//~^ ERROR expected `Foo<_, _>`, found `_` //~^ ERROR mismatched types
//~| expected `Foo<_, _>`
//~| found `_`
//~| expected struct `Foo`
//~| found integral variable
} }
} }

View file

@ -12,11 +12,27 @@ struct Foo { a: isize, b: isize }
struct Bar { x: isize } struct Bar { x: isize }
static bar: Bar = Bar { x: 5 }; static bar: Bar = Bar { x: 5 };
static foo: Foo = Foo { a: 2, ..bar }; //~ ERROR mismatched types: expected `Foo`, found `Bar` static foo: Foo = Foo { a: 2, ..bar }; //~ ERROR mismatched types
static foo_i: Foo = Foo { a: 2, ..4 }; //~ ERROR mismatched types: expected `Foo` //~| 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() { fn main() {
let b = Bar { x: 5 }; let b = Bar { x: 5 };
let f = Foo { a: 2, ..b }; //~ ERROR mismatched types: expected `Foo`, found `Bar` let f = Foo { a: 2, ..b }; //~ ERROR mismatched types
let f_i = Foo { a: 2, ..4 }; //~ ERROR mismatched types: expected `Foo` //~| 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
} }

View file

@ -24,25 +24,33 @@ type PairF<U> = Pair<f32,U>;
fn main() { fn main() {
let pt = PointF { let pt = PointF {
//~^ ERROR expected f32, found isize //~^ ERROR structure constructor specifies a structure of type
//~| expected f32
//~| found isize
x: 1is, x: 1is,
y: 2is, y: 2is,
}; };
let pt2 = Point::<f32> { let pt2 = Point::<f32> {
//~^ ERROR expected f32, found isize //~^ ERROR structure constructor specifies a structure of type
//~| expected f32
//~| found isize
x: 3is, x: 3is,
y: 4is, y: 4is,
}; };
let pair = PairF { let pair = PairF {
//~^ ERROR expected f32, found isize //~^ ERROR structure constructor specifies a structure of type
//~| expected f32
//~| found isize
x: 5is, x: 5is,
y: 6is, y: 6is,
}; };
let pair2 = PairF::<isize> { let pair2 = PairF::<isize> {
//~^ ERROR expected f32, found isize //~^ ERROR structure constructor specifies a structure of type
//~| expected f32
//~| found isize
x: 7is, x: 7is,
y: 8is, y: 8is,
}; };

View file

@ -10,6 +10,10 @@
fn main() { fn main() {
let (x, y) = (); let (x, y) = ();
//~^ ERROR expected `()`, found `(_, _)` (expected (), found tuple) //~^ ERROR mismatched types
//~| expected `()`
//~| found `(_, _)`
//~| expected ()
//~| found tuple
return x; return x;
} }

View file

@ -8,7 +8,6 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
// error-pattern:mismatched types: expected `char`, found
// Issue #876 // Issue #876
#![no_implicit_prelude] #![no_implicit_prelude]
@ -21,4 +20,9 @@ fn last<T>(v: Vec<&T> ) -> std::option::Option<T> {
fn main() { fn main() {
let y; let y;
let x : char = last(y); let x : char = last(y);
//~^ ERROR mismatched types
//~| expected `char`
//~| found `core::option::Option<_>`
//~| expected char
//~| found enum `core::option::Option`
} }

View file

@ -20,7 +20,11 @@ struct bar {
fn want_foo(f: foo) {} fn want_foo(f: foo) {}
fn have_bar(b: bar) { 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() {} fn main() {}

View file

@ -18,7 +18,11 @@ type bar = Box<foo>;
fn want_foo(f: foo) {} fn want_foo(f: foo) {}
fn have_bar(b: bar) { fn have_bar(b: bar) {
want_foo(b); //~ ERROR (expected struct foo, found box) want_foo(b); //~ ERROR mismatched types
//~| expected `foo`
//~| found `Box<foo>`
//~| expected struct `foo`
//~| found box
} }
fn main() {} fn main() {}

View file

@ -20,7 +20,11 @@ fn c(x: Box<Foo+Sync+Send>) {
} }
fn d(x: Box<Foo>) { fn d(x: Box<Foo>) {
a(x); //~ ERROR found no bounds a(x); //~ ERROR mismatched types
//~| expected `Box<Foo + Send>`
//~| found `Box<Foo>`
//~| expected bounds `Send`
//~| found no bounds
} }
fn main() { } fn main() { }

View file

@ -14,8 +14,16 @@ fn first((value, _): (isize, f64)) -> isize { value }
fn main() { fn main() {
let y = first ((1,2.0,3)); 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,)); 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
} }

View file

@ -17,9 +17,17 @@ fn main() {
identity_u8(x); // after this, `x` is assumed to have type `u8` identity_u8(x); // after this, `x` is assumed to have type `u8`
identity_u16(x); identity_u16(x);
//~^ ERROR mismatched types: expected `u16`, found `u8` //~^ ERROR mismatched types
//~| expected `u16`
//~| found `u8`
//~| expected u16
//~| found u8
identity_u16(y); identity_u16(y);
//~^ ERROR mismatched types: expected `u16`, found `i32` //~^ ERROR mismatched types
//~| expected `u16`
//~| found `i32`
//~| expected u16
//~| found i32
let a = 3is; let a = 3is;
@ -27,6 +35,10 @@ fn main() {
identity_i(a); // ok identity_i(a); // ok
identity_u16(a); identity_u16(a);
//~^ ERROR mismatched types: expected `u16`, found `isize` //~^ ERROR mismatched types
//~| expected `u16`
//~| found `isize`
//~| expected u16
//~| found isize
} }

View file

@ -9,7 +9,15 @@
// except according to those terms. // except according to those terms.
// Checking that the compiler reports multiple type errors at once // 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; } 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

View file

@ -13,7 +13,11 @@
fn foo<Foo, Bar>(x: Foo) -> Bar { fn foo<Foo, Bar>(x: Foo) -> Bar {
x 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() {} fn main() {}

View file

@ -12,7 +12,11 @@ use std::num::Int;
trait BrokenAdd: Int { trait BrokenAdd: Int {
fn broken_add<T>(&self, rhs: T) -> Self { fn broken_add<T>(&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
} }
} }

View file

@ -19,11 +19,19 @@ pub fn main() {
fn test1() { fn test1() {
let x: Foo<_> = Bar::<usize>; let x: Foo<_> = Bar::<usize>;
//~^ ERROR mismatched types: expected `Foo<_>`, found `Bar<usize>` //~^ ERROR mismatched types
//~| expected `Foo<_>`
//~| found `Bar<usize>`
//~| expected struct `Foo`
//~| found struct `Bar`
let y: Foo<usize> = x; let y: Foo<usize> = x;
} }
fn test2() { fn test2() {
let x: Foo<_> = Bar::<usize>; let x: Foo<_> = Bar::<usize>;
//~^ ERROR mismatched types: expected `Foo<_>`, found `Bar<usize>` //~^ ERROR mismatched types
//~| expected `Foo<_>`
//~| found `Bar<usize>`
//~| expected struct `Foo`
//~| found struct `Bar`
} }

View file

@ -42,8 +42,15 @@ trait SomeTrait {
impl<'a, T> SomeTrait for &'a Bar<T> { impl<'a, T> SomeTrait for &'a Bar<T> {
fn dummy1(self: &&'a Bar<T>) { } fn dummy1(self: &&'a Bar<T>) { }
fn dummy2(self: &Bar<T>) {} //~ ERROR mismatched self type fn dummy2(self: &Bar<T>) {} //~ ERROR mismatched self type
fn dummy3(self: &&Bar<T>) {} //~ ERROR lifetime mismatch fn dummy3(self: &&Bar<T>) {}
//~^ ERROR lifetime mismatch //~^ ERROR mismatched types
//~| expected `&'a Bar<T>`
//~| found `&Bar<T>`
//~| lifetime mismatch
//~| ERROR mismatched types
//~| expected `&'a Bar<T>`
//~| found `&Bar<T>`
//~| lifetime mismatch
} }
fn main() { fn main() {

View file

@ -24,14 +24,18 @@ fn main() {
foo(1); //~ ERROR: this function takes at least 2 parameters but 1 parameter was 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 x: unsafe extern "C" fn(f: isize, x: u8) = foo;
//~^ ERROR: mismatched types: expected `unsafe extern "C" fn(isize, u8)` //~^ ERROR: mismatched types
// , found `unsafe extern "C" fn(isize, u8, ...)` //~| expected `unsafe extern "C" fn(isize, u8)`
// (expected non-variadic fn, found variadic function) //~| 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; let y: unsafe extern "C" fn(f: isize, x: u8, ...) = bar;
//~^ ERROR: mismatched types: expected `unsafe extern "C" fn(isize, u8, ...)` //~^ ERROR: mismatched types
// , found `extern "C" extern fn(isize, u8)` //~| expected `unsafe extern "C" fn(isize, u8, ...)`
// (expected variadic fn, found non-variadic function) //~| 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, 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 foo(1, 2, true); //~ ERROR: can't pass bool to variadic function, cast to c_int

View file

@ -24,7 +24,7 @@ impl Mul<f64> for Vec1 {
type Output = Vec1; type Output = Vec1;
fn mul(self, s: &f64) -> 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 { Vec1 {
x: self.x * *s x: self.x * *s
} }
@ -41,7 +41,7 @@ impl Mul<Vec2> for Vec2 {
type Output = f64; type Output = f64;
fn mul(self, s: f64) -> Vec2 { 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 { Vec2 {
x: self.x * s, x: self.x * s,
y: self.y * s y: self.y * s
@ -60,7 +60,7 @@ impl Mul<f64> for Vec3 {
type Output = i32; type Output = i32;
fn mul(self, s: f64) -> f64 { 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 s
} }
} }
@ -72,7 +72,15 @@ pub fn main() {
let x: Vec2 = Vec2 { x: 1.0, y: 2.0 } * 2.0; // trait had reversed order let x: Vec2 = Vec2 { x: 1.0, y: 2.0 } * 2.0; // trait had reversed order
//~^ ERROR mismatched types //~^ 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; let x: i32 = Vec3 { x: 1.0, y: 2.0, z: 3.0 } * 2.0;
} }