save-analysis: use qpath_def
for associated types
This commit is contained in:
parent
850912704e
commit
1ced262653
2 changed files with 4 additions and 19 deletions
|
@ -23,7 +23,6 @@ use rustc::middle::cstore::ExternCrate;
|
||||||
use rustc::session::config::{CrateType, Input, OutputType};
|
use rustc::session::config::{CrateType, Input, OutputType};
|
||||||
use rustc::ty::{self, DefIdTree, TyCtxt};
|
use rustc::ty::{self, DefIdTree, TyCtxt};
|
||||||
use rustc::{bug, span_bug};
|
use rustc::{bug, span_bug};
|
||||||
use rustc_typeck::hir_ty_to_ty;
|
|
||||||
use rustc_codegen_utils::link::{filename_for_metadata, out_filename};
|
use rustc_codegen_utils::link::{filename_for_metadata, out_filename};
|
||||||
use rustc_data_structures::sync::Lrc;
|
use rustc_data_structures::sync::Lrc;
|
||||||
|
|
||||||
|
@ -658,23 +657,9 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
||||||
..
|
..
|
||||||
}) => HirDef::Local(self.tcx.hir().hir_to_node_id(canonical_id)),
|
}) => HirDef::Local(self.tcx.hir().hir_to_node_id(canonical_id)),
|
||||||
|
|
||||||
Node::Ty(ty) => if let hir::Ty {
|
Node::Ty(&hir::Ty { node: hir::TyKind::Path(ref qpath), .. } ) => {
|
||||||
node: hir::TyKind::Path(ref qpath),
|
let hir_id = self.tcx.hir().node_to_hir_id(id);
|
||||||
..
|
self.tables.qpath_def(qpath, hir_id)
|
||||||
} = *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
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_ => HirDef::Err,
|
_ => HirDef::Err,
|
||||||
|
|
|
@ -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.
|
/// 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> {
|
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"
|
// In case there are any projections etc, find the "environment"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue