From 636270f4a4f80f5d24571147bcadfbeaa29310a0 Mon Sep 17 00:00:00 2001 From: robojumper Date: Wed, 3 Apr 2019 17:11:56 +0200 Subject: Parse unsafe async / const unsafe fns properly --- .../data/parser/inline/err/0010_wrong_order_fns.rs | 2 ++ .../parser/inline/err/0010_wrong_order_fns.txt | 39 ++++++++++++++++++++++ .../data/parser/inline/ok/0128_combined_fns.rs | 2 ++ .../data/parser/inline/ok/0128_combined_fns.txt | 35 +++++++++++++++++++ 4 files changed, 78 insertions(+) create mode 100644 crates/ra_syntax/tests/data/parser/inline/err/0010_wrong_order_fns.rs create mode 100644 crates/ra_syntax/tests/data/parser/inline/err/0010_wrong_order_fns.txt create mode 100644 crates/ra_syntax/tests/data/parser/inline/ok/0128_combined_fns.rs create mode 100644 crates/ra_syntax/tests/data/parser/inline/ok/0128_combined_fns.txt (limited to 'crates/ra_syntax') diff --git a/crates/ra_syntax/tests/data/parser/inline/err/0010_wrong_order_fns.rs b/crates/ra_syntax/tests/data/parser/inline/err/0010_wrong_order_fns.rs new file mode 100644 index 000000000..16edee95d --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/inline/err/0010_wrong_order_fns.rs @@ -0,0 +1,2 @@ +async unsafe fn foo() {} +unsafe const fn bar() {} diff --git a/crates/ra_syntax/tests/data/parser/inline/err/0010_wrong_order_fns.txt b/crates/ra_syntax/tests/data/parser/inline/err/0010_wrong_order_fns.txt new file mode 100644 index 000000000..220191ffa --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/inline/err/0010_wrong_order_fns.txt @@ -0,0 +1,39 @@ +SOURCE_FILE@[0; 50) + ERROR@[0; 5) + ASYNC_KW@[0; 5) "async" + err: `expected fn, trait or impl` + WHITESPACE@[5; 6) " " + FN_DEF@[6; 24) + UNSAFE_KW@[6; 12) "unsafe" + WHITESPACE@[12; 13) " " + FN_KW@[13; 15) "fn" + WHITESPACE@[15; 16) " " + NAME@[16; 19) + IDENT@[16; 19) "foo" + PARAM_LIST@[19; 21) + L_PAREN@[19; 20) "(" + R_PAREN@[20; 21) ")" + WHITESPACE@[21; 22) " " + BLOCK@[22; 24) + L_CURLY@[22; 23) "{" + R_CURLY@[23; 24) "}" + WHITESPACE@[24; 25) "\n" + ERROR@[25; 31) + UNSAFE_KW@[25; 31) "unsafe" + err: `expected fn, trait or impl` + WHITESPACE@[31; 32) " " + FN_DEF@[32; 49) + CONST_KW@[32; 37) "const" + WHITESPACE@[37; 38) " " + FN_KW@[38; 40) "fn" + WHITESPACE@[40; 41) " " + NAME@[41; 44) + IDENT@[41; 44) "bar" + PARAM_LIST@[44; 46) + L_PAREN@[44; 45) "(" + R_PAREN@[45; 46) ")" + WHITESPACE@[46; 47) " " + BLOCK@[47; 49) + L_CURLY@[47; 48) "{" + R_CURLY@[48; 49) "}" + WHITESPACE@[49; 50) "\n" diff --git a/crates/ra_syntax/tests/data/parser/inline/ok/0128_combined_fns.rs b/crates/ra_syntax/tests/data/parser/inline/ok/0128_combined_fns.rs new file mode 100644 index 000000000..46af91b82 --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/inline/ok/0128_combined_fns.rs @@ -0,0 +1,2 @@ +unsafe async fn foo() {} +const unsafe fn bar() {} diff --git a/crates/ra_syntax/tests/data/parser/inline/ok/0128_combined_fns.txt b/crates/ra_syntax/tests/data/parser/inline/ok/0128_combined_fns.txt new file mode 100644 index 000000000..2a16aeb61 --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/inline/ok/0128_combined_fns.txt @@ -0,0 +1,35 @@ +SOURCE_FILE@[0; 50) + FN_DEF@[0; 24) + UNSAFE_KW@[0; 6) "unsafe" + WHITESPACE@[6; 7) " " + ASYNC_KW@[7; 12) "async" + WHITESPACE@[12; 13) " " + FN_KW@[13; 15) "fn" + WHITESPACE@[15; 16) " " + NAME@[16; 19) + IDENT@[16; 19) "foo" + PARAM_LIST@[19; 21) + L_PAREN@[19; 20) "(" + R_PAREN@[20; 21) ")" + WHITESPACE@[21; 22) " " + BLOCK@[22; 24) + L_CURLY@[22; 23) "{" + R_CURLY@[23; 24) "}" + WHITESPACE@[24; 25) "\n" + FN_DEF@[25; 49) + CONST_KW@[25; 30) "const" + WHITESPACE@[30; 31) " " + UNSAFE_KW@[31; 37) "unsafe" + WHITESPACE@[37; 38) " " + FN_KW@[38; 40) "fn" + WHITESPACE@[40; 41) " " + NAME@[41; 44) + IDENT@[41; 44) "bar" + PARAM_LIST@[44; 46) + L_PAREN@[44; 45) "(" + R_PAREN@[45; 46) ")" + WHITESPACE@[46; 47) " " + BLOCK@[47; 49) + L_CURLY@[47; 48) "{" + R_CURLY@[48; 49) "}" + WHITESPACE@[49; 50) "\n" -- cgit v1.2.3