From 60e19ce9e60ae054d1c468d1a4385bad3fbb8f63 Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Fri, 17 Jun 2016 15:14:25 +0100 Subject: [PATCH] save-analysis: fix a bug with tuple sub-expressions --- src/librustc_save_analysis/dump_visitor.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index 56c7436a8fe5c..906c3e87a6d99 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -29,6 +29,7 @@ use rustc::hir::def::Def; use rustc::hir::def_id::DefId; +use rustc::hir::map::Node; use rustc::session::Session; use rustc::ty::{self, TyCtxt, ImplOrTraitItem, ImplOrTraitItemContainer}; @@ -1297,7 +1298,14 @@ impl<'v, 'l, 'tcx: 'l, 'll, D: Dump +'ll> Visitor<'v> for DumpVisitor<'l, 'tcx, ast::ExprKind::TupField(ref sub_ex, idx) => { self.visit_expr(&sub_ex); - let hir_node = self.save_ctxt.tcx.map.expect_expr(sub_ex.id); + let hir_node = match self.save_ctxt.tcx.map.find(sub_ex.id) { + Some(Node::NodeExpr(expr)) => expr, + _ => { + debug!("Missing or weird node for sub-expression {} in {:?}", + sub_ex.id, ex); + return; + } + }; let ty = &self.tcx.expr_ty_adjusted(&hir_node).sty; match *ty { ty::TyStruct(def, _) => {