diff --git a/src/librustc/cfg/construct.rs b/src/librustc/cfg/construct.rs index 36aeaba0c5ec..fb205655df29 100644 --- a/src/librustc/cfg/construct.rs +++ b/src/librustc/cfg/construct.rs @@ -389,7 +389,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { hir::ExprUnary(_, ref e) | hir::ExprField(ref e, _) | hir::ExprTupField(ref e, _) | - hir::ExprSuspend(ref e) | + hir::ExprYield(ref e) | hir::ExprRepeat(ref e, _) => { self.straightline(expr, pred, Some(&**e).into_iter()) } diff --git a/src/librustc/hir/intravisit.rs b/src/librustc/hir/intravisit.rs index 47a0f67a6407..9e4117033724 100644 --- a/src/librustc/hir/intravisit.rs +++ b/src/librustc/hir/intravisit.rs @@ -1045,7 +1045,7 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) { visitor.visit_expr(input) } } - ExprSuspend(ref subexpression) => { + ExprYield(ref subexpression) => { visitor.visit_expr(subexpression); } ExprImplArg(id) => { diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index 50c8763600fa..3aa7149933cb 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -2108,7 +2108,7 @@ impl<'a> LoweringContext<'a> { let expr = opt_expr.as_ref().map(|x| self.lower_expr(x)).unwrap_or_else(|| { self.expr(e.span, hir::ExprTup(hir_vec![]), ThinVec::new()) }); - hir::ExprSuspend(P(expr)) + hir::ExprYield(P(expr)) } ExprKind::ImplArg => { diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index 28d5cf2472d7..40a745bcebfb 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -1069,8 +1069,8 @@ pub enum Expr_ { /// to be repeated; the second is the number of times to repeat it. ExprRepeat(P, BodyId), - /// A suspension point for generators - ExprSuspend(P), + /// A suspension point for generators. This is `yield ` in Rust. + ExprYield(P), /// The argument to a generator ExprImplArg(NodeId), diff --git a/src/librustc/hir/print.rs b/src/librustc/hir/print.rs index b076fb7ff812..d51371914628 100644 --- a/src/librustc/hir/print.rs +++ b/src/librustc/hir/print.rs @@ -1461,8 +1461,8 @@ impl<'a> State<'a> { self.pclose()?; } - hir::ExprSuspend(ref expr) => { - word(&mut self.s, "suspend ")?; + hir::ExprYield(ref expr) => { + word(&mut self.s, "yield ")?; self.print_expr(&expr)?; } hir::ExprImplArg(_) => { diff --git a/src/librustc/ich/impls_hir.rs b/src/librustc/ich/impls_hir.rs index d2cc186bad43..39fa0cb44d09 100644 --- a/src/librustc/ich/impls_hir.rs +++ b/src/librustc/ich/impls_hir.rs @@ -573,7 +573,7 @@ impl<'a, 'gcx, 'tcx> HashStable> for hir::E hir::ExprBreak(..) | hir::ExprAgain(..) | hir::ExprRet(..) | - hir::ExprSuspend(..) | + hir::ExprYield(..) | hir::ExprImplArg(..) | hir::ExprInlineAsm(..) | hir::ExprRepeat(..) | @@ -654,7 +654,7 @@ impl_stable_hash_for!(enum hir::Expr_ { ExprInlineAsm(asm, inputs, outputs), ExprStruct(path, fields, base), ExprRepeat(val, times), - ExprSuspend(val), + ExprYield(val), ExprImplArg(id) }); diff --git a/src/librustc/ich/impls_mir.rs b/src/librustc/ich/impls_mir.rs index d273c6c9c42f..63100f4c11a2 100644 --- a/src/librustc/ich/impls_mir.rs +++ b/src/librustc/ich/impls_mir.rs @@ -58,7 +58,7 @@ for mir::Terminator<'tcx> { mir::TerminatorKind::Unreachable | mir::TerminatorKind::Drop { .. } | mir::TerminatorKind::DropAndReplace { .. } | - mir::TerminatorKind::Suspend { .. } | + mir::TerminatorKind::Yield { .. } | mir::TerminatorKind::Call { .. } => false, }; @@ -164,7 +164,7 @@ for mir::TerminatorKind<'tcx> { target.hash_stable(hcx, hasher); unwind.hash_stable(hcx, hasher); } - mir::TerminatorKind::Suspend { ref value, + mir::TerminatorKind::Yield { ref value, resume, drop } => { value.hash_stable(hcx, hasher); diff --git a/src/librustc/ich/impls_ty.rs b/src/librustc/ich/impls_ty.rs index 22f202a35ecf..29f201f84c99 100644 --- a/src/librustc/ich/impls_ty.rs +++ b/src/librustc/ich/impls_ty.rs @@ -144,7 +144,7 @@ for ty::UpvarCapture<'tcx> { impl_stable_hash_for!(struct ty::GenSig<'tcx> { impl_arg_ty, - suspend_ty, + yield_ty, return_ty }); diff --git a/src/librustc/middle/expr_use_visitor.rs b/src/librustc/middle/expr_use_visitor.rs index 945b612027b9..1154c82cd2ed 100644 --- a/src/librustc/middle/expr_use_visitor.rs +++ b/src/librustc/middle/expr_use_visitor.rs @@ -525,7 +525,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> { self.consume_expr(&base); } - hir::ExprSuspend(ref value) => { + hir::ExprYield(ref value) => { self.consume_expr(&value); } diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index 1487ae5908e5..98e742c694e9 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -470,7 +470,7 @@ fn visit_expr<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, expr: &'tcx Expr) { hir::ExprAgain(_) | hir::ExprLit(_) | hir::ExprRet(..) | hir::ExprBlock(..) | hir::ExprAssign(..) | hir::ExprAssignOp(..) | hir::ExprStruct(..) | hir::ExprRepeat(..) | - hir::ExprInlineAsm(..) | hir::ExprBox(..) | hir::ExprSuspend(..) | + hir::ExprInlineAsm(..) | hir::ExprBox(..) | hir::ExprYield(..) | hir::ExprType(..) | hir::ExprPath(hir::QPath::TypeRelative(..)) => { intravisit::walk_expr(ir, expr); } @@ -1129,7 +1129,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { hir::ExprCast(ref e, _) | hir::ExprType(ref e, _) | hir::ExprUnary(_, ref e) | - hir::ExprSuspend(ref e) | + hir::ExprYield(ref e) | hir::ExprRepeat(ref e, _) => { self.propagate_through_expr(&e, succ) } @@ -1420,7 +1420,7 @@ fn check_expr<'a, 'tcx>(this: &mut Liveness<'a, 'tcx>, expr: &'tcx Expr) { hir::ExprBreak(..) | hir::ExprAgain(..) | hir::ExprLit(_) | hir::ExprBlock(..) | hir::ExprAddrOf(..) | hir::ExprStruct(..) | hir::ExprRepeat(..) | hir::ExprImplArg(_) | - hir::ExprClosure(..) | hir::ExprPath(_) | hir::ExprSuspend(..) | + hir::ExprClosure(..) | hir::ExprPath(_) | hir::ExprYield(..) | hir::ExprBox(..) | hir::ExprType(..) => { intravisit::walk_expr(this, expr); } diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index bf5263e75da2..92883ca1b11a 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -620,7 +620,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> { hir::ExprAddrOf(..) | hir::ExprCall(..) | hir::ExprAssign(..) | hir::ExprAssignOp(..) | hir::ExprClosure(..) | hir::ExprRet(..) | - hir::ExprUnary(..) | hir::ExprSuspend(..) | + hir::ExprUnary(..) | hir::ExprYield(..) | hir::ExprMethodCall(..) | hir::ExprCast(..) | hir::ExprArray(..) | hir::ExprTup(..) | hir::ExprIf(..) | hir::ExprBinary(..) | hir::ExprWhile(..) | diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index 2d0269e5845f..b8b8476d54b4 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -1158,7 +1158,7 @@ impl<'tcx> Visitor<'tcx> for YieldFinder { } fn visit_expr(&mut self, expr: &'tcx hir::Expr) { - if let hir::ExprSuspend(..) = expr.node { + if let hir::ExprYield(..) = expr.node { self.0 = true; } diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index 9bfd7f175c27..2c500aa9c6fe 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -104,8 +104,8 @@ pub struct Mir<'tcx> { /// Return type of the function. pub return_ty: Ty<'tcx>, - /// Suspend type of the function, if it is a generator. - pub suspend_ty: Option>, + /// Yield type of the function, if it is a generator. + pub yield_ty: Option>, /// Generator drop glue pub generator_drop: Option>>, @@ -153,7 +153,7 @@ impl<'tcx> Mir<'tcx> { visibility_scopes: IndexVec, promoted: IndexVec>, return_ty: Ty<'tcx>, - suspend_ty: Option>, + yield_ty: Option>, local_decls: IndexVec>, arg_count: usize, upvar_decls: Vec, @@ -169,7 +169,7 @@ impl<'tcx> Mir<'tcx> { visibility_scopes, promoted, return_ty, - suspend_ty, + yield_ty, generator_drop: None, generator_layout: None, local_decls, @@ -287,7 +287,7 @@ impl_stable_hash_for!(struct Mir<'tcx> { visibility_scopes, promoted, return_ty, - suspend_ty, + yield_ty, generator_drop, generator_layout, local_decls, @@ -590,7 +590,7 @@ pub enum TerminatorKind<'tcx> { }, /// A suspend point - Suspend { + Yield { /// The value to return value: Operand<'tcx>, /// Where to resume to @@ -638,8 +638,8 @@ impl<'tcx> TerminatorKind<'tcx> { slice::ref_slice(t).into_cow(), Call { destination: None, cleanup: Some(ref c), .. } => slice::ref_slice(c).into_cow(), Call { destination: None, cleanup: None, .. } => (&[]).into_cow(), - Suspend { resume: t, drop: Some(c), .. } => vec![t, c].into_cow(), - Suspend { resume: ref t, drop: None, .. } => slice::ref_slice(t).into_cow(), + Yield { resume: t, drop: Some(c), .. } => vec![t, c].into_cow(), + Yield { resume: ref t, drop: None, .. } => slice::ref_slice(t).into_cow(), DropAndReplace { target, unwind: Some(unwind), .. } | Drop { target, unwind: Some(unwind), .. } => { vec![target, unwind].into_cow() @@ -667,8 +667,8 @@ impl<'tcx> TerminatorKind<'tcx> { Call { destination: Some((_, ref mut t)), cleanup: None, .. } => vec![t], Call { destination: None, cleanup: Some(ref mut c), .. } => vec![c], Call { destination: None, cleanup: None, .. } => vec![], - Suspend { resume: ref mut t, drop: Some(ref mut c), .. } => vec![t, c], - Suspend { resume: ref mut t, drop: None, .. } => vec![t], + Yield { resume: ref mut t, drop: Some(ref mut c), .. } => vec![t, c], + Yield { resume: ref mut t, drop: None, .. } => vec![t], DropAndReplace { ref mut target, unwind: Some(ref mut unwind), .. } | Drop { ref mut target, unwind: Some(ref mut unwind), .. } => vec![target, unwind], DropAndReplace { ref mut target, unwind: None, .. } | @@ -750,7 +750,7 @@ impl<'tcx> TerminatorKind<'tcx> { Return => write!(fmt, "return"), GeneratorDrop => write!(fmt, "generator_drop"), Resume => write!(fmt, "resume"), - Suspend { ref value, .. } => write!(fmt, "_1 = suspend({:?})", value), + Yield { ref value, .. } => write!(fmt, "_1 = suspend({:?})", value), Unreachable => write!(fmt, "unreachable"), Drop { ref location, .. } => write!(fmt, "drop({:?})", location), DropAndReplace { ref location, ref value, .. } => @@ -818,9 +818,9 @@ impl<'tcx> TerminatorKind<'tcx> { Call { destination: Some(_), cleanup: None, .. } => vec!["return".into_cow()], Call { destination: None, cleanup: Some(_), .. } => vec!["unwind".into_cow()], Call { destination: None, cleanup: None, .. } => vec![], - Suspend { drop: Some(_), .. } => + Yield { drop: Some(_), .. } => vec!["resume".into_cow(), "drop".into_cow()], - Suspend { drop: None, .. } => vec!["resume".into_cow()], + Yield { drop: None, .. } => vec!["resume".into_cow()], DropAndReplace { unwind: None, .. } | Drop { unwind: None, .. } => vec!["return".into_cow()], DropAndReplace { unwind: Some(_), .. } | @@ -1526,7 +1526,7 @@ impl<'tcx> TypeFoldable<'tcx> for Mir<'tcx> { visibility_scopes: self.visibility_scopes.clone(), promoted: self.promoted.fold_with(folder), return_ty: self.return_ty.fold_with(folder), - suspend_ty: self.suspend_ty.fold_with(folder), + yield_ty: self.yield_ty.fold_with(folder), generator_drop: self.generator_drop.fold_with(folder), generator_layout: self.generator_layout.fold_with(folder), local_decls: self.local_decls.fold_with(folder), @@ -1542,7 +1542,7 @@ impl<'tcx> TypeFoldable<'tcx> for Mir<'tcx> { self.basic_blocks.visit_with(visitor) || self.generator_drop.visit_with(visitor) || self.generator_layout.visit_with(visitor) || - self.suspend_ty.visit_with(visitor) || + self.yield_ty.visit_with(visitor) || self.promoted.visit_with(visitor) || self.return_ty.visit_with(visitor) || self.local_decls.visit_with(visitor) @@ -1665,7 +1665,7 @@ impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> { target, unwind, }, - Suspend { ref value, resume, drop } => Suspend { + Yield { ref value, resume, drop } => Yield { value: value.fold_with(folder), resume: resume, drop: drop, @@ -1719,7 +1719,7 @@ impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> { Drop { ref location, ..} => location.visit_with(visitor), DropAndReplace { ref location, ref value, ..} => location.visit_with(visitor) || value.visit_with(visitor), - Suspend { ref value, ..} => + Yield { ref value, ..} => value.visit_with(visitor), Call { ref func, ref args, ref destination, .. } => { let dest = if let Some((ref loc, _)) = *destination { diff --git a/src/librustc/mir/visit.rs b/src/librustc/mir/visit.rs index bd162c090f75..325c87fded61 100644 --- a/src/librustc/mir/visit.rs +++ b/src/librustc/mir/visit.rs @@ -448,7 +448,7 @@ macro_rules! make_mir_visitor { cleanup.map(|t| self.visit_branch(block, t)); } - TerminatorKind::Suspend { ref $($mutability)* value, + TerminatorKind::Yield { ref $($mutability)* value, resume, drop } => { self.visit_operand(value, source_location); diff --git a/src/librustc/traits/project.rs b/src/librustc/traits/project.rs index 35b8b9358155..91d6fac26f1b 100644 --- a/src/librustc/traits/project.rs +++ b/src/librustc/traits/project.rs @@ -1156,7 +1156,7 @@ fn confirm_generator_candidate<'cx, 'gcx, 'tcx>( let gen_def_id = tcx.lang_items.gen_trait().unwrap(); // Note: we unwrap the binder here but re-create it below (1) - let ty::Binder((trait_ref, suspend_ty, return_ty)) = + let ty::Binder((trait_ref, yield_ty, return_ty)) = tcx.generator_trait_ref_and_outputs(gen_def_id, obligation.predicate.trait_ref.self_ty(), gen_sig); @@ -1165,7 +1165,7 @@ fn confirm_generator_candidate<'cx, 'gcx, 'tcx>( let ty = if name == Symbol::intern("Return") { return_ty } else if name == Symbol::intern("Yield") { - suspend_ty + yield_ty } else { bug!() }; diff --git a/src/librustc/traits/util.rs b/src/librustc/traits/util.rs index dd3c0d66a9cc..f0b812ff9687 100644 --- a/src/librustc/traits/util.rs +++ b/src/librustc/traits/util.rs @@ -523,7 +523,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { def_id: fn_trait_def_id, substs: self.mk_substs_trait(self_ty, &[sig.skip_binder().impl_arg_ty]), }; - ty::Binder((trait_ref, sig.skip_binder().suspend_ty, sig.skip_binder().return_ty)) + ty::Binder((trait_ref, sig.skip_binder().yield_ty, sig.skip_binder().return_ty)) } pub fn impl_is_default(self, node_item_def_id: DefId) -> bool { diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index cfcb0c062ad2..21a98bceedff 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -2030,7 +2030,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { hir::ExprBox(..) | hir::ExprAddrOf(..) | hir::ExprBinary(..) | - hir::ExprSuspend(..) | + hir::ExprYield(..) | hir::ExprCast(..) => { false } diff --git a/src/librustc/ty/structural_impls.rs b/src/librustc/ty/structural_impls.rs index 255528896207..c70831cd551c 100644 --- a/src/librustc/ty/structural_impls.rs +++ b/src/librustc/ty/structural_impls.rs @@ -304,11 +304,11 @@ impl<'a, 'tcx> Lift<'tcx> for ty::adjustment::AutoBorrow<'a> { impl<'a, 'tcx> Lift<'tcx> for ty::GenSig<'a> { type Lifted = ty::GenSig<'tcx>; fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option { - tcx.lift(&(self.impl_arg_ty, self.suspend_ty, self.return_ty)) - .map(|(impl_arg_ty, suspend_ty, return_ty)| { + tcx.lift(&(self.impl_arg_ty, self.yield_ty, self.return_ty)) + .map(|(impl_arg_ty, yield_ty, return_ty)| { ty::GenSig { impl_arg_ty, - suspend_ty, + yield_ty, return_ty, } }) @@ -638,14 +638,14 @@ impl<'tcx> TypeFoldable<'tcx> for ty::GenSig<'tcx> { fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { ty::GenSig { impl_arg_ty: self.impl_arg_ty.fold_with(folder), - suspend_ty: self.suspend_ty.fold_with(folder), + yield_ty: self.yield_ty.fold_with(folder), return_ty: self.return_ty.fold_with(folder), } } fn super_visit_with>(&self, visitor: &mut V) -> bool { self.impl_arg_ty.visit_with(visitor) || - self.suspend_ty.visit_with(visitor) || + self.yield_ty.visit_with(visitor) || self.return_ty.visit_with(visitor) } } diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index 7d703ebc8541..bd5f6a8e2625 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -643,7 +643,7 @@ impl<'a, 'tcx> ProjectionTy<'tcx> { #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)] pub struct GenSig<'tcx> { pub impl_arg_ty: Ty<'tcx>, - pub suspend_ty: Ty<'tcx>, + pub yield_ty: Ty<'tcx>, pub return_ty: Ty<'tcx>, } @@ -652,8 +652,8 @@ pub type PolyGenSig<'tcx> = Binder>; #[allow(warnings)] impl<'tcx> PolyGenSig<'tcx> { - pub fn suspend_ty(&self) -> ty::Binder> { - self.map_bound_ref(|sig| sig.suspend_ty) + pub fn yield_ty(&self) -> ty::Binder> { + self.map_bound_ref(|sig| sig.yield_ty) } pub fn return_ty(&self) -> ty::Binder> { self.map_bound_ref(|sig| sig.return_ty) diff --git a/src/librustc_mir/build/expr/as_lvalue.rs b/src/librustc_mir/build/expr/as_lvalue.rs index 78175e053510..659a5e60364b 100644 --- a/src/librustc_mir/build/expr/as_lvalue.rs +++ b/src/librustc_mir/build/expr/as_lvalue.rs @@ -121,7 +121,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { ExprKind::Return { .. } | ExprKind::Literal { .. } | ExprKind::InlineAsm { .. } | - ExprKind::Suspend { .. } | + ExprKind::Yield { .. } | ExprKind::Call { .. } => { // these are not lvalues, so we need to make a temporary. debug_assert!(match Category::of(&expr.kind) { diff --git a/src/librustc_mir/build/expr/as_rvalue.rs b/src/librustc_mir/build/expr/as_rvalue.rs index 6af7bd056b4a..024b1a3483ac 100644 --- a/src/librustc_mir/build/expr/as_rvalue.rs +++ b/src/librustc_mir/build/expr/as_rvalue.rs @@ -239,7 +239,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { block = unpack!(this.stmt_expr(block, expr)); block.and(this.unit_rvalue()) } - ExprKind::Suspend { value } => { + ExprKind::Yield { value } => { let value = unpack!(block = this.as_operand(block, scope, value)); let impl_arg_ty = this.impl_arg_ty.unwrap(); block = unpack!(this.build_drop(block, @@ -248,7 +248,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { impl_arg_ty)); let resume = this.cfg.start_new_block(); let cleanup = this.generator_drop_cleanup(expr_span); - this.cfg.terminate(block, source_info, TerminatorKind::Suspend { + this.cfg.terminate(block, source_info, TerminatorKind::Yield { value: value, resume: resume, drop: cleanup, diff --git a/src/librustc_mir/build/expr/category.rs b/src/librustc_mir/build/expr/category.rs index 0208dbf70349..7f576666dcdc 100644 --- a/src/librustc_mir/build/expr/category.rs +++ b/src/librustc_mir/build/expr/category.rs @@ -78,7 +78,7 @@ impl Category { ExprKind::Borrow { .. } | ExprKind::Assign { .. } | ExprKind::AssignOp { .. } | - ExprKind::Suspend { .. } | + ExprKind::Yield { .. } | ExprKind::InlineAsm { .. } => Some(Category::Rvalue(RvalueFunc::AsRvalue)), diff --git a/src/librustc_mir/build/expr/into.rs b/src/librustc_mir/build/expr/into.rs index ee5b04d03be3..ef7533e8d49e 100644 --- a/src/librustc_mir/build/expr/into.rs +++ b/src/librustc_mir/build/expr/into.rs @@ -284,7 +284,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { ExprKind::Index { .. } | ExprKind::Deref { .. } | ExprKind::Literal { .. } | - ExprKind::Suspend { .. } | + ExprKind::Yield { .. } | ExprKind::ImplArg | ExprKind::Field { .. } => { debug_assert!(match Category::of(&expr.kind).unwrap() { diff --git a/src/librustc_mir/build/mod.rs b/src/librustc_mir/build/mod.rs index c0bf46dd0fa7..9a8c43e32863 100644 --- a/src/librustc_mir/build/mod.rs +++ b/src/librustc_mir/build/mod.rs @@ -119,14 +119,14 @@ pub fn mir_build<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Mir<'t let arguments = implicit_argument.into_iter().chain(explicit_arguments); - let (suspend_ty, impl_arg_ty, return_ty) = if body.is_generator() { + let (yield_ty, impl_arg_ty, return_ty) = if body.is_generator() { let gen_sig = cx.tables().generator_sigs[&id].clone().unwrap(); - (Some(gen_sig.suspend_ty), Some(gen_sig.impl_arg_ty), gen_sig.return_ty) + (Some(gen_sig.yield_ty), Some(gen_sig.impl_arg_ty), gen_sig.return_ty) } else { (None, None, fn_sig.output()) }; - build::construct_fn(cx, id, arguments, abi, return_ty, suspend_ty, impl_arg_ty, body) + build::construct_fn(cx, id, arguments, abi, return_ty, yield_ty, impl_arg_ty, body) } else { build::construct_const(cx, body_id) }; @@ -342,7 +342,7 @@ fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>, arguments: A, abi: Abi, return_ty: Ty<'gcx>, - suspend_ty: Option>, + yield_ty: Option>, impl_arg_ty: Option>, body: &'gcx hir::Body) -> Mir<'tcx> @@ -411,7 +411,7 @@ fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>, }).collect() }); - let mut mir = builder.finish(upvar_decls, return_ty, suspend_ty); + let mut mir = builder.finish(upvar_decls, return_ty, yield_ty); mir.spread_arg = spread_arg; mir } @@ -487,7 +487,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { fn finish(self, upvar_decls: Vec, return_ty: Ty<'tcx>, - suspend_ty: Option>) + yield_ty: Option>) -> Mir<'tcx> { for (index, block) in self.cfg.basic_blocks.iter().enumerate() { if block.terminator.is_none() { @@ -499,7 +499,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { self.visibility_scopes, IndexVec::new(), return_ty, - suspend_ty, + yield_ty, self.local_decls, self.arg_count, upvar_decls, diff --git a/src/librustc_mir/dataflow/drop_flag_effects.rs b/src/librustc_mir/dataflow/drop_flag_effects.rs index 2f8e932a7382..0b740e5f0283 100644 --- a/src/librustc_mir/dataflow/drop_flag_effects.rs +++ b/src/librustc_mir/dataflow/drop_flag_effects.rs @@ -299,7 +299,7 @@ pub(crate) fn drop_flag_effects_for_location<'a, 'tcx, F>( move_data.rev_lookup.find(location), |moi| callback(moi, DropFlagState::Present)) } - mir::TerminatorKind::Suspend { .. } => { + mir::TerminatorKind::Yield { .. } => { on_lookup_result_bits(tcx, mir, move_data, move_data.rev_lookup.find(&Mir::impl_arg_lvalue()), |moi| callback(moi, DropFlagState::Present)) diff --git a/src/librustc_mir/dataflow/mod.rs b/src/librustc_mir/dataflow/mod.rs index 6eebe9da9f08..6392bde9eaeb 100644 --- a/src/librustc_mir/dataflow/mod.rs +++ b/src/librustc_mir/dataflow/mod.rs @@ -456,14 +456,14 @@ impl<'a, 'tcx: 'a, D> DataflowAnalysis<'a, 'tcx, D> mir::TerminatorKind::Unreachable => {} mir::TerminatorKind::Goto { ref target } | mir::TerminatorKind::Assert { ref target, cleanup: None, .. } | - mir::TerminatorKind::Suspend { resume: ref target, drop: None, .. } | + mir::TerminatorKind::Yield { resume: ref target, drop: None, .. } | mir::TerminatorKind::Drop { ref target, location: _, unwind: None } | mir::TerminatorKind::DropAndReplace { ref target, value: _, location: _, unwind: None } => { self.propagate_bits_into_entry_set_for(in_out, changed, target); } - mir::TerminatorKind::Suspend { resume: ref target, drop: Some(ref drop), .. } => { + mir::TerminatorKind::Yield { resume: ref target, drop: Some(ref drop), .. } => { self.propagate_bits_into_entry_set_for(in_out, changed, target); self.propagate_bits_into_entry_set_for(in_out, changed, drop); } diff --git a/src/librustc_mir/dataflow/move_paths/mod.rs b/src/librustc_mir/dataflow/move_paths/mod.rs index cc12ae6abfc1..dba396e81398 100644 --- a/src/librustc_mir/dataflow/move_paths/mod.rs +++ b/src/librustc_mir/dataflow/move_paths/mod.rs @@ -474,7 +474,7 @@ impl<'a, 'tcx> MoveDataBuilder<'a, 'tcx> { // branching terminators - these don't move anything } - TerminatorKind::Suspend { ref value, .. } => { + TerminatorKind::Yield { ref value, .. } => { self.create_move_path(&Mir::impl_arg_lvalue()); self.gather_operand(loc, value); } diff --git a/src/librustc_mir/hair/cx/expr.rs b/src/librustc_mir/hair/cx/expr.rs index ca634ffef544..4a223ce61f74 100644 --- a/src/librustc_mir/hair/cx/expr.rs +++ b/src/librustc_mir/hair/cx/expr.rs @@ -568,7 +568,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, hir::ExprTup(ref fields) => ExprKind::Tuple { fields: fields.to_ref() }, hir::ExprImplArg(_) => ExprKind::ImplArg, - hir::ExprSuspend(ref v) => ExprKind::Suspend { value: v.to_ref() }, + hir::ExprYield(ref v) => ExprKind::Yield { value: v.to_ref() }, }; Expr { diff --git a/src/librustc_mir/hair/mod.rs b/src/librustc_mir/hair/mod.rs index dece9a974f17..a2e9e5c40f94 100644 --- a/src/librustc_mir/hair/mod.rs +++ b/src/librustc_mir/hair/mod.rs @@ -250,7 +250,7 @@ pub enum ExprKind<'tcx> { inputs: Vec> }, ImplArg, - Suspend { + Yield { value: ExprRef<'tcx>, }, } diff --git a/src/librustc_mir/transform/elaborate_drops.rs b/src/librustc_mir/transform/elaborate_drops.rs index 387d769e01f6..472623ec20ab 100644 --- a/src/librustc_mir/transform/elaborate_drops.rs +++ b/src/librustc_mir/transform/elaborate_drops.rs @@ -100,7 +100,7 @@ fn find_dead_unwinds<'a, 'tcx>( let location = match bb_data.terminator().kind { TerminatorKind::Drop { ref location, unwind: Some(_), .. } | TerminatorKind::DropAndReplace { ref location, unwind: Some(_), .. } => location, - TerminatorKind::Suspend { .. } => &impl_arg, + TerminatorKind::Yield { .. } => &impl_arg, _ => continue, }; @@ -348,7 +348,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> { let location = match terminator.kind { TerminatorKind::Drop { ref location, .. } | TerminatorKind::DropAndReplace { ref location, .. } => location, - TerminatorKind::Suspend { .. } => &impl_arg, + TerminatorKind::Yield { .. } => &impl_arg, _ => continue }; diff --git a/src/librustc_mir/transform/generator.rs b/src/librustc_mir/transform/generator.rs index a2c1cf415974..fc5834d60533 100644 --- a/src/librustc_mir/transform/generator.rs +++ b/src/librustc_mir/transform/generator.rs @@ -159,7 +159,7 @@ impl<'a, 'tcx> MutVisitor<'tcx> for TransformVisitor<'a, 'tcx> { self.return_block, Operand::Consume(Lvalue::Local(self.new_ret_local)), None)), - TerminatorKind::Suspend { ref value, resume, drop } => Some((0, + TerminatorKind::Yield { ref value, resume, drop } => Some((0, resume, value.clone(), drop)), @@ -325,7 +325,7 @@ fn locals_live_across_suspend_points<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, liveness::dump_mir(tcx, "generator_liveness", source, mir, &result); for (block, data) in mir.basic_blocks().iter_enumerated() { - if let TerminatorKind::Suspend { .. } = data.terminator().kind { + if let TerminatorKind::Yield { .. } = data.terminator().kind { set.union(&result.outs[block]); } } @@ -742,8 +742,8 @@ impl MirPass for StateTransform { tcx: TyCtxt<'a, 'tcx, 'tcx>, source: MirSource, mir: &mut Mir<'tcx>) { - let suspend_ty = if let Some(suspend_ty) = mir.suspend_ty { - suspend_ty + let yield_ty = if let Some(yield_ty) = mir.yield_ty { + yield_ty } else { // This only applies to generators return @@ -758,7 +758,7 @@ impl MirPass for StateTransform { let state_did = tcx.lang_items.gen_state().unwrap(); let state_adt_ref = tcx.adt_def(state_did); - let state_substs = tcx.mk_substs([Kind::from(suspend_ty), + let state_substs = tcx.mk_substs([Kind::from(yield_ty), Kind::from(mir.return_ty)].iter()); let ret_ty = tcx.mk_adt(state_adt_ref, state_substs); @@ -787,7 +787,7 @@ impl MirPass for StateTransform { transform.visit_mir(mir); mir.return_ty = ret_ty; - mir.suspend_ty = None; + mir.yield_ty = None; mir.arg_count = 2; mir.spread_arg = None; mir.generator_layout = Some(layout); diff --git a/src/librustc_mir/transform/inline.rs b/src/librustc_mir/transform/inline.rs index 1353be0046de..e7ee68b104b4 100644 --- a/src/librustc_mir/transform/inline.rs +++ b/src/librustc_mir/transform/inline.rs @@ -176,7 +176,7 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> { } // Cannot inline generators which haven't been transformed yet - if callee_mir.suspend_ty.is_some() { + if callee_mir.yield_ty.is_some() { return false; } @@ -657,7 +657,7 @@ impl<'a, 'tcx> MutVisitor<'tcx> for Integrator<'a, 'tcx> { match *kind { TerminatorKind::GeneratorDrop | - TerminatorKind::Suspend { .. } => bug!(), + TerminatorKind::Yield { .. } => bug!(), TerminatorKind::Goto { ref mut target} => { *target = self.update_target(*target); } diff --git a/src/librustc_mir/transform/no_landing_pads.rs b/src/librustc_mir/transform/no_landing_pads.rs index d68d702696f5..fa6bb644871d 100644 --- a/src/librustc_mir/transform/no_landing_pads.rs +++ b/src/librustc_mir/transform/no_landing_pads.rs @@ -44,7 +44,7 @@ impl<'tcx> MutVisitor<'tcx> for NoLandingPads { TerminatorKind::Return | TerminatorKind::Unreachable | TerminatorKind::GeneratorDrop | - TerminatorKind::Suspend { .. } | + TerminatorKind::Yield { .. } | TerminatorKind::SwitchInt { .. } => { /* nothing to do */ }, diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index cb75dd9a5299..3ae0f8f2e82a 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -377,7 +377,7 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx, 'tcx> { TerminatorKind::DropAndReplace { .. } | TerminatorKind::Resume | TerminatorKind::GeneratorDrop | - TerminatorKind::Suspend { .. } | + TerminatorKind::Yield { .. } | TerminatorKind::Unreachable => None, TerminatorKind::Return => { diff --git a/src/librustc_mir/transform/type_check.rs b/src/librustc_mir/transform/type_check.rs index b196d8aca1f4..38b9454f8962 100644 --- a/src/librustc_mir/transform/type_check.rs +++ b/src/librustc_mir/transform/type_check.rs @@ -512,14 +512,14 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { } } } - TerminatorKind::Suspend { ref value, .. } => { + TerminatorKind::Yield { ref value, .. } => { let value_ty = value.ty(mir, tcx); - match mir.suspend_ty { - None => span_mirbug!(self, term, "suspend in non-generator"), + match mir.yield_ty { + None => span_mirbug!(self, term, "yield in non-generator"), Some(ty) if ty != value_ty => { span_mirbug!(self, term, - "type of suspend value is ({:?}, but the suspend type is ({:?}", + "type of yield value is ({:?}, but the yield type is ({:?}", value_ty, ty); } @@ -657,9 +657,9 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { span_mirbug!(self, block, "generator_drop in cleanup block") } } - TerminatorKind::Suspend { resume, drop, .. } => { + TerminatorKind::Yield { resume, drop, .. } => { if is_cleanup { - span_mirbug!(self, block, "suspend in cleanup block") + span_mirbug!(self, block, "yield in cleanup block") } self.assert_iscleanup(mir, block, resume, is_cleanup); if let Some(drop) = drop { diff --git a/src/librustc_passes/consts.rs b/src/librustc_passes/consts.rs index e3d665c4bcb1..b85218338065 100644 --- a/src/librustc_passes/consts.rs +++ b/src/librustc_passes/consts.rs @@ -436,7 +436,7 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>, e: &hir::Expr, node hir::ExprRet(_) | // Generator expressions - hir::ExprSuspend(_) | + hir::ExprYield(_) | hir::ExprImplArg(_) | // Expressions with side-effects. diff --git a/src/librustc_passes/mir_stats.rs b/src/librustc_passes/mir_stats.rs index cc7df7acb499..2e3c594e43c5 100644 --- a/src/librustc_passes/mir_stats.rs +++ b/src/librustc_passes/mir_stats.rs @@ -159,7 +159,7 @@ impl<'a, 'tcx> mir_visit::Visitor<'tcx> for StatCollector<'a, 'tcx> { TerminatorKind::Call { .. } => "TerminatorKind::Call", TerminatorKind::Assert { .. } => "TerminatorKind::Assert", TerminatorKind::GeneratorDrop => "TerminatorKind::GeneratorDrop", - TerminatorKind::Suspend { .. } => "TerminatorKind::Suspend", + TerminatorKind::Yield { .. } => "TerminatorKind::Yield", }, kind); self.super_terminator_kind(block, kind, location); } diff --git a/src/librustc_trans/collector.rs b/src/librustc_trans/collector.rs index 57edb14a42d4..559acd53a360 100644 --- a/src/librustc_trans/collector.rs +++ b/src/librustc_trans/collector.rs @@ -630,7 +630,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> { mir::TerminatorKind::Unreachable | mir::TerminatorKind::Assert { .. } => {} mir::TerminatorKind::GeneratorDrop | - mir::TerminatorKind::Suspend { .. } => bug!(), + mir::TerminatorKind::Yield { .. } => bug!(), } self.super_terminator_kind(block, kind, location); diff --git a/src/librustc_trans/common.rs b/src/librustc_trans/common.rs index ebadba51bcf2..8cf22e2e4fea 100644 --- a/src/librustc_trans/common.rs +++ b/src/librustc_trans/common.rs @@ -538,7 +538,7 @@ pub fn ty_fn_sig<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, sig.map_bound(|sig| { let state_did = tcx.lang_items.gen_state().unwrap(); let state_adt_ref = tcx.adt_def(state_did); - let state_substs = tcx.mk_substs([Kind::from(sig.suspend_ty), + let state_substs = tcx.mk_substs([Kind::from(sig.yield_ty), Kind::from(sig.return_ty)].iter()); let ret_ty = tcx.mk_adt(state_adt_ref, state_substs); diff --git a/src/librustc_trans/mir/analyze.rs b/src/librustc_trans/mir/analyze.rs index 54f2af3c179b..9ff32bb70880 100644 --- a/src/librustc_trans/mir/analyze.rs +++ b/src/librustc_trans/mir/analyze.rs @@ -218,7 +218,7 @@ pub fn cleanup_kinds<'a, 'tcx>(mir: &mir::Mir<'tcx>) -> IndexVec { + TerminatorKind::Yield { .. } => { /* nothing to do */ } TerminatorKind::Call { cleanup: unwind, .. } | diff --git a/src/librustc_trans/mir/block.rs b/src/librustc_trans/mir/block.rs index a0369b80df0d..edf833a26307 100644 --- a/src/librustc_trans/mir/block.rs +++ b/src/librustc_trans/mir/block.rs @@ -579,7 +579,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { cleanup); } mir::TerminatorKind::GeneratorDrop | - mir::TerminatorKind::Suspend { .. } => bug!("generator ops in trans"), + mir::TerminatorKind::Yield { .. } => bug!("generator ops in trans"), } } diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 40693d4d0ea7..d8cedb81ac8e 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -506,7 +506,7 @@ pub struct FnCtxt<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { ret_coercion: Option>>, - suspend_ty: Option>, + yield_ty: Option>, impl_arg_ty: Option>, ps: RefCell, @@ -1037,7 +1037,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>, // Write the type to the impl arg id fcx.write_ty(impl_arg.id, impl_arg_ty); - fcx.suspend_ty = Some(fcx.next_ty_var(TypeVariableOrigin::TypeInference(span))); + fcx.yield_ty = Some(fcx.next_ty_var(TypeVariableOrigin::TypeInference(span))); } } @@ -1062,7 +1062,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>, let gen_ty = if can_be_generator && body.is_generator() { let gen_sig = ty::GenSig { impl_arg_ty: fcx.impl_arg_ty.unwrap(), - suspend_ty: fcx.suspend_ty.unwrap(), + yield_ty: fcx.yield_ty.unwrap(), return_ty: ret_ty, }; inherited.tables.borrow_mut().generator_sigs.insert(fn_id, Some(gen_sig)); @@ -1750,7 +1750,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { param_env, err_count_on_creation: inh.tcx.sess.err_count(), ret_coercion: None, - suspend_ty: None, + yield_ty: None, impl_arg_ty: None, ps: RefCell::new(UnsafetyState::function(hir::Unsafety::Normal, ast::CRATE_NODE_ID)), @@ -4008,8 +4008,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } } } - hir::ExprSuspend(ref value) => { - match self.suspend_ty { + hir::ExprYield(ref value) => { + match self.yield_ty { Some(ty) => { self.check_expr_coercable_to_type(&value, ty); } diff --git a/src/librustc_typeck/check/writeback.rs b/src/librustc_typeck/check/writeback.rs index 2b166d2418b7..5c397a984371 100644 --- a/src/librustc_typeck/check/writeback.rs +++ b/src/librustc_typeck/check/writeback.rs @@ -329,7 +329,7 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> { for (&node_id, gen_sig) in self.fcx.tables.borrow().generator_sigs.iter() { let gen_sig = gen_sig.map(|s| ty::GenSig { impl_arg_ty: self.resolve(&s.impl_arg_ty, &node_id), - suspend_ty: self.resolve(&s.suspend_ty, &node_id), + yield_ty: self.resolve(&s.yield_ty, &node_id), return_ty: self.resolve(&s.return_ty, &node_id), }); self.tables.generator_sigs.insert(node_id, gen_sig);