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
This commit is contained in:
Emil Lauridsen
2020-02-07 13:51:51 +01:00
parent 5aba5a756a
commit 73ec2ab184
5 changed files with 20 additions and 20 deletions

View File

@@ -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, flavor);