s/Generator/Coroutine/
This commit is contained in:
parent
96027d945b
commit
60956837cf
310 changed files with 1271 additions and 1271 deletions
|
@ -487,11 +487,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
.collect();
|
||||
|
||||
let result = match args {
|
||||
UpvarArgs::Generator(args) => {
|
||||
UpvarArgs::Coroutine(args) => {
|
||||
// We implicitly set the discriminant to 0. See
|
||||
// librustc_mir/transform/deaggregator.rs for details.
|
||||
let movability = movability.unwrap();
|
||||
Box::new(AggregateKind::Generator(closure_id.to_def_id(), args, movability))
|
||||
Box::new(AggregateKind::Coroutine(closure_id.to_def_id(), args, movability))
|
||||
}
|
||||
UpvarArgs::Closure(args) => {
|
||||
Box::new(AggregateKind::Closure(closure_id.to_def_id(), args))
|
||||
|
|
|
@ -9,7 +9,7 @@ use rustc_errors::ErrorGuaranteed;
|
|||
use rustc_hir as hir;
|
||||
use rustc_hir::def::DefKind;
|
||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
use rustc_hir::{GeneratorKind, Node};
|
||||
use rustc_hir::{CoroutineKind, Node};
|
||||
use rustc_index::bit_set::GrowableBitSet;
|
||||
use rustc_index::{Idx, IndexSlice, IndexVec};
|
||||
use rustc_infer::infer::{InferCtxt, TyCtxtInferExt};
|
||||
|
@ -173,7 +173,7 @@ struct Builder<'a, 'tcx> {
|
|||
check_overflow: bool,
|
||||
fn_span: Span,
|
||||
arg_count: usize,
|
||||
generator_kind: Option<GeneratorKind>,
|
||||
generator_kind: Option<CoroutineKind>,
|
||||
|
||||
/// The current set of scopes, updated as we traverse;
|
||||
/// see the `scope` module for more details.
|
||||
|
@ -481,7 +481,7 @@ fn construct_fn<'tcx>(
|
|||
let (yield_ty, return_ty) = if generator_kind.is_some() {
|
||||
let gen_ty = arguments[thir::UPVAR_ENV_PARAM].ty;
|
||||
let gen_sig = match gen_ty.kind() {
|
||||
ty::Generator(_, gen_args, ..) => gen_args.as_generator().sig(),
|
||||
ty::Coroutine(_, gen_args, ..) => gen_args.as_generator().sig(),
|
||||
_ => {
|
||||
span_bug!(span, "generator w/o generator type: {:?}", gen_ty)
|
||||
}
|
||||
|
@ -629,7 +629,7 @@ fn construct_error(tcx: TyCtxt<'_>, def: LocalDefId, err: ErrorGuaranteed) -> Bo
|
|||
let ty = tcx.type_of(def).instantiate_identity();
|
||||
match ty.kind() {
|
||||
ty::Closure(_, args) => 1 + args.as_closure().sig().inputs().skip_binder().len(),
|
||||
ty::Generator(..) => 2,
|
||||
ty::Coroutine(..) => 2,
|
||||
_ => bug!("expected closure or generator, found {ty:?}"),
|
||||
}
|
||||
}
|
||||
|
@ -687,7 +687,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
safety: Safety,
|
||||
return_ty: Ty<'tcx>,
|
||||
return_span: Span,
|
||||
generator_kind: Option<GeneratorKind>,
|
||||
generator_kind: Option<CoroutineKind>,
|
||||
) -> Builder<'a, 'tcx> {
|
||||
let tcx = infcx.tcx;
|
||||
let attrs = tcx.hir().attrs(hir_id);
|
||||
|
@ -777,7 +777,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
|
||||
let upvar_args = match closure_ty.kind() {
|
||||
ty::Closure(_, args) => ty::UpvarArgs::Closure(args),
|
||||
ty::Generator(_, args, _) => ty::UpvarArgs::Generator(args),
|
||||
ty::Coroutine(_, args, _) => ty::UpvarArgs::Coroutine(args),
|
||||
_ => return,
|
||||
};
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@ pub struct Scopes<'tcx> {
|
|||
/// [DropTree] for more details.
|
||||
unwind_drops: DropTree,
|
||||
|
||||
/// Drops that need to be done on paths to the `GeneratorDrop` terminator.
|
||||
/// Drops that need to be done on paths to the `CoroutineDrop` terminator.
|
||||
generator_drops: DropTree,
|
||||
}
|
||||
|
||||
|
@ -1140,7 +1140,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
/// generator, starting from the given block that ends in
|
||||
/// [TerminatorKind::Yield].
|
||||
///
|
||||
/// This path terminates in GeneratorDrop.
|
||||
/// This path terminates in CoroutineDrop.
|
||||
pub(crate) fn generator_drop_cleanup(&mut self, yield_block: BasicBlock) {
|
||||
debug_assert!(
|
||||
matches!(
|
||||
|
@ -1401,12 +1401,12 @@ impl<'a, 'tcx: 'a> Builder<'a, 'tcx> {
|
|||
let cfg = &mut self.cfg;
|
||||
let fn_span = self.fn_span;
|
||||
let mut blocks = IndexVec::from_elem(None, &drops.drops);
|
||||
drops.build_mir::<GeneratorDrop>(cfg, &mut blocks);
|
||||
drops.build_mir::<CoroutineDrop>(cfg, &mut blocks);
|
||||
if let Some(root_block) = blocks[ROOT_NODE] {
|
||||
cfg.terminate(
|
||||
root_block,
|
||||
SourceInfo::outermost(fn_span),
|
||||
TerminatorKind::GeneratorDrop,
|
||||
TerminatorKind::CoroutineDrop,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1461,9 +1461,9 @@ impl<'tcx> DropTreeBuilder<'tcx> for ExitScopes {
|
|||
}
|
||||
}
|
||||
|
||||
struct GeneratorDrop;
|
||||
struct CoroutineDrop;
|
||||
|
||||
impl<'tcx> DropTreeBuilder<'tcx> for GeneratorDrop {
|
||||
impl<'tcx> DropTreeBuilder<'tcx> for CoroutineDrop {
|
||||
fn make_block(cfg: &mut CFG<'tcx>) -> BasicBlock {
|
||||
cfg.start_new_block()
|
||||
}
|
||||
|
@ -1511,7 +1511,7 @@ impl<'tcx> DropTreeBuilder<'tcx> for Unwind {
|
|||
| TerminatorKind::Return
|
||||
| TerminatorKind::Unreachable
|
||||
| TerminatorKind::Yield { .. }
|
||||
| TerminatorKind::GeneratorDrop
|
||||
| TerminatorKind::CoroutineDrop
|
||||
| TerminatorKind::FalseEdge { .. } => {
|
||||
span_bug!(term.source_info.span, "cannot unwind from {:?}", term.kind)
|
||||
}
|
||||
|
|
|
@ -192,7 +192,7 @@ impl<'mir, 'tcx, C: TerminatorClassifier<'tcx>> TriColorVisitor<BasicBlocks<'tcx
|
|||
match self.body[bb].terminator().kind {
|
||||
// These terminators return control flow to the caller.
|
||||
TerminatorKind::UnwindTerminate(_)
|
||||
| TerminatorKind::GeneratorDrop
|
||||
| TerminatorKind::CoroutineDrop
|
||||
| TerminatorKind::UnwindResume
|
||||
| TerminatorKind::Return
|
||||
| TerminatorKind::Unreachable
|
||||
|
|
|
@ -574,8 +574,8 @@ impl<'tcx> Cx<'tcx> {
|
|||
let closure_ty = self.typeck_results().expr_ty(expr);
|
||||
let (def_id, args, movability) = match *closure_ty.kind() {
|
||||
ty::Closure(def_id, args) => (def_id, UpvarArgs::Closure(args), None),
|
||||
ty::Generator(def_id, args, movability) => {
|
||||
(def_id, UpvarArgs::Generator(args), Some(movability))
|
||||
ty::Coroutine(def_id, args, movability) => {
|
||||
(def_id, UpvarArgs::Coroutine(args), Some(movability))
|
||||
}
|
||||
_ => {
|
||||
span_bug!(expr.span, "closure expr w/o closure type: {:?}", closure_ty);
|
||||
|
|
|
@ -37,7 +37,7 @@ pub(crate) fn thir_body(
|
|||
|
||||
// The resume argument may be missing, in that case we need to provide it here.
|
||||
// It will always be `()` in this case.
|
||||
if tcx.def_kind(owner_def) == DefKind::Generator && body.params.is_empty() {
|
||||
if tcx.def_kind(owner_def) == DefKind::Coroutine && body.params.is_empty() {
|
||||
cx.thir.params.push(Param {
|
||||
ty: Ty::new_unit(tcx),
|
||||
pat: None,
|
||||
|
@ -148,7 +148,7 @@ impl<'tcx> Cx<'tcx> {
|
|||
|
||||
Some(env_param)
|
||||
}
|
||||
DefKind::Generator => {
|
||||
DefKind::Coroutine => {
|
||||
let gen_ty = self.typeck_results.node_type(owner_id);
|
||||
let gen_param =
|
||||
Param { ty: gen_ty, pat: None, ty_span: None, self_kind: None, hir_id: None };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue