Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update async unsafe fn ordering in parser #3047

Merged
merged 1 commit into from
Feb 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions crates/ra_parser/src/grammar/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,20 @@ 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![|] {
p.eat(T![async]);
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);
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
async unsafe fn foo() {}
unsafe async fn foo() {}
unsafe const fn bar() {}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
SOURCE_FILE@[0; 50)
ERROR@[0; 5)
ASYNC_KW@[0; 5) "async"
WHITESPACE@[5; 6) " "
FN_DEF@[6; 24)
UNSAFE_KW@[6; 12) "unsafe"
ERROR@[0; 6)
UNSAFE_KW@[0; 6) "unsafe"
WHITESPACE@[6; 7) " "
FN_DEF@[7; 24)
ASYNC_KW@[7; 12) "async"
WHITESPACE@[12; 13) " "
FN_KW@[13; 15) "fn"
WHITESPACE@[15; 16) " "
Expand Down Expand Up @@ -37,5 +37,5 @@ SOURCE_FILE@[0; 50)
L_CURLY@[47; 48) "{"
R_CURLY@[48; 49) "}"
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
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
unsafe async fn foo() {}
async unsafe fn foo() {}
const unsafe fn bar() {}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
SOURCE_FILE@[0; 50)
FN_DEF@[0; 24)
UNSAFE_KW@[0; 6) "unsafe"
WHITESPACE@[6; 7) " "
ASYNC_KW@[7; 12) "async"
ASYNC_KW@[0; 5) "async"
WHITESPACE@[5; 6) " "
UNSAFE_KW@[6; 12) "unsafe"
WHITESPACE@[12; 13) " "
FN_KW@[13; 15) "fn"
WHITESPACE@[15; 16) " "
Expand Down