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` --- 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 + 3 files changed, 29 insertions(+) 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 (limited to 'crates') 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