aboutsummaryrefslogtreecommitdiff
path: root/src/parser/grammar/items
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-07-31 16:24:30 +0100
committerAleksey Kladov <[email protected]>2018-07-31 16:24:30 +0100
commitcd814fdf8113bc801b735ed462ba142e98f1f81b (patch)
tree07d131346f583ccdbc24fb5ebe81fa69d21290e5 /src/parser/grammar/items
parent892acc5b36552995515f91d2bc14ae82f81d7b8d (diff)
trait bounds
Diffstat (limited to 'src/parser/grammar/items')
-rw-r--r--src/parser/grammar/items/mod.rs11
-rw-r--r--src/parser/grammar/items/traits.rs7
2 files changed, 18 insertions, 0 deletions
diff --git a/src/parser/grammar/items/mod.rs b/src/parser/grammar/items/mod.rs
index 12bcf7924..037cdca53 100644
--- a/src/parser/grammar/items/mod.rs
+++ b/src/parser/grammar/items/mod.rs
@@ -149,6 +149,17 @@ fn item(p: &mut Parser) {
149 } 149 }
150 } 150 }
151 } 151 }
152 TRAIT_KW => {
153 traits::trait_item(p);
154 TRAIT_ITEM
155 }
156 // test auto_trait
157 // auto trait T {}
158 IDENT if p.at_contextual_kw("auto") && la == TRAIT_KW => {
159 p.bump_remap(AUTO_KW);
160 traits::trait_item(p);
161 TRAIT_ITEM
162 }
152 IMPL_KW => { 163 IMPL_KW => {
153 traits::impl_item(p); 164 traits::impl_item(p);
154 IMPL_ITEM 165 IMPL_ITEM
diff --git a/src/parser/grammar/items/traits.rs b/src/parser/grammar/items/traits.rs
index 7d657ced0..60158fe41 100644
--- a/src/parser/grammar/items/traits.rs
+++ b/src/parser/grammar/items/traits.rs
@@ -1,9 +1,16 @@
1use super::*; 1use super::*;
2 2
3// test trait_item
4// trait T<U>: Hash + Clone where U: Copy {}
3pub(super) fn trait_item(p: &mut Parser) { 5pub(super) fn trait_item(p: &mut Parser) {
4 assert!(p.at(TRAIT_KW)); 6 assert!(p.at(TRAIT_KW));
5 p.bump(); 7 p.bump();
6 name(p); 8 name(p);
9 type_params::list(p);
10 if p.at(COLON) {
11 type_params::bounds(p);
12 }
13 type_params::where_clause(p);
7 p.expect(L_CURLY); 14 p.expect(L_CURLY);
8 p.expect(R_CURLY); 15 p.expect(R_CURLY);
9} 16}