Skip to content

Commit 1328c29

Browse files
committed
save-analysis: fix bug with method ids
This just handles a missing entry, doesn't try to recover, because I couldn't actually find a test case. cc rust-lang/rls#558
1 parent 9593799 commit 1328c29

File tree

1 file changed

+7
-1
lines changed
  • src/librustc_save_analysis

1 file changed

+7
-1
lines changed

src/librustc_save_analysis/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,13 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
548548
}
549549
ast::ExprKind::MethodCall(ref seg, ..) => {
550550
let expr_hir_id = self.tcx.hir.definitions().node_to_hir_id(expr.id);
551-
let method_id = self.tables.type_dependent_defs()[expr_hir_id].def_id();
551+
let method_id = match self.tables.type_dependent_defs().get(expr_hir_id) {
552+
Some(id) => id.def_id(),
553+
None => {
554+
debug!("Could not resolve method id for {:?}", expr);
555+
return None;
556+
}
557+
};
552558
let (def_id, decl_id) = match self.tcx.associated_item(method_id).container {
553559
ty::ImplContainer(_) => (Some(method_id), None),
554560
ty::TraitContainer(_) => (None, Some(method_id)),

0 commit comments

Comments
 (0)