Copy path View file
@@ -18,8 +18,16 @@ fn eq<T>(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
}
Copy path View file
@@ -14,12 +14,25 @@
fn needs_fn<F>(x: F) where F: Fn(isize) -> isize {}

fn main() {
let _: () = (box |:_: isize| {}) as Box<FnOnce(isize)>; //~ ERROR object-safe
//~^ ERROR Box<core::ops::FnOnce(isize)>
let _: () = (box |:_: isize| {}) as Box<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)>;
//~^ 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>;
//~^ 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`
}
Copy path View file
@@ -13,5 +13,9 @@
fn main() {
let x: Option<usize>;
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
}
Copy path View file
@@ -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() {
Copy path View file
@@ -14,7 +14,11 @@ use std::option::Option;

fn bar(x: usize) -> Option<usize> {
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() {
Copy path View file
@@ -19,23 +19,47 @@ struct HashMap<K, V, H = Hash<K>>;
fn main() {
// Ensure that the printed type doesn't include the default type params...
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.
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.
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>> = ();
//~^ 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.
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.
let _: Foo<A, B, C> = ();
//~^ ERROR mismatched types: expected `Foo`, found `()`
//~^ ERROR mismatched types
//~| expected `Foo`
//~| found `()`
//~| expected struct `Foo`
//~| found ()
}
Copy path View file
@@ -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
}
Copy path View file
@@ -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);
}
Copy path View file
@@ -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

This comment has been minimized.

@nrc

nrc Jan 11, 2015

Member

for all these tests, I don't think its is necessary to check for the detail twice - if in the future we stop reporting them twice, it wouldn't be a bug (it would actually be an improvement)

This comment has been minimized.

@mdinger

mdinger Jan 11, 2015

Author Contributor

I have to do both. It doesn't pass if I only do 3 lines instead of 5. (I'm not sure if this is just a comment or suggesting I do something so...)

This comment has been minimized.

@nrc

nrc Jan 11, 2015

Member

Is that because it treats each line like its own error? That seems like something that should be fixed either way. Not here, but please file an issue for it.

This comment has been minimized.

@mdinger

mdinger Jan 11, 2015

Author Contributor

Yeah. That sytax also doesn't seem to work with macros. Macros seem to put out a different prefix than the rest so it doesn't work. You have the use the header notation for macro errors.


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
}
Copy path View file
@@ -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
}
Copy path View file
@@ -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() {}
Copy path View file
@@ -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
Copy path View file
@@ -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 ()
;
}
Copy path View file
@@ -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
Copy path View file
@@ -35,5 +35,9 @@ fn check<'r, I: Iterator<Item=usize>, 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
}
Copy path View file
@@ -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
}
Copy path View file
@@ -15,7 +15,18 @@ pub fn main() {
// the actual arm `Result<T, E>` 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<usize>`
Err(e) => panic!(e) //~ ERROR mismatched types: expected `core::option::Option<usize>`
Ok(u) => u,
//~^ 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`
};
}
Copy path View file
@@ -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)
};
}
Copy path View file
@@ -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)
};
}
Copy path View file
@@ -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`
}
}
}
Copy path View file
@@ -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);}
Copy path View file
@@ -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() { }
Copy path View file
@@ -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
}
Copy path View file
@@ -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);
}
Copy path View file
@@ -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,
};
}
Copy path View file
@@ -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`
}

Copy path View file
@@ -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!()
}
}
Copy path View file
@@ -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() {}
Copy path View file
@@ -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);
}
}
Copy path View file
@@ -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
}
}

Copy path View file
@@ -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);
}
}
Copy path View file
@@ -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
};
}
Copy path View file
@@ -10,7 +10,12 @@

fn foo<T, U>(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() {
Copy path View file
@@ -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
}
Copy path View file
@@ -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() {}
Copy path View file
@@ -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`
}
}
Copy path View file
@@ -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
};
}
Copy path View file
@@ -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
}
Copy path View file
@@ -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
}
Copy path View file
@@ -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
}
Copy path View file
@@ -13,7 +13,12 @@ struct S(Either<usize, usize>);

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`
_ => {}
}
}
Copy path View file
@@ -10,5 +10,9 @@

fn main() {
&panic!()
//~^ ERROR mismatched types: expected `()`, found `&_` (expected (), found &-ptr)
//~^ ERROR mismatched types
//~| expected `()`
//~| found `&_`
//~| expected ()
//~| found &-ptr
}
Copy path View file
@@ -12,7 +12,11 @@ struct BarStruct;

impl<'a> BarStruct {
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() {}
Copy path View file
@@ -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
}
}
Copy path View file
@@ -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<isize>`,
// found `core::option::Option<_>`
None => () //~ ERROR expected `&core::option::Option<isize>`,
// found `core::option::Option<_>`
Some(x) => (),
//~^ ERROR mismatched types
//~| expected `&core::option::Option<isize>`
//~| 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`
}
}
Copy path View file
@@ -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() {}
Copy path View file
@@ -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`
_ => ()
}
}
Copy path View file
@@ -11,6 +11,10 @@
fn main() {
match () {
[()] => { }
//~^ ERROR mismatched types: expected `()`, found `&[_]` (expected (), found &-ptr)
//~^ ERROR mismatched types
//~| expected `()`
//~| found `&[_]`
//~| expected ()
//~| found &-ptr
}
}
Copy path View file
@@ -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
}
Copy path View file
@@ -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;
}
Copy path View file
@@ -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<isize>`
//~^ ERROR mismatched types
//~| expected `isize`
//~| found `core::option::Option<isize>`
//~| expected isize
//~| found enum `core::option::Option`
}
Copy path View file
@@ -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
}
Copy path View file
@@ -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
}
Copy path View file
@@ -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
}
Copy path View file
@@ -12,8 +12,16 @@ fn let_in<T, F>(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
}
Copy path View file
@@ -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
}
Copy path View file
@@ -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() { }
Copy path View file
@@ -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

}
}
Copy path 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 {
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() {
Copy path View file
@@ -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() {
Copy path View file
@@ -31,7 +31,10 @@ impl<'a> set_f<'a> for c<'a> {

fn set_f_bad(&mut self, b: Box<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
}
}

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

}
Copy path View file
@@ -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
}
Copy path View file
@@ -24,25 +24,33 @@ type PairF<U> = Pair<f32,U>;

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::<f32> {
//~^ 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::<isize> {
//~^ ERROR expected f32, found isize
//~^ ERROR structure constructor specifies a structure of type
//~| expected f32
//~| found isize
x: 7is,
y: 8is,
};
Copy path View file
@@ -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;
}
Copy path View file
@@ -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<T>(v: Vec<&T> ) -> std::option::Option<T> {
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`
}
Copy path View file
@@ -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() {}
Copy path View file
@@ -18,7 +18,11 @@ type bar = Box<foo>;

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<foo>`
//~| expected struct `foo`
//~| found box
}

fn main() {}
Copy path View file
@@ -20,7 +20,11 @@ fn c(x: Box<Foo+Sync+Send>) {
}

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() { }
Copy path View file
@@ -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
}
Copy path View file
@@ -17,16 +17,28 @@ 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;

fn identity_i(n: isize) -> isize { n }

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

}
Copy path View file
@@ -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
Copy path View file
@@ -13,7 +13,11 @@

fn foo<Foo, Bar>(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() {}
Copy path View file
@@ -12,7 +12,11 @@ use std::num::Int;

trait BrokenAdd: Int {
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
}
}

Copy path View file
@@ -19,11 +19,19 @@ pub fn main() {

fn test1() {
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;
}

fn test2() {
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`
}
Copy path View file
@@ -42,8 +42,15 @@ trait SomeTrait {
impl<'a, T> SomeTrait for &'a Bar<T> {
fn dummy1(self: &&'a Bar<T>) { }
fn dummy2(self: &Bar<T>) {} //~ ERROR mismatched self type
fn dummy3(self: &&Bar<T>) {} //~ ERROR lifetime mismatch
//~^ ERROR lifetime mismatch
fn dummy3(self: &&Bar<T>) {}
//~^ 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() {
Copy path View file
@@ -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
Copy path View file
@@ -24,7 +24,7 @@ impl Mul<f64> 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<Vec2> 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<f64> 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;
}