Skip to content

Commit 9c31482

Browse files
committed
Refactor msvc_enum_fallbck() a bit
1 parent f6d2843 commit 9c31482

File tree

1 file changed

+12
-19
lines changed

1 file changed

+12
-19
lines changed

compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs

+12-19
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,10 @@ pub fn push_debuginfo_type_name<'tcx>(
367367
) {
368368
let layout = tcx.layout_of(tcx.param_env(def.did).and(ty)).expect("layout error");
369369

370+
output.push_str("enum$<");
371+
push_item_name(tcx, def.did, true, output);
372+
push_generic_params_internal(tcx, substs, output, visited);
373+
370374
if let Variants::Multiple {
371375
tag_encoding: TagEncoding::Niche { dataful_variant, .. },
372376
tag,
@@ -386,30 +390,19 @@ pub fn push_debuginfo_type_name<'tcx>(
386390
let max = dataful_discriminant_range.end();
387391
let max = tag.value.size(&tcx).truncate(*max);
388392

389-
output.push_str("enum$<");
390-
push_item_name(tcx, def.did, true, output);
391-
push_generic_params_internal(tcx, substs, output, visited);
392-
393393
let dataful_variant_name = def.variants[*dataful_variant].ident.as_str();
394394

395-
output.push_str(&format!(", {}, {}, {}>", min, max, dataful_variant_name));
396-
} else {
397-
output.push_str("enum$<");
398-
push_item_name(tcx, def.did, true, output);
399-
push_generic_params_internal(tcx, substs, output, visited);
400-
401-
if let Variants::Single { index: variant_idx } = &layout.variants {
402-
// Uninhabited enums can't be constructed and should never need to be visualized so
403-
// skip this step for them.
404-
if def.variants.len() != 0 {
405-
let variant = def.variants[*variant_idx].ident.as_str();
395+
output.push_str(&format!(", {}, {}, {}", min, max, dataful_variant_name));
396+
} else if let Variants::Single { index: variant_idx } = &layout.variants {
397+
// Uninhabited enums can't be constructed and should never need to be visualized so
398+
// skip this step for them.
399+
if def.variants.len() != 0 {
400+
let variant = def.variants[*variant_idx].ident.as_str();
406401

407-
output.push_str(&format!(", {}", variant));
408-
}
402+
output.push_str(&format!(", {}", variant));
409403
}
410-
411-
push_close_angle_bracket(tcx, output);
412404
}
405+
push_close_angle_bracket(tcx, output);
413406
}
414407
}
415408

0 commit comments

Comments
 (0)