Skip to content

Commit

Permalink
save_analysis: fix ice in get_expr_data
Browse files Browse the repository at this point in the history
  • Loading branch information
marmeladema committed Jun 5, 2020
1 parent 826cb06 commit 84e4777
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/librustc_save_analysis/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -580,7 +584,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
}
_ => {
// FIXME
bug!();
bug!("invalid expression: {:?}", expr);
}
}
}
Expand Down
13 changes: 13 additions & 0 deletions src/test/ui/save-analysis/issue-73022.rs
Original file line number Diff line number Diff line change
@@ -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() {}

0 comments on commit 84e4777

Please sign in to comment.