Skip to content

Commit

Permalink
Rollup merge of #96986 - kdashg:save-an-enum-vars, r=oli-obk
Browse files Browse the repository at this point in the history
[save-analysis] Reference the variant not enum at struct-literal cons…

…truction.

Closes #96985
  • Loading branch information
JohnTitor committed May 14, 2022
2 parents 6c6958b + 5fde765 commit c031413
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions compiler/rustc_save_analysis/src/dump_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -780,13 +780,18 @@ impl<'tcx> DumpVisitor<'tcx> {
variant: &'tcx ty::VariantDef,
rest: Option<&'tcx hir::Expr<'tcx>>,
) {
if let Some(struct_lit_data) = self.save_ctxt.get_expr_data(ex) {
if let Some(_ex_res_data) = self.save_ctxt.get_expr_data(ex) {
if let hir::QPath::Resolved(_, path) = path {
self.write_sub_paths_truncated(path);
}
down_cast_data!(struct_lit_data, RefData, ex.span);
// For MyEnum::MyVariant, get_expr_data gives us MyEnum, not MyVariant.
// For recording the span's ref id, we want MyVariant.
if !generated_code(ex.span) {
self.dumper.dump_ref(struct_lit_data);
let sub_span = path.last_segment_span();
let span = self.save_ctxt.span_from_span(sub_span);
let reff =
Ref { kind: RefKind::Type, span, ref_id: id_from_def_id(variant.def_id) };
self.dumper.dump_ref(reff);
}

for field in fields {
Expand Down

0 comments on commit c031413

Please sign in to comment.