mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 09:14:20 +00:00
Parse unsafe async fn
instead of async unsafe fn
This commit is contained in:
parent
cf844b547d
commit
09f6caabe5
@ -6744,13 +6744,19 @@ impl<'a> Parser<'a> {
|
||||
maybe_append(attrs, extra_attrs));
|
||||
return Ok(Some(item));
|
||||
}
|
||||
if self.check_keyword(keywords::Async) &&
|
||||
(self.look_ahead(1, |t| t.is_keyword(keywords::Fn)) ||
|
||||
self.look_ahead(1, |t| t.is_keyword(keywords::Unsafe)))
|
||||
|
||||
// `unsafe async fn` or `async fn`
|
||||
if (
|
||||
self.check_keyword(keywords::Unsafe) &&
|
||||
self.look_ahead(1, |t| t.is_keyword(keywords::Async))
|
||||
) || (
|
||||
self.check_keyword(keywords::Async) &&
|
||||
self.look_ahead(1, |t| t.is_keyword(keywords::Fn))
|
||||
)
|
||||
{
|
||||
// ASYNC FUNCTION ITEM
|
||||
self.expect_keyword(keywords::Async)?;
|
||||
let unsafety = self.parse_unsafety();
|
||||
self.expect_keyword(keywords::Async)?;
|
||||
self.expect_keyword(keywords::Fn)?;
|
||||
let fn_span = self.prev_span;
|
||||
let (ident, item_, extra_attrs) =
|
||||
|
@ -99,6 +99,19 @@ fn async_fn_with_internal_borrow(y: u8) -> impl Future<Output = u8> {
|
||||
}
|
||||
}
|
||||
|
||||
unsafe async fn unsafe_async_fn(x: u8) -> u8 {
|
||||
await!(wake_and_yield_once());
|
||||
x
|
||||
}
|
||||
|
||||
struct Foo {
|
||||
async fn async_method(x: u8) -> u8 {
|
||||
unsafe {
|
||||
await!(unsafe_async_fn())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn test_future_yields_once_then_returns<F, Fut>(f: F)
|
||||
where
|
||||
F: FnOnce(u8) -> Fut,
|
||||
|
Loading…
Reference in New Issue
Block a user