diff options
| author | Yuki Okushi <jtitor@2k36.org> | 2022-05-14 13:42:50 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-14 13:42:50 +0900 |
| commit | c031413f2897562c97f989266a2c6c95f9a45e71 (patch) | |
| tree | 424c2150eebae8e46e5db7eef4835a2190eb7201 | |
| parent | 6c6958b5315961deb569505b97db34abd5d7f392 (diff) | |
| parent | 5fde765df08d5f9d22df1368a8dbc0ed99e52b04 (diff) | |
| download | rust-c031413f2897562c97f989266a2c6c95f9a45e71.tar.gz rust-c031413f2897562c97f989266a2c6c95f9a45e71.zip | |
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
| -rw-r--r-- | compiler/rustc_save_analysis/src/dump_visitor.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/compiler/rustc_save_analysis/src/dump_visitor.rs b/compiler/rustc_save_analysis/src/dump_visitor.rs index e1c9ecc055f..fe417f45e88 100644 --- a/compiler/rustc_save_analysis/src/dump_visitor.rs +++ b/compiler/rustc_save_analysis/src/dump_visitor.rs @@ -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 { |
