s/Generator/Coroutine/

This commit is contained in:
Oli Scherer 2023-10-19 16:06:43 +00:00
parent 96027d945b
commit 60956837cf
310 changed files with 1271 additions and 1271 deletions

View file

@ -132,7 +132,7 @@ pub struct AwaitOnlyInAsyncFnAndBlocks {
#[derive(Diagnostic, Clone, Copy)]
#[diag(ast_lowering_generator_too_many_parameters, code = "E0628")]
pub struct GeneratorTooManyParameters {
pub struct CoroutineTooManyParameters {
#[primary_span]
pub fn_decl_span: Span,
}
@ -162,7 +162,7 @@ pub struct FunctionalRecordUpdateDestructuringAssignment {
#[derive(Diagnostic, Clone, Copy)]
#[diag(ast_lowering_async_generators_not_supported, code = "E0727")]
pub struct AsyncGeneratorsNotSupported {
pub struct AsyncCoroutinesNotSupported {
#[primary_span]
pub span: Span,
}

View file

@ -1,8 +1,8 @@
use super::errors::{
AsyncGeneratorsNotSupported, AsyncNonMoveClosureNotSupported, AwaitOnlyInAsyncFnAndBlocks,
BaseExpressionDoubleDot, ClosureCannotBeStatic, FunctionalRecordUpdateDestructuringAssignment,
GeneratorTooManyParameters, InclusiveRangeWithNoEnd, NotSupportedForLifetimeBinderAsyncClosure,
UnderscoreExprLhsAssign,
AsyncCoroutinesNotSupported, AsyncNonMoveClosureNotSupported, AwaitOnlyInAsyncFnAndBlocks,
BaseExpressionDoubleDot, ClosureCannotBeStatic, CoroutineTooManyParameters,
FunctionalRecordUpdateDestructuringAssignment, InclusiveRangeWithNoEnd,
NotSupportedForLifetimeBinderAsyncClosure, UnderscoreExprLhsAssign,
};
use super::ResolverAstLoweringExt;
use super::{ImplTraitContext, LoweringContext, ParamMode, ParenthesizedGenericArgs};
@ -188,7 +188,7 @@ pub(super) fn lower_expr_mut(&mut self, e: &Expr) -> hir::Expr<'hir> {
e.id,
None,
e.span,
hir::AsyncGeneratorKind::Block,
hir::AsyncCoroutineKind::Block,
|this| this.with_new_scopes(|this| this.lower_block_expr(block)),
),
ExprKind::Await(expr, await_kw_span) => self.lower_expr_await(*await_kw_span, expr),
@ -598,7 +598,7 @@ pub(super) fn make_async_expr(
closure_node_id: NodeId,
ret_ty: Option<hir::FnRetTy<'hir>>,
span: Span,
async_gen_kind: hir::AsyncGeneratorKind,
async_gen_kind: hir::AsyncCoroutineKind,
body: impl FnOnce(&mut Self) -> hir::Expr<'hir>,
) -> hir::ExprKind<'hir> {
let output = ret_ty.unwrap_or_else(|| hir::FnRetTy::DefaultReturn(self.lower_span(span)));
@ -637,7 +637,7 @@ pub(super) fn make_async_expr(
let params = arena_vec![self; param];
let body = self.lower_body(move |this| {
this.generator_kind = Some(hir::GeneratorKind::Async(async_gen_kind));
this.generator_kind = Some(hir::CoroutineKind::Async(async_gen_kind));
let old_ctx = this.task_context;
this.task_context = Some(task_context_hid);
@ -711,8 +711,8 @@ pub(super) fn maybe_forward_track_caller(
fn lower_expr_await(&mut self, await_kw_span: Span, expr: &Expr) -> hir::ExprKind<'hir> {
let full_span = expr.span.to(await_kw_span);
match self.generator_kind {
Some(hir::GeneratorKind::Async(_)) => {}
Some(hir::GeneratorKind::Gen) | None => {
Some(hir::CoroutineKind::Async(_)) => {}
Some(hir::CoroutineKind::Gen) | None => {
self.tcx.sess.emit_err(AwaitOnlyInAsyncFnAndBlocks {
await_kw_span,
item_span: self.current_item,
@ -926,17 +926,17 @@ fn generator_movability_for_fn(
&mut self,
decl: &FnDecl,
fn_decl_span: Span,
generator_kind: Option<hir::GeneratorKind>,
generator_kind: Option<hir::CoroutineKind>,
movability: Movability,
) -> Option<hir::Movability> {
match generator_kind {
Some(hir::GeneratorKind::Gen) => {
Some(hir::CoroutineKind::Gen) => {
if decl.inputs.len() > 1 {
self.tcx.sess.emit_err(GeneratorTooManyParameters { fn_decl_span });
self.tcx.sess.emit_err(CoroutineTooManyParameters { fn_decl_span });
}
Some(movability)
}
Some(hir::GeneratorKind::Async(_)) => {
Some(hir::CoroutineKind::Async(_)) => {
panic!("non-`async` closure body turned `async` during lowering");
}
None => {
@ -1005,7 +1005,7 @@ fn lower_expr_async_closure(
inner_closure_id,
async_ret_ty,
body.span,
hir::AsyncGeneratorKind::Closure,
hir::AsyncCoroutineKind::Closure,
|this| this.with_new_scopes(|this| this.lower_expr_mut(body)),
);
let hir_id = this.lower_node_id(inner_closure_id);
@ -1445,11 +1445,11 @@ fn lower_expr_field(&mut self, f: &ExprField) -> hir::ExprField<'hir> {
fn lower_expr_yield(&mut self, span: Span, opt_expr: Option<&Expr>) -> hir::ExprKind<'hir> {
match self.generator_kind {
Some(hir::GeneratorKind::Gen) => {}
Some(hir::GeneratorKind::Async(_)) => {
self.tcx.sess.emit_err(AsyncGeneratorsNotSupported { span });
Some(hir::CoroutineKind::Gen) => {}
Some(hir::CoroutineKind::Async(_)) => {
self.tcx.sess.emit_err(AsyncCoroutinesNotSupported { span });
}
None => self.generator_kind = Some(hir::GeneratorKind::Gen),
None => self.generator_kind = Some(hir::CoroutineKind::Gen),
}
let expr =

View file

@ -1206,7 +1206,7 @@ fn lower_maybe_async_body(
closure_id,
None,
body.span,
hir::AsyncGeneratorKind::Fn,
hir::AsyncCoroutineKind::Fn,
|this| {
// Create a block from the user's function body:
let user_body = this.lower_block_expr(body);

View file

@ -111,7 +111,7 @@ struct LoweringContext<'a, 'hir> {
/// Collect items that were created by lowering the current owner.
children: Vec<(LocalDefId, hir::MaybeOwner<&'hir hir::OwnerInfo<'hir>>)>,
generator_kind: Option<hir::GeneratorKind>,
generator_kind: Option<hir::CoroutineKind>,
/// When inside an `async` context, this is the `HirId` of the
/// `task_context` local bound to the resume argument of the generator.

View file

@ -8,7 +8,7 @@
use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::intravisit::{walk_block, walk_expr, Visitor};
use rustc_hir::{AsyncGeneratorKind, GeneratorKind, LangItem};
use rustc_hir::{AsyncCoroutineKind, CoroutineKind, LangItem};
use rustc_infer::traits::ObligationCause;
use rustc_middle::hir::nested_filter::OnlyBodies;
use rustc_middle::mir::tcx::PlaceTy;
@ -848,7 +848,7 @@ pub(crate) fn report_move_out_while_borrowed(
move_spans.var_subdiag(None, &mut err, None, |kind, var_span| {
use crate::session_diagnostics::CaptureVarCause::*;
match kind {
Some(_) => MoveUseInGenerator { var_span },
Some(_) => MoveUseInCoroutine { var_span },
None => MoveUseInClosure { var_span },
}
});
@ -894,7 +894,7 @@ pub(crate) fn report_use_while_mutably_borrowed(
let desc_place = self.describe_any_place(place.as_ref());
match kind {
Some(_) => {
BorrowUsePlaceGenerator { place: desc_place, var_span, is_single_var: true }
BorrowUsePlaceCoroutine { place: desc_place, var_span, is_single_var: true }
}
None => BorrowUsePlaceClosure { place: desc_place, var_span, is_single_var: true },
}
@ -1040,7 +1040,7 @@ pub(crate) fn report_conflicting_borrow(
|kind, var_span| {
use crate::session_diagnostics::CaptureVarCause::*;
match kind {
Some(_) => BorrowUsePlaceGenerator {
Some(_) => BorrowUsePlaceCoroutine {
place: desc_place,
var_span,
is_single_var: true,
@ -1125,7 +1125,7 @@ pub(crate) fn report_conflicting_borrow(
borrow_spans.var_subdiag(None, &mut err, Some(gen_borrow_kind), |kind, var_span| {
use crate::session_diagnostics::CaptureVarCause::*;
match kind {
Some(_) => BorrowUsePlaceGenerator {
Some(_) => BorrowUsePlaceCoroutine {
place: desc_place,
var_span,
is_single_var: false,
@ -1146,7 +1146,7 @@ pub(crate) fn report_conflicting_borrow(
let borrow_place_desc = self.describe_any_place(borrow_place.as_ref());
match kind {
Some(_) => {
FirstBorrowUsePlaceGenerator { place: borrow_place_desc, var_span }
FirstBorrowUsePlaceCoroutine { place: borrow_place_desc, var_span }
}
None => FirstBorrowUsePlaceClosure { place: borrow_place_desc, var_span },
}
@ -1160,7 +1160,7 @@ pub(crate) fn report_conflicting_borrow(
|kind, var_span| {
use crate::session_diagnostics::CaptureVarCause::*;
match kind {
Some(_) => SecondBorrowUsePlaceGenerator { place: desc_place, var_span },
Some(_) => SecondBorrowUsePlaceCoroutine { place: desc_place, var_span },
None => SecondBorrowUsePlaceClosure { place: desc_place, var_span },
}
},
@ -2077,7 +2077,7 @@ fn report_local_value_does_not_live_long_enough(
.unwrap_or_else(|| {
match &self.infcx.tcx.def_kind(self.mir_def_id()) {
DefKind::Closure => "enclosing closure",
DefKind::Generator => "enclosing generator",
DefKind::Coroutine => "enclosing generator",
kind => bug!("expected closure or generator, found {:?}", kind),
}
.to_string()
@ -2483,12 +2483,12 @@ fn report_escaping_closure_capture(
};
let kind = match use_span.generator_kind() {
Some(generator_kind) => match generator_kind {
GeneratorKind::Async(async_kind) => match async_kind {
AsyncGeneratorKind::Block => "async block",
AsyncGeneratorKind::Closure => "async closure",
CoroutineKind::Async(async_kind) => match async_kind {
AsyncCoroutineKind::Block => "async block",
AsyncCoroutineKind::Closure => "async closure",
_ => bug!("async block/closure expected, but async function found."),
},
GeneratorKind::Gen => "generator",
CoroutineKind::Gen => "generator",
},
None => "closure",
};
@ -2517,7 +2517,7 @@ fn report_escaping_closure_capture(
}
ConstraintCategory::CallArgument(_) => {
fr_name.highlight_region_name(&mut err);
if matches!(use_span.generator_kind(), Some(GeneratorKind::Async(_))) {
if matches!(use_span.generator_kind(), Some(CoroutineKind::Async(_))) {
err.note(
"async blocks are not executed immediately and must either take a \
reference or ownership of outside variables they use",
@ -2785,7 +2785,7 @@ pub(crate) fn report_illegal_mutation_of_borrowed(
loan_spans.var_subdiag(None, &mut err, Some(loan.kind), |kind, var_span| {
use crate::session_diagnostics::CaptureVarCause::*;
match kind {
Some(_) => BorrowUseInGenerator { var_span },
Some(_) => BorrowUseInCoroutine { var_span },
None => BorrowUseInClosure { var_span },
}
});
@ -2801,7 +2801,7 @@ pub(crate) fn report_illegal_mutation_of_borrowed(
loan_spans.var_subdiag(None, &mut err, Some(loan.kind), |kind, var_span| {
use crate::session_diagnostics::CaptureVarCause::*;
match kind {
Some(_) => BorrowUseInGenerator { var_span },
Some(_) => BorrowUseInCoroutine { var_span },
None => BorrowUseInClosure { var_span },
}
});

View file

@ -182,7 +182,7 @@ pub(crate) fn add_explanation_to_diagnostic(
// Otherwise, just report the whole type (and use
// the intentionally fuzzy phrase "destructor")
ty::Closure(..) => ("destructor", "closure".to_owned()),
ty::Generator(..) => ("destructor", "generator".to_owned()),
ty::Coroutine(..) => ("destructor", "generator".to_owned()),
_ => ("destructor", format!("type `{}`", local_decl.ty)),
};

View file

@ -8,7 +8,7 @@
use rustc_errors::{Applicability, Diagnostic};
use rustc_hir as hir;
use rustc_hir::def::{CtorKind, Namespace};
use rustc_hir::GeneratorKind;
use rustc_hir::CoroutineKind;
use rustc_index::IndexSlice;
use rustc_infer::infer::LateBoundRegionConversionTime;
use rustc_middle::mir::tcx::PlaceTy;
@ -369,7 +369,7 @@ fn describe_field_from_ty(
ty::Array(ty, _) | ty::Slice(ty) => {
self.describe_field_from_ty(ty, field, variant_index, including_tuple_field)
}
ty::Closure(def_id, _) | ty::Generator(def_id, _, _) => {
ty::Closure(def_id, _) | ty::Coroutine(def_id, _, _) => {
// We won't be borrowck'ing here if the closure came from another crate,
// so it's safe to call `expect_local`.
//
@ -502,7 +502,7 @@ pub(super) enum UseSpans<'tcx> {
/// The access is caused by capturing a variable for a closure.
ClosureUse {
/// This is true if the captured variable was from a generator.
generator_kind: Option<GeneratorKind>,
generator_kind: Option<CoroutineKind>,
/// The span of the args of the closure, including the `move` keyword if
/// it's present.
args_span: Span,
@ -569,7 +569,7 @@ pub(super) fn var_or_use(self) -> Span {
}
}
pub(super) fn generator_kind(self) -> Option<GeneratorKind> {
pub(super) fn generator_kind(self) -> Option<CoroutineKind> {
match self {
UseSpans::ClosureUse { generator_kind, .. } => generator_kind,
_ => None,
@ -600,10 +600,10 @@ pub(super) fn var_path_only_subdiag(
match generator_kind {
Some(_) => {
err.subdiagnostic(match action {
Borrow => BorrowInGenerator { path_span },
MatchOn | Use => UseInGenerator { path_span },
Assignment => AssignInGenerator { path_span },
PartialAssignment => AssignPartInGenerator { path_span },
Borrow => BorrowInCoroutine { path_span },
MatchOn | Use => UseInCoroutine { path_span },
Assignment => AssignInCoroutine { path_span },
PartialAssignment => AssignPartInCoroutine { path_span },
});
}
None => {
@ -624,7 +624,7 @@ pub(super) fn var_subdiag(
handler: Option<&rustc_errors::Handler>,
err: &mut Diagnostic,
kind: Option<rustc_middle::mir::BorrowKind>,
f: impl FnOnce(Option<GeneratorKind>, Span) -> CaptureVarCause,
f: impl FnOnce(Option<CoroutineKind>, Span) -> CaptureVarCause,
) {
if let UseSpans::ClosureUse { generator_kind, capture_kind_span, path_span, .. } = self {
if capture_kind_span != path_span {
@ -780,7 +780,7 @@ pub(super) fn move_spans(
debug!("move_spans: moved_place={:?} location={:?} stmt={:?}", moved_place, location, stmt);
if let StatementKind::Assign(box (_, Rvalue::Aggregate(kind, places))) = &stmt.kind
&& let AggregateKind::Closure(def_id, _) | AggregateKind::Generator(def_id, _, _) =
&& let AggregateKind::Closure(def_id, _) | AggregateKind::Coroutine(def_id, _, _) =
**kind
{
debug!("move_spans: def_id={:?} places={:?}", def_id, places);
@ -916,7 +916,7 @@ pub(super) fn borrow_spans(&self, use_span: Span, location: Location) -> UseSpan
if let StatementKind::Assign(box (_, Rvalue::Aggregate(kind, places))) = &stmt.kind {
let (&def_id, is_generator) = match kind {
box AggregateKind::Closure(def_id, _) => (def_id, false),
box AggregateKind::Generator(def_id, _, _) => (def_id, true),
box AggregateKind::Coroutine(def_id, _, _) => (def_id, true),
_ => continue,
};
let def_id = def_id.expect_local();
@ -950,7 +950,7 @@ fn closure_span(
def_id: LocalDefId,
target_place: PlaceRef<'tcx>,
places: &IndexSlice<FieldIdx, Operand<'tcx>>,
) -> Option<(Span, Option<GeneratorKind>, Span, Span)> {
) -> Option<(Span, Option<CoroutineKind>, Span, Span)> {
debug!(
"closure_span: def_id={:?} target_place={:?} places={:?}",
def_id, target_place, places
@ -1188,7 +1188,7 @@ fn explain_captures(
// another message for the same span
if !is_loop_message {
move_spans.var_subdiag(None, err, None, |kind, var_span| match kind {
Some(_) => CaptureVarCause::PartialMoveUseInGenerator { var_span, is_partial },
Some(_) => CaptureVarCause::PartialMoveUseInCoroutine { var_span, is_partial },
None => CaptureVarCause::PartialMoveUseInClosure { var_span, is_partial },
})
}

View file

@ -580,7 +580,7 @@ fn report_fnmut_error(
let err = FnMutError {
span: *span,
ty_err: match output_ty.kind() {
ty::Generator(def, ..) if self.infcx.tcx.generator_is_async(*def) => {
ty::Coroutine(def, ..) if self.infcx.tcx.generator_is_async(*def) => {
FnMutReturnTypeErr::ReturnAsyncBlock { span: *span }
}
_ if output_ty.contains_closure() => {
@ -1036,7 +1036,7 @@ fn suggest_move_on_borrowing_closure(&self, diag: &mut Diagnostic) {
..
}) => {
let body = map.body(*body);
if !matches!(body.generator_kind, Some(hir::GeneratorKind::Async(..))) {
if !matches!(body.generator_kind, Some(hir::CoroutineKind::Async(..))) {
closure_span = Some(expr.span.shrink_to_lo());
}
}

View file

@ -681,10 +681,10 @@ fn give_name_if_anonymous_region_appears_in_output(&self, fr: RegionVid) -> Opti
hir::FnRetTy::Return(hir_ty) => (fn_decl.output.span(), Some(hir_ty)),
};
let mir_description = match hir.body(body).generator_kind {
Some(hir::GeneratorKind::Async(gen)) => match gen {
hir::AsyncGeneratorKind::Block => " of async block",
hir::AsyncGeneratorKind::Closure => " of async closure",
hir::AsyncGeneratorKind::Fn => {
Some(hir::CoroutineKind::Async(gen)) => match gen {
hir::AsyncCoroutineKind::Block => " of async block",
hir::AsyncCoroutineKind::Closure => " of async closure",
hir::AsyncCoroutineKind::Fn => {
let parent_item =
hir.get_by_def_id(hir.get_parent_item(mir_hir_id).def_id);
let output = &parent_item
@ -698,7 +698,7 @@ fn give_name_if_anonymous_region_appears_in_output(&self, fr: RegionVid) -> Opti
" of async function"
}
},
Some(hir::GeneratorKind::Gen) => " of generator",
Some(hir::CoroutineKind::Gen) => " of generator",
None => " of closure",
};
(span, mir_description, hir_ty)

View file

@ -161,7 +161,7 @@ fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location
}
TerminatorKind::UnwindResume
| TerminatorKind::Return
| TerminatorKind::GeneratorDrop => {
| TerminatorKind::CoroutineDrop => {
// Invalidate all borrows of local places
let borrow_set = self.borrow_set;
let start = self.location_table.start_index(location);

View file

@ -306,7 +306,7 @@ fn do_mir_borrowck<'tcx>(
// The first argument is the generator type passed by value
if let Some(local) = body.local_decls.raw.get(1)
// Get the interior types and args which typeck computed
&& let ty::Generator(_, _, hir::Movability::Static) = local.ty.kind()
&& let ty::Coroutine(_, _, hir::Movability::Static) = local.ty.kind()
{
false
} else {
@ -778,7 +778,7 @@ fn visit_terminator_before_primary_effect(
| TerminatorKind::Unreachable
| TerminatorKind::UnwindResume
| TerminatorKind::Return
| TerminatorKind::GeneratorDrop
| TerminatorKind::CoroutineDrop
| TerminatorKind::FalseEdge { real_target: _, imaginary_target: _ }
| TerminatorKind::FalseUnwind { real_target: _, unwind: _ } => {
// no data used, thus irrelevant to borrowck
@ -809,7 +809,7 @@ fn visit_terminator_after_primary_effect(
TerminatorKind::UnwindResume
| TerminatorKind::Return
| TerminatorKind::GeneratorDrop => {
| TerminatorKind::CoroutineDrop => {
// Returning from the function implicitly kills storage for all locals and statics.
// Often, the storage will already have been killed by an explicit
// StorageDead, but we don't always emit those (notably on unwind paths),
@ -1326,7 +1326,7 @@ fn consume_rvalue(
// moved into the closure and subsequently used by the closure,
// in order to populate our used_mut set.
match **aggregate_kind {
AggregateKind::Closure(def_id, _) | AggregateKind::Generator(def_id, _, _) => {
AggregateKind::Closure(def_id, _) | AggregateKind::Coroutine(def_id, _, _) => {
let def_id = def_id.expect_local();
let BorrowCheckResult { used_mut_upvars, .. } =
self.infcx.tcx.mir_borrowck(def_id);

View file

@ -140,22 +140,22 @@ pub(crate) enum RequireStaticErr {
#[derive(Subdiagnostic)]
pub(crate) enum CaptureVarPathUseCause {
#[label(borrowck_borrow_due_to_use_generator)]
BorrowInGenerator {
BorrowInCoroutine {
#[primary_span]
path_span: Span,
},
#[label(borrowck_use_due_to_use_generator)]
UseInGenerator {
UseInCoroutine {
#[primary_span]
path_span: Span,
},
#[label(borrowck_assign_due_to_use_generator)]
AssignInGenerator {
AssignInCoroutine {
#[primary_span]
path_span: Span,
},
#[label(borrowck_assign_part_due_to_use_generator)]
AssignPartInGenerator {
AssignPartInCoroutine {
#[primary_span]
path_span: Span,
},
@ -203,7 +203,7 @@ pub(crate) enum CaptureVarKind {
#[derive(Subdiagnostic)]
pub(crate) enum CaptureVarCause {
#[label(borrowck_var_borrow_by_use_place_in_generator)]
BorrowUsePlaceGenerator {
BorrowUsePlaceCoroutine {
is_single_var: bool,
place: String,
#[primary_span]
@ -217,7 +217,7 @@ pub(crate) enum CaptureVarCause {
var_span: Span,
},
#[label(borrowck_var_borrow_by_use_in_generator)]
BorrowUseInGenerator {
BorrowUseInCoroutine {
#[primary_span]
var_span: Span,
},
@ -227,7 +227,7 @@ pub(crate) enum CaptureVarCause {
var_span: Span,
},
#[label(borrowck_var_move_by_use_in_generator)]
MoveUseInGenerator {
MoveUseInCoroutine {
#[primary_span]
var_span: Span,
},
@ -237,7 +237,7 @@ pub(crate) enum CaptureVarCause {
var_span: Span,
},
#[label(borrowck_var_first_borrow_by_use_place_in_generator)]
FirstBorrowUsePlaceGenerator {
FirstBorrowUsePlaceCoroutine {
place: String,
#[primary_span]
var_span: Span,
@ -249,7 +249,7 @@ pub(crate) enum CaptureVarCause {
var_span: Span,
},
#[label(borrowck_var_second_borrow_by_use_place_in_generator)]
SecondBorrowUsePlaceGenerator {
SecondBorrowUsePlaceCoroutine {
place: String,
#[primary_span]
var_span: Span,
@ -267,7 +267,7 @@ pub(crate) enum CaptureVarCause {
var_span: Span,
},
#[label(borrowck_partial_var_move_by_use_in_generator)]
PartialMoveUseInGenerator {
PartialMoveUseInCoroutine {
#[primary_span]
var_span: Span,
is_partial: bool,

View file

@ -774,7 +774,7 @@ fn field_ty(
let (variant, args) = match base_ty {
PlaceTy { ty, variant_index: Some(variant_index) } => match *ty.kind() {
ty::Adt(adt_def, args) => (adt_def.variant(variant_index), args),
ty::Generator(def_id, args, _) => {
ty::Coroutine(def_id, args, _) => {
let mut variants = args.as_generator().state_tys(def_id, tcx);
let Some(mut variant) = variants.nth(variant_index.into()) else {
bug!(
@ -802,7 +802,7 @@ fn field_ty(
}),
};
}
ty::Generator(_, args, _) => {
ty::Coroutine(_, args, _) => {
// Only prefix fields (upvars and current state) are
// accessible without a variant index.
return match args.as_generator().prefix_tys().get(field.index()) {
@ -1351,7 +1351,7 @@ fn check_terminator(
| TerminatorKind::UnwindResume
| TerminatorKind::UnwindTerminate(_)
| TerminatorKind::Return
| TerminatorKind::GeneratorDrop
| TerminatorKind::CoroutineDrop
| TerminatorKind::Unreachable
| TerminatorKind::Drop { .. }
| TerminatorKind::FalseEdge { .. }
@ -1648,7 +1648,7 @@ fn check_iscleanup(&mut self, body: &Body<'tcx>, block_data: &BasicBlockData<'tc
span_mirbug!(self, block_data, "return on cleanup block")
}
}
TerminatorKind::GeneratorDrop { .. } => {
TerminatorKind::CoroutineDrop { .. } => {
if is_cleanup {
span_mirbug!(self, block_data, "generator_drop in cleanup block")
}
@ -1797,7 +1797,7 @@ fn aggregate_field_ty(
}),
}
}
AggregateKind::Generator(_, args, _) => {
AggregateKind::Coroutine(_, args, _) => {
// It doesn't make sense to look at a field beyond the prefix;
// these require a variant index, and are not initialized in
// aggregate rvalues.
@ -2397,7 +2397,7 @@ fn rvalue_user_ty(&self, rvalue: &Rvalue<'tcx>) -> Option<UserTypeAnnotationInde
AggregateKind::Array(_) => None,
AggregateKind::Tuple => None,
AggregateKind::Closure(_, _) => None,
AggregateKind::Generator(_, _, _) => None,
AggregateKind::Coroutine(_, _, _) => None,
},
}
}
@ -2625,7 +2625,7 @@ fn prove_aggregate_predicates(
// desugaring. A closure gets desugared to a struct, and
// these extra requirements are basically like where
// clauses on the struct.
AggregateKind::Closure(def_id, args) | AggregateKind::Generator(def_id, args, _) => {
AggregateKind::Closure(def_id, args) | AggregateKind::Coroutine(def_id, args, _) => {
(def_id, self.prove_closure_bounds(tcx, def_id.expect_local(), args, location))
}
@ -2673,7 +2673,7 @@ fn prove_closure_bounds(
let parent_args = match tcx.def_kind(def_id) {
DefKind::Closure => args.as_closure().parent_args(),
DefKind::Generator => args.as_generator().parent_args(),
DefKind::Coroutine => args.as_generator().parent_args(),
DefKind::InlineConst => args.as_inline_const().parent_args(),
other => bug!("unexpected item {:?}", other),
};

View file

@ -94,7 +94,7 @@ pub enum DefiningTy<'tcx> {
/// The MIR is a generator. The signature is that generators take
/// no parameters and return the result of
/// `ClosureArgs::generator_return_ty`.
Generator(DefId, GenericArgsRef<'tcx>, hir::Movability),
Coroutine(DefId, GenericArgsRef<'tcx>, hir::Movability),
/// The MIR is a fn item with the given `DefId` and args. The signature
/// of the function can be bound then with the `fn_sig` query.
@ -118,7 +118,7 @@ impl<'tcx> DefiningTy<'tcx> {
pub fn upvar_tys(self) -> &'tcx ty::List<Ty<'tcx>> {
match self {
DefiningTy::Closure(_, args) => args.as_closure().upvar_tys(),
DefiningTy::Generator(_, args, _) => args.as_generator().upvar_tys(),
DefiningTy::Coroutine(_, args, _) => args.as_generator().upvar_tys(),
DefiningTy::FnDef(..) | DefiningTy::Const(..) | DefiningTy::InlineConst(..) => {
ty::List::empty()
}
@ -130,7 +130,7 @@ pub fn upvar_tys(self) -> &'tcx ty::List<Ty<'tcx>> {
/// user's code.
pub fn implicit_inputs(self) -> usize {
match self {
DefiningTy::Closure(..) | DefiningTy::Generator(..) => 1,
DefiningTy::Closure(..) | DefiningTy::Coroutine(..) => 1,
DefiningTy::FnDef(..) | DefiningTy::Const(..) | DefiningTy::InlineConst(..) => 0,
}
}
@ -146,7 +146,7 @@ pub fn is_const(&self) -> bool {
pub fn def_id(&self) -> DefId {
match *self {
DefiningTy::Closure(def_id, ..)
| DefiningTy::Generator(def_id, ..)
| DefiningTy::Coroutine(def_id, ..)
| DefiningTy::FnDef(def_id, ..)
| DefiningTy::Const(def_id, ..)
| DefiningTy::InlineConst(def_id, ..) => def_id,
@ -354,7 +354,7 @@ pub(crate) fn annotate(&self, tcx: TyCtxt<'tcx>, err: &mut Diagnostic) {
err.note(format!("late-bound region is {:?}", self.to_region_vid(r)));
});
}
DefiningTy::Generator(def_id, args, _) => {
DefiningTy::Coroutine(def_id, args, _) => {
let v = with_no_trimmed_paths!(
args[tcx.generics_of(def_id).parent_count..]
.iter()
@ -528,7 +528,7 @@ fn build(self) -> UniversalRegions<'tcx> {
debug!("build: local regions = {}..{}", first_local_index, num_universals);
let yield_ty = match defining_ty {
DefiningTy::Generator(_, args, _) => Some(args.as_generator().yield_ty()),
DefiningTy::Coroutine(_, args, _) => Some(args.as_generator().yield_ty()),
_ => None,
};
@ -563,8 +563,8 @@ fn defining_ty(&self) -> DefiningTy<'tcx> {
match *defining_ty.kind() {
ty::Closure(def_id, args) => DefiningTy::Closure(def_id, args),
ty::Generator(def_id, args, movability) => {
DefiningTy::Generator(def_id, args, movability)
ty::Coroutine(def_id, args, movability) => {
DefiningTy::Coroutine(def_id, args, movability)
}
ty::FnDef(def_id, args) => DefiningTy::FnDef(def_id, args),
_ => span_bug!(
@ -621,7 +621,7 @@ fn compute_indices(
let identity_args = GenericArgs::identity_for_item(tcx, typeck_root_def_id);
let fr_args = match defining_ty {
DefiningTy::Closure(_, args)
| DefiningTy::Generator(_, args, _)
| DefiningTy::Coroutine(_, args, _)
| DefiningTy::InlineConst(_, args) => {
// In the case of closures, we rely on the fact that
// the first N elements in the ClosureArgs are
@ -686,7 +686,7 @@ fn compute_inputs_and_output(
)
}
DefiningTy::Generator(def_id, args, movability) => {
DefiningTy::Coroutine(def_id, args, movability) => {
assert_eq!(self.mir_def.to_def_id(), def_id);
let resume_ty = args.as_generator().resume_ty();
let output = args.as_generator().return_ty();

View file

@ -12,7 +12,7 @@
use std::arch::x86_64::*;
use std::hint::black_box;
use std::io::Write;
use std::ops::Generator;
use std::ops::Coroutine;
fn main() {
println!("{:?}", std::env::args().collect::<Vec<_>>());

View file

@ -157,7 +157,7 @@ rm -r tests/run-make/compressed-debuginfo
rm -r tests/run-make/extern-fn-explicit-align # argument alignment not yet supported
rm tests/ui/codegen/subtyping-enforces-type-equality.rs # assert_assignable bug with Generator's
rm tests/ui/codegen/subtyping-enforces-type-equality.rs # assert_assignable bug with Coroutine's
# bugs in the test suite
# ======================

View file

@ -478,7 +478,7 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
TerminatorKind::Yield { .. }
| TerminatorKind::FalseEdge { .. }
| TerminatorKind::FalseUnwind { .. }
| TerminatorKind::GeneratorDrop => {
| TerminatorKind::CoroutineDrop => {
bug!("shouldn't exist at codegen {:?}", bb_data.terminator());
}
TerminatorKind::Drop { place, target, unwind: _, replace: _ } => {

View file

@ -510,7 +510,7 @@ pub(crate) fn mir_operand_get_const_val<'tcx>(
| TerminatorKind::Drop { .. }
| TerminatorKind::Assert { .. } => {}
TerminatorKind::Yield { .. }
| TerminatorKind::GeneratorDrop
| TerminatorKind::CoroutineDrop
| TerminatorKind::FalseEdge { .. }
| TerminatorKind::FalseUnwind { .. } => unreachable!(),
TerminatorKind::InlineAsm { .. } => return None,

View file

@ -3,7 +3,7 @@
#[cfg(feature="master")]
use std::arch::x86_64::*;
use std::io::Write;
use std::ops::Generator;
use std::ops::Coroutine;
extern {
pub fn printf(format: *const i8, ...) -> i32;

View file

@ -87,7 +87,7 @@ fn uncached_gcc_type<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, layout: TyAndLayout
// FIXME(eddyb) producing readable type names for trait objects can result
// in problematically distinct types due to HRTB and subtyping (see #47638).
// ty::Dynamic(..) |
ty::Adt(..) | ty::Closure(..) | ty::Foreign(..) | ty::Generator(..) | ty::Str
ty::Adt(..) | ty::Closure(..) | ty::Foreign(..) | ty::Coroutine(..) | ty::Str
if !cx.sess().fewer_names() =>
{
let mut name = with_no_trimmed_paths!(layout.ty.to_string());
@ -98,10 +98,10 @@ fn uncached_gcc_type<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, layout: TyAndLayout
write!(&mut name, "::{}", def.variant(index).name).unwrap();
}
}
if let (&ty::Generator(_, _, _), &Variants::Single { index }) =
if let (&ty::Coroutine(_, _, _), &Variants::Single { index }) =
(layout.ty.kind(), &layout.variants)
{
write!(&mut name, "::{}", ty::GeneratorArgs::variant_name(index)).unwrap();
write!(&mut name, "::{}", ty::CoroutineArgs::variant_name(index)).unwrap();
}
Some(name)
}

View file

@ -313,7 +313,7 @@ fn add_unused_functions(cx: &CodegenCx<'_, '_>) {
// generic functions from consideration as well.
if !matches!(
kind,
DefKind::Fn | DefKind::AssocFn | DefKind::Closure | DefKind::Generator
DefKind::Fn | DefKind::AssocFn | DefKind::Closure | DefKind::Coroutine
) {
return None;
}

View file

@ -460,7 +460,7 @@ pub fn type_di_node<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll D
}
ty::FnDef(..) | ty::FnPtr(_) => build_subroutine_type_di_node(cx, unique_type_id),
ty::Closure(..) => build_closure_env_di_node(cx, unique_type_id),
ty::Generator(..) => enums::build_generator_di_node(cx, unique_type_id),
ty::Coroutine(..) => enums::build_generator_di_node(cx, unique_type_id),
ty::Adt(def, ..) => match def.adt_kind() {
AdtKind::Struct => build_struct_type_di_node(cx, unique_type_id),
AdtKind::Union => build_union_type_di_node(cx, unique_type_id),
@ -1034,7 +1034,7 @@ fn build_upvar_field_di_nodes<'ll, 'tcx>(
closure_or_generator_di_node: &'ll DIType,
) -> SmallVec<&'ll DIType> {
let (&def_id, up_var_tys) = match closure_or_generator_ty.kind() {
ty::Generator(def_id, args, _) => (def_id, args.as_generator().prefix_tys()),
ty::Coroutine(def_id, args, _) => (def_id, args.as_generator().prefix_tys()),
ty::Closure(def_id, args) => (def_id, args.as_closure().upvar_tys()),
_ => {
bug!(

View file

@ -12,7 +12,7 @@
ty::{
self,
layout::{LayoutOf, TyAndLayout},
AdtDef, GeneratorArgs, Ty,
AdtDef, CoroutineArgs, Ty,
},
};
use rustc_target::abi::{Align, Endian, Size, TagEncoding, VariantIdx, Variants};
@ -674,7 +674,7 @@ fn build_union_fields_for_direct_tag_generator<'ll, 'tcx>(
};
let (generator_def_id, generator_args) = match generator_type_and_layout.ty.kind() {
&ty::Generator(def_id, args, _) => (def_id, args.as_generator()),
&ty::Coroutine(def_id, args, _) => (def_id, args.as_generator()),
_ => unreachable!(),
};
@ -691,7 +691,7 @@ fn build_union_fields_for_direct_tag_generator<'ll, 'tcx>(
generator_type_di_node,
variant_range
.clone()
.map(|variant_index| (variant_index, GeneratorArgs::variant_name(variant_index))),
.map(|variant_index| (variant_index, CoroutineArgs::variant_name(variant_index))),
);
let discriminants: IndexVec<VariantIdx, DiscrResult> = {

View file

@ -6,11 +6,11 @@
use rustc_index::IndexSlice;
use rustc_middle::{
bug,
mir::GeneratorLayout,
mir::CoroutineLayout,
ty::{
self,
layout::{IntegerExt, LayoutOf, PrimitiveExt, TyAndLayout},
AdtDef, GeneratorArgs, Ty, VariantDef,
AdtDef, CoroutineArgs, Ty, VariantDef,
},
};
use rustc_span::Symbol;
@ -107,7 +107,7 @@ fn tag_base_type<'ll, 'tcx>(
enum_type_and_layout: TyAndLayout<'tcx>,
) -> Ty<'tcx> {
debug_assert!(match enum_type_and_layout.ty.kind() {
ty::Generator(..) => true,
ty::Coroutine(..) => true,
ty::Adt(adt_def, _) => adt_def.is_enum(),
_ => false,
});
@ -322,10 +322,10 @@ pub fn build_generator_variant_struct_type_di_node<'ll, 'tcx>(
variant_index: VariantIdx,
generator_type_and_layout: TyAndLayout<'tcx>,
generator_type_di_node: &'ll DIType,
generator_layout: &GeneratorLayout<'tcx>,
generator_layout: &CoroutineLayout<'tcx>,
common_upvar_names: &IndexSlice<FieldIdx, Symbol>,
) -> &'ll DIType {
let variant_name = GeneratorArgs::variant_name(variant_index);
let variant_name = CoroutineArgs::variant_name(variant_index);
let unique_type_id = UniqueTypeId::for_enum_variant_struct_type(
cx.tcx,
generator_type_and_layout.ty,
@ -335,7 +335,7 @@ pub fn build_generator_variant_struct_type_di_node<'ll, 'tcx>(
let variant_layout = generator_type_and_layout.for_variant(cx, variant_index);
let generator_args = match generator_type_and_layout.ty.kind() {
ty::Generator(_, args, _) => args.as_generator(),
ty::Coroutine(_, args, _) => args.as_generator(),
_ => unreachable!(),
};

View file

@ -132,7 +132,7 @@ pub(super) fn build_generator_di_node<'ll, 'tcx>(
unique_type_id: UniqueTypeId<'tcx>,
) -> DINodeCreationResult<'ll> {
let generator_type = unique_type_id.expect_ty();
let &ty::Generator(generator_def_id, _, _) = generator_type.kind() else {
let &ty::Coroutine(generator_def_id, _, _) = generator_type.kind() else {
bug!("build_generator_di_node() called with non-generator type: `{:?}`", generator_type)
};
@ -175,7 +175,7 @@ pub(super) fn build_generator_di_node<'ll, 'tcx>(
.indices()
.map(|variant_index| {
// FIXME: This is problematic because just a number is not a valid identifier.
// GeneratorArgs::variant_name(variant_index), would be consistent
// CoroutineArgs::variant_name(variant_index), would be consistent
// with enums?
let variant_name = format!("{}", variant_index.as_usize()).into();
@ -310,7 +310,7 @@ fn build_discr_member_di_node<'ll, 'tcx>(
enum_or_generator_type_di_node: &'ll DIType,
) -> Option<&'ll DIType> {
let tag_name = match enum_or_generator_type_and_layout.ty.kind() {
ty::Generator(..) => "__state",
ty::Coroutine(..) => "__state",
_ => "",
};

View file

@ -42,7 +42,7 @@ fn uncached_llvm_type<'a, 'tcx>(
// FIXME(eddyb) producing readable type names for trait objects can result
// in problematically distinct types due to HRTB and subtyping (see #47638).
// ty::Dynamic(..) |
ty::Adt(..) | ty::Closure(..) | ty::Foreign(..) | ty::Generator(..) | ty::Str
ty::Adt(..) | ty::Closure(..) | ty::Foreign(..) | ty::Coroutine(..) | ty::Str
// For performance reasons we use names only when emitting LLVM IR.
if !cx.sess().fewer_names() =>
{
@ -54,10 +54,10 @@ fn uncached_llvm_type<'a, 'tcx>(
write!(&mut name, "::{}", def.variant(index).name).unwrap();
}
}
if let (&ty::Generator(_, _, _), &Variants::Single { index }) =
if let (&ty::Coroutine(_, _, _), &Variants::Single { index }) =
(layout.ty.kind(), &layout.variants)
{
write!(&mut name, "::{}", ty::GeneratorArgs::variant_name(index)).unwrap();
write!(&mut name, "::{}", ty::CoroutineArgs::variant_name(index)).unwrap();
}
Some(name)
}

View file

@ -15,7 +15,7 @@
use rustc_data_structures::stable_hasher::{Hash64, HashStable, StableHasher};
use rustc_hir::def_id::DefId;
use rustc_hir::definitions::{DefPathData, DefPathDataName, DisambiguatedDefPathData};
use rustc_hir::{AsyncGeneratorKind, GeneratorKind, Mutability};
use rustc_hir::{AsyncCoroutineKind, CoroutineKind, Mutability};
use rustc_middle::ty::layout::{IntegerExt, TyAndLayout};
use rustc_middle::ty::{self, ExistentialProjection, ParamEnv, Ty, TyCtxt};
use rustc_middle::ty::{GenericArgKind, GenericArgsRef};
@ -398,7 +398,7 @@ fn push_debuginfo_type_name<'tcx>(
// processing
visited.remove(&t);
}
ty::Closure(def_id, args) | ty::Generator(def_id, args, ..) => {
ty::Closure(def_id, args) | ty::Coroutine(def_id, args, ..) => {
// Name will be "{closure_env#0}<T1, T2, ...>", "{generator_env#0}<T1, T2, ...>", or
// "{async_fn_env#0}<T1, T2, ...>", etc.
// In the case of cpp-like debuginfo, the name additionally gets wrapped inside of
@ -426,7 +426,7 @@ fn push_debuginfo_type_name<'tcx>(
| ty::Placeholder(..)
| ty::Alias(..)
| ty::Bound(..)
| ty::GeneratorWitness(..) => {
| ty::CoroutineWitness(..) => {
bug!(
"debuginfo: Trying to create type name for \
unexpected type: {:?}",
@ -558,12 +558,12 @@ pub fn push_item_name(tcx: TyCtxt<'_>, def_id: DefId, qualified: bool, output: &
push_unqualified_item_name(tcx, def_id, def_key.disambiguated_data, output);
}
fn generator_kind_label(generator_kind: Option<GeneratorKind>) -> &'static str {
fn generator_kind_label(generator_kind: Option<CoroutineKind>) -> &'static str {
match generator_kind {
Some(GeneratorKind::Async(AsyncGeneratorKind::Block)) => "async_block",
Some(GeneratorKind::Async(AsyncGeneratorKind::Closure)) => "async_closure",
Some(GeneratorKind::Async(AsyncGeneratorKind::Fn)) => "async_fn",
Some(GeneratorKind::Gen) => "generator",
Some(CoroutineKind::Async(AsyncCoroutineKind::Block)) => "async_block",
Some(CoroutineKind::Async(AsyncCoroutineKind::Closure)) => "async_closure",
Some(CoroutineKind::Async(AsyncCoroutineKind::Fn)) => "async_fn",
Some(CoroutineKind::Gen) => "generator",
None => "closure",
}
}

View file

@ -272,7 +272,7 @@ fn discover_masters<'tcx>(
| TerminatorKind::UnwindResume
| TerminatorKind::UnwindTerminate(_)
| TerminatorKind::Return
| TerminatorKind::GeneratorDrop
| TerminatorKind::CoroutineDrop
| TerminatorKind::Unreachable
| TerminatorKind::SwitchInt { .. }
| TerminatorKind::Yield { .. }

View file

@ -1265,7 +1265,7 @@ fn codegen_terminator(
fn_span,
mergeable_succ(),
),
mir::TerminatorKind::GeneratorDrop | mir::TerminatorKind::Yield { .. } => {
mir::TerminatorKind::CoroutineDrop | mir::TerminatorKind::Yield { .. } => {
bug!("generator ops in codegen")
}
mir::TerminatorKind::FalseEdge { .. } | mir::TerminatorKind::FalseUnwind { .. } => {

View file

@ -151,8 +151,8 @@ pub(crate) fn const_to_valtree_inner<'tcx>(
| ty::Infer(_)
// FIXME(oli-obk): we can probably encode closures just like structs
| ty::Closure(..)
| ty::Generator(..)
| ty::GeneratorWitness(..) => Err(ValTreeCreationError::NonSupportedType),
| ty::Coroutine(..)
| ty::CoroutineWitness(..) => Err(ValTreeCreationError::NonSupportedType),
}
}
@ -278,8 +278,8 @@ pub fn valtree_to_const_value<'tcx>(
| ty::Placeholder(..)
| ty::Infer(_)
| ty::Closure(..)
| ty::Generator(..)
| ty::GeneratorWitness(..)
| ty::Coroutine(..)
| ty::CoroutineWitness(..)
| ty::FnPtr(_)
| ty::RawPtr(_)
| ty::Str

View file

@ -170,7 +170,7 @@ pub fn read_discriminant(
ty::Adt(adt, _) => {
adt.discriminants(*self.tcx).find(|(_, var)| var.val == discr_bits)
}
ty::Generator(def_id, args, _) => {
ty::Coroutine(def_id, args, _) => {
let args = args.as_generator();
args.discriminants(def_id, *self.tcx).find(|(_, var)| var.val == discr_bits)
}

View file

@ -963,8 +963,8 @@ fn is_very_trivially_sized(ty: Ty<'_>) -> bool {
| ty::RawPtr(..)
| ty::Char
| ty::Ref(..)
| ty::Generator(..)
| ty::GeneratorWitness(..)
| ty::Coroutine(..)
| ty::CoroutineWitness(..)
| ty::Array(..)
| ty::Closure(..)
| ty::Never

View file

@ -99,8 +99,8 @@ pub(crate) fn eval_nullary_intrinsic<'tcx>(
| ty::FnPtr(_)
| ty::Dynamic(_, _, _)
| ty::Closure(_, _)
| ty::Generator(_, _, _)
| ty::GeneratorWitness(..)
| ty::Coroutine(_, _, _)
| ty::CoroutineWitness(..)
| ty::Never
| ty::Tuple(_)
| ty::Error(_) => ConstValue::from_target_usize(0u64, &tcx),

View file

@ -218,7 +218,7 @@ pub(super) fn eval_terminator(
Unreachable => throw_ub!(Unreachable),
// These should never occur for MIR we actually run.
FalseEdge { .. } | FalseUnwind { .. } | Yield { .. } | GeneratorDrop => span_bug!(
FalseEdge { .. } | FalseUnwind { .. } | Yield { .. } | CoroutineDrop => span_bug!(
terminator.source_info.span,
"{:#?} should have been eliminated by MIR pass",
terminator.kind

View file

@ -34,7 +34,7 @@ fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
match *ty.kind() {
ty::Param(_) => ControlFlow::Break(FoundParam),
ty::Closure(def_id, args)
| ty::Generator(def_id, args, ..)
| ty::Coroutine(def_id, args, ..)
| ty::FnDef(def_id, args) => {
let instance = ty::InstanceDef::Item(def_id);
let unused_params = self.tcx.unused_generic_params(instance);

View file

@ -112,13 +112,13 @@ macro_rules! try_validation {
pub enum PathElem {
Field(Symbol),
Variant(Symbol),
GeneratorState(VariantIdx),
CoroutineState(VariantIdx),
CapturedVar(Symbol),
ArrayElem(usize),
TupleElem(usize),
Deref,
EnumTag,
GeneratorTag,
CoroutineTag,
DynDowncast,
}
@ -171,8 +171,8 @@ fn write_path(out: &mut String, path: &[PathElem]) {
Field(name) => write!(out, ".{name}"),
EnumTag => write!(out, ".<enum-tag>"),
Variant(name) => write!(out, ".<enum-variant({name})>"),
GeneratorTag => write!(out, ".<generator-tag>"),
GeneratorState(idx) => write!(out, ".<generator-state({})>", idx.index()),
CoroutineTag => write!(out, ".<generator-tag>"),
CoroutineState(idx) => write!(out, ".<generator-state({})>", idx.index()),
CapturedVar(name) => write!(out, ".<captured-var({name})>"),
TupleElem(idx) => write!(out, ".{idx}"),
ArrayElem(idx) => write!(out, "[{idx}]"),
@ -206,7 +206,7 @@ fn aggregate_field_path_elem(&mut self, layout: TyAndLayout<'tcx>, field: usize)
if tag_field == field {
return match layout.ty.kind() {
ty::Adt(def, ..) if def.is_enum() => PathElem::EnumTag,
ty::Generator(..) => PathElem::GeneratorTag,
ty::Coroutine(..) => PathElem::CoroutineTag,
_ => bug!("non-variant type {:?}", layout.ty),
};
}
@ -217,7 +217,7 @@ fn aggregate_field_path_elem(&mut self, layout: TyAndLayout<'tcx>, field: usize)
// Now we know we are projecting to a field, so figure out which one.
match layout.ty.kind() {
// generators and closures.
ty::Closure(def_id, _) | ty::Generator(def_id, _, _) => {
ty::Closure(def_id, _) | ty::Coroutine(def_id, _, _) => {
let mut name = None;
// FIXME this should be more descriptive i.e. CapturePlace instead of CapturedVar
// https://github.com/rust-lang/project-rfc-2229/issues/46
@ -580,7 +580,7 @@ fn try_visit_primitive(
| ty::Str
| ty::Dynamic(..)
| ty::Closure(..)
| ty::Generator(..) => Ok(false),
| ty::Coroutine(..) => Ok(false),
// Some types only occur during typechecking, they have no layout.
// We should not see them here and we could not check them anyway.
ty::Error(_)
@ -589,7 +589,7 @@ fn try_visit_primitive(
| ty::Bound(..)
| ty::Param(..)
| ty::Alias(..)
| ty::GeneratorWitness(..) => bug!("Encountered invalid type {:?}", ty),
| ty::CoroutineWitness(..) => bug!("Encountered invalid type {:?}", ty),
}
}
@ -692,8 +692,8 @@ fn visit_variant(
) -> InterpResult<'tcx> {
let name = match old_op.layout.ty.kind() {
ty::Adt(adt, _) => PathElem::Variant(adt.variant(variant_id).name),
// Generators also have variants
ty::Generator(..) => PathElem::GeneratorState(variant_id),
// Coroutines also have variants
ty::Coroutine(..) => PathElem::CoroutineState(variant_id),
_ => bug!("Unexpected type with variant: {:?}", old_op.layout.ty),
};
self.with_elem(name, move |this| this.visit_value(new_op))

View file

@ -463,11 +463,11 @@ fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) {
| Rvalue::Len(_) => {}
Rvalue::Aggregate(kind, ..) => {
if let AggregateKind::Generator(def_id, ..) = kind.as_ref()
&& let Some(generator_kind @ hir::GeneratorKind::Async(..)) =
if let AggregateKind::Coroutine(def_id, ..) = kind.as_ref()
&& let Some(generator_kind @ hir::CoroutineKind::Async(..)) =
self.tcx.generator_kind(def_id)
{
self.check_op(ops::Generator(generator_kind));
self.check_op(ops::Coroutine(generator_kind));
}
}
@ -1042,8 +1042,8 @@ fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location
TerminatorKind::InlineAsm { .. } => self.check_op(ops::InlineAsm),
TerminatorKind::GeneratorDrop | TerminatorKind::Yield { .. } => {
self.check_op(ops::Generator(hir::GeneratorKind::Gen))
TerminatorKind::CoroutineDrop | TerminatorKind::Yield { .. } => {
self.check_op(ops::Coroutine(hir::CoroutineKind::Gen))
}
TerminatorKind::UnwindTerminate(_) => {

View file

@ -357,10 +357,10 @@ fn build_error(
}
#[derive(Debug)]
pub struct Generator(pub hir::GeneratorKind);
impl<'tcx> NonConstOp<'tcx> for Generator {
pub struct Coroutine(pub hir::CoroutineKind);
impl<'tcx> NonConstOp<'tcx> for Coroutine {
fn status_in_item(&self, _: &ConstCx<'_, 'tcx>) -> Status {
if let hir::GeneratorKind::Async(hir::AsyncGeneratorKind::Block) = self.0 {
if let hir::CoroutineKind::Async(hir::AsyncCoroutineKind::Block) = self.0 {
Status::Unstable(sym::const_async_blocks)
} else {
Status::Forbidden
@ -373,7 +373,7 @@ fn build_error(
span: Span,
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let msg = format!("{}s are not allowed in {}s", self.0.descr(), ccx.const_kind());
if let hir::GeneratorKind::Async(hir::AsyncGeneratorKind::Block) = self.0 {
if let hir::CoroutineKind::Async(hir::AsyncCoroutineKind::Block) = self.0 {
ccx.tcx.sess.create_feature_err(
errors::UnallowedOpInConstContext { span, msg },
sym::const_async_blocks,

View file

@ -111,7 +111,7 @@ fn visit_terminator(&mut self, terminator: &mir::Terminator<'tcx>, location: Loc
| mir::TerminatorKind::Assert { .. }
| mir::TerminatorKind::FalseEdge { .. }
| mir::TerminatorKind::FalseUnwind { .. }
| mir::TerminatorKind::GeneratorDrop
| mir::TerminatorKind::CoroutineDrop
| mir::TerminatorKind::Goto { .. }
| mir::TerminatorKind::InlineAsm { .. }
| mir::TerminatorKind::UnwindResume

View file

@ -67,7 +67,7 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
let body_abi = match body_ty.kind() {
ty::FnDef(..) => body_ty.fn_sig(tcx).abi(),
ty::Closure(..) => Abi::RustCall,
ty::Generator(..) => Abi::Rust,
ty::Coroutine(..) => Abi::Rust,
_ => {
span_bug!(body.span, "unexpected body ty: {:?} phase {:?}", body_ty, mir_phase)
}
@ -509,14 +509,14 @@ fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location
}
self.check_unwind_edge(location, *unwind);
}
TerminatorKind::GeneratorDrop => {
TerminatorKind::CoroutineDrop => {
if self.body.generator.is_none() {
self.fail(location, "`GeneratorDrop` cannot appear outside generator bodies");
self.fail(location, "`CoroutineDrop` cannot appear outside generator bodies");
}
if self.mir_phase >= MirPhase::Runtime(RuntimePhase::Initial) {
self.fail(
location,
"`GeneratorDrop` should have been replaced by generator lowering",
"`CoroutineDrop` should have been replaced by generator lowering",
);
}
}
@ -716,7 +716,7 @@ fn visit_projection_elem(
};
check_equal(self, location, f_ty);
}
&ty::Generator(def_id, args, _) => {
&ty::Coroutine(def_id, args, _) => {
let f_ty = if let Some(var) = parent_ty.variant_index {
let gen_body = if def_id == self.body.source.def_id() {
self.body
@ -1211,7 +1211,7 @@ fn visit_statement(&mut self, statement: &Statement<'tcx>, location: Location) {
self.fail(location, "`SetDiscriminant`is not allowed until deaggregation");
}
let pty = place.ty(&self.body.local_decls, self.tcx).ty.kind();
if !matches!(pty, ty::Adt(..) | ty::Generator(..) | ty::Alias(ty::Opaque, ..)) {
if !matches!(pty, ty::Adt(..) | ty::Coroutine(..) | ty::Alias(ty::Opaque, ..)) {
self.fail(
location,
format!(
@ -1295,7 +1295,7 @@ fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location
| TerminatorKind::FalseEdge { .. }
| TerminatorKind::FalseUnwind { .. }
| TerminatorKind::InlineAsm { .. }
| TerminatorKind::GeneratorDrop
| TerminatorKind::CoroutineDrop
| TerminatorKind::UnwindResume
| TerminatorKind::UnwindTerminate(_)
| TerminatorKind::Return

View file

@ -51,12 +51,12 @@ fn print_type(mut self, ty: Ty<'tcx>) -> Result<Self, PrintError> {
| ty::FnDef(def_id, args)
| ty::Alias(ty::Projection | ty::Opaque, ty::AliasTy { def_id, args, .. })
| ty::Closure(def_id, args)
| ty::Generator(def_id, args, _) => self.print_def_path(def_id, args),
| ty::Coroutine(def_id, args, _) => self.print_def_path(def_id, args),
ty::Foreign(def_id) => self.print_def_path(def_id, &[]),
ty::Alias(ty::Weak, _) => bug!("type_name: unexpected weak projection"),
ty::Alias(ty::Inherent, _) => bug!("type_name: unexpected inherent projection"),
ty::GeneratorWitness(..) => bug!("type_name: unexpected `GeneratorWitness`"),
ty::CoroutineWitness(..) => bug!("type_name: unexpected `CoroutineWitness`"),
}
}

View file

@ -5,7 +5,7 @@ Erroneous code example:
```compile_fail,E0626
# #![feature(generators, generator_trait, pin)]
# use std::ops::Generator;
# use std::ops::Coroutine;
# use std::pin::Pin;
let mut b = || {
let a = &String::new(); // <-- This borrow...
@ -24,7 +24,7 @@ the integer by value:
```
# #![feature(generators, generator_trait, pin)]
# use std::ops::Generator;
# use std::ops::Coroutine;
# use std::pin::Pin;
let mut b = || {
let a = 3;
@ -42,7 +42,7 @@ This error also frequently arises with iteration:
```compile_fail,E0626
# #![feature(generators, generator_trait, pin)]
# use std::ops::Generator;
# use std::ops::Coroutine;
# use std::pin::Pin;
let mut b = || {
let v = vec![1,2,3];
@ -58,7 +58,7 @@ Such cases can sometimes be resolved by iterating "by value" (or using
```
# #![feature(generators, generator_trait, pin)]
# use std::ops::Generator;
# use std::ops::Coroutine;
# use std::pin::Pin;
let mut b = || {
let v = vec![1,2,3];
@ -73,7 +73,7 @@ If taking ownership is not an option, using indices can work too:
```
# #![feature(generators, generator_trait, pin)]
# use std::ops::Generator;
# use std::ops::Coroutine;
# use std::pin::Pin;
let mut b = || {
let v = vec![1,2,3];

View file

@ -4,24 +4,24 @@ method.
Erroneous code example:
```compile_fail,E0790
trait Generator {
trait Coroutine {
fn create() -> u32;
}
struct Impl;
impl Generator for Impl {
impl Coroutine for Impl {
fn create() -> u32 { 1 }
}
struct AnotherImpl;
impl Generator for AnotherImpl {
impl Coroutine for AnotherImpl {
fn create() -> u32 { 2 }
}
let cont: u32 = Generator::create();
// error, impossible to choose one of Generator trait implementation
let cont: u32 = Coroutine::create();
// error, impossible to choose one of Coroutine trait implementation
// Should it be Impl or AnotherImpl, maybe something else?
```
@ -30,18 +30,18 @@ information to the compiler. In this case, the solution is to use a concrete
type:
```
trait Generator {
trait Coroutine {
fn create() -> u32;
}
struct AnotherImpl;
impl Generator for AnotherImpl {
impl Coroutine for AnotherImpl {
fn create() -> u32 { 2 }
}
let gen1 = AnotherImpl::create();
// if there are multiple methods with same name (different traits)
let gen2 = <AnotherImpl as Generator>::create();
let gen2 = <AnotherImpl as Coroutine>::create();
```

View file

@ -118,7 +118,7 @@ pub enum DefKind {
of_trait: bool,
},
Closure,
Generator,
Coroutine,
}
impl DefKind {
@ -161,7 +161,7 @@ pub fn descr(self, def_id: DefId) -> &'static str {
DefKind::Field => "field",
DefKind::Impl { .. } => "implementation",
DefKind::Closure => "closure",
DefKind::Generator => "generator",
DefKind::Coroutine => "generator",
DefKind::ExternCrate => "extern crate",
DefKind::GlobalAsm => "global assembly block",
}
@ -220,7 +220,7 @@ pub fn ns(&self) -> Option<Namespace> {
| DefKind::LifetimeParam
| DefKind::ExternCrate
| DefKind::Closure
| DefKind::Generator
| DefKind::Coroutine
| DefKind::Use
| DefKind::ForeignMod
| DefKind::GlobalAsm
@ -230,7 +230,7 @@ pub fn ns(&self) -> Option<Namespace> {
#[inline]
pub fn is_fn_like(self) -> bool {
matches!(self, DefKind::Fn | DefKind::AssocFn | DefKind::Closure | DefKind::Generator)
matches!(self, DefKind::Fn | DefKind::AssocFn | DefKind::Closure | DefKind::Coroutine)
}
/// Whether `query get_codegen_attrs` should be used with this definition.
@ -240,7 +240,7 @@ pub fn has_codegen_attrs(self) -> bool {
| DefKind::AssocFn
| DefKind::Ctor(..)
| DefKind::Closure
| DefKind::Generator
| DefKind::Coroutine
| DefKind::Static(_) => true,
DefKind::Mod
| DefKind::Struct

View file

@ -1493,7 +1493,7 @@ pub struct BodyId {
pub struct Body<'hir> {
pub params: &'hir [Param<'hir>],
pub value: &'hir Expr<'hir>,
pub generator_kind: Option<GeneratorKind>,
pub generator_kind: Option<CoroutineKind>,
}
impl<'hir> Body<'hir> {
@ -1501,7 +1501,7 @@ pub fn id(&self) -> BodyId {
BodyId { hir_id: self.value.hir_id }
}
pub fn generator_kind(&self) -> Option<GeneratorKind> {
pub fn generator_kind(&self) -> Option<CoroutineKind> {
self.generator_kind
}
}
@ -1509,28 +1509,28 @@ pub fn generator_kind(&self) -> Option<GeneratorKind> {
/// The type of source expression that caused this generator to be created.
#[derive(Clone, PartialEq, Eq, Debug, Copy, Hash)]
#[derive(HashStable_Generic, Encodable, Decodable)]
pub enum GeneratorKind {
pub enum CoroutineKind {
/// An explicit `async` block or the body of an async function.
Async(AsyncGeneratorKind),
Async(AsyncCoroutineKind),
/// A generator literal created via a `yield` inside a closure.
Gen,
}
impl fmt::Display for GeneratorKind {
impl fmt::Display for CoroutineKind {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
GeneratorKind::Async(k) => fmt::Display::fmt(k, f),
GeneratorKind::Gen => f.write_str("generator"),
CoroutineKind::Async(k) => fmt::Display::fmt(k, f),
CoroutineKind::Gen => f.write_str("generator"),
}
}
}
impl GeneratorKind {
impl CoroutineKind {
pub fn descr(&self) -> &'static str {
match self {
GeneratorKind::Async(ask) => ask.descr(),
GeneratorKind::Gen => "generator",
CoroutineKind::Async(ask) => ask.descr(),
CoroutineKind::Gen => "generator",
}
}
}
@ -1542,7 +1542,7 @@ pub fn descr(&self) -> &'static str {
/// type-checking (see #60424).
#[derive(Clone, PartialEq, Eq, Hash, Debug, Copy)]
#[derive(HashStable_Generic, Encodable, Decodable)]
pub enum AsyncGeneratorKind {
pub enum AsyncCoroutineKind {
/// An explicit `async` block written by the user.
Block,
@ -1553,22 +1553,22 @@ pub enum AsyncGeneratorKind {
Fn,
}
impl fmt::Display for AsyncGeneratorKind {
impl fmt::Display for AsyncCoroutineKind {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(match self {
AsyncGeneratorKind::Block => "async block",
AsyncGeneratorKind::Closure => "async closure body",
AsyncGeneratorKind::Fn => "async fn body",
AsyncCoroutineKind::Block => "async block",
AsyncCoroutineKind::Closure => "async closure body",
AsyncCoroutineKind::Fn => "async fn body",
})
}
}
impl AsyncGeneratorKind {
impl AsyncCoroutineKind {
pub fn descr(&self) -> &'static str {
match self {
AsyncGeneratorKind::Block => "`async` block",
AsyncGeneratorKind::Closure => "`async` closure body",
AsyncGeneratorKind::Fn => "`async fn` body",
AsyncCoroutineKind::Block => "`async` block",
AsyncCoroutineKind::Closure => "`async` closure body",
AsyncCoroutineKind::Fn => "`async fn` body",
}
}
}
@ -2247,12 +2247,12 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
}
}
impl From<GeneratorKind> for YieldSource {
fn from(kind: GeneratorKind) -> Self {
impl From<CoroutineKind> for YieldSource {
fn from(kind: CoroutineKind) -> Self {
match kind {
// Guess based on the kind of the current generator.
GeneratorKind::Gen => Self::Yield,
GeneratorKind::Async(_) => Self::Await { expr: None },
CoroutineKind::Gen => Self::Yield,
CoroutineKind::Async(_) => Self::Await { expr: None },
}
}
}

View file

@ -211,8 +211,8 @@ pub fn extract(attrs: &[ast::Attribute]) -> Option<(Symbol, Span)> {
FnOnceOutput, sym::fn_once_output, fn_once_output, Target::AssocTy, GenericRequirement::None;
Future, sym::future_trait, future_trait, Target::Trait, GenericRequirement::Exact(0);
GeneratorState, sym::generator_state, gen_state, Target::Enum, GenericRequirement::None;
Generator, sym::generator, gen_trait, Target::Trait, GenericRequirement::Minimum(1);
CoroutineState, sym::generator_state, gen_state, Target::Enum, GenericRequirement::None;
Coroutine, sym::generator, gen_trait, Target::Trait, GenericRequirement::Minimum(1);
Unpin, sym::unpin, unpin_trait, Target::Trait, GenericRequirement::None;
Pin, sym::pin, pin_type, Target::Struct, GenericRequirement::None;

View file

@ -1394,7 +1394,7 @@ fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
self.opaques.push(def);
ControlFlow::Continue(())
}
ty::Closure(def_id, ..) | ty::Generator(def_id, ..) => {
ty::Closure(def_id, ..) | ty::Coroutine(def_id, ..) => {
self.closures.push(def_id);
t.super_visit_with(self)
}
@ -1447,7 +1447,7 @@ fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
label_match(capture.place.ty(), capture.get_path_span(tcx));
}
// Label any generator locals that capture the opaque
if let DefKind::Generator = tcx.def_kind(closure_def_id)
if let DefKind::Coroutine = tcx.def_kind(closure_def_id)
&& let Some(generator_layout) = tcx.mir_generator_witnesses(closure_def_id)
{
for interior_ty in &generator_layout.field_tys {
@ -1465,7 +1465,7 @@ fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
}
pub(super) fn check_generator_obligations(tcx: TyCtxt<'_>, def_id: LocalDefId) {
debug_assert!(matches!(tcx.def_kind(def_id), DefKind::Generator));
debug_assert!(matches!(tcx.def_kind(def_id), DefKind::Coroutine));
let typeck = tcx.typeck(def_id);
let param_env = tcx.param_env(def_id);
@ -1500,7 +1500,7 @@ pub(super) fn check_generator_obligations(tcx: TyCtxt<'_>, def_id: LocalDefId) {
ObligationCause::new(
field_ty.source_info.span,
def_id,
ObligationCauseCode::SizedGeneratorInterior(def_id),
ObligationCauseCode::SizedCoroutineInterior(def_id),
),
);
}

View file

@ -155,8 +155,8 @@ fn check_item(&mut self, id: hir::ItemId) {
}
ty::FnDef(..)
| ty::Closure(..)
| ty::Generator(..)
| ty::GeneratorWitness(..)
| ty::Coroutine(..)
| ty::CoroutineWitness(..)
| ty::Bound(..)
| ty::Placeholder(_)
| ty::Infer(_) => {

View file

@ -243,8 +243,8 @@ enum NonlocalImpl {
| ty::Tuple(..) => (LocalImpl::Allow, NonlocalImpl::DisallowOther),
ty::Closure(..)
| ty::Generator(..)
| ty::GeneratorWitness(..)
| ty::Coroutine(..)
| ty::CoroutineWitness(..)
| ty::Bound(..)
| ty::Placeholder(..)
| ty::Infer(..) => {

View file

@ -1548,7 +1548,7 @@ fn compute_sig_of_foreign_fn_decl<'tcx>(
fty
}
fn generator_kind(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<hir::GeneratorKind> {
fn generator_kind(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<hir::CoroutineKind> {
match tcx.hir().get_by_def_id(def_id) {
Node::Expr(&rustc_hir::Expr {
kind: rustc_hir::ExprKind::Closure(&rustc_hir::Closure { body, .. }),

View file

@ -235,7 +235,7 @@ fn add_constraints_from_ty(
// leaf type -- noop
}
ty::FnDef(..) | ty::Generator(..) | ty::Closure(..) => {
ty::FnDef(..) | ty::Coroutine(..) | ty::Closure(..) => {
bug!("Unexpected closure type in variance computation");
}
@ -312,7 +312,7 @@ fn add_constraints_from_ty(
// types, where we use Error as the Self type
}
ty::Placeholder(..) | ty::GeneratorWitness(..) | ty::Bound(..) | ty::Infer(..) => {
ty::Placeholder(..) | ty::CoroutineWitness(..) | ty::Bound(..) | ty::Infer(..) => {
bug!("unexpected type encountered in variance inference: {}", ty);
}
}

View file

@ -305,7 +305,7 @@ fn identify_bad_closure_def_and_call(
) = (parent_node, callee_node)
{
let fn_decl_span = if hir.body(body).generator_kind
== Some(hir::GeneratorKind::Async(hir::AsyncGeneratorKind::Closure))
== Some(hir::CoroutineKind::Async(hir::AsyncCoroutineKind::Closure))
{
// Actually need to unwrap one more layer of HIR to get to
// the _real_ closure...

View file

@ -128,13 +128,13 @@ fn pointer_kind(
| ty::Uint(..)
| ty::Float(_)
| ty::Array(..)
| ty::GeneratorWitness(..)
| ty::CoroutineWitness(..)
| ty::RawPtr(_)
| ty::Ref(..)
| ty::FnDef(..)
| ty::FnPtr(..)
| ty::Closure(..)
| ty::Generator(..)
| ty::Coroutine(..)
| ty::Adt(..)
| ty::Never
| ty::Dynamic(_, _, ty::DynStar)

View file

@ -2,8 +2,8 @@
use crate::coercion::CoerceMany;
use crate::gather_locals::GatherLocalsVisitor;
use crate::CoroutineTypes;
use crate::FnCtxt;
use crate::GeneratorTypes;
use rustc_hir as hir;
use rustc_hir::def::DefKind;
use rustc_hir::intravisit::Visitor;
@ -33,7 +33,7 @@ pub(super) fn check_fn<'a, 'tcx>(
body: &'tcx hir::Body<'tcx>,
can_be_generator: Option<hir::Movability>,
params_can_be_unsized: bool,
) -> Option<GeneratorTypes<'tcx>> {
) -> Option<CoroutineTypes<'tcx>> {
let fn_id = fcx.tcx.hir().local_def_id_to_hir_id(fn_def_id);
let tcx = fcx.tcx;
@ -58,7 +58,7 @@ pub(super) fn check_fn<'a, 'tcx>(
if let Some(kind) = body.generator_kind
&& can_be_generator.is_some()
{
let yield_ty = if kind == hir::GeneratorKind::Gen {
let yield_ty = if kind == hir::CoroutineKind::Gen {
let yield_ty = fcx.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::TypeInference,
span,
@ -138,7 +138,7 @@ pub(super) fn check_fn<'a, 'tcx>(
));
let (resume_ty, yield_ty) = fcx.resume_yield_tys.unwrap();
Some(GeneratorTypes {
Some(CoroutineTypes {
resume_ty,
yield_ty,
interior,

View file

@ -1,6 +1,6 @@
//! Code for type-checking closure expressions.
use super::{check_fn, Expectation, FnCtxt, GeneratorTypes};
use super::{check_fn, CoroutineTypes, Expectation, FnCtxt};
use rustc_errors::ErrorGuaranteed;
use rustc_hir as hir;
@ -105,11 +105,11 @@ fn check_closure(
span: self.tcx.def_span(expr_def_id),
});
if let Some(GeneratorTypes { resume_ty, yield_ty, interior, movability }) = generator_types
if let Some(CoroutineTypes { resume_ty, yield_ty, interior, movability }) = generator_types
{
let generator_args = ty::GeneratorArgs::new(
let generator_args = ty::CoroutineArgs::new(
self.tcx,
ty::GeneratorArgsParts {
ty::CoroutineArgsParts {
parent_args,
resume_ty,
yield_ty,
@ -310,10 +310,10 @@ fn deduce_sig_from_projection(
return None;
}
// Check that we deduce the signature from the `<_ as std::ops::Generator>::Return`
// Check that we deduce the signature from the `<_ as std::ops::Coroutine>::Return`
// associated item and not yield.
if is_gen && self.tcx.associated_item(projection.projection_def_id()).name != sym::Return {
debug!("not `Return` assoc item of `Generator`");
debug!("not `Return` assoc item of `Coroutine`");
return None;
}
@ -327,7 +327,7 @@ fn deduce_sig_from_projection(
_ => return None,
}
} else {
// Generators with a `()` resume type may be defined with 0 or 1 explicit arguments,
// Coroutines with a `()` resume type may be defined with 0 or 1 explicit arguments,
// else they must have exactly 1 argument. For now though, just give up in this case.
return None;
};
@ -636,7 +636,7 @@ fn supplied_sig_of_closure(
// In the case of the async block that we create for a function body,
// we expect the return type of the block to match that of the enclosing
// function.
Some(hir::GeneratorKind::Async(hir::AsyncGeneratorKind::Fn)) => {
Some(hir::CoroutineKind::Async(hir::AsyncCoroutineKind::Fn)) => {
debug!("closure is async fn body");
let def_id = self.tcx.hir().body_owner_def_id(body.id());
self.deduce_future_output_from_obligations(expr_def_id, def_id).unwrap_or_else(

View file

@ -63,7 +63,7 @@ pub struct RustCallIncorrectArgs {
#[derive(Diagnostic)]
#[diag(hir_typeck_yield_expr_outside_of_generator, code = "E0627")]
pub struct YieldExprOutsideOfGenerator {
pub struct YieldExprOutsideOfCoroutine {
#[primary_span]
pub span: Span,
}

View file

@ -10,7 +10,7 @@
use crate::errors::{AddressOfTemporaryTaken, ReturnStmtOutsideOfFnBody, StructExprNonExhaustive};
use crate::errors::{
FieldMultiplySpecifiedInInitializer, FunctionalRecordUpdateOnNonStruct, HelpUseLatestEdition,
YieldExprOutsideOfGenerator,
YieldExprOutsideOfCoroutine,
};
use crate::fatally_break_rust;
use crate::method::{MethodCallComponents, SelfSource};
@ -3019,7 +3019,7 @@ fn check_expr_yield(
Ty::new_unit(self.tcx)
}
_ => {
self.tcx.sess.emit_err(YieldExprOutsideOfGenerator { span: expr.span });
self.tcx.sess.emit_err(YieldExprOutsideOfCoroutine { span: expr.span });
// Avoid expressions without types during writeback (#78653).
self.check_expr(value);
Ty::new_unit(self.tcx)

View file

@ -530,7 +530,7 @@ pub(in super::super) fn resolve_generator_interiors(&self, def_id: DefId) {
for &(expr_def_id, body_id, interior, _) in generators.iter() {
debug!(?expr_def_id);
// Create the `GeneratorWitness` type that we will unify with `interior`.
// Create the `CoroutineWitness` type that we will unify with `interior`.
let args = ty::GenericArgs::identity_for_item(
self.tcx,
self.tcx.typeck_root_def_id(expr_def_id.to_def_id()),

View file

@ -366,7 +366,7 @@ fn closure_span_overlaps_error(
box traits::SelectionOutputTypeParameterMismatch { expected_trait_ref, .. },
),
) = error.code
&& let ty::Closure(def_id, _) | ty::Generator(def_id, ..) =
&& let ty::Closure(def_id, _) | ty::Coroutine(def_id, ..) =
expected_trait_ref.skip_binder().self_ty().kind()
&& span.overlaps(self.tcx.def_span(*def_id))
{

View file

@ -9,7 +9,7 @@
use rustc_hir::def::{CtorKind, CtorOf, DefKind};
use rustc_hir::lang_items::LangItem;
use rustc_hir::{
AsyncGeneratorKind, Expr, ExprKind, GeneratorKind, GenericBound, HirId, Node, Path, QPath,
AsyncCoroutineKind, CoroutineKind, Expr, ExprKind, GenericBound, HirId, Node, Path, QPath,
Stmt, StmtKind, TyKind, WherePredicate,
};
use rustc_hir_analysis::astconv::AstConv;
@ -532,10 +532,10 @@ pub(in super::super) fn suggest_boxing_when_appropriate(
ty::Tuple(tuple) if tuple.is_empty() => {
errors::SuggestBoxing::Unit { start: span.shrink_to_lo(), end: span }
}
ty::Generator(def_id, ..)
ty::Coroutine(def_id, ..)
if matches!(
self.tcx.generator_kind(def_id),
Some(GeneratorKind::Async(AsyncGeneratorKind::Closure))
Some(CoroutineKind::Async(AsyncCoroutineKind::Closure))
) =>
{
errors::SuggestBoxing::AsyncBody

View file

@ -56,7 +56,7 @@ pub struct Inherited<'tcx> {
pub(super) deferred_asm_checks: RefCell<Vec<(&'tcx hir::InlineAsm<'tcx>, hir::HirId)>>,
pub(super) deferred_generator_interiors:
RefCell<Vec<(LocalDefId, hir::BodyId, Ty<'tcx>, hir::GeneratorKind)>>,
RefCell<Vec<(LocalDefId, hir::BodyId, Ty<'tcx>, hir::CoroutineKind)>>,
/// Whenever we introduce an adjustment from `!` into a type variable,
/// we record that type variable here. This is later used to inform

View file

@ -301,14 +301,14 @@ fn typeck_with_fallback<'tcx>(
/// When `check_fn` is invoked on a generator (i.e., a body that
/// includes yield), it returns back some information about the yield
/// points.
struct GeneratorTypes<'tcx> {
struct CoroutineTypes<'tcx> {
/// Type of generator argument / values returned by `yield`.
resume_ty: Ty<'tcx>,
/// Type of value that is yielded.
yield_ty: Ty<'tcx>,
/// Types that are captured (see `GeneratorInterior` for more).
/// Types that are captured (see `CoroutineInterior` for more).
interior: Ty<'tcx>,
/// Indicates if the generator is movable or static (immovable).

View file

@ -172,7 +172,7 @@ fn analyze_closure(
let ty = self.node_ty(closure_hir_id);
let (closure_def_id, args) = match *ty.kind() {
ty::Closure(def_id, args) => (def_id, UpvarArgs::Closure(args)),
ty::Generator(def_id, args, _) => (def_id, UpvarArgs::Generator(args)),
ty::Coroutine(def_id, args, _) => (def_id, UpvarArgs::Coroutine(args)),
ty::Error(_) => {
// #51714: skip analysis when we have already encountered type errors
return;

View file

@ -457,8 +457,8 @@ fn fold_ty(&mut self, mut t: Ty<'tcx>) -> Ty<'tcx> {
}
ty::Closure(..)
| ty::Generator(..)
| ty::GeneratorWitness(..)
| ty::Coroutine(..)
| ty::CoroutineWitness(..)
| ty::Bool
| ty::Char
| ty::Int(..)

View file

@ -2936,7 +2936,7 @@ pub enum TyCategory {
Closure,
Opaque,
OpaqueFuture,
Generator(hir::GeneratorKind),
Coroutine(hir::CoroutineKind),
Foreign,
}
@ -2946,7 +2946,7 @@ fn descr(&self) -> &'static str {
Self::Closure => "closure",
Self::Opaque => "opaque type",
Self::OpaqueFuture => "future",
Self::Generator(gk) => gk.descr(),
Self::Coroutine(gk) => gk.descr(),
Self::Foreign => "foreign type",
}
}
@ -2959,8 +2959,8 @@ pub fn from_ty(tcx: TyCtxt<'_>, ty: Ty<'_>) -> Option<(Self, DefId)> {
if tcx.ty_is_opaque_future(ty) { Self::OpaqueFuture } else { Self::Opaque };
Some((kind, def_id))
}
ty::Generator(def_id, ..) => {
Some((Self::Generator(tcx.generator_kind(def_id).unwrap()), def_id))
ty::Coroutine(def_id, ..) => {
Some((Self::Coroutine(tcx.generator_kind(def_id).unwrap()), def_id))
}
ty::Foreign(def_id) => Some((Self::Foreign, def_id)),
_ => None,

View file

@ -864,7 +864,7 @@ fn generic_arg_contains_target(&self, arg: GenericArg<'tcx>) -> bool {
GenericArgKind::Type(ty) => {
if matches!(
ty.kind(),
ty::Alias(ty::Opaque, ..) | ty::Closure(..) | ty::Generator(..)
ty::Alias(ty::Opaque, ..) | ty::Closure(..) | ty::Coroutine(..)
) {
// Opaque types can't be named by the user right now.
//

View file

@ -215,7 +215,7 @@ fn foo(&self, x: T) -> T { x }
#traits-as-parameters",
);
}
(ty::Param(p), ty::Closure(..) | ty::Generator(..)) => {
(ty::Param(p), ty::Closure(..) | ty::Coroutine(..)) => {
let generics = tcx.generics_of(body_owner_def_id);
let p_span = tcx.def_span(generics.type_param(p, tcx).def_id);
if !sp.contains(p_span) {

View file

@ -454,7 +454,7 @@ fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
args.as_closure().sig_as_fn_ptr_ty().visit_with(self);
}
ty::Generator(_, ref args, _) => {
ty::Coroutine(_, ref args, _) => {
// Skip lifetime parameters of the enclosing item(s)
// Also skip the witness type, because that has no free regions.

View file

@ -102,7 +102,7 @@ fn compute_components<'tcx>(
compute_components(tcx, tupled_ty, out, visited);
}
ty::Generator(_, ref args, _) => {
ty::Coroutine(_, ref args, _) => {
// Same as the closure case
let tupled_ty = args.as_generator().tupled_upvars_ty();
compute_components(tcx, tupled_ty, out, visited);
@ -112,7 +112,7 @@ fn compute_components<'tcx>(
}
// All regions are bound inside a witness
ty::GeneratorWitness(..) => (),
ty::CoroutineWitness(..) => (),
// OutlivesTypeParameterEnv -- the actual checking that `X:'a`
// is implied by the environment is done in regionck.

View file

@ -799,7 +799,7 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> {
});
tcx.hir().par_body_owners(|def_id| {
if let rustc_hir::def::DefKind::Generator = tcx.def_kind(def_id) {
if let rustc_hir::def::DefKind::Coroutine = tcx.def_kind(def_id) {
tcx.ensure().mir_generator_witnesses(def_id);
tcx.ensure().check_generator_obligations(def_id);
}

View file

@ -369,8 +369,8 @@ fn structurally_same_type_impl<'tcx>(
(Dynamic(..), Dynamic(..))
| (Error(..), Error(..))
| (Closure(..), Closure(..))
| (Generator(..), Generator(..))
| (GeneratorWitness(..), GeneratorWitness(..))
| (Coroutine(..), Coroutine(..))
| (CoroutineWitness(..), CoroutineWitness(..))
| (Alias(ty::Projection, ..), Alias(ty::Projection, ..))
| (Alias(ty::Inherent, ..), Alias(ty::Inherent, ..))
| (Alias(ty::Opaque, ..), Alias(ty::Opaque, ..)) => false,

View file

@ -1702,7 +1702,7 @@ pub struct UnusedClosure<'a> {
#[derive(LintDiagnostic)]
#[diag(lint_unused_generator)]
#[note]
pub struct UnusedGenerator<'a> {
pub struct UnusedCoroutine<'a> {
pub count: usize,
pub pre: &'a str,
pub post: &'a str,

View file

@ -1272,8 +1272,8 @@ fn check_type_for_ffi(&self, cache: &mut FxHashSet<Ty<'tcx>>, ty: Ty<'tcx>) -> F
| ty::Bound(..)
| ty::Error(_)
| ty::Closure(..)
| ty::Generator(..)
| ty::GeneratorWitness(..)
| ty::Coroutine(..)
| ty::CoroutineWitness(..)
| ty::Placeholder(..)
| ty::FnDef(..) => bug!("unexpected type in foreign function: {:?}", ty),
}

View file

@ -1,7 +1,7 @@
use crate::lints::{
PathStatementDrop, PathStatementDropSub, PathStatementNoEffect, UnusedAllocationDiag,
UnusedAllocationMutDiag, UnusedClosure, UnusedDef, UnusedDefSuggestion, UnusedDelim,
UnusedDelimSuggestion, UnusedGenerator, UnusedImportBracesDiag, UnusedOp, UnusedOpSuggestion,
UnusedAllocationMutDiag, UnusedClosure, UnusedCoroutine, UnusedDef, UnusedDefSuggestion,
UnusedDelim, UnusedDelimSuggestion, UnusedImportBracesDiag, UnusedOp, UnusedOpSuggestion,
UnusedResult,
};
use crate::Lint;
@ -258,7 +258,7 @@ enum MustUsePath {
/// The root of the unused_closures lint.
Closure(Span),
/// The root of the unused_generators lint.
Generator(Span),
Coroutine(Span),
}
#[instrument(skip(cx, expr), level = "debug", ret)]
@ -350,7 +350,7 @@ fn is_ty_must_use<'tcx>(
.map(|inner| MustUsePath::Array(Box::new(inner), len)),
},
ty::Closure(..) => Some(MustUsePath::Closure(span)),
ty::Generator(def_id, ..) => {
ty::Coroutine(def_id, ..) => {
// async fn should be treated as "implementor of `Future`"
let must_use = if cx.tcx.generator_is_async(def_id) {
let def_id = cx.tcx.lang_items().future_trait()?;
@ -359,7 +359,7 @@ fn is_ty_must_use<'tcx>(
} else {
None
};
must_use.or(Some(MustUsePath::Generator(span)))
must_use.or(Some(MustUsePath::Coroutine(span)))
}
_ => None,
}
@ -482,11 +482,11 @@ fn emit_must_use_untranslated(
UnusedClosure { count: plural_len, pre: descr_pre, post: descr_post },
);
}
MustUsePath::Generator(span) => {
MustUsePath::Coroutine(span) => {
cx.emit_spanned_lint(
UNUSED_MUST_USE,
*span,
UnusedGenerator { count: plural_len, pre: descr_pre, post: descr_post },
UnusedCoroutine { count: plural_len, pre: descr_pre, post: descr_post },
);
}
MustUsePath::Def(span, def_id, reason) => {

View file

@ -856,7 +856,7 @@ fn should_encode_span(def_kind: DefKind) -> bool {
| DefKind::Field
| DefKind::Impl { .. }
| DefKind::Closure
| DefKind::Generator => true,
| DefKind::Coroutine => true,
DefKind::ForeignMod | DefKind::GlobalAsm => false,
}
}
@ -897,7 +897,7 @@ fn should_encode_attrs(def_kind: DefKind) -> bool {
| DefKind::OpaqueTy
| DefKind::LifetimeParam
| DefKind::GlobalAsm
| DefKind::Generator => false,
| DefKind::Coroutine => false,
}
}
@ -933,7 +933,7 @@ fn should_encode_expn_that_defined(def_kind: DefKind) -> bool {
| DefKind::LifetimeParam
| DefKind::GlobalAsm
| DefKind::Closure
| DefKind::Generator => false,
| DefKind::Coroutine => false,
}
}
@ -968,7 +968,7 @@ fn should_encode_visibility(def_kind: DefKind) -> bool {
| DefKind::GlobalAsm
| DefKind::Impl { .. }
| DefKind::Closure
| DefKind::Generator
| DefKind::Coroutine
| DefKind::ExternCrate => false,
}
}
@ -1004,7 +1004,7 @@ fn should_encode_stability(def_kind: DefKind) -> bool {
| DefKind::InlineConst
| DefKind::GlobalAsm
| DefKind::Closure
| DefKind::Generator
| DefKind::Coroutine
| DefKind::ExternCrate => false,
}
}
@ -1060,8 +1060,8 @@ fn should_encode_mir(
|| tcx.is_const_default_method(def_id.to_def_id());
(is_const_fn, opt)
}
// Generators require optimized MIR to compute layout.
DefKind::Generator => (false, true),
// Coroutines require optimized MIR to compute layout.
DefKind::Coroutine => (false, true),
// The others don't have MIR.
_ => (false, false),
}
@ -1097,7 +1097,7 @@ fn should_encode_variances<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, def_kind: Def
| DefKind::InlineConst
| DefKind::GlobalAsm
| DefKind::Closure
| DefKind::Generator
| DefKind::Coroutine
| DefKind::ExternCrate => false,
DefKind::TyAlias => tcx.type_alias_is_lazy(def_id),
}
@ -1127,7 +1127,7 @@ fn should_encode_generics(def_kind: DefKind) -> bool {
| DefKind::Field
| DefKind::TyParam
| DefKind::Closure
| DefKind::Generator => true,
| DefKind::Coroutine => true,
DefKind::Mod
| DefKind::ForeignMod
| DefKind::ConstParam
@ -1156,7 +1156,7 @@ fn should_encode_type(tcx: TyCtxt<'_>, def_id: LocalDefId, def_kind: DefKind) ->
| DefKind::AssocFn
| DefKind::AssocConst
| DefKind::Closure
| DefKind::Generator
| DefKind::Coroutine
| DefKind::ConstParam
| DefKind::AnonConst
| DefKind::InlineConst => true,
@ -1217,7 +1217,7 @@ fn should_encode_fn_sig(def_kind: DefKind) -> bool {
| DefKind::Impl { .. }
| DefKind::AssocConst
| DefKind::Closure
| DefKind::Generator
| DefKind::Coroutine
| DefKind::ConstParam
| DefKind::AnonConst
| DefKind::InlineConst
@ -1256,7 +1256,7 @@ fn should_encode_constness(def_kind: DefKind) -> bool {
| DefKind::OpaqueTy
| DefKind::Impl { of_trait: false }
| DefKind::ForeignTy
| DefKind::Generator
| DefKind::Coroutine
| DefKind::ConstParam
| DefKind::InlineConst
| DefKind::AssocTy
@ -1291,7 +1291,7 @@ fn should_encode_const(def_kind: DefKind) -> bool {
| DefKind::Impl { .. }
| DefKind::AssocFn
| DefKind::Closure
| DefKind::Generator
| DefKind::Coroutine
| DefKind::ConstParam
| DefKind::AssocTy
| DefKind::TyParam
@ -1446,7 +1446,7 @@ fn encode_def_ids(&mut self) {
self.encode_info_for_assoc_item(def_id);
}
}
if let DefKind::Generator = def_kind {
if let DefKind::Coroutine = def_kind {
let data = self.tcx.generator_kind(def_id).unwrap();
record!(self.tables.generator_kind[def_id] <- data);
}
@ -1629,7 +1629,7 @@ fn encode_mir(&mut self) {
record!(self.tables.closure_saved_names_of_captured_variables[def_id.to_def_id()]
<- tcx.closure_saved_names_of_captured_variables(def_id));
if let DefKind::Generator = self.tcx.def_kind(def_id)
if let DefKind::Coroutine = self.tcx.def_kind(def_id)
&& let Some(witnesses) = tcx.mir_generator_witnesses(def_id)
{
record!(self.tables.mir_generator_witnesses[def_id.to_def_id()] <- witnesses);
@ -1656,7 +1656,7 @@ fn encode_mir(&mut self) {
}
record!(self.tables.promoted_mir[def_id.to_def_id()] <- tcx.promoted_mir(def_id));
if let DefKind::Generator = self.tcx.def_kind(def_id)
if let DefKind::Coroutine = self.tcx.def_kind(def_id)
&& let Some(witnesses) = tcx.mir_generator_witnesses(def_id)
{
record!(self.tables.mir_generator_witnesses[def_id.to_def_id()] <- witnesses);

View file

@ -429,7 +429,7 @@ fn encode(&self, buf: &mut FileEncoder) -> LazyTables {
mir_for_ctfe: Table<DefIndex, LazyValue<mir::Body<'static>>>,
cross_crate_inlinable: Table<DefIndex, bool>,
closure_saved_names_of_captured_variables: Table<DefIndex, LazyValue<IndexVec<FieldIdx, Symbol>>>,
mir_generator_witnesses: Table<DefIndex, LazyValue<mir::GeneratorLayout<'static>>>,
mir_generator_witnesses: Table<DefIndex, LazyValue<mir::CoroutineLayout<'static>>>,
promoted_mir: Table<DefIndex, LazyValue<IndexVec<mir::Promoted, mir::Body<'static>>>>,
thir_abstract_const: Table<DefIndex, LazyValue<ty::EarlyBinder<ty::Const<'static>>>>,
impl_parent: Table<DefIndex, RawDefId>,
@ -442,7 +442,7 @@ fn encode(&self, buf: &mut FileEncoder) -> LazyTables {
rendered_const: Table<DefIndex, LazyValue<String>>,
asyncness: Table<DefIndex, ty::Asyncness>,
fn_arg_names: Table<DefIndex, LazyArray<Ident>>,
generator_kind: Table<DefIndex, LazyValue<hir::GeneratorKind>>,
generator_kind: Table<DefIndex, LazyValue<hir::CoroutineKind>>,
trait_def: Table<DefIndex, LazyValue<ty::TraitDef>>,
trait_item_def_id: Table<DefIndex, RawDefId>,
expn_that_defined: Table<DefIndex, LazyValue<ExpnId>>,

View file

@ -167,7 +167,7 @@ impl FixedSizeEncoding for Option<$ty> {
( Impl { of_trait: false } )
( Impl { of_trait: true } )
( Closure )
( Generator )
( Coroutine )
( Static(ast::Mutability::Not) )
( Static(ast::Mutability::Mut) )
( Ctor(CtorOf::Struct, CtorKind::Fn) )

View file

@ -240,7 +240,7 @@ pub(super) fn opt_def_kind(self, local_def_id: LocalDefId) -> Option<DefKind> {
Node::Field(_) => DefKind::Field,
Node::Expr(expr) => match expr.kind {
ExprKind::Closure(Closure { movability: None, .. }) => DefKind::Closure,
ExprKind::Closure(Closure { movability: Some(_), .. }) => DefKind::Generator,
ExprKind::Closure(Closure { movability: Some(_), .. }) => DefKind::Coroutine,
_ => bug!("def_kind: unsupported node: {}", self.node_to_string(hir_id)),
},
Node::GenericParam(param) => match param.kind {
@ -445,7 +445,7 @@ pub fn body_owner_kind(self, def_id: LocalDefId) -> BodyOwnerKind {
}
DefKind::InlineConst => BodyOwnerKind::Const { inline: true },
DefKind::Ctor(..) | DefKind::Fn | DefKind::AssocFn => BodyOwnerKind::Fn,
DefKind::Closure | DefKind::Generator => BodyOwnerKind::Closure,
DefKind::Closure | DefKind::Coroutine => BodyOwnerKind::Closure,
DefKind::Static(mt) => BodyOwnerKind::Static(mt),
dk => bug!("{:?} is not a body node: {:?}", def_id, dk),
}

View file

@ -17,7 +17,7 @@
use rustc_errors::{DiagnosticArgValue, DiagnosticMessage, ErrorGuaranteed, IntoDiagnosticArg};
use rustc_hir::def::{CtorKind, Namespace};
use rustc_hir::def_id::{DefId, CRATE_DEF_ID};
use rustc_hir::{self, GeneratorKind, ImplicitSelfKind};
use rustc_hir::{self, CoroutineKind, ImplicitSelfKind};
use rustc_hir::{self as hir, HirId};
use rustc_session::Session;
use rustc_target::abi::{FieldIdx, VariantIdx};
@ -246,19 +246,19 @@ pub fn def_id(&self) -> DefId {
}
#[derive(Clone, TyEncodable, TyDecodable, Debug, HashStable, TypeFoldable, TypeVisitable)]
pub struct GeneratorInfo<'tcx> {
pub struct CoroutineInfo<'tcx> {
/// The yield type of the function, if it is a generator.
pub yield_ty: Option<Ty<'tcx>>,
/// Generator drop glue.
/// Coroutine drop glue.
pub generator_drop: Option<Body<'tcx>>,
/// The layout of a generator. Produced by the state transformation.
pub generator_layout: Option<GeneratorLayout<'tcx>>,
pub generator_layout: Option<CoroutineLayout<'tcx>>,
/// If this is a generator then record the type of source expression that caused this generator
/// to be created.
pub generator_kind: GeneratorKind,
pub generator_kind: CoroutineKind,
}
/// The lowered representation of a single function.
@ -284,7 +284,7 @@ pub struct Body<'tcx> {
/// and used for debuginfo. Indexed by a `SourceScope`.
pub source_scopes: IndexVec<SourceScope, SourceScopeData<'tcx>>,
pub generator: Option<Box<GeneratorInfo<'tcx>>>,
pub generator: Option<Box<CoroutineInfo<'tcx>>>,
/// Declarations of locals.
///
@ -365,7 +365,7 @@ pub fn new(
arg_count: usize,
var_debug_info: Vec<VarDebugInfo<'tcx>>,
span: Span,
generator_kind: Option<GeneratorKind>,
generator_kind: Option<CoroutineKind>,
tainted_by_errors: Option<ErrorGuaranteed>,
) -> Self {
// We need `arg_count` locals, and one for the return place.
@ -383,7 +383,7 @@ pub fn new(
basic_blocks: BasicBlocks::new(basic_blocks),
source_scopes,
generator: generator_kind.map(|generator_kind| {
Box::new(GeneratorInfo {
Box::new(CoroutineInfo {
yield_ty: None,
generator_drop: None,
generator_layout: None,
@ -552,7 +552,7 @@ pub fn yield_ty(&self) -> Option<Ty<'tcx>> {
}
#[inline]
pub fn generator_layout(&self) -> Option<&GeneratorLayout<'tcx>> {
pub fn generator_layout(&self) -> Option<&CoroutineLayout<'tcx>> {
self.generator.as_ref().and_then(|generator| generator.generator_layout.as_ref())
}
@ -562,7 +562,7 @@ pub fn generator_drop(&self) -> Option<&Body<'tcx>> {
}
#[inline]
pub fn generator_kind(&self) -> Option<GeneratorKind> {
pub fn generator_kind(&self) -> Option<CoroutineKind> {
self.generator.as_ref().map(|generator| generator.generator_kind)
}

View file

@ -782,7 +782,7 @@ pub fn fmt_head<W: fmt::Write>(&self, fmt: &mut W) -> fmt::Result {
Goto { .. } => write!(fmt, "goto"),
SwitchInt { discr, .. } => write!(fmt, "switchInt({discr:?})"),
Return => write!(fmt, "return"),
GeneratorDrop => write!(fmt, "generator_drop"),
CoroutineDrop => write!(fmt, "generator_drop"),
UnwindResume => write!(fmt, "resume"),
UnwindTerminate(reason) => {
write!(fmt, "abort({})", reason.as_short_str())
@ -865,7 +865,7 @@ pub fn fmt_head<W: fmt::Write>(&self, fmt: &mut W) -> fmt::Result {
pub fn fmt_successor_labels(&self) -> Vec<Cow<'static, str>> {
use self::TerminatorKind::*;
match *self {
Return | UnwindResume | UnwindTerminate(_) | Unreachable | GeneratorDrop => vec![],
Return | UnwindResume | UnwindTerminate(_) | Unreachable | CoroutineDrop => vec![],
Goto { .. } => vec!["".into()],
SwitchInt { ref targets, .. } => targets
.values
@ -1046,7 +1046,7 @@ fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result {
struct_fmt.finish()
}),
AggregateKind::Generator(def_id, _, _) => ty::tls::with(|tcx| {
AggregateKind::Coroutine(def_id, _, _) => ty::tls::with(|tcx| {
let name = format!("{{generator@{:?}}}", tcx.def_span(def_id));
let mut struct_fmt = fmt.debug_struct(&name);
@ -1301,7 +1301,7 @@ fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) {
self.push(&format!("+ args: {args:#?}"));
}
AggregateKind::Generator(def_id, args, movability) => {
AggregateKind::Coroutine(def_id, args, movability) => {
self.push("generator");
self.push(&format!("+ def_id: {def_id:?}"));
self.push(&format!("+ args: {args:#?}"));

View file

@ -133,11 +133,11 @@ pub struct UnsafetyCheckResult {
rustc_index::newtype_index! {
#[derive(HashStable)]
#[debug_format = "_{}"]
pub struct GeneratorSavedLocal {}
pub struct CoroutineSavedLocal {}
}
#[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable)]
pub struct GeneratorSavedTy<'tcx> {
pub struct CoroutineSavedTy<'tcx> {
pub ty: Ty<'tcx>,
/// Source info corresponding to the local in the original MIR body.
pub source_info: SourceInfo,
@ -147,16 +147,16 @@ pub struct GeneratorSavedTy<'tcx> {
/// The layout of generator state.
#[derive(Clone, TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable)]
pub struct GeneratorLayout<'tcx> {
pub struct CoroutineLayout<'tcx> {
/// The type of every local stored inside the generator.
pub field_tys: IndexVec<GeneratorSavedLocal, GeneratorSavedTy<'tcx>>,
pub field_tys: IndexVec<CoroutineSavedLocal, CoroutineSavedTy<'tcx>>,
/// The name for debuginfo.
pub field_names: IndexVec<GeneratorSavedLocal, Option<Symbol>>,
pub field_names: IndexVec<CoroutineSavedLocal, Option<Symbol>>,
/// Which of the above fields are in each variant. Note that one field may
/// be stored in multiple variants.
pub variant_fields: IndexVec<VariantIdx, IndexVec<FieldIdx, GeneratorSavedLocal>>,
pub variant_fields: IndexVec<VariantIdx, IndexVec<FieldIdx, CoroutineSavedLocal>>,
/// The source that led to each variant being created (usually, a yield or
/// await).
@ -167,10 +167,10 @@ pub struct GeneratorLayout<'tcx> {
/// layout.
#[type_foldable(identity)]
#[type_visitable(ignore)]
pub storage_conflicts: BitMatrix<GeneratorSavedLocal, GeneratorSavedLocal>,
pub storage_conflicts: BitMatrix<CoroutineSavedLocal, CoroutineSavedLocal>,
}
impl Debug for GeneratorLayout<'_> {
impl Debug for CoroutineLayout<'_> {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
/// Prints an iterator of (key, value) tuples as a map.
struct MapPrinter<'a, K, V>(Cell<Option<Box<dyn Iterator<Item = (K, V)> + 'a>>>);
@ -194,7 +194,7 @@ fn from(idx: VariantIdx) -> Self {
}
impl Debug for GenVariantPrinter {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
let variant_name = ty::GeneratorArgs::variant_name(self.0);
let variant_name = ty::CoroutineArgs::variant_name(self.0);
if fmt.alternate() {
write!(fmt, "{:9}({:?})", variant_name, self.0)
} else {
@ -211,7 +211,7 @@ fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
}
}
fmt.debug_struct("GeneratorLayout")
fmt.debug_struct("CoroutineLayout")
.field("field_tys", &MapPrinter::new(self.field_tys.iter_enumerated()))
.field(
"variant_fields",

View file

@ -15,7 +15,7 @@
use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece};
use rustc_hir::def_id::DefId;
use rustc_hir::{self as hir};
use rustc_hir::{self, GeneratorKind};
use rustc_hir::{self, CoroutineKind};
use rustc_index::IndexVec;
use rustc_target::abi::{FieldIdx, VariantIdx};
@ -82,7 +82,7 @@ pub enum MirPhase {
/// that Rust itself has them. Where exactly these are is generally subject to change, and so we
/// don't document this here. Runtime MIR has most retags explicit (though implicit retags
/// can still occur at `Rvalue::{Ref,AddrOf}`).
/// - Generator bodies: In analysis MIR, locals may actually be behind a pointer that user code has
/// - Coroutine bodies: In analysis MIR, locals may actually be behind a pointer that user code has
/// access to. This occurs in generator bodies. Such locals do not behave like other locals,
/// because they eg may be aliased in surprising ways. Runtime MIR has no such special locals -
/// all generator bodies are lowered and so all places that look like locals really are locals.
@ -137,7 +137,7 @@ pub enum RuntimePhase {
/// In addition to the semantic changes, beginning with this phase, the following variants are
/// disallowed:
/// * [`TerminatorKind::Yield`]
/// * [`TerminatorKind::GeneratorDrop`]
/// * [`TerminatorKind::CoroutineDrop`]
/// * [`Rvalue::Aggregate`] for any `AggregateKind` except `Array`
/// * [`PlaceElem::OpaqueCast`]
///
@ -627,7 +627,7 @@ pub enum TerminatorKind<'tcx> {
/// aliasing model.
///
/// If the body is a generator body, this has slightly different semantics; it instead causes a
/// `GeneratorState::Returned(_0)` to be created (as if by an `Aggregate` rvalue) and assigned
/// `CoroutineState::Returned(_0)` to be created (as if by an `Aggregate` rvalue) and assigned
/// to the return place.
Return,
@ -710,7 +710,7 @@ pub enum TerminatorKind<'tcx> {
/// Marks a suspend point.
///
/// Like `Return` terminators in generator bodies, this computes `value` and then a
/// `GeneratorState::Yielded(value)` as if by `Aggregate` rvalue. That value is then assigned to
/// `CoroutineState::Yielded(value)` as if by `Aggregate` rvalue. That value is then assigned to
/// the return place of the function calling this one, and execution continues in the calling
/// function. When next invoked with the same first argument, execution of this function
/// continues at the `resume` basic block, with the second argument written to the `resume_arg`
@ -740,7 +740,7 @@ pub enum TerminatorKind<'tcx> {
///
/// **Needs clarification**: Are there type system constraints on these terminators? Should
/// there be a "block type" like `cleanup` blocks for them?
GeneratorDrop,
CoroutineDrop,
/// A block where control flow only ever takes one real path, but borrowck needs to be more
/// conservative.
@ -815,7 +815,7 @@ pub const fn name(&self) -> &'static str {
TerminatorKind::Call { .. } => "Call",
TerminatorKind::Assert { .. } => "Assert",
TerminatorKind::Yield { .. } => "Yield",
TerminatorKind::GeneratorDrop => "GeneratorDrop",
TerminatorKind::CoroutineDrop => "CoroutineDrop",
TerminatorKind::FalseEdge { .. } => "FalseEdge",
TerminatorKind::FalseUnwind { .. } => "FalseUnwind",
TerminatorKind::InlineAsm { .. } => "InlineAsm",
@ -883,8 +883,8 @@ pub enum AssertKind<O> {
OverflowNeg(O),
DivisionByZero(O),
RemainderByZero(O),
ResumedAfterReturn(GeneratorKind),
ResumedAfterPanic(GeneratorKind),
ResumedAfterReturn(CoroutineKind),
ResumedAfterPanic(CoroutineKind),
MisalignedPointerDereference { required: O, found: O },
}
@ -1278,8 +1278,8 @@ pub enum Rvalue<'tcx> {
/// `dest = Foo { x: ..., y: ... }` from `dest.x = ...; dest.y = ...;` in the case that `Foo`
/// has a destructor.
///
/// Disallowed after deaggregation for all aggregate kinds except `Array` and `Generator`. After
/// generator lowering, `Generator` aggregate kinds are disallowed too.
/// Disallowed after deaggregation for all aggregate kinds except `Array` and `Coroutine`. After
/// generator lowering, `Coroutine` aggregate kinds are disallowed too.
Aggregate(Box<AggregateKind<'tcx>>, IndexVec<FieldIdx, Operand<'tcx>>),
/// Transmutes a `*mut u8` into shallow-initialized `Box<T>`.
@ -1344,7 +1344,7 @@ pub enum AggregateKind<'tcx> {
Adt(DefId, VariantIdx, GenericArgsRef<'tcx>, Option<UserTypeAnnotationIndex>, Option<FieldIdx>),
Closure(DefId, GenericArgsRef<'tcx>),
Generator(DefId, GenericArgsRef<'tcx>, hir::Movability),
Coroutine(DefId, GenericArgsRef<'tcx>, hir::Movability),
}
#[derive(Copy, Clone, Debug, PartialEq, Eq, TyEncodable, TyDecodable, Hash, HashStable)]

View file

@ -205,7 +205,7 @@ pub fn ty<D: ?Sized>(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> Ty<'tcx>
}
AggregateKind::Adt(did, _, args, _, _) => tcx.type_of(did).instantiate(tcx, args),
AggregateKind::Closure(did, args) => Ty::new_closure(tcx, did, args),
AggregateKind::Generator(did, args, movability) => {
AggregateKind::Coroutine(did, args, movability) => {
Ty::new_generator(tcx, did, args, movability)
}
},

View file

@ -139,10 +139,10 @@ pub fn description(&self) -> &'static str {
Overflow(op, _, _) => bug!("{:?} cannot overflow", op),
DivisionByZero(_) => "attempt to divide by zero",
RemainderByZero(_) => "attempt to calculate the remainder with a divisor of zero",
ResumedAfterReturn(GeneratorKind::Gen) => "generator resumed after completion",
ResumedAfterReturn(GeneratorKind::Async(_)) => "`async fn` resumed after completion",
ResumedAfterPanic(GeneratorKind::Gen) => "generator resumed after panicking",
ResumedAfterPanic(GeneratorKind::Async(_)) => "`async fn` resumed after panicking",
ResumedAfterReturn(CoroutineKind::Gen) => "generator resumed after completion",
ResumedAfterReturn(CoroutineKind::Async(_)) => "`async fn` resumed after completion",
ResumedAfterPanic(CoroutineKind::Gen) => "generator resumed after panicking",
ResumedAfterPanic(CoroutineKind::Async(_)) => "`async fn` resumed after panicking",
BoundsCheck { .. } | MisalignedPointerDereference { .. } => {
bug!("Unexpected AssertKind")
}
@ -228,10 +228,10 @@ pub fn diagnostic_message(&self) -> DiagnosticMessage {
OverflowNeg(_) => middle_assert_overflow_neg,
DivisionByZero(_) => middle_assert_divide_by_zero,
RemainderByZero(_) => middle_assert_remainder_by_zero,
ResumedAfterReturn(GeneratorKind::Async(_)) => middle_assert_async_resume_after_return,
ResumedAfterReturn(GeneratorKind::Gen) => middle_assert_generator_resume_after_return,
ResumedAfterPanic(GeneratorKind::Async(_)) => middle_assert_async_resume_after_panic,
ResumedAfterPanic(GeneratorKind::Gen) => middle_assert_generator_resume_after_panic,
ResumedAfterReturn(CoroutineKind::Async(_)) => middle_assert_async_resume_after_return,
ResumedAfterReturn(CoroutineKind::Gen) => middle_assert_generator_resume_after_return,
ResumedAfterPanic(CoroutineKind::Async(_)) => middle_assert_async_resume_after_panic,
ResumedAfterPanic(CoroutineKind::Gen) => middle_assert_generator_resume_after_panic,
MisalignedPointerDereference { .. } => middle_assert_misaligned_ptr_deref,
}
@ -331,7 +331,7 @@ pub fn successors(&self) -> Successors<'_> {
}
UnwindResume
| UnwindTerminate(_)
| GeneratorDrop
| CoroutineDrop
| Return
| Unreachable
| Call { target: None, unwind: _, .. }
@ -373,7 +373,7 @@ pub fn successors_mut(&mut self) -> SuccessorsMut<'_> {
}
UnwindResume
| UnwindTerminate(_)
| GeneratorDrop
| CoroutineDrop
| Return
| Unreachable
| Call { target: None, unwind: _, .. }
@ -392,7 +392,7 @@ pub fn unwind(&self) -> Option<&UnwindAction> {
| TerminatorKind::UnwindTerminate(_)
| TerminatorKind::Return
| TerminatorKind::Unreachable
| TerminatorKind::GeneratorDrop
| TerminatorKind::CoroutineDrop
| TerminatorKind::Yield { .. }
| TerminatorKind::SwitchInt { .. }
| TerminatorKind::FalseEdge { .. } => None,
@ -411,7 +411,7 @@ pub fn unwind_mut(&mut self) -> Option<&mut UnwindAction> {
| TerminatorKind::UnwindTerminate(_)
| TerminatorKind::Return
| TerminatorKind::Unreachable
| TerminatorKind::GeneratorDrop
| TerminatorKind::CoroutineDrop
| TerminatorKind::Yield { .. }
| TerminatorKind::SwitchInt { .. }
| TerminatorKind::FalseEdge { .. } => None,
@ -493,7 +493,7 @@ impl<'tcx> TerminatorKind<'tcx> {
pub fn edges(&self) -> TerminatorEdges<'_, 'tcx> {
use TerminatorKind::*;
match *self {
Return | UnwindResume | UnwindTerminate(_) | GeneratorDrop | Unreachable => {
Return | UnwindResume | UnwindTerminate(_) | CoroutineDrop | Unreachable => {
TerminatorEdges::None
}

View file

@ -19,8 +19,8 @@
hir::Movability,
BasicBlock,
SwitchTargets,
GeneratorKind,
GeneratorSavedLocal,
CoroutineKind,
CoroutineSavedLocal,
}
TrivialTypeTraversalImpls! {

View file

@ -473,7 +473,7 @@ fn super_terminator(&mut self,
TerminatorKind::Goto { .. } |
TerminatorKind::UnwindResume |
TerminatorKind::UnwindTerminate(_) |
TerminatorKind::GeneratorDrop |
TerminatorKind::CoroutineDrop |
TerminatorKind::Unreachable |
TerminatorKind::FalseEdge { .. } |
TerminatorKind::FalseUnwind { .. } => {}
@ -735,7 +735,7 @@ fn super_rvalue(&mut self,
) => {
self.visit_args(closure_args, location);
}
AggregateKind::Generator(
AggregateKind::Coroutine(
_,
generator_args,
_movability,

View file

@ -210,7 +210,7 @@ impl EraseType for $ty {
Option<rustc_attr::Stability>,
Option<rustc_data_structures::svh::Svh>,
Option<rustc_hir::def::DefKind>,
Option<rustc_hir::GeneratorKind>,
Option<rustc_hir::CoroutineKind>,
Option<rustc_hir::HirId>,
Option<rustc_middle::middle::stability::DeprecationEntry>,
Option<rustc_middle::ty::Destructor>,
@ -239,7 +239,7 @@ impl EraseType for $ty {
rustc_hir::def::DefKind,
rustc_hir::Defaultness,
rustc_hir::definitions::DefKey,
rustc_hir::GeneratorKind,
rustc_hir::CoroutineKind,
rustc_hir::HirId,
rustc_hir::IsAsync,
rustc_hir::ItemLocalId,

View file

@ -554,7 +554,7 @@
separate_provide_extern
}
query mir_generator_witnesses(key: DefId) -> &'tcx Option<mir::GeneratorLayout<'tcx>> {
query mir_generator_witnesses(key: DefId) -> &'tcx Option<mir::CoroutineLayout<'tcx>> {
arena_cache
desc { |tcx| "generator witness types for `{}`", tcx.def_path_str(key) }
cache_on_disk_if { key.is_local() }
@ -744,7 +744,7 @@
}
/// Returns `Some(generator_kind)` if the node pointed to by `def_id` is a generator.
query generator_kind(def_id: DefId) -> Option<hir::GeneratorKind> {
query generator_kind(def_id: DefId) -> Option<hir::CoroutineKind> {
desc { |tcx| "looking up generator kind of `{}`", tcx.def_path_str(def_id) }
separate_provide_extern
}

View file

@ -302,7 +302,7 @@ pub enum ObligationCauseCode<'tcx> {
/// Captured closure type must be `Sized`.
SizedClosureCapture(LocalDefId),
/// Types live across generator yields must be `Sized`.
SizedGeneratorInterior(LocalDefId),
SizedCoroutineInterior(LocalDefId),
/// `[expr; N]` requires `type_of(expr): Copy`.
RepeatElementCopy {
/// If element is a `const fn` we display a help message suggesting to move the

View file

@ -136,9 +136,9 @@ pub enum SelectionCandidate<'tcx> {
is_const: bool,
},
/// Implementation of a `Generator` trait by one of the anonymous types
/// Implementation of a `Coroutine` trait by one of the anonymous types
/// generated for a generator.
GeneratorCandidate,
CoroutineCandidate,
/// Implementation of a `Future` trait by one of the generator types
/// generated for an async construct.

View file

@ -763,7 +763,7 @@ pub fn is_diagnostic_item(self, name: Symbol, did: DefId) -> bool {
/// Returns `true` if the node pointed to by `def_id` is a generator for an async construct.
pub fn generator_is_async(self, def_id: DefId) -> bool {
matches!(self.generator_kind(def_id), Some(hir::GeneratorKind::Async(_)))
matches!(self.generator_kind(def_id), Some(hir::CoroutineKind::Async(_)))
}
pub fn stability(self) -> &'tcx stability::Index {
@ -1382,8 +1382,8 @@ fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
FnDef,
FnPtr,
Placeholder,
Generator,
GeneratorWitness,
Coroutine,
CoroutineWitness,
Dynamic,
Closure,
Tuple,

View file

@ -482,8 +482,8 @@ fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
FnDef(..)
| Closure(..)
| Infer(..)
| Generator(..)
| GeneratorWitness(..)
| Coroutine(..)
| CoroutineWitness(..)
| Bound(_, _)
| Placeholder(_)
| Error(_) => {
@ -567,8 +567,8 @@ fn try_fold_ty(&mut self, t: Ty<'tcx>) -> Result<Ty<'tcx>, Self::Error> {
// FIXME(compiler-errors): We could replace these with infer, I guess.
Closure(..)
| Infer(..)
| Generator(..)
| GeneratorWitness(..)
| Coroutine(..)
| CoroutineWitness(..)
| Bound(_, _)
| Placeholder(_)
| Error(_) => {

View file

@ -241,8 +241,8 @@ pub fn sort_string(self, tcx: TyCtxt<'tcx>) -> Cow<'static, str> {
}
ty::Dynamic(..) => "trait object".into(),
ty::Closure(..) => "closure".into(),
ty::Generator(def_id, ..) => tcx.generator_kind(def_id).unwrap().descr().into(),
ty::GeneratorWitness(..) => "generator witness".into(),
ty::Coroutine(def_id, ..) => tcx.generator_kind(def_id).unwrap().descr().into(),
ty::CoroutineWitness(..) => "generator witness".into(),
ty::Infer(ty::TyVar(_)) => "inferred type".into(),
ty::Infer(ty::IntVar(_)) => "integer".into(),
ty::Infer(ty::FloatVar(_)) => "floating-point number".into(),
@ -299,8 +299,8 @@ pub fn prefix_string(self, tcx: TyCtxt<'_>) -> Cow<'static, str> {
ty::FnPtr(_) => "fn pointer".into(),
ty::Dynamic(..) => "trait object".into(),
ty::Closure(..) => "closure".into(),
ty::Generator(def_id, ..) => tcx.generator_kind(def_id).unwrap().descr().into(),
ty::GeneratorWitness(..) => "generator witness".into(),
ty::Coroutine(def_id, ..) => tcx.generator_kind(def_id).unwrap().descr().into(),
ty::CoroutineWitness(..) => "generator witness".into(),
ty::Tuple(..) => "tuple".into(),
ty::Placeholder(..) => "higher-ranked type".into(),
ty::Bound(..) => "bound type variable".into(),

View file

@ -28,8 +28,8 @@ pub enum SimplifiedType {
MarkerTraitObject,
Trait(DefId),
Closure(DefId),
Generator(DefId),
GeneratorWitness(DefId),
Coroutine(DefId),
CoroutineWitness(DefId),
Function(usize),
Placeholder,
}
@ -128,8 +128,8 @@ pub fn simplify_type<'tcx>(
},
ty::Ref(_, _, mutbl) => Some(SimplifiedType::Ref(mutbl)),
ty::FnDef(def_id, _) | ty::Closure(def_id, _) => Some(SimplifiedType::Closure(def_id)),
ty::Generator(def_id, _, _) => Some(SimplifiedType::Generator(def_id)),
ty::GeneratorWitness(def_id, _) => Some(SimplifiedType::GeneratorWitness(def_id)),
ty::Coroutine(def_id, _, _) => Some(SimplifiedType::Coroutine(def_id)),
ty::CoroutineWitness(def_id, _) => Some(SimplifiedType::CoroutineWitness(def_id)),
ty::Never => Some(SimplifiedType::Never),
ty::Tuple(tys) => Some(SimplifiedType::Tuple(tys.len())),
ty::FnPtr(f) => Some(SimplifiedType::Function(f.skip_binder().inputs().len())),
@ -164,8 +164,8 @@ pub fn def(self) -> Option<DefId> {
| SimplifiedType::Foreign(d)
| SimplifiedType::Trait(d)
| SimplifiedType::Closure(d)
| SimplifiedType::Generator(d)
| SimplifiedType::GeneratorWitness(d) => Some(d),
| SimplifiedType::Coroutine(d)
| SimplifiedType::CoroutineWitness(d) => Some(d),
_ => None,
}
}
@ -234,8 +234,8 @@ pub fn types_may_unify<'tcx>(self, obligation_ty: Ty<'tcx>, impl_ty: Ty<'tcx>) -
| ty::Foreign(..) => {}
ty::FnDef(..)
| ty::Closure(..)
| ty::Generator(..)
| ty::GeneratorWitness(..)
| ty::Coroutine(..)
| ty::CoroutineWitness(..)
| ty::Placeholder(..)
| ty::Bound(..)
| ty::Infer(_) => bug!("unexpected impl_ty: {impl_ty}"),
@ -310,7 +310,7 @@ pub fn types_may_unify<'tcx>(self, obligation_ty: Ty<'tcx>, impl_ty: Ty<'tcx>) -
},
// Impls cannot contain these types as these cannot be named directly.
ty::FnDef(..) | ty::Closure(..) | ty::Generator(..) => false,
ty::FnDef(..) | ty::Closure(..) | ty::Coroutine(..) => false,
// Placeholder types don't unify with anything on their own
ty::Placeholder(..) | ty::Bound(..) => false,
@ -337,7 +337,7 @@ pub fn types_may_unify<'tcx>(self, obligation_ty: Ty<'tcx>, impl_ty: Ty<'tcx>) -
ty::Error(_) => true,
ty::GeneratorWitness(..) => {
ty::CoroutineWitness(..) => {
bug!("unexpected obligation type: {:?}", obligation_ty)
}
}

View file

@ -111,7 +111,7 @@ fn add_kind(&mut self, kind: &ty::TyKind<'_>) {
self.add_flags(TypeFlags::STILL_FURTHER_SPECIALIZABLE);
}
ty::Generator(_, args, _) => {
ty::Coroutine(_, args, _) => {
let args = args.as_generator();
let should_remove_further_specializable =
!self.flags.contains(TypeFlags::STILL_FURTHER_SPECIALIZABLE);
@ -127,7 +127,7 @@ fn add_kind(&mut self, kind: &ty::TyKind<'_>) {
self.add_ty(args.tupled_upvars_ty());
}
ty::GeneratorWitness(_, args) => {
ty::CoroutineWitness(_, args) => {
let should_remove_further_specializable =
!self.flags.contains(TypeFlags::STILL_FURTHER_SPECIALIZABLE);
self.add_args(args);

View file

@ -2,7 +2,7 @@
use crate::ty::codec::{TyDecoder, TyEncoder};
use crate::ty::fold::{FallibleTypeFolder, TypeFoldable, TypeFolder, TypeSuperFoldable};
use crate::ty::sty::{ClosureArgs, GeneratorArgs, InlineConstArgs};
use crate::ty::sty::{ClosureArgs, CoroutineArgs, InlineConstArgs};
use crate::ty::visit::{TypeVisitable, TypeVisitableExt, TypeVisitor};
use crate::ty::{self, Lift, List, ParamConst, Ty, TyCtxt};
@ -267,11 +267,11 @@ pub fn as_closure(&'tcx self) -> ClosureArgs<'tcx> {
}
/// Interpret these generic args as the args of a generator type.
/// Generator args have a particular structure controlled by the
/// Coroutine args have a particular structure controlled by the
/// compiler that encodes information like the signature and generator kind;
/// see `ty::GeneratorArgs` struct for more comments.
pub fn as_generator(&'tcx self) -> GeneratorArgs<'tcx> {
GeneratorArgs { args: self }
/// see `ty::CoroutineArgs` struct for more comments.
pub fn as_generator(&'tcx self) -> CoroutineArgs<'tcx> {
CoroutineArgs { args: self }
}
/// Interpret these generic args as the args of an inline const.

View file

@ -689,7 +689,7 @@ fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
Ty::new_closure(self.tcx, def_id, polymorphized_args)
}
}
ty::Generator(def_id, args, movability) => {
ty::Coroutine(def_id, args, movability) => {
let polymorphized_args =
polymorphize(self.tcx, ty::InstanceDef::Item(def_id), args);
if args == polymorphized_args {

View file

@ -809,7 +809,7 @@ fn field_ty_or_layout<'tcx>(
| ty::FnPtr(_)
| ty::Never
| ty::FnDef(..)
| ty::GeneratorWitness(..)
| ty::CoroutineWitness(..)
| ty::Foreign(..)
| ty::Dynamic(_, _, ty::Dyn) => {
bug!("TyAndLayout::field({:?}): not applicable", this)
@ -905,7 +905,7 @@ fn field_ty_or_layout<'tcx>(
i,
),
ty::Generator(def_id, ref args, _) => match this.variants {
ty::Coroutine(def_id, ref args, _) => match this.variants {
Variants::Single { index } => TyMaybeWithLayout::Ty(
args.as_generator()
.state_tys(def_id, tcx)

View file

@ -20,7 +20,7 @@
use crate::error::{OpaqueHiddenTypeMismatch, TypeMismatchReason};
use crate::metadata::ModChild;
use crate::middle::privacy::EffectiveVisibilities;
use crate::mir::{Body, GeneratorLayout};
use crate::mir::{Body, CoroutineLayout};
use crate::query::Providers;
use crate::traits::{self, Reveal};
use crate::ty;
@ -98,8 +98,8 @@
pub use self::sty::{
AliasTy, Article, Binder, BoundRegion, BoundRegionKind, BoundTy, BoundTyKind, BoundVar,
BoundVariableKind, CanonicalPolyFnSig, ClosureArgs, ClosureArgsParts, ConstKind, ConstVid,
EarlyBoundRegion, EffectVid, ExistentialPredicate, ExistentialProjection, ExistentialTraitRef,
FnSig, FreeRegion, GenSig, GeneratorArgs, GeneratorArgsParts, InlineConstArgs,
CoroutineArgs, CoroutineArgsParts, EarlyBoundRegion, EffectVid, ExistentialPredicate,
ExistentialProjection, ExistentialTraitRef, FnSig, FreeRegion, GenSig, InlineConstArgs,
InlineConstArgsParts, ParamConst, ParamTy, PolyExistentialPredicate, PolyExistentialProjection,
PolyExistentialTraitRef, PolyFnSig, PolyGenSig, PolyTraitRef, Region, RegionKind, RegionVid,
TraitRef, TyKind, TypeAndMut, UpvarArgs, VarianceDiagInfo,
@ -2423,7 +2423,7 @@ pub fn trait_is_alias(self, trait_def_id: DefId) -> bool {
/// Returns layout of a generator. Layout might be unavailable if the
/// generator is tainted by errors.
pub fn generator_layout(self, def_id: DefId) -> Option<&'tcx GeneratorLayout<'tcx>> {
pub fn generator_layout(self, def_id: DefId) -> Option<&'tcx CoroutineLayout<'tcx>> {
self.optimized_mir(def_id).generator_layout()
}

View file

@ -152,12 +152,12 @@ fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
Ty::new_closure(self.tcx, def_id, args)
}
ty::Generator(def_id, args, movability) => {
ty::Coroutine(def_id, args, movability) => {
let args = self.fold_closure_args(def_id, args);
Ty::new_generator(self.tcx, def_id, args, movability)
}
ty::GeneratorWitness(def_id, args) => {
ty::CoroutineWitness(def_id, args) => {
let args = self.fold_closure_args(def_id, args);
Ty::new_generator_witness(self.tcx, def_id, args)
}

Some files were not shown because too many files have changed in this diff Show more