Skip to content

Commit 1f9f94d

Browse files
Rollup merge of rust-lang#157294 - cjgillot:split-coroutine-layout, r=oli-obk
Split coroutine layout computation to its own file `coroutine.rs` is getting too large, and mixes MIR analyses for trait solving and runtime transformations.
2 parents e68c830 + ac63a3e commit 1f9f94d

7 files changed

Lines changed: 742 additions & 708 deletions

File tree

compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,8 @@ fn build_coroutine_variant_struct_type_di_node<'ll, 'tcx>(
328328
.map(|field_index| {
329329
let coroutine_saved_local = coroutine_layout.variant_fields[variant_index]
330330
[FieldIdx::from_usize(field_index)];
331-
let field_name_maybe = coroutine_layout.field_names[coroutine_saved_local];
331+
let field_name_maybe =
332+
coroutine_layout.field_tys[coroutine_saved_local].debuginfo_name;
332333
let field_name = field_name_maybe
333334
.as_ref()
334335
.map(|s| Cow::from(s.as_str()))

compiler/rustc_middle/src/mir/pretty.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -429,9 +429,9 @@ fn write_scope_tree(
429429

430430
// Coroutine debuginfo.
431431
if let Some(layout) = body.coroutine_layout_raw() {
432-
for (field, name) in layout.field_names.iter_enumerated() {
433-
let source_info = layout.field_tys[field].source_info;
434-
if let Some(name) = name
432+
for (field, field_decl) in layout.field_tys.iter_enumerated() {
433+
let source_info = field_decl.source_info;
434+
if let Some(name) = field_decl.debuginfo_name
435435
&& source_info.scope == parent
436436
{
437437
let indented_debug_info =
@@ -559,17 +559,12 @@ fn write_coroutine_layout<'tcx>(
559559
w: &mut dyn io::Write,
560560
options: PrettyPrintMirOptions,
561561
) -> io::Result<()> {
562-
let CoroutineLayout {
563-
field_tys,
564-
field_names: _, // Dumped in scope tree with debug info.
565-
variant_fields,
566-
variant_source_info,
567-
storage_conflicts,
568-
} = layout;
562+
let CoroutineLayout { field_tys, variant_fields, variant_source_info, storage_conflicts } =
563+
layout;
569564

570565
writeln!(w, "{INDENT}coroutine layout {{")?;
571566

572-
for (field, CoroutineSavedTy { ty, source_info, ignore_for_traits }) in
567+
for (field, CoroutineSavedTy { ty, source_info, ignore_for_traits, debuginfo_name: _ }) in
573568
field_tys.iter_enumerated()
574569
{
575570
let ignore_for_traits = if *ignore_for_traits { " (ignored for traits)" } else { "" };

compiler/rustc_middle/src/mir/query.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ pub struct CoroutineSavedTy<'tcx> {
2727
pub source_info: SourceInfo,
2828
/// Whether the local should be ignored for trait bound computations.
2929
pub ignore_for_traits: bool,
30+
/// The name for debuginfo.
31+
pub debuginfo_name: Option<Symbol>,
3032
}
3133

3234
/// The layout of coroutine state.
@@ -36,9 +38,6 @@ pub struct CoroutineLayout<'tcx> {
3638
/// The type of every local stored inside the coroutine.
3739
pub field_tys: IndexVec<CoroutineSavedLocal, CoroutineSavedTy<'tcx>>,
3840

39-
/// The name for debuginfo.
40-
pub field_names: IndexVec<CoroutineSavedLocal, Option<Symbol>>,
41-
4241
/// Which of the above fields are in each variant. Note that one field may
4342
/// be stored in multiple variants.
4443
pub variant_fields: IndexVec<VariantIdx, IndexVec<FieldIdx, CoroutineSavedLocal>>,

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1929,7 +1929,6 @@ impl<'tcx> TyCtxt<'tcx> {
19291929
iter::repeat(source_info).take(CoroutineArgs::RESERVED_VARIANTS).collect();
19301930
let proxy_layout = CoroutineLayout {
19311931
field_tys: [].into(),
1932-
field_names: [].into(),
19331932
variant_fields,
19341933
variant_source_info,
19351934
storage_conflicts: BitMatrix::new(0, 0),

0 commit comments

Comments
 (0)