Parse async fn header.
This is gated on edition 2018 & the `async_await` feature gate. The parser will accept `async fn` and `async unsafe fn` as fn items. Along the same lines as `const fn`, only `async unsafe fn` is permitted, not `unsafe async fn`.The parser will not accept `async` functions as trait methods. To do a little code clean up, four fields of the function type struct have been merged into the new `FnHeader` struct: constness, asyncness, unsafety, and ABI. Also, a small bug in HIR printing is fixed: it previously printed `const unsafe fn` as `unsafe const fn`, which is grammatically incorrect.
This commit is contained in:
committed by
Taylor Cramer
parent
4b17d31f11
commit
18ff7d091a
@@ -881,11 +881,11 @@ pub fn noop_fold_item_kind<T: Folder>(i: ItemKind, folder: &mut T) -> ItemKind {
|
||||
ItemKind::Const(t, e) => {
|
||||
ItemKind::Const(folder.fold_ty(t), folder.fold_expr(e))
|
||||
}
|
||||
ItemKind::Fn(decl, unsafety, constness, abi, generics, body) => {
|
||||
ItemKind::Fn(decl, header, generics, body) => {
|
||||
let generics = folder.fold_generics(generics);
|
||||
let decl = folder.fold_fn_decl(decl);
|
||||
let body = folder.fold_block(body);
|
||||
ItemKind::Fn(decl, unsafety, constness, abi, generics, body)
|
||||
ItemKind::Fn(decl, header, generics, body)
|
||||
}
|
||||
ItemKind::Mod(m) => ItemKind::Mod(folder.fold_mod(m)),
|
||||
ItemKind::ForeignMod(nm) => ItemKind::ForeignMod(folder.fold_foreign_mod(nm)),
|
||||
@@ -1082,9 +1082,7 @@ pub fn noop_fold_foreign_item_simple<T: Folder>(ni: ForeignItem, folder: &mut T)
|
||||
|
||||
pub fn noop_fold_method_sig<T: Folder>(sig: MethodSig, folder: &mut T) -> MethodSig {
|
||||
MethodSig {
|
||||
abi: sig.abi,
|
||||
unsafety: sig.unsafety,
|
||||
constness: sig.constness,
|
||||
header: sig.header,
|
||||
decl: folder.fold_fn_decl(sig.decl)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user