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