]> git.proxmox.com Git - rustc.git/blob - tests/ui/parser/attr-stmt-expr-attr-bad.rs
New upstream version 1.70.0+dfsg1
[rustc.git] / tests / ui / parser / attr-stmt-expr-attr-bad.rs
1 fn main() {}
2
3 #[cfg(FALSE)] fn e() { let _ = [#[attr]]; }
4 //~^ ERROR expected expression, found `]`
5 #[cfg(FALSE)] fn e() { let _ = foo#[attr](); }
6 //~^ ERROR expected one of
7 #[cfg(FALSE)] fn e() { let _ = foo(#![attr]); }
8 //~^ ERROR an inner attribute is not permitted in this context
9 //~| ERROR expected expression, found `)`
10 #[cfg(FALSE)] fn e() { let _ = x.foo(#![attr]); }
11 //~^ ERROR an inner attribute is not permitted in this context
12 //~| ERROR expected expression, found `)`
13 #[cfg(FALSE)] fn e() { let _ = 0 + #![attr] 0; }
14 //~^ ERROR an inner attribute is not permitted in this context
15 #[cfg(FALSE)] fn e() { let _ = !#![attr] 0; }
16 //~^ ERROR an inner attribute is not permitted in this context
17 #[cfg(FALSE)] fn e() { let _ = -#![attr] 0; }
18 //~^ ERROR an inner attribute is not permitted in this context
19 #[cfg(FALSE)] fn e() { let _ = x #![attr] as Y; }
20 //~^ ERROR expected one of
21 #[cfg(FALSE)] fn e() { let _ = || #![attr] foo; }
22 //~^ ERROR an inner attribute is not permitted in this context
23 #[cfg(FALSE)] fn e() { let _ = move || #![attr] foo; }
24 //~^ ERROR an inner attribute is not permitted in this context
25 #[cfg(FALSE)] fn e() { let _ = || #![attr] {foo}; }
26 //~^ ERROR an inner attribute is not permitted in this context
27 #[cfg(FALSE)] fn e() { let _ = move || #![attr] {foo}; }
28 //~^ ERROR an inner attribute is not permitted in this context
29 #[cfg(FALSE)] fn e() { let _ = #[attr] ..#[attr] 0; }
30 //~^ ERROR expected expression, found `..`
31 #[cfg(FALSE)] fn e() { let _ = #[attr] ..; }
32 //~^ ERROR expected expression, found `..`
33 #[cfg(FALSE)] fn e() { let _ = #[attr] &#![attr] 0; }
34 //~^ ERROR an inner attribute is not permitted in this context
35 #[cfg(FALSE)] fn e() { let _ = #[attr] &mut #![attr] 0; }
36 //~^ ERROR an inner attribute is not permitted in this context
37 #[cfg(FALSE)] fn e() { let _ = if 0 #[attr] {}; }
38 //~^ ERROR outer attributes are not allowed on `if`
39 #[cfg(FALSE)] fn e() { let _ = if 0 {#![attr]}; }
40 //~^ ERROR an inner attribute is not permitted in this context
41 #[cfg(FALSE)] fn e() { let _ = if 0 {} #[attr] else {}; }
42 //~^ ERROR expected one of
43 #[cfg(FALSE)] fn e() { let _ = if 0 {} else #[attr] {}; }
44 //~^ ERROR outer attributes are not allowed on `if`
45 #[cfg(FALSE)] fn e() { let _ = if 0 {} else {#![attr]}; }
46 //~^ ERROR an inner attribute is not permitted in this context
47 #[cfg(FALSE)] fn e() { let _ = if 0 {} else #[attr] if 0 {}; }
48 //~^ ERROR outer attributes are not allowed on `if`
49 #[cfg(FALSE)] fn e() { let _ = if 0 {} else if 0 #[attr] {}; }
50 //~^ ERROR outer attributes are not allowed on `if`
51 #[cfg(FALSE)] fn e() { let _ = if 0 {} else if 0 {#![attr]}; }
52 //~^ ERROR an inner attribute is not permitted in this context
53 #[cfg(FALSE)] fn e() { let _ = if let _ = 0 #[attr] {}; }
54 //~^ ERROR outer attributes are not allowed on `if`
55 #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {#![attr]}; }
56 //~^ ERROR an inner attribute is not permitted in this context
57 #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} #[attr] else {}; }
58 //~^ ERROR expected one of
59 #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else #[attr] {}; }
60 //~^ ERROR outer attributes are not allowed on `if`
61 #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else {#![attr]}; }
62 //~^ ERROR an inner attribute is not permitted in this context
63 #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else #[attr] if let _ = 0 {}; }
64 //~^ ERROR outer attributes are not allowed on `if`
65 #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else if let _ = 0 #[attr] {}; }
66 //~^ ERROR outer attributes are not allowed on `if`
67 #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else if let _ = 0 {#![attr]}; }
68 //~^ ERROR an inner attribute is not permitted in this context
69
70 #[cfg(FALSE)] fn s() { #[attr] #![attr] let _ = 0; }
71 //~^ ERROR an inner attribute is not permitted following an outer attribute
72 #[cfg(FALSE)] fn s() { #[attr] #![attr] 0; }
73 //~^ ERROR an inner attribute is not permitted following an outer attribute
74 #[cfg(FALSE)] fn s() { #[attr] #![attr] foo!(); }
75 //~^ ERROR an inner attribute is not permitted following an outer attribute
76 #[cfg(FALSE)] fn s() { #[attr] #![attr] foo![]; }
77 //~^ ERROR an inner attribute is not permitted following an outer attribute
78 #[cfg(FALSE)] fn s() { #[attr] #![attr] foo!{}; }
79 //~^ ERROR an inner attribute is not permitted following an outer attribute
80
81 // FIXME: Allow attributes in pattern constexprs?
82 // note: requires parens in patterns to allow disambiguation
83
84 #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] 10 => () } }
85 //~^ ERROR inclusive range with no end
86 //~| ERROR expected one of `=>`, `if`, or `|`, found `#`
87 #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] -10 => () } }
88 //~^ ERROR inclusive range with no end
89 //~| ERROR expected one of `=>`, `if`, or `|`, found `#`
90 #[cfg(FALSE)] fn e() { match 0 { 0..=-#[attr] 10 => () } }
91 //~^ ERROR unexpected token: `#`
92 #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] FOO => () } }
93 //~^ ERROR inclusive range with no end
94 //~| ERROR expected one of `=>`, `if`, or `|`, found `#`
95
96 #[cfg(FALSE)] fn e() { let _ = x.#![attr]foo(); }
97 //~^ ERROR unexpected token: `#`
98 //~| ERROR expected one of `.`
99 #[cfg(FALSE)] fn e() { let _ = x.#[attr]foo(); }
100 //~^ ERROR unexpected token: `#`
101 //~| ERROR expected one of `.`
102
103 // make sure we don't catch this bug again...
104 #[cfg(FALSE)] fn e() { { fn foo() { #[attr]; } } }
105 //~^ ERROR expected statement after outer attribute
106 #[cfg(FALSE)] fn e() { { fn foo() { #[attr] } } }
107 //~^ ERROR expected statement after outer attribute