1
Fork 0

rustc_hir: Change representation of import paths to support multiple resolutions

This commit is contained in:
Vadim Petrochenkov 2022-11-25 17:39:38 +03:00
parent 6cd4dd3091
commit 1f259ae679
19 changed files with 136 additions and 114 deletions

View file

@ -185,13 +185,13 @@ impl<'tcx> DumpVisitor<'tcx> {
}
}
fn write_sub_paths(&mut self, path: &'tcx hir::Path<'tcx>) {
fn write_sub_paths<R>(&mut self, path: &'tcx hir::Path<'tcx, R>) {
self.write_segments(path.segments)
}
// As write_sub_paths, but does not process the last ident in the path (assuming it
// will be processed elsewhere). See note on write_sub_paths about global.
fn write_sub_paths_truncated(&mut self, path: &'tcx hir::Path<'tcx>) {
fn write_sub_paths_truncated<R>(&mut self, path: &'tcx hir::Path<'tcx, R>) {
if let [segments @ .., _] = path.segments {
self.write_segments(segments)
}

View file

@ -594,7 +594,9 @@ impl<'tcx> SaveContext<'tcx> {
match self.tcx.hir().get(hir_id) {
Node::TraitRef(tr) => tr.path.res,
Node::Item(&hir::Item { kind: hir::ItemKind::Use(path, _), .. }) => path.res,
Node::Item(&hir::Item { kind: hir::ItemKind::Use(path, _), .. }) => {
path.res.get(0).copied().unwrap_or(Res::Err)
}
Node::PathSegment(seg) => {
if seg.res != Res::Err {
seg.res