s/Generator/Coroutine/
This commit is contained in:
@@ -17,7 +17,7 @@ use rustc_data_structures::captures::Captures;
|
||||
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 @@ impl<'tcx> MirSource<'tcx> {
|
||||
}
|
||||
|
||||
#[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 @@ impl<'tcx> Body<'tcx> {
|
||||
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 @@ impl<'tcx> Body<'tcx> {
|
||||
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 @@ impl<'tcx> Body<'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 @@ impl<'tcx> 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)
|
||||
}
|
||||
|
||||
|
||||
@@ -782,7 +782,7 @@ impl<'tcx> TerminatorKind<'tcx> {
|
||||
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 @@ impl<'tcx> TerminatorKind<'tcx> {
|
||||
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 @@ impl<'tcx> Debug for Rvalue<'tcx> {
|
||||
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 @@ impl<'tcx> Visitor<'tcx> for ExtraComments<'tcx> {
|
||||
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:#?}"));
|
||||
|
||||
@@ -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 @@ impl Debug for GeneratorLayout<'_> {
|
||||
}
|
||||
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 @@ impl Debug for GeneratorLayout<'_> {
|
||||
}
|
||||
}
|
||||
|
||||
fmt.debug_struct("GeneratorLayout")
|
||||
fmt.debug_struct("CoroutineLayout")
|
||||
.field("field_tys", &MapPrinter::new(self.field_tys.iter_enumerated()))
|
||||
.field(
|
||||
"variant_fields",
|
||||
|
||||
@@ -15,7 +15,7 @@ use crate::ty::{Region, UserTypeAnnotationIndex};
|
||||
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 @@ impl TerminatorKind<'_> {
|
||||
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)]
|
||||
|
||||
@@ -205,7 +205,7 @@ impl<'tcx> Rvalue<'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)
|
||||
}
|
||||
},
|
||||
|
||||
@@ -139,10 +139,10 @@ impl<O> AssertKind<O> {
|
||||
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 @@ impl<O> AssertKind<O> {
|
||||
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 @@ impl<'tcx> TerminatorKind<'tcx> {
|
||||
}
|
||||
UnwindResume
|
||||
| UnwindTerminate(_)
|
||||
| GeneratorDrop
|
||||
| CoroutineDrop
|
||||
| Return
|
||||
| Unreachable
|
||||
| Call { target: None, unwind: _, .. }
|
||||
@@ -373,7 +373,7 @@ impl<'tcx> TerminatorKind<'tcx> {
|
||||
}
|
||||
UnwindResume
|
||||
| UnwindTerminate(_)
|
||||
| GeneratorDrop
|
||||
| CoroutineDrop
|
||||
| Return
|
||||
| Unreachable
|
||||
| Call { target: None, unwind: _, .. }
|
||||
@@ -392,7 +392,7 @@ impl<'tcx> TerminatorKind<'tcx> {
|
||||
| TerminatorKind::UnwindTerminate(_)
|
||||
| TerminatorKind::Return
|
||||
| TerminatorKind::Unreachable
|
||||
| TerminatorKind::GeneratorDrop
|
||||
| TerminatorKind::CoroutineDrop
|
||||
| TerminatorKind::Yield { .. }
|
||||
| TerminatorKind::SwitchInt { .. }
|
||||
| TerminatorKind::FalseEdge { .. } => None,
|
||||
@@ -411,7 +411,7 @@ impl<'tcx> TerminatorKind<'tcx> {
|
||||
| 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
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@ TrivialTypeTraversalImpls! {
|
||||
hir::Movability,
|
||||
BasicBlock,
|
||||
SwitchTargets,
|
||||
GeneratorKind,
|
||||
GeneratorSavedLocal,
|
||||
CoroutineKind,
|
||||
CoroutineSavedLocal,
|
||||
}
|
||||
|
||||
TrivialTypeTraversalImpls! {
|
||||
|
||||
@@ -473,7 +473,7 @@ macro_rules! make_mir_visitor {
|
||||
TerminatorKind::Goto { .. } |
|
||||
TerminatorKind::UnwindResume |
|
||||
TerminatorKind::UnwindTerminate(_) |
|
||||
TerminatorKind::GeneratorDrop |
|
||||
TerminatorKind::CoroutineDrop |
|
||||
TerminatorKind::Unreachable |
|
||||
TerminatorKind::FalseEdge { .. } |
|
||||
TerminatorKind::FalseUnwind { .. } => {}
|
||||
@@ -735,7 +735,7 @@ macro_rules! make_mir_visitor {
|
||||
) => {
|
||||
self.visit_args(closure_args, location);
|
||||
}
|
||||
AggregateKind::Generator(
|
||||
AggregateKind::Coroutine(
|
||||
_,
|
||||
generator_args,
|
||||
_movability,
|
||||
|
||||
Reference in New Issue
Block a user