File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -139,7 +139,8 @@ fn mir_build(tcx: TyCtxt<'_>, def_id: DefId) -> BodyAndCache<'_> {
139
139
let arguments = implicit_argument. into_iter ( ) . chain ( explicit_arguments) ;
140
140
141
141
let ( yield_ty, return_ty) = if body. generator_kind . is_some ( ) {
142
- let gen_sig = match ty. kind {
142
+ let gen_ty = tcx. body_tables ( body_id) . node_type ( id) ;
143
+ let gen_sig = match gen_ty. kind {
143
144
ty:: Generator ( _, gen_substs, ..) => gen_substs. as_generator ( ) . sig ( ) ,
144
145
_ => span_bug ! ( tcx. hir( ) . span( id) , "generator w/o generator type: {:?}" , ty) ,
145
146
} ;
Original file line number Diff line number Diff line change @@ -188,12 +188,12 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
188
188
Node :: Field ( field) => icx. to_ty ( & field. ty ) ,
189
189
190
190
Node :: Expr ( & Expr { kind : ExprKind :: Closure ( .., gen) , .. } ) => {
191
- if gen. is_some ( ) {
192
- return tcx. typeck_tables_of ( def_id) . node_type ( hir_id) ;
193
- }
194
-
195
191
let substs = InternalSubsts :: identity_for_item ( tcx, def_id) ;
196
- tcx. mk_closure ( def_id, substs)
192
+ if let Some ( movability) = gen {
193
+ tcx. mk_generator ( def_id, substs, movability)
194
+ } else {
195
+ tcx. mk_closure ( def_id, substs)
196
+ }
197
197
}
198
198
199
199
Node :: AnonConst ( _) => {
You can’t perform that action at this time.
0 commit comments