mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-03 21:25:25 +00:00
Merge #3047
3047: Update async unsafe fn ordering in parser r=matklad a=kiljacken 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 Co-authored-by: Emil Lauridsen <mine809@gmail.com>
This commit is contained in:
commit
8337dcd9e2
5 changed files with 20 additions and 20 deletions
|
|
@ -91,13 +91,6 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Resul
|
||||||
// modifiers
|
// modifiers
|
||||||
has_mods |= p.eat(T![const]);
|
has_mods |= p.eat(T![const]);
|
||||||
|
|
||||||
// test_err unsafe_block_in_mod
|
|
||||||
// fn foo(){} unsafe { } fn bar(){}
|
|
||||||
if p.at(T![unsafe]) && p.nth(1) != T!['{'] {
|
|
||||||
p.eat(T![unsafe]);
|
|
||||||
has_mods = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// test_err async_without_semicolon
|
// test_err async_without_semicolon
|
||||||
// fn foo() { let _ = async {} }
|
// fn foo() { let _ = async {} }
|
||||||
if p.at(T![async]) && p.nth(1) != T!['{'] && p.nth(1) != T![move] && p.nth(1) != T![|] {
|
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
|
||||||
has_mods = true;
|
has_mods = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// test_err unsafe_block_in_mod
|
||||||
|
// fn foo(){} unsafe { } fn bar(){}
|
||||||
|
if p.at(T![unsafe]) && p.nth(1) != T!['{'] {
|
||||||
|
p.eat(T![unsafe]);
|
||||||
|
has_mods = true;
|
||||||
|
}
|
||||||
|
|
||||||
if p.at(T![extern]) {
|
if p.at(T![extern]) {
|
||||||
has_mods = true;
|
has_mods = true;
|
||||||
abi(p);
|
abi(p);
|
||||||
|
|
@ -157,11 +157,11 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Resul
|
||||||
// unsafe fn foo() {}
|
// unsafe fn foo() {}
|
||||||
|
|
||||||
// test combined_fns
|
// test combined_fns
|
||||||
// unsafe async fn foo() {}
|
// async unsafe fn foo() {}
|
||||||
// const unsafe fn bar() {}
|
// const unsafe fn bar() {}
|
||||||
|
|
||||||
// test_err wrong_order_fns
|
// test_err wrong_order_fns
|
||||||
// async unsafe fn foo() {}
|
// unsafe async fn foo() {}
|
||||||
// unsafe const fn bar() {}
|
// unsafe const fn bar() {}
|
||||||
T![fn] => {
|
T![fn] => {
|
||||||
fn_def(p);
|
fn_def(p);
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,2 @@
|
||||||
async unsafe fn foo() {}
|
unsafe async fn foo() {}
|
||||||
unsafe const fn bar() {}
|
unsafe const fn bar() {}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
SOURCE_FILE@[0; 50)
|
SOURCE_FILE@[0; 50)
|
||||||
ERROR@[0; 5)
|
ERROR@[0; 6)
|
||||||
ASYNC_KW@[0; 5) "async"
|
UNSAFE_KW@[0; 6) "unsafe"
|
||||||
WHITESPACE@[5; 6) " "
|
WHITESPACE@[6; 7) " "
|
||||||
FN_DEF@[6; 24)
|
FN_DEF@[7; 24)
|
||||||
UNSAFE_KW@[6; 12) "unsafe"
|
ASYNC_KW@[7; 12) "async"
|
||||||
WHITESPACE@[12; 13) " "
|
WHITESPACE@[12; 13) " "
|
||||||
FN_KW@[13; 15) "fn"
|
FN_KW@[13; 15) "fn"
|
||||||
WHITESPACE@[15; 16) " "
|
WHITESPACE@[15; 16) " "
|
||||||
|
|
@ -37,5 +37,5 @@ SOURCE_FILE@[0; 50)
|
||||||
L_CURLY@[47; 48) "{"
|
L_CURLY@[47; 48) "{"
|
||||||
R_CURLY@[48; 49) "}"
|
R_CURLY@[48; 49) "}"
|
||||||
WHITESPACE@[49; 50) "\n"
|
WHITESPACE@[49; 50) "\n"
|
||||||
error 5: expected existential, fn, trait or impl
|
error 6: expected existential, fn, trait or impl
|
||||||
error 31: expected existential, fn, trait or impl
|
error 31: expected existential, fn, trait or impl
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,2 @@
|
||||||
unsafe async fn foo() {}
|
async unsafe fn foo() {}
|
||||||
const unsafe fn bar() {}
|
const unsafe fn bar() {}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
SOURCE_FILE@[0; 50)
|
SOURCE_FILE@[0; 50)
|
||||||
FN_DEF@[0; 24)
|
FN_DEF@[0; 24)
|
||||||
UNSAFE_KW@[0; 6) "unsafe"
|
ASYNC_KW@[0; 5) "async"
|
||||||
WHITESPACE@[6; 7) " "
|
WHITESPACE@[5; 6) " "
|
||||||
ASYNC_KW@[7; 12) "async"
|
UNSAFE_KW@[6; 12) "unsafe"
|
||||||
WHITESPACE@[12; 13) " "
|
WHITESPACE@[12; 13) " "
|
||||||
FN_KW@[13; 15) "fn"
|
FN_KW@[13; 15) "fn"
|
||||||
WHITESPACE@[15; 16) " "
|
WHITESPACE@[15; 16) " "
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue