2018-11-17 01:37:23 -06:00
|
|
|
// For each of these, we should get the appropriate type mismatch error message,
|
|
|
|
// and the function should be echoed.
|
|
|
|
|
2019-11-09 13:05:20 -06:00
|
|
|
// aux-build:test-macros.rs
|
|
|
|
|
2019-05-21 17:09:58 -05:00
|
|
|
#[macro_use]
|
|
|
|
extern crate test_macros;
|
2018-11-17 01:37:23 -06:00
|
|
|
|
2019-05-21 17:09:58 -05:00
|
|
|
#[recollect_attr]
|
2018-11-17 01:37:23 -06:00
|
|
|
fn a() {
|
2019-07-30 12:52:32 -05:00
|
|
|
let x: usize = "hello"; //~ ERROR mismatched types
|
2018-11-17 01:37:23 -06:00
|
|
|
}
|
|
|
|
|
2019-05-21 17:09:58 -05:00
|
|
|
#[recollect_attr]
|
2018-11-17 01:37:23 -06:00
|
|
|
fn b(x: Option<isize>) -> usize {
|
|
|
|
match x {
|
2018-11-30 02:41:26 -06:00
|
|
|
Some(x) => { return x }, //~ ERROR mismatched types
|
2018-11-17 01:37:23 -06:00
|
|
|
None => 10
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-21 17:09:58 -05:00
|
|
|
#[recollect_attr]
|
2018-11-17 01:37:23 -06:00
|
|
|
fn c() {
|
|
|
|
struct Foo {
|
|
|
|
a: usize
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Bar {
|
|
|
|
a: usize,
|
|
|
|
b: usize
|
|
|
|
}
|
|
|
|
|
2018-11-30 02:41:26 -06:00
|
|
|
let x = Foo { a: 10isize }; //~ ERROR mismatched types
|
|
|
|
let y = Foo { a: 10, b: 10isize }; //~ ERROR has no field named `b`
|
2018-11-17 01:37:23 -06:00
|
|
|
}
|
|
|
|
|
2019-05-21 17:09:58 -05:00
|
|
|
#[recollect_attr]
|
2020-09-01 16:28:11 -05:00
|
|
|
extern "C" fn bar() {
|
2019-11-09 13:05:20 -06:00
|
|
|
0 //~ ERROR mismatched types
|
2018-11-17 01:37:23 -06:00
|
|
|
}
|
|
|
|
|
2019-05-21 17:09:58 -05:00
|
|
|
#[recollect_attr]
|
2018-11-17 01:37:23 -06:00
|
|
|
extern "C" fn baz() {
|
2018-11-30 02:41:26 -06:00
|
|
|
0 //~ ERROR mismatched types
|
2018-11-17 01:37:23 -06:00
|
|
|
}
|
|
|
|
|
2019-11-16 16:11:35 -06:00
|
|
|
#[recollect_attr]
|
|
|
|
extern "Rust" fn rust_abi() {
|
|
|
|
0 //~ ERROR mismatched types
|
|
|
|
}
|
|
|
|
|
|
|
|
#[recollect_attr]
|
|
|
|
extern "\x43" fn c_abi_escaped() {
|
|
|
|
0 //~ ERROR mismatched types
|
|
|
|
}
|
|
|
|
|
2018-11-17 01:37:23 -06:00
|
|
|
fn main() {}
|