summaryrefslogtreecommitdiffstats
path: root/src/test/ui/parser/default-on-wrong-item-kind.rs
blob: 98a95cfa35a9ea0295b18593f1e53c5ac679c327 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
// Test parsing for `default` where it doesn't belong.
// Specifically, we are interested in kinds of items or items in certain contexts.
// Also test item kinds in `extern` blocks and associated contexts which are not allowed there.

fn main() {}

#[cfg(FALSE)]
mod free_items {
    default extern crate foo; //~ ERROR an extern crate cannot be `default`
    default use foo; //~ ERROR a `use` import cannot be `default`
    default static foo: u8; //~ ERROR a static item cannot be `default`
    default const foo: u8;
    default fn foo();
    default mod foo {} //~ ERROR a module cannot be `default`
    default extern "C" {} //~ ERROR an extern block cannot be `default`
    default type foo = u8;
    default enum foo {} //~ ERROR an enum cannot be `default`
    default struct foo {} //~ ERROR a struct cannot be `default`
    default union foo {} //~ ERROR a union cannot be `default`
    default trait foo {} //~ ERROR a trait cannot be `default`
    default trait foo = Ord; //~ ERROR a trait alias cannot be `default`
    default impl foo {}
    default!();
    default::foo::bar!();
    default default!(); //~ ERROR an item macro invocation cannot be `default`
    default default::foo::bar!(); //~ ERROR an item macro invocation cannot be `default`
    default macro foo {} //~ ERROR a macro definition cannot be `default`
    default macro_rules! foo {} //~ ERROR a macro definition cannot be `default`
}

#[cfg(FALSE)]
extern "C" {
    default extern crate foo; //~ ERROR an extern crate cannot be `default`
    //~^ ERROR extern crate is not supported in `extern` blocks
    default use foo; //~ ERROR a `use` import cannot be `default`
    //~^ ERROR `use` import is not supported in `extern` blocks
    default static foo: u8; //~ ERROR a static item cannot be `default`
    default const foo: u8;
    //~^ ERROR extern items cannot be `const`
    default fn foo();
    default mod foo {} //~ ERROR a module cannot be `default`
    //~^ ERROR module is not supported in `extern` blocks
    default extern "C" {} //~ ERROR an extern block cannot be `default`
    //~^ ERROR extern block is not supported in `extern` blocks
    default type foo = u8;
    default enum foo {} //~ ERROR an enum cannot be `default`
    //~^ ERROR enum is not supported in `extern` blocks
    default struct foo {} //~ ERROR a struct cannot be `default`
    //~^ ERROR struct is not supported in `extern` blocks
    default union foo {} //~ ERROR a union cannot be `default`
    //~^ ERROR union is not supported in `extern` blocks
    default trait foo {} //~ ERROR a trait cannot be `default`
    //~^ ERROR trait is not supported in `extern` blocks
    default trait foo = Ord; //~ ERROR a trait alias cannot be `default`
    //~^ ERROR trait alias is not supported in `extern` blocks
    default impl foo {}
    //~^ ERROR implementation is not supported in `extern` blocks
    default!();
    default::foo::bar!();
    default default!(); //~ ERROR an item macro invocation cannot be `default`
    default default::foo::bar!(); //~ ERROR an item macro invocation cannot be `default`
    default macro foo {} //~ ERROR a macro definition cannot be `default`
    //~^ ERROR macro definition is not supported in `extern` blocks
    default macro_rules! foo {} //~ ERROR a macro definition cannot be `default`
    //~^ ERROR macro definition is not supported in `extern` blocks
}

#[cfg(FALSE)]
impl S {
    default extern crate foo; //~ ERROR an extern crate cannot be `default`
    //~^ ERROR extern crate is not supported in `trait`s or `impl`s
    default use foo; //~ ERROR a `use` import cannot be `default`
    //~^ ERROR `use` import is not supported in `trait`s or `impl`s
    default static foo: u8; //~ ERROR a static item cannot be `default`
    //~^ ERROR associated `static` items are not allowed
    default const foo: u8;
    default fn foo();
    default mod foo {}//~ ERROR a module cannot be `default`
    //~^ ERROR module is not supported in `trait`s or `impl`s
    default extern "C" {} //~ ERROR an extern block cannot be `default`
    //~^ ERROR extern block is not supported in `trait`s or `impl`s
    default type foo = u8;
    default enum foo {} //~ ERROR an enum cannot be `default`
    //~^ ERROR enum is not supported in `trait`s or `impl`s
    default struct foo {} //~ ERROR a struct cannot be `default`
    //~^ ERROR struct is not supported in `trait`s or `impl`s
    default union foo {} //~ ERROR a union cannot be `default`
    //~^ ERROR union is not supported in `trait`s or `impl`s
    default trait foo {} //~ ERROR a trait cannot be `default`
    //~^ ERROR trait is not supported in `trait`s or `impl`s
    default trait foo = Ord; //~ ERROR a trait alias cannot be `default`
    //~^ ERROR trait alias is not supported in `trait`s or `impl`s
    default impl foo {}
    //~^ ERROR implementation is not supported in `trait`s or `impl`s
    default!();
    default::foo::bar!();
    default default!(); //~ ERROR an item macro invocation cannot be `default`
    default default::foo::bar!(); //~ ERROR an item macro invocation cannot be `default`
    default macro foo {} //~ ERROR a macro definition cannot be `default`
    //~^ ERROR macro definition is not supported in `trait`s or `impl`s
    default macro_rules! foo {} //~ ERROR a macro definition cannot be `default`
    //~^ ERROR macro definition is not supported in `trait`s or `impl`s
}

#[cfg(FALSE)]
trait T {
    default extern crate foo; //~ ERROR an extern crate cannot be `default`
    //~^ ERROR extern crate is not supported in `trait`s or `impl`s
    default use foo; //~ ERROR a `use` import cannot be `default`
    //~^ ERROR `use` import is not supported in `trait`s or `impl`s
    default static foo: u8; //~ ERROR a static item cannot be `default`
    //~^ ERROR associated `static` items are not allowed
    default const foo: u8;
    default fn foo();
    default mod foo {}//~ ERROR a module cannot be `default`
    //~^ ERROR module is not supported in `trait`s or `impl`s
    default extern "C" {} //~ ERROR an extern block cannot be `default`
    //~^ ERROR extern block is not supported in `trait`s or `impl`s
    default type foo = u8;
    default enum foo {} //~ ERROR an enum cannot be `default`
    //~^ ERROR enum is not supported in `trait`s or `impl`s
    default struct foo {} //~ ERROR a struct cannot be `default`
    //~^ ERROR struct is not supported in `trait`s or `impl`s
    default union foo {} //~ ERROR a union cannot be `default`
    //~^ ERROR union is not supported in `trait`s or `impl`s
    default trait foo {} //~ ERROR a trait cannot be `default`
    //~^ ERROR trait is not supported in `trait`s or `impl`s
    default trait foo = Ord; //~ ERROR a trait alias cannot be `default`
    //~^ ERROR trait alias is not supported in `trait`s or `impl`s
    default impl foo {}
    //~^ ERROR implementation is not supported in `trait`s or `impl`s
    default!();
    default::foo::bar!();
    default default!(); //~ ERROR an item macro invocation cannot be `default`
    default default::foo::bar!(); //~ ERROR an item macro invocation cannot be `default`
    default macro foo {} //~ ERROR a macro definition cannot be `default`
    //~^ ERROR macro definition is not supported in `trait`s or `impl`s
    default macro_rules! foo {} //~ ERROR a macro definition cannot be `default`
    //~^ ERROR macro definition is not supported in `trait`s or `impl`s
}