1
Fork 0

s/generator/coroutine/

This commit is contained in:
Oli Scherer 2023-10-19 21:46:28 +00:00
parent 60956837cf
commit e96ce20b34
468 changed files with 2201 additions and 2197 deletions

View file

@ -399,22 +399,22 @@ fn push_debuginfo_type_name<'tcx>(
visited.remove(&t);
}
ty::Closure(def_id, args) | ty::Coroutine(def_id, args, ..) => {
// Name will be "{closure_env#0}<T1, T2, ...>", "{generator_env#0}<T1, T2, ...>", or
// Name will be "{closure_env#0}<T1, T2, ...>", "{coroutine_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
// an artificial `enum2$<>` type, as defined in msvc_enum_fallback().
if cpp_like_debuginfo && t.is_generator() {
if cpp_like_debuginfo && t.is_coroutine() {
let ty_and_layout = tcx.layout_of(ParamEnv::reveal_all().and(t)).unwrap();
msvc_enum_fallback(
ty_and_layout,
&|output, visited| {
push_closure_or_generator_name(tcx, def_id, args, true, output, visited);
push_closure_or_coroutine_name(tcx, def_id, args, true, output, visited);
},
output,
visited,
);
} else {
push_closure_or_generator_name(tcx, def_id, args, qualified, output, visited);
push_closure_or_coroutine_name(tcx, def_id, args, qualified, output, visited);
}
}
// Type parameters from polymorphized functions.
@ -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<CoroutineKind>) -> &'static str {
match generator_kind {
fn coroutine_kind_label(coroutine_kind: Option<CoroutineKind>) -> &'static str {
match coroutine_kind {
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",
Some(CoroutineKind::Gen) => "coroutine",
None => "closure",
}
}
@ -592,7 +592,7 @@ fn push_unqualified_item_name(
output.push_str(tcx.crate_name(def_id.krate).as_str());
}
DefPathData::ClosureExpr => {
let label = generator_kind_label(tcx.generator_kind(def_id));
let label = coroutine_kind_label(tcx.coroutine_kind(def_id));
push_disambiguated_special_name(
label,
@ -707,7 +707,7 @@ pub fn push_generic_params<'tcx>(
push_generic_params_internal(tcx, args, def_id, output, &mut visited);
}
fn push_closure_or_generator_name<'tcx>(
fn push_closure_or_coroutine_name<'tcx>(
tcx: TyCtxt<'tcx>,
def_id: DefId,
args: GenericArgsRef<'tcx>,
@ -715,10 +715,10 @@ fn push_closure_or_generator_name<'tcx>(
output: &mut String,
visited: &mut FxHashSet<Ty<'tcx>>,
) {
// Name will be "{closure_env#0}<T1, T2, ...>", "{generator_env#0}<T1, T2, ...>", or
// Name will be "{closure_env#0}<T1, T2, ...>", "{coroutine_env#0}<T1, T2, ...>", or
// "{async_fn_env#0}<T1, T2, ...>", etc.
let def_key = tcx.def_key(def_id);
let generator_kind = tcx.generator_kind(def_id);
let coroutine_kind = tcx.coroutine_kind(def_id);
if qualified {
let parent_def_id = DefId { index: def_key.parent.unwrap(), ..def_id };
@ -727,7 +727,7 @@ fn push_closure_or_generator_name<'tcx>(
}
let mut label = String::with_capacity(20);
write!(&mut label, "{}_env", generator_kind_label(generator_kind)).unwrap();
write!(&mut label, "{}_env", coroutine_kind_label(coroutine_kind)).unwrap();
push_disambiguated_special_name(
&label,
@ -736,7 +736,7 @@ fn push_closure_or_generator_name<'tcx>(
output,
);
// We also need to add the generic arguments of the async fn/generator or
// We also need to add the generic arguments of the async fn/coroutine or
// the enclosing function (for closures or async blocks), so that we end
// up with a unique name for every instantiation.
@ -745,7 +745,7 @@ fn push_closure_or_generator_name<'tcx>(
let generics = tcx.generics_of(enclosing_fn_def_id);
// Truncate the args to the length of the above generics. This will cut off
// anything closure- or generator-specific.
// anything closure- or coroutine-specific.
let args = args.truncate_to(tcx, generics);
push_generic_params_internal(tcx, args, enclosing_fn_def_id, output, visited);
}

View file

@ -1266,7 +1266,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
mergeable_succ(),
),
mir::TerminatorKind::CoroutineDrop | mir::TerminatorKind::Yield { .. } => {
bug!("generator ops in codegen")
bug!("coroutine ops in codegen")
}
mir::TerminatorKind::FalseEdge { .. } | mir::TerminatorKind::FalseUnwind { .. } => {
bug!("borrowck false edges in codegen")