Skip to content

Commit

Permalink
save-analysis: use qpath_def for associated types
Browse files Browse the repository at this point in the history
  • Loading branch information
Xanewok committed May 16, 2019
1 parent 2bafaaf commit 7b9f9fa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 19 deletions.
21 changes: 3 additions & 18 deletions src/librustc_save_analysis/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ use rustc::middle::cstore::ExternCrate;
use rustc::session::config::{CrateType, Input, OutputType};
use rustc::ty::{self, DefIdTree, TyCtxt};
use rustc::{bug, span_bug};
use rustc_typeck::hir_ty_to_ty;
use rustc_codegen_utils::link::{filename_for_metadata, out_filename};
use rustc_data_structures::sync::Lrc;

Expand Down Expand Up @@ -658,23 +657,9 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
..
}) => HirDef::Local(self.tcx.hir().hir_to_node_id(canonical_id)),

Node::Ty(ty) => if let hir::Ty {
node: hir::TyKind::Path(ref qpath),
..
} = *ty
{
match *qpath {
hir::QPath::Resolved(_, ref path) => path.def,
hir::QPath::TypeRelative(..) => {
let ty = hir_ty_to_ty(self.tcx, ty);
if let ty::Projection(proj) = ty.sty {
return HirDef::AssociatedTy(proj.item_def_id);
}
HirDef::Err
}
}
} else {
HirDef::Err
Node::Ty(&hir::Ty { node: hir::TyKind::Path(ref qpath), .. } ) => {
let hir_id = self.tcx.hir().node_to_hir_id(id);
self.tables.qpath_def(qpath, hir_id)
},

_ => HirDef::Err,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>)
}
}

/// A quasi-deprecated helper used in rustdoc and save-analysis to get
/// A quasi-deprecated helper used in rustdoc and clippy to get
/// the type from a HIR node.
pub fn hir_ty_to_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, hir_ty: &hir::Ty) -> Ty<'tcx> {
// In case there are any projections etc, find the "environment"
Expand Down

0 comments on commit 7b9f9fa

Please sign in to comment.