Introduce TyCtxt::expect_def/expect_resolution helpers and use them where possible

This commit is contained in:
Vadim Petrochenkov
2016-06-03 23:15:00 +03:00
parent 4c30f6405c
commit ee4e55398b
42 changed files with 276 additions and 472 deletions

View File

@@ -2631,7 +2631,7 @@ fn resolve_type(cx: &DocContext,
};
}
};
let def = tcx.def_map.borrow().get(&id).expect("unresolved id not in defmap").full_def();
let def = tcx.expect_def(id);
debug!("resolve_type: def={:?}", def);
let is_generic = match def {
@@ -2700,7 +2700,7 @@ fn resolve_use_source(cx: &DocContext, path: Path, id: ast::NodeId) -> ImportSou
fn resolve_def(cx: &DocContext, id: ast::NodeId) -> Option<DefId> {
cx.tcx_opt().and_then(|tcx| {
tcx.def_map.borrow().get(&id).map(|d| register_def(cx, d.full_def()))
tcx.expect_def_or_none(id).map(|def| register_def(cx, def))
})
}