about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc_save_analysis/lib.rs10
-rw-r--r--src/test/ui/save-analysis/issue-73022.rs13
2 files changed, 20 insertions, 3 deletions
diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs
index 8c7731c18e9..0341b542526 100644
--- a/src/librustc_save_analysis/lib.rs
+++ b/src/librustc_save_analysis/lib.rs
@@ -534,10 +534,14 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
                     }
                 }
             }
-            hir::ExprKind::Struct(hir::QPath::Resolved(_, path), ..) => {
+            hir::ExprKind::Struct(qpath, ..) => {
+                let segment = match qpath {
+                    hir::QPath::Resolved(_, path) => path.segments.last().unwrap(),
+                    hir::QPath::TypeRelative(_, segment) => segment,
+                };
                 match self.tables.expr_ty_adjusted(&hir_node).kind {
                     ty::Adt(def, _) if !def.is_enum() => {
-                        let sub_span = path.segments.last().unwrap().ident.span;
+                        let sub_span = segment.ident.span;
                         filter!(self.span_utils, sub_span);
                         let span = self.span_from_span(sub_span);
                         Some(Data::RefData(Ref {
@@ -580,7 +584,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
             }
             _ => {
                 // FIXME
-                bug!();
+                bug!("invalid expression: {:?}", expr);
             }
         }
     }
diff --git a/src/test/ui/save-analysis/issue-73022.rs b/src/test/ui/save-analysis/issue-73022.rs
new file mode 100644
index 00000000000..9ad89a319ba
--- /dev/null
+++ b/src/test/ui/save-analysis/issue-73022.rs
@@ -0,0 +1,13 @@
+// build-pass
+// compile-flags: -Zsave-analysis
+enum Enum2 {
+    Variant8 { _field: bool },
+}
+
+impl Enum2 {
+    fn new_variant8() -> Enum2 {
+        Self::Variant8 { _field: true }
+    }
+}
+
+fn main() {}