diff options
author | Emil Lauridsen <[email protected]> | 2020-02-07 12:51:51 +0000 |
---|---|---|
committer | Emil Lauridsen <[email protected]> | 2020-02-07 12:51:51 +0000 |
commit | 73ec2ab184f6d8828ebcdca418a7ae83bb60b0bc (patch) | |
tree | 71dbd689e3bdbf4884d78265f4371e7668bce74c /crates | |
parent | 5aba5a756a19a54d5c4edd51d8055db36182688b (diff) |
Update async unsafe fn ordering.
As of rust-lang/rust#61319 the correct order for functions that are both
unsafe and async is: `async unsafe fn` and not `unsafe async fn`.
This commit updates the parser tests to reflect this, and corrects
parsing behavior to accept the correct ordering.
Fixes #3025
Diffstat (limited to 'crates')
5 files changed, 20 insertions, 20 deletions
diff --git a/crates/ra_parser/src/grammar/items.rs b/crates/ra_parser/src/grammar/items.rs index 6e23d9b72..a88206fa8 100644 --- a/crates/ra_parser/src/grammar/items.rs +++ b/crates/ra_parser/src/grammar/items.rs | |||
@@ -91,13 +91,6 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Resul | |||
91 | // modifiers | 91 | // modifiers |
92 | has_mods |= p.eat(T![const]); | 92 | has_mods |= p.eat(T![const]); |
93 | 93 | ||
94 | // test_err unsafe_block_in_mod | ||
95 | // fn foo(){} unsafe { } fn bar(){} | ||
96 | if p.at(T![unsafe]) && p.nth(1) != T!['{'] { | ||
97 | p.eat(T![unsafe]); | ||
98 | has_mods = true; | ||
99 | } | ||
100 | |||
101 | // test_err async_without_semicolon | 94 | // test_err async_without_semicolon |
102 | // fn foo() { let _ = async {} } | 95 | // fn foo() { let _ = async {} } |
103 | if p.at(T![async]) && p.nth(1) != T!['{'] && p.nth(1) != T![move] && p.nth(1) != T![|] { | 96 | if p.at(T![async]) && p.nth(1) != T!['{'] && p.nth(1) != T![move] && p.nth(1) != T![|] { |
@@ -105,6 +98,13 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Resul | |||
105 | has_mods = true; | 98 | has_mods = true; |
106 | } | 99 | } |
107 | 100 | ||
101 | // test_err unsafe_block_in_mod | ||
102 | // fn foo(){} unsafe { } fn bar(){} | ||
103 | if p.at(T![unsafe]) && p.nth(1) != T!['{'] { | ||
104 | p.eat(T![unsafe]); | ||
105 | has_mods = true; | ||
106 | } | ||
107 | |||
108 | if p.at(T![extern]) { | 108 | if p.at(T![extern]) { |
109 | has_mods = true; | 109 | has_mods = true; |
110 | abi(p); | 110 | abi(p); |
@@ -157,11 +157,11 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Resul | |||
157 | // unsafe fn foo() {} | 157 | // unsafe fn foo() {} |
158 | 158 | ||
159 | // test combined_fns | 159 | // test combined_fns |
160 | // unsafe async fn foo() {} | 160 | // async unsafe fn foo() {} |
161 | // const unsafe fn bar() {} | 161 | // const unsafe fn bar() {} |
162 | 162 | ||
163 | // test_err wrong_order_fns | 163 | // test_err wrong_order_fns |
164 | // async unsafe fn foo() {} | 164 | // unsafe async fn foo() {} |
165 | // unsafe const fn bar() {} | 165 | // unsafe const fn bar() {} |
166 | T![fn] => { | 166 | T![fn] => { |
167 | fn_def(p, flavor); | 167 | fn_def(p, flavor); |
diff --git a/crates/ra_syntax/test_data/parser/inline/err/0010_wrong_order_fns.rs b/crates/ra_syntax/test_data/parser/inline/err/0010_wrong_order_fns.rs index 16edee95d..731e58013 100644 --- a/crates/ra_syntax/test_data/parser/inline/err/0010_wrong_order_fns.rs +++ b/crates/ra_syntax/test_data/parser/inline/err/0010_wrong_order_fns.rs | |||
@@ -1,2 +1,2 @@ | |||
1 | async unsafe fn foo() {} | 1 | unsafe async fn foo() {} |
2 | unsafe const fn bar() {} | 2 | unsafe const fn bar() {} |
diff --git a/crates/ra_syntax/test_data/parser/inline/err/0010_wrong_order_fns.txt b/crates/ra_syntax/test_data/parser/inline/err/0010_wrong_order_fns.txt index 2ea6a566d..289193b9e 100644 --- a/crates/ra_syntax/test_data/parser/inline/err/0010_wrong_order_fns.txt +++ b/crates/ra_syntax/test_data/parser/inline/err/0010_wrong_order_fns.txt | |||
@@ -1,9 +1,9 @@ | |||
1 | SOURCE_FILE@[0; 50) | 1 | SOURCE_FILE@[0; 50) |
2 | ERROR@[0; 5) | 2 | ERROR@[0; 6) |
3 | ASYNC_KW@[0; 5) "async" | 3 | UNSAFE_KW@[0; 6) "unsafe" |
4 | WHITESPACE@[5; 6) " " | 4 | WHITESPACE@[6; 7) " " |
5 | FN_DEF@[6; 24) | 5 | FN_DEF@[7; 24) |
6 | UNSAFE_KW@[6; 12) "unsafe" | 6 | ASYNC_KW@[7; 12) "async" |
7 | WHITESPACE@[12; 13) " " | 7 | WHITESPACE@[12; 13) " " |
8 | FN_KW@[13; 15) "fn" | 8 | FN_KW@[13; 15) "fn" |
9 | WHITESPACE@[15; 16) " " | 9 | WHITESPACE@[15; 16) " " |
@@ -37,5 +37,5 @@ SOURCE_FILE@[0; 50) | |||
37 | L_CURLY@[47; 48) "{" | 37 | L_CURLY@[47; 48) "{" |
38 | R_CURLY@[48; 49) "}" | 38 | R_CURLY@[48; 49) "}" |
39 | WHITESPACE@[49; 50) "\n" | 39 | WHITESPACE@[49; 50) "\n" |
40 | error 5: expected existential, fn, trait or impl | 40 | error 6: expected existential, fn, trait or impl |
41 | error 31: expected existential, fn, trait or impl | 41 | error 31: expected existential, fn, trait or impl |
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0128_combined_fns.rs b/crates/ra_syntax/test_data/parser/inline/ok/0128_combined_fns.rs index 46af91b82..126287145 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0128_combined_fns.rs +++ b/crates/ra_syntax/test_data/parser/inline/ok/0128_combined_fns.rs | |||
@@ -1,2 +1,2 @@ | |||
1 | unsafe async fn foo() {} | 1 | async unsafe fn foo() {} |
2 | const unsafe fn bar() {} | 2 | const unsafe fn bar() {} |
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0128_combined_fns.txt b/crates/ra_syntax/test_data/parser/inline/ok/0128_combined_fns.txt index cae75c41d..8a972cdb2 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0128_combined_fns.txt +++ b/crates/ra_syntax/test_data/parser/inline/ok/0128_combined_fns.txt | |||
@@ -1,8 +1,8 @@ | |||
1 | SOURCE_FILE@[0; 50) | 1 | SOURCE_FILE@[0; 50) |
2 | FN_DEF@[0; 24) | 2 | FN_DEF@[0; 24) |
3 | UNSAFE_KW@[0; 6) "unsafe" | 3 | ASYNC_KW@[0; 5) "async" |
4 | WHITESPACE@[6; 7) " " | 4 | WHITESPACE@[5; 6) " " |
5 | ASYNC_KW@[7; 12) "async" | 5 | UNSAFE_KW@[6; 12) "unsafe" |
6 | WHITESPACE@[12; 13) " " | 6 | WHITESPACE@[12; 13) " " |
7 | FN_KW@[13; 15) "fn" | 7 | FN_KW@[13; 15) "fn" |
8 | WHITESPACE@[15; 16) " " | 8 | WHITESPACE@[15; 16) " " |