]> git.lizzy.rs Git - rust.git/blob - src/test/ui/proc-macro/span-preservation.rs
Update tests for excess semicolon lint
[rust.git] / src / test / ui / proc-macro / span-preservation.rs
1 //~ ERROR mismatched types
2 // aux-build:test-macros.rs
3
4 // For each of these, we should get the appropriate type mismatch error message,
5 // and the function should be echoed.
6
7 #[macro_use]
8 extern crate test_macros;
9
10 #[recollect_attr]
11 fn a() {
12     let x: usize = "hello"; //~ ERROR mismatched types
13 }
14
15 #[recollect_attr]
16 fn b(x: Option<isize>) -> usize {
17     match x {
18         Some(x) => { return x }, //~ ERROR mismatched types
19         None => 10
20     }
21 }
22
23 #[recollect_attr]
24 fn c() {
25     struct Foo {
26         a: usize
27     }
28
29     struct Bar {
30         a: usize,
31         b: usize
32     }
33
34     let x = Foo { a: 10isize }; //~ ERROR mismatched types
35     let y = Foo { a: 10, b: 10isize }; //~ ERROR has no field named `b`
36 }
37
38 // FIXME: This doesn't work at the moment. See the one below. The pretty-printer
39 // injects a "C" between `extern` and `fn` which causes a "probably_eq"
40 // `TokenStream` mismatch. The lack of `"C"` should be preserved in the AST.
41 #[recollect_attr]
42 extern fn bar() {
43     0
44 }
45
46 #[recollect_attr]
47 extern "C" fn baz() {
48     0 //~ ERROR mismatched types
49 }
50
51 fn main() {}