From d6ab1af0868f176caadeec4e184c282af56d1094 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 7 Aug 2019 21:00:02 +0200 Subject: assoc types bounds --- crates/ra_parser/src/grammar/type_args.rs | 7 +++ .../inline/ok/0138_associated_type_bounds.rs | 1 + .../inline/ok/0138_associated_type_bounds.txt | 55 ++++++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0138_associated_type_bounds.rs create mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0138_associated_type_bounds.txt (limited to 'crates') diff --git a/crates/ra_parser/src/grammar/type_args.rs b/crates/ra_parser/src/grammar/type_args.rs index f391b63db..3db08b280 100644 --- a/crates/ra_parser/src/grammar/type_args.rs +++ b/crates/ra_parser/src/grammar/type_args.rs @@ -35,6 +35,13 @@ fn type_arg(p: &mut Parser) { p.bump(); m.complete(p, LIFETIME_ARG); } + // test associated_type_bounds + // fn print_all>(printables: T) {} + IDENT if p.nth(1) == T![:] => { + name_ref(p); + type_params::bounds(p); + m.complete(p, ASSOC_TYPE_ARG); + } IDENT if p.nth(1) == T![=] => { name_ref(p); p.bump(); diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0138_associated_type_bounds.rs b/crates/ra_syntax/test_data/parser/inline/ok/0138_associated_type_bounds.rs new file mode 100644 index 000000000..eb21a657b --- /dev/null +++ b/crates/ra_syntax/test_data/parser/inline/ok/0138_associated_type_bounds.rs @@ -0,0 +1 @@ +fn print_all>(printables: T) {} diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0138_associated_type_bounds.txt b/crates/ra_syntax/test_data/parser/inline/ok/0138_associated_type_bounds.txt new file mode 100644 index 000000000..33e75510d --- /dev/null +++ b/crates/ra_syntax/test_data/parser/inline/ok/0138_associated_type_bounds.txt @@ -0,0 +1,55 @@ +SOURCE_FILE@[0; 59) + FN_DEF@[0; 58) + FN_KW@[0; 2) "fn" + WHITESPACE@[2; 3) " " + NAME@[3; 12) + IDENT@[3; 12) "print_all" + TYPE_PARAM_LIST@[12; 40) + L_ANGLE@[12; 13) "<" + TYPE_PARAM@[13; 39) + NAME@[13; 14) + IDENT@[13; 14) "T" + COLON@[14; 15) ":" + WHITESPACE@[15; 16) " " + TYPE_BOUND_LIST@[16; 39) + TYPE_BOUND@[16; 39) + PATH_TYPE@[16; 39) + PATH@[16; 39) + PATH_SEGMENT@[16; 39) + NAME_REF@[16; 24) + IDENT@[16; 24) "Iterator" + TYPE_ARG_LIST@[24; 39) + L_ANGLE@[24; 25) "<" + ASSOC_TYPE_ARG@[25; 38) + NAME_REF@[25; 29) + IDENT@[25; 29) "Item" + COLON@[29; 30) ":" + WHITESPACE@[30; 31) " " + TYPE_BOUND_LIST@[31; 38) + TYPE_BOUND@[31; 38) + PATH_TYPE@[31; 38) + PATH@[31; 38) + PATH_SEGMENT@[31; 38) + NAME_REF@[31; 38) + IDENT@[31; 38) "Display" + R_ANGLE@[38; 39) ">" + R_ANGLE@[39; 40) ">" + PARAM_LIST@[40; 55) + L_PAREN@[40; 41) "(" + PARAM@[41; 54) + BIND_PAT@[41; 51) + NAME@[41; 51) + IDENT@[41; 51) "printables" + COLON@[51; 52) ":" + WHITESPACE@[52; 53) " " + PATH_TYPE@[53; 54) + PATH@[53; 54) + PATH_SEGMENT@[53; 54) + NAME_REF@[53; 54) + IDENT@[53; 54) "T" + R_PAREN@[54; 55) ")" + WHITESPACE@[55; 56) " " + BLOCK@[56; 58) + L_CURLY@[56; 57) "{" + R_CURLY@[57; 58) "}" + WHITESPACE@[58; 59) "\n" -- cgit v1.2.3