diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-02-04 14:07:09 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-02-04 14:07:09 +0000 |
commit | 550b17d7cf321c2aebff75d00b1654b55beca53c (patch) | |
tree | a7759795877d2d5fef25915997c2679af0cd3e94 /src/parser/grammar | |
parent | b86e87c8885895e5b3fcec021ee65003d64c4cbe (diff) | |
parent | 351107d0b143e2c3497bd0f424f0d76bc51df0c0 (diff) |
Merge #43
43: Ctx r=matklad a=matklad
Diffstat (limited to 'src/parser/grammar')
-rw-r--r-- | src/parser/grammar/items/mod.rs | 82 |
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 |