Rollup merge of #62091 - ljedrz:hiridification_almost_there, r=Zoxc

HirIdification: almost there

I'm beginning to run out of stuff to HirIdify 😉.

This time I targeted mainly `hir::map::{find, get_parent_node}`, but a few other bits got changed too.

r? @Zoxc
This commit is contained in:
Mazdak Farrokhzad 2019-06-25 17:15:36 +02:00 committed by GitHub
commit abc7423f27
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
35 changed files with 119 additions and 128 deletions

View file

@ -410,7 +410,10 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
let mut decl_id = None;
let mut docs = String::new();
let mut attrs = vec![];
if let Some(Node::ImplItem(item)) = self.tcx.hir().find(id) {
let hir_id = self.tcx.hir().node_to_hir_id(id);
if let Some(Node::ImplItem(item)) =
self.tcx.hir().find(hir_id)
{
docs = self.docs_for_attrs(&item.attrs);
attrs = item.attrs.to_vec();
}
@ -451,8 +454,9 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
Some(def_id) => {
let mut docs = String::new();
let mut attrs = vec![];
let hir_id = self.tcx.hir().node_to_hir_id(id);
if let Some(Node::TraitItem(item)) = self.tcx.hir().find(id) {
if let Some(Node::TraitItem(item)) = self.tcx.hir().find(hir_id) {
docs = self.docs_for_attrs(&item.attrs);
attrs = item.attrs.to_vec();
}
@ -521,7 +525,8 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
}
match expr.node {
ast::ExprKind::Field(ref sub_ex, ident) => {
let hir_node = match self.tcx.hir().find(sub_ex.id) {
let sub_ex_hir_id = self.tcx.hir().node_to_hir_id(sub_ex.id);
let hir_node = match self.tcx.hir().find(sub_ex_hir_id) {
Some(Node::Expr(expr)) => expr,
_ => {
debug!(
@ -621,7 +626,10 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
Node::PathSegment(seg) => {
match seg.res {
Some(res) if res != Res::Err => res,
_ => self.get_path_res(self.tcx.hir().get_parent_node(id)),
_ => {
let parent_node = self.tcx.hir().get_parent_node(hir_id);
self.get_path_res(self.tcx.hir().hir_to_node_id(parent_node))
},
}
}