aboutsummaryrefslogtreecommitdiff
path: root/src/parser/grammar/items/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/parser/grammar/items/mod.rs')
-rw-r--r--src/parser/grammar/items/mod.rs82
1 files changed, 68 insertions, 14 deletions
diff --git a/src/parser/grammar/items/mod.rs b/src/parser/grammar/items/mod.rs
index 3612802e1..37f2ab132 100644
--- a/src/parser/grammar/items/mod.rs
+++ b/src/parser/grammar/items/mod.rs
@@ -81,22 +81,76 @@ fn item(p: &mut Parser) {
81 CONST_ITEM 81 CONST_ITEM
82 } 82 }
83 }, 83 },
84 // TODO: auto trait 84 UNSAFE_KW => {
85 // test unsafe_trait
86 // unsafe trait T {}
87 UNSAFE_KW if la == TRAIT_KW => {
88 p.bump(); 85 p.bump();
89 traits::trait_item(p); 86 let la = p.nth(1);
90 TRAIT_ITEM 87 match p.current() {
91 } 88 // test unsafe_trait
92 // TODO: default impl 89 // unsafe trait T {}
93 // test unsafe_impl 90 TRAIT_KW => {
94 // unsafe impl Foo {} 91 traits::trait_item(p);
95 UNSAFE_KW if la == IMPL_KW => { 92 TRAIT_ITEM
96 p.bump(); 93 }
97 traits::impl_item(p); 94
98 IMPL_ITEM 95 // test unsafe_auto_trait
96 // unsafe auto trait T {}
97 IDENT if p.at_kw("auto") && la == TRAIT_KW => {
98 p.bump_remap(AUTO_KW);
99 traits::trait_item(p);
100 TRAIT_ITEM
101 }
102
103 // test unsafe_impl
104 // unsafe impl Foo {}
105 IMPL_KW => {
106 traits::impl_item(p);
107 IMPL_ITEM
108 }
109
110 // test unsafe_default_impl
111 // unsafe default impl Foo {}
112 IDENT if p.at_kw("default") && la == IMPL_KW => {
113 p.bump_remap(DEFAULT_KW);
114 traits::impl_item(p);
115 IMPL_ITEM
116 }
117
118 // test unsafe_extern_fn
119 // unsafe extern "C" fn foo() {}
120 EXTERN_KW => {
121 abi(p);
122 if !p.at(FN_KW) {
123 item.abandon(p);
124 p.error().message("expected function").emit();
125 return;
126 }
127 fn_item(p);
128 FN_ITEM
129 }
130
131 // test unsafe_fn
132 // unsafe fn foo() {}
133 FN_KW => {
134 fn_item(p);
135 FN_ITEM
136 }
137
138 t => {
139 item.abandon(p);
140 let message = "expected `trait`, `impl` or `fn`";
141
142 // test unsafe_block_in_mod
143 // fn foo(){} unsafe { } fn bar(){}
144 if t == L_CURLY {
145 error_block(p, message);
146 } else {
147 p.error().message(message).emit();
148 }
149 return;
150 }
151 }
99 } 152 }
153
100 MOD_KW => { 154 MOD_KW => {
101 mod_item(p); 155 mod_item(p);
102 MOD_ITEM 156 MOD_ITEM