mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Rename suspend to yield
This commit is contained in:
parent
66fc6dfbb6
commit
df608e710c
@ -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())
|
||||
}
|
||||
|
@ -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) => {
|
||||
|
@ -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 => {
|
||||
|
@ -1069,8 +1069,8 @@ pub enum Expr_ {
|
||||
/// to be repeated; the second is the number of times to repeat it.
|
||||
ExprRepeat(P<Expr>, BodyId),
|
||||
|
||||
/// A suspension point for generators
|
||||
ExprSuspend(P<Expr>),
|
||||
/// A suspension point for generators. This is `yield <expr>` in Rust.
|
||||
ExprYield(P<Expr>),
|
||||
|
||||
/// The argument to a generator
|
||||
ExprImplArg(NodeId),
|
||||
|
@ -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(_) => {
|
||||
|
@ -573,7 +573,7 @@ impl<'a, 'gcx, 'tcx> HashStable<StableHashingContext<'a, 'gcx, 'tcx>> 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)
|
||||
});
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
});
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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(..) |
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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<Ty<'tcx>>,
|
||||
/// Yield type of the function, if it is a generator.
|
||||
pub yield_ty: Option<Ty<'tcx>>,
|
||||
|
||||
/// Generator drop glue
|
||||
pub generator_drop: Option<Box<Mir<'tcx>>>,
|
||||
@ -153,7 +153,7 @@ impl<'tcx> Mir<'tcx> {
|
||||
visibility_scopes: IndexVec<VisibilityScope, VisibilityScopeData>,
|
||||
promoted: IndexVec<Promoted, Mir<'tcx>>,
|
||||
return_ty: Ty<'tcx>,
|
||||
suspend_ty: Option<Ty<'tcx>>,
|
||||
yield_ty: Option<Ty<'tcx>>,
|
||||
local_decls: IndexVec<Local, LocalDecl<'tcx>>,
|
||||
arg_count: usize,
|
||||
upvar_decls: Vec<UpvarDecl>,
|
||||
@ -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 {
|
||||
|
@ -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);
|
||||
|
@ -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!()
|
||||
};
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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<Self::Lifted> {
|
||||
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<V: TypeVisitor<'tcx>>(&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)
|
||||
}
|
||||
}
|
||||
|
@ -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<GenSig<'tcx>>;
|
||||
|
||||
#[allow(warnings)]
|
||||
impl<'tcx> PolyGenSig<'tcx> {
|
||||
pub fn suspend_ty(&self) -> ty::Binder<Ty<'tcx>> {
|
||||
self.map_bound_ref(|sig| sig.suspend_ty)
|
||||
pub fn yield_ty(&self) -> ty::Binder<Ty<'tcx>> {
|
||||
self.map_bound_ref(|sig| sig.yield_ty)
|
||||
}
|
||||
pub fn return_ty(&self) -> ty::Binder<Ty<'tcx>> {
|
||||
self.map_bound_ref(|sig| sig.return_ty)
|
||||
|
@ -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) {
|
||||
|
@ -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,
|
||||
|
@ -78,7 +78,7 @@ impl Category {
|
||||
ExprKind::Borrow { .. } |
|
||||
ExprKind::Assign { .. } |
|
||||
ExprKind::AssignOp { .. } |
|
||||
ExprKind::Suspend { .. } |
|
||||
ExprKind::Yield { .. } |
|
||||
ExprKind::InlineAsm { .. } =>
|
||||
Some(Category::Rvalue(RvalueFunc::AsRvalue)),
|
||||
|
||||
|
@ -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() {
|
||||
|
@ -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<Ty<'gcx>>,
|
||||
yield_ty: Option<Ty<'gcx>>,
|
||||
impl_arg_ty: Option<Ty<'gcx>>,
|
||||
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<UpvarDecl>,
|
||||
return_ty: Ty<'tcx>,
|
||||
suspend_ty: Option<Ty<'tcx>>)
|
||||
yield_ty: Option<Ty<'tcx>>)
|
||||
-> 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,
|
||||
|
@ -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))
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -250,7 +250,7 @@ pub enum ExprKind<'tcx> {
|
||||
inputs: Vec<ExprRef<'tcx>>
|
||||
},
|
||||
ImplArg,
|
||||
Suspend {
|
||||
Yield {
|
||||
value: ExprRef<'tcx>,
|
||||
},
|
||||
}
|
||||
|
@ -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
|
||||
};
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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 */
|
||||
},
|
||||
|
@ -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 => {
|
||||
|
@ -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 {
|
||||
|
@ -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.
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -218,7 +218,7 @@ pub fn cleanup_kinds<'a, 'tcx>(mir: &mir::Mir<'tcx>) -> IndexVec<mir::BasicBlock
|
||||
TerminatorKind::GeneratorDrop |
|
||||
TerminatorKind::Unreachable |
|
||||
TerminatorKind::SwitchInt { .. } |
|
||||
TerminatorKind::Suspend { .. } => {
|
||||
TerminatorKind::Yield { .. } => {
|
||||
/* nothing to do */
|
||||
}
|
||||
TerminatorKind::Call { cleanup: unwind, .. } |
|
||||
|
@ -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"),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -506,7 +506,7 @@ pub struct FnCtxt<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
|
||||
|
||||
ret_coercion: Option<RefCell<DynamicCoerceMany<'gcx, 'tcx>>>,
|
||||
|
||||
suspend_ty: Option<Ty<'tcx>>,
|
||||
yield_ty: Option<Ty<'tcx>>,
|
||||
impl_arg_ty: Option<Ty<'tcx>>,
|
||||
|
||||
ps: RefCell<UnsafetyState>,
|
||||
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user