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