Skip to content

Commit 8fd2d12

Browse files
committed
typeck/expr.rs: extract out check_expr_yield.
1 parent 8da059b commit 8fd2d12

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/librustc_typeck/check/expr.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -144,16 +144,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
144144
self.check_expr_index(base, idx, needs, expr)
145145
}
146146
ExprKind::Yield(ref value) => {
147-
match self.yield_ty {
148-
Some(ty) => {
149-
self.check_expr_coercable_to_type(&value, ty);
150-
}
151-
None => {
152-
struct_span_err!(self.tcx.sess, expr.span, E0627,
153-
"yield statement outside of generator literal").emit();
154-
}
155-
}
156-
tcx.mk_unit()
147+
self.check_expr_yield(value, expr)
157148
}
158149
hir::ExprKind::Err => {
159150
tcx.types.err
@@ -914,4 +905,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
914905
}
915906
}
916907
}
908+
909+
fn check_expr_yield(&self, value: &'tcx hir::Expr, expr: &'tcx hir::Expr) -> Ty<'tcx> {
910+
match self.yield_ty {
911+
Some(ty) => {
912+
self.check_expr_coercable_to_type(&value, ty);
913+
}
914+
None => {
915+
struct_span_err!(self.tcx.sess, expr.span, E0627,
916+
"yield statement outside of generator literal").emit();
917+
}
918+
}
919+
self.tcx.mk_unit()
920+
}
917921
}

0 commit comments

Comments
 (0)