diff options
| author | bors <bors@rust-lang.org> | 2016-05-29 11:23:00 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2016-05-29 11:23:00 -0700 |
| commit | a2a8694128e738d194b33aa10698e6cf2e225879 (patch) | |
| tree | 82ad2e7973f5fdc47a1e5136f67cd99f9c2bd98e /src | |
| parent | 8f3e8c7863b5af9c85f13ec546d7897359acd32f (diff) | |
| parent | c8ee3f20823251b6141f3046593526c5bb218da3 (diff) | |
| download | rust-a2a8694128e738d194b33aa10698e6cf2e225879.tar.gz rust-a2a8694128e738d194b33aa10698e6cf2e225879.zip | |
Auto merge of #33859 - nrc:save-field-sub, r=pnkfelix
save-analysis: be a bit more defensive with field sub-expressions Prevents an ice with `(...).f` since the sub-expression is in the AST but not the HIR. We could actually do better in this specific case, but it doesn't seem worth it.
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_save_analysis/lib.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index 05de5d2770d..23c03670c1e 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -38,7 +38,7 @@ pub mod external_data; pub mod span_utils; use rustc::hir; -use rustc::hir::map::NodeItem; +use rustc::hir::map::{Node, NodeItem}; use rustc::hir::def::Def; use rustc::hir::def_id::DefId; use rustc::session::config::CrateType::CrateTypeExecutable; @@ -391,7 +391,14 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { } match expr.node { ast::ExprKind::Field(ref sub_ex, ident) => { - let hir_node = self.tcx.map.expect_expr(sub_ex.id); + let hir_node = match self.tcx.map.find(sub_ex.id) { + Some(Node::NodeExpr(expr)) => expr, + _ => { + debug!("Missing or weird node for sub-expression {} in {:?}", + sub_ex.id, expr); + return None; + } + }; match self.tcx.expr_ty_adjusted(&hir_node).sty { ty::TyStruct(def, _) => { let f = def.struct_variant().field_named(ident.node.name); @@ -411,7 +418,6 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { } } ast::ExprKind::Struct(ref path, _, _) => { - let hir_node = self.tcx.map.expect_expr(expr.id); match self.tcx.expr_ty_adjusted(&hir_node).sty { ty::TyStruct(def, _) => { let sub_span = self.span_utils.span_for_last_ident(path.span); |
