diff options
-rw-r--r-- | src/parser/grammar/items/mod.rs | 12 | ||||
-rw-r--r-- | src/parser/grammar/items/traits.rs | 3 | ||||
-rw-r--r-- | tests/data/parser/inline/0046_default_impl.rs | 1 | ||||
-rw-r--r-- | tests/data/parser/inline/0046_default_impl.txt | 11 | ||||
-rw-r--r-- | tests/data/parser/inline/0047_impl_item.rs | 1 | ||||
-rw-r--r-- | tests/data/parser/inline/0047_impl_item.txt | 9 |
6 files changed, 37 insertions, 0 deletions
diff --git a/src/parser/grammar/items/mod.rs b/src/parser/grammar/items/mod.rs index c88e39596..73fd5235a 100644 --- a/src/parser/grammar/items/mod.rs +++ b/src/parser/grammar/items/mod.rs | |||
@@ -149,6 +149,18 @@ fn item(p: &mut Parser) { | |||
149 | } | 149 | } |
150 | } | 150 | } |
151 | } | 151 | } |
152 | IMPL_KW => { | ||
153 | traits::impl_item(p); | ||
154 | IMPL_ITEM | ||
155 | } | ||
156 | // test default_impl | ||
157 | // default impl Foo {} | ||
158 | IDENT if p.at_contextual_kw("default") && la == IMPL_KW => { | ||
159 | p.bump_remap(DEFAULT_KW); | ||
160 | traits::impl_item(p); | ||
161 | IMPL_ITEM | ||
162 | } | ||
163 | |||
152 | FN_KW => { | 164 | FN_KW => { |
153 | fn_item(p); | 165 | fn_item(p); |
154 | FN_ITEM | 166 | FN_ITEM |
diff --git a/src/parser/grammar/items/traits.rs b/src/parser/grammar/items/traits.rs index 9961a88fe..7fd011ffd 100644 --- a/src/parser/grammar/items/traits.rs +++ b/src/parser/grammar/items/traits.rs | |||
@@ -8,6 +8,9 @@ pub(super) fn trait_item(p: &mut Parser) { | |||
8 | p.expect(R_CURLY); | 8 | p.expect(R_CURLY); |
9 | } | 9 | } |
10 | 10 | ||
11 | |||
12 | // test impl_item | ||
13 | // impl Foo {} | ||
11 | pub(super) fn impl_item(p: &mut Parser) { | 14 | pub(super) fn impl_item(p: &mut Parser) { |
12 | assert!(p.at(IMPL_KW)); | 15 | assert!(p.at(IMPL_KW)); |
13 | p.bump(); | 16 | p.bump(); |
diff --git a/tests/data/parser/inline/0046_default_impl.rs b/tests/data/parser/inline/0046_default_impl.rs new file mode 100644 index 000000000..ef6aa84a2 --- /dev/null +++ b/tests/data/parser/inline/0046_default_impl.rs | |||
@@ -0,0 +1 @@ | |||
default impl Foo {} | |||
diff --git a/tests/data/parser/inline/0046_default_impl.txt b/tests/data/parser/inline/0046_default_impl.txt new file mode 100644 index 000000000..bc17bcaff --- /dev/null +++ b/tests/data/parser/inline/0046_default_impl.txt | |||
@@ -0,0 +1,11 @@ | |||
1 | FILE@[0; 20) | ||
2 | IMPL_ITEM@[0; 20) | ||
3 | DEFAULT_KW@[0; 7) | ||
4 | WHITESPACE@[7; 8) | ||
5 | IMPL_KW@[8; 12) | ||
6 | WHITESPACE@[12; 13) | ||
7 | IDENT@[13; 16) "Foo" | ||
8 | WHITESPACE@[16; 17) | ||
9 | L_CURLY@[17; 18) | ||
10 | R_CURLY@[18; 19) | ||
11 | WHITESPACE@[19; 20) | ||
diff --git a/tests/data/parser/inline/0047_impl_item.rs b/tests/data/parser/inline/0047_impl_item.rs new file mode 100644 index 000000000..d6337f6b3 --- /dev/null +++ b/tests/data/parser/inline/0047_impl_item.rs | |||
@@ -0,0 +1 @@ | |||
impl Foo {} | |||
diff --git a/tests/data/parser/inline/0047_impl_item.txt b/tests/data/parser/inline/0047_impl_item.txt new file mode 100644 index 000000000..a7f3155e1 --- /dev/null +++ b/tests/data/parser/inline/0047_impl_item.txt | |||
@@ -0,0 +1,9 @@ | |||
1 | FILE@[0; 12) | ||
2 | IMPL_ITEM@[0; 12) | ||
3 | IMPL_KW@[0; 4) | ||
4 | WHITESPACE@[4; 5) | ||
5 | IDENT@[5; 8) "Foo" | ||
6 | WHITESPACE@[8; 9) | ||
7 | L_CURLY@[9; 10) | ||
8 | R_CURLY@[10; 11) | ||
9 | WHITESPACE@[11; 12) | ||