From b26002410b5acda8d0e1322071881cdb8a2b6724 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Mon, 18 Jan 2021 19:50:13 +0100 Subject: Parse `impl const Trait` --- Cargo.lock | 4 ++-- crates/parser/src/grammar/items/traits.rs | 4 ++++ .../parser/inline/ok/0161_impl_def_const.rast | 24 ++++++++++++++++++++++ .../parser/inline/ok/0161_impl_def_const.rs | 1 + 4 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 crates/syntax/test_data/parser/inline/ok/0161_impl_def_const.rast create mode 100644 crates/syntax/test_data/parser/inline/ok/0161_impl_def_const.rs diff --git a/Cargo.lock b/Cargo.lock index aac473191..eafec00d3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1839,9 +1839,9 @@ checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" [[package]] name = "ungrammar" -version = "1.9.2" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58a02e2041a872d56354e843e8e86e6b946fc8e7dc32982fcdc335e29eb4cc8b" +checksum = "f5901372c0f3a6a1a9d880aef134c8eaf5e54409343637508c0a344270b42d7b" [[package]] name = "unicase" diff --git a/crates/parser/src/grammar/items/traits.rs b/crates/parser/src/grammar/items/traits.rs index d076974ed..d3327271c 100644 --- a/crates/parser/src/grammar/items/traits.rs +++ b/crates/parser/src/grammar/items/traits.rs @@ -40,6 +40,10 @@ pub(super) fn impl_(p: &mut Parser) { type_params::opt_generic_param_list(p); } + // test impl_def_const + // impl const Send for X {} + p.eat(T![const]); + // FIXME: never type // impl ! {} diff --git a/crates/syntax/test_data/parser/inline/ok/0161_impl_def_const.rast b/crates/syntax/test_data/parser/inline/ok/0161_impl_def_const.rast new file mode 100644 index 000000000..dcd39535b --- /dev/null +++ b/crates/syntax/test_data/parser/inline/ok/0161_impl_def_const.rast @@ -0,0 +1,24 @@ +SOURCE_FILE@0..25 + IMPL@0..24 + IMPL_KW@0..4 "impl" + WHITESPACE@4..5 " " + CONST_KW@5..10 "const" + WHITESPACE@10..11 " " + PATH_TYPE@11..15 + PATH@11..15 + PATH_SEGMENT@11..15 + NAME_REF@11..15 + IDENT@11..15 "Send" + WHITESPACE@15..16 " " + FOR_KW@16..19 "for" + WHITESPACE@19..20 " " + PATH_TYPE@20..21 + PATH@20..21 + PATH_SEGMENT@20..21 + NAME_REF@20..21 + IDENT@20..21 "X" + WHITESPACE@21..22 " " + ASSOC_ITEM_LIST@22..24 + L_CURLY@22..23 "{" + R_CURLY@23..24 "}" + WHITESPACE@24..25 "\n" diff --git a/crates/syntax/test_data/parser/inline/ok/0161_impl_def_const.rs b/crates/syntax/test_data/parser/inline/ok/0161_impl_def_const.rs new file mode 100644 index 000000000..8d6886469 --- /dev/null +++ b/crates/syntax/test_data/parser/inline/ok/0161_impl_def_const.rs @@ -0,0 +1 @@ +impl const Send for X {} -- cgit v1.2.3