Skip to content

Commit e92e679

Browse files
committed
Fix not parse never type in inherent impl
1 parent c46279d commit e92e679

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

crates/parser/src/grammar/items/traits.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,13 @@ pub(super) fn impl_(p: &mut Parser<'_>, m: Marker) {
5454
// impl const Send for S {}
5555
p.eat(T![const]);
5656

57-
// FIXME: never type
57+
// test impl_item_never_type
5858
// impl ! {}
59-
60-
// test impl_item_neg
61-
// impl !Send for S {}
62-
p.eat(T![!]);
59+
if p.at(T![!]) && !p.nth_at(1, T!['{']) {
60+
// test impl_item_neg
61+
// impl !Send for S {}
62+
p.eat(T![!]);
63+
}
6364
impl_type(p);
6465
if p.eat(T![for]) {
6566
impl_type(p);

crates/parser/test_data/generated/runner.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,10 @@ mod ok {
322322
#[test]
323323
fn impl_item_neg() { run_and_expect_no_errors("test_data/parser/inline/ok/impl_item_neg.rs"); }
324324
#[test]
325+
fn impl_item_never_type() {
326+
run_and_expect_no_errors("test_data/parser/inline/ok/impl_item_never_type.rs");
327+
}
328+
#[test]
325329
fn impl_trait_type() {
326330
run_and_expect_no_errors("test_data/parser/inline/ok/impl_trait_type.rs");
327331
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
SOURCE_FILE
2+
IMPL
3+
IMPL_KW "impl"
4+
WHITESPACE " "
5+
NEVER_TYPE
6+
BANG "!"
7+
WHITESPACE " "
8+
ASSOC_ITEM_LIST
9+
L_CURLY "{"
10+
R_CURLY "}"
11+
WHITESPACE "\n"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
impl ! {}

0 commit comments

Comments
 (0)