Skip to content

Commit c031413

Browse files
authored
Rollup merge of #96986 - kdashg:save-an-enum-vars, r=oli-obk
[save-analysis] Reference the variant not enum at struct-literal cons… …truction. Closes #96985
2 parents 6c6958b + 5fde765 commit c031413

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

compiler/rustc_save_analysis/src/dump_visitor.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -780,13 +780,18 @@ impl<'tcx> DumpVisitor<'tcx> {
780780
variant: &'tcx ty::VariantDef,
781781
rest: Option<&'tcx hir::Expr<'tcx>>,
782782
) {
783-
if let Some(struct_lit_data) = self.save_ctxt.get_expr_data(ex) {
783+
if let Some(_ex_res_data) = self.save_ctxt.get_expr_data(ex) {
784784
if let hir::QPath::Resolved(_, path) = path {
785785
self.write_sub_paths_truncated(path);
786786
}
787-
down_cast_data!(struct_lit_data, RefData, ex.span);
787+
// For MyEnum::MyVariant, get_expr_data gives us MyEnum, not MyVariant.
788+
// For recording the span's ref id, we want MyVariant.
788789
if !generated_code(ex.span) {
789-
self.dumper.dump_ref(struct_lit_data);
790+
let sub_span = path.last_segment_span();
791+
let span = self.save_ctxt.span_from_span(sub_span);
792+
let reff =
793+
Ref { kind: RefKind::Type, span, ref_id: id_from_def_id(variant.def_id) };
794+
self.dumper.dump_ref(reff);
790795
}
791796

792797
for field in fields {

0 commit comments

Comments
 (0)