span-preservation.rs 1.0 KB
Newer Older
1 2 3
// For each of these, we should get the appropriate type mismatch error message,
// and the function should be echoed.

4 5
// aux-build:test-macros.rs

6 7
#[macro_use]
extern crate test_macros;
8

9
#[recollect_attr]
10
fn a() {
N
Nathan 已提交
11
    let x: usize = "hello"; //~ ERROR mismatched types
12 13
}

14
#[recollect_attr]
15 16
fn b(x: Option<isize>) -> usize {
    match x {
O
Oliver Scherer 已提交
17
        Some(x) => { return x }, //~ ERROR mismatched types
18 19 20 21
        None => 10
    }
}

22
#[recollect_attr]
23 24 25 26 27 28 29 30 31 32
fn c() {
    struct Foo {
        a: usize
    }

    struct Bar {
        a: usize,
        b: usize
    }

O
Oliver Scherer 已提交
33 34
    let x = Foo { a: 10isize }; //~ ERROR mismatched types
    let y = Foo { a: 10, b: 10isize }; //~ ERROR has no field named `b`
35 36
}

37
#[recollect_attr]
38
extern "C" fn bar() {
39
    0 //~ ERROR mismatched types
40 41
}

42
#[recollect_attr]
43
extern "C" fn baz() {
O
Oliver Scherer 已提交
44
    0 //~ ERROR mismatched types
45 46
}

V
Vadim Petrochenkov 已提交
47 48 49 50 51 52 53 54 55 56
#[recollect_attr]
extern "Rust" fn rust_abi() {
    0 //~ ERROR mismatched types
}

#[recollect_attr]
extern "\x43" fn c_abi_escaped() {
    0 //~ ERROR mismatched types
}

57
fn main() {}