Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

save-analysis: fix a bug with tuple sub-expressions #34327

Merged
merged 1 commit into from
Jul 7, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/librustc_save_analysis/dump_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: If sub_ex.id is not mapped to an hir expression node, I think that's solely a problem with sub_ex and sub_ex.id -- I don't think ex is relevant.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My reasoning is that if subex is messed up for some other reason, then it is useful to have an expression which we know is not messed up. I also find it easier to debug this way - you get a reference to say (a, b, x + 4) rather than a and the former is easier to grep for.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense.

return;
}
};
let ty = &self.tcx.expr_ty_adjusted(&hir_node).sty;
match *ty {
ty::TyStruct(def, _) => {
Expand Down