File tree Expand file tree Collapse file tree 3 files changed +12
-7
lines changed Expand file tree Collapse file tree 3 files changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ pub(crate) fn rewrite_closure(
2929 binder : & ast:: ClosureBinder ,
3030 constness : ast:: Const ,
3131 capture : ast:: CaptureBy ,
32- coro_kind : & ast:: CoroutineKind ,
32+ coro_kind : & Option < ast:: CoroutineKind > ,
3333 movability : ast:: Movability ,
3434 fn_decl : & ast:: FnDecl ,
3535 body : & ast:: Expr ,
@@ -233,7 +233,7 @@ fn rewrite_closure_fn_decl(
233233 binder : & ast:: ClosureBinder ,
234234 constness : ast:: Const ,
235235 capture : ast:: CaptureBy ,
236- coro_kind : & ast:: CoroutineKind ,
236+ coro_kind : & Option < ast:: CoroutineKind > ,
237237 movability : ast:: Movability ,
238238 fn_decl : & ast:: FnDecl ,
239239 body : & ast:: Expr ,
@@ -263,8 +263,13 @@ fn rewrite_closure_fn_decl(
263263 } else {
264264 ""
265265 } ;
266- let is_async = if coro_kind. is_async ( ) { "async " } else { "" } ;
267- let is_gen = if coro_kind. is_gen ( ) { "gen " } else { "" } ;
266+ let ( is_async, is_gen) = if let Some ( coro_kind) = coro_kind {
267+ let is_async = if coro_kind. is_async ( ) { "async " } else { "" } ;
268+ let is_gen = if coro_kind. is_gen ( ) { "gen " } else { "" } ;
269+ ( is_async, is_gen)
270+ } else {
271+ ( "" , "" )
272+ } ;
268273 let mover = if matches ! ( capture, ast:: CaptureBy :: Value { .. } ) {
269274 "move "
270275 } else {
Original file line number Diff line number Diff line change @@ -287,7 +287,7 @@ pub(crate) struct FnSig<'a> {
287287 decl : & ' a ast:: FnDecl ,
288288 generics : & ' a ast:: Generics ,
289289 ext : ast:: Extern ,
290- coro_kind : Cow < ' a , ast:: CoroutineKind > ,
290+ coro_kind : Cow < ' a , Option < ast:: CoroutineKind > > ,
291291 constness : ast:: Const ,
292292 defaultness : ast:: Defaultness ,
293293 unsafety : ast:: Unsafe ,
@@ -343,7 +343,8 @@ impl<'a> FnSig<'a> {
343343 result. push_str ( & * format_visibility ( context, self . visibility ) ) ;
344344 result. push_str ( format_defaultness ( self . defaultness ) ) ;
345345 result. push_str ( format_constness ( self . constness ) ) ;
346- result. push_str ( format_coro ( & self . coro_kind ) ) ;
346+ self . coro_kind
347+ . map ( |coro_kind| result. push_str ( format_coro ( & coro_kind) ) ) ;
347348 result. push_str ( format_unsafety ( self . unsafety ) ) ;
348349 result. push_str ( & format_extern (
349350 self . ext ,
Original file line number Diff line number Diff line change @@ -79,7 +79,6 @@ pub(crate) fn format_coro(coro_kind: &ast::CoroutineKind) -> &'static str {
7979 match coro_kind {
8080 ast:: CoroutineKind :: Async { .. } => "async " ,
8181 ast:: CoroutineKind :: Gen { .. } => "gen " ,
82- ast:: CoroutineKind :: None => "" ,
8382 }
8483}
8584
You can’t perform that action at this time.
0 commit comments