aboutsummaryrefslogtreecommitdiff
path: root/crates/libsyntax2/src/grammar/items/traits.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-08-24 17:27:30 +0100
committerAleksey Kladov <[email protected]>2018-08-24 17:27:30 +0100
commit7edab6ae6b4c5d0c411e88f10e923b91dca31de3 (patch)
tree4c17856285f568c56adb7c02024ef80e821dd367 /crates/libsyntax2/src/grammar/items/traits.rs
parent4d293003964c8f9fabadb1ceb77eab29c0438de3 (diff)
nodes for blocks
Diffstat (limited to 'crates/libsyntax2/src/grammar/items/traits.rs')
-rw-r--r--crates/libsyntax2/src/grammar/items/traits.rs54
1 files changed, 38 insertions, 16 deletions
diff --git a/crates/libsyntax2/src/grammar/items/traits.rs b/crates/libsyntax2/src/grammar/items/traits.rs
index 73ecd4bef..3853ccaab 100644
--- a/crates/libsyntax2/src/grammar/items/traits.rs
+++ b/crates/libsyntax2/src/grammar/items/traits.rs
@@ -11,18 +11,29 @@ pub(super) fn trait_def(p: &mut Parser) {
11 type_params::bounds(p); 11 type_params::bounds(p);
12 } 12 }
13 type_params::opt_where_clause(p); 13 type_params::opt_where_clause(p);
14 p.expect(L_CURLY); 14 if p.at(L_CURLY) {
15 // test trait_item_items 15 trait_item_list(p);
16 // impl F { 16 } else {
17 // type A: Clone; 17 p.error("expected `{`");
18 // const B: i32; 18 }
19 // fn foo() {} 19}
20 // fn bar(&self); 20
21 // } 21// test trait_item_list
22// impl F {
23// type A: Clone;
24// const B: i32;
25// fn foo() {}
26// fn bar(&self);
27// }
28fn trait_item_list(p: &mut Parser) {
29 assert!(p.at(L_CURLY));
30 let m = p.start();
31 p.bump();
22 while !p.at(EOF) && !p.at(R_CURLY) { 32 while !p.at(EOF) && !p.at(R_CURLY) {
23 item_or_macro(p, true, ItemFlavor::Trait); 33 item_or_macro(p, true, ItemFlavor::Trait);
24 } 34 }
25 p.expect(R_CURLY); 35 p.expect(R_CURLY);
36 m.complete(p, ITEM_LIST);
26} 37}
27 38
28// test impl_item 39// test impl_item
@@ -45,19 +56,30 @@ pub(super) fn impl_item(p: &mut Parser) {
45 types::type_(p); 56 types::type_(p);
46 } 57 }
47 type_params::opt_where_clause(p); 58 type_params::opt_where_clause(p);
48 p.expect(L_CURLY); 59 if p.at(L_CURLY) {
60 impl_item_list(p);
61 } else {
62 p.error("expected `{`");
63 }
64}
65
66// test impl_item_list
67// impl F {
68// type A = i32;
69// const B: i32 = 92;
70// fn foo() {}
71// fn bar(&self) {}
72// }
73fn impl_item_list(p: &mut Parser) {
74 assert!(p.at(L_CURLY));
75 let m = p.start();
76 p.bump();
49 77
50 // test impl_item_items
51 // impl F {
52 // type A = i32;
53 // const B: i32 = 92;
54 // fn foo() {}
55 // fn bar(&self) {}
56 // }
57 while !p.at(EOF) && !p.at(R_CURLY) { 78 while !p.at(EOF) && !p.at(R_CURLY) {
58 item_or_macro(p, true, ItemFlavor::Mod); 79 item_or_macro(p, true, ItemFlavor::Mod);
59 } 80 }
60 p.expect(R_CURLY); 81 p.expect(R_CURLY);
82 m.complete(p, ITEM_LIST);
61} 83}
62 84
63fn choose_type_params_over_qpath(p: &Parser) -> bool { 85fn choose_type_params_over_qpath(p: &Parser) -> bool {