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:
@@ -91,13 +91,6 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Resul
|
||||
// modifiers
|
||||
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
|
||||
// fn foo() { let _ = async {} }
|
||||
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;
|
||||
}
|
||||
|
||||
// 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]) {
|
||||
has_mods = true;
|
||||
abi(p);
|
||||
@@ -157,11 +157,11 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Resul
|
||||
// unsafe fn foo() {}
|
||||
|
||||
// test combined_fns
|
||||
// unsafe async fn foo() {}
|
||||
// async unsafe fn foo() {}
|
||||
// const unsafe fn bar() {}
|
||||
|
||||
// test_err wrong_order_fns
|
||||
// async unsafe fn foo() {}
|
||||
// unsafe async fn foo() {}
|
||||
// unsafe const fn bar() {}
|
||||
T![fn] => {
|
||||
fn_def(p);
|
||||
|
||||
Reference in New Issue
Block a user