Skip to content

Commit

Permalink
convert save-analysis to use ItemCtxt and not ast_ty_to_ty_cache
Browse files Browse the repository at this point in the history
  • Loading branch information
nikomatsakis committed May 4, 2017
1 parent 196c98d commit 3039398
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/librustc_save_analysis/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ crate-type = ["dylib"]
[dependencies]
log = "0.3"
rustc = { path = "../librustc" }
rustc_typeck = { path = "../librustc_typeck" }
syntax = { path = "../libsyntax" }
syntax_pos = { path = "../libsyntax_pos" }
rls-data = "0.1"
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_save_analysis/dump_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
f(self);
self.save_ctxt.tables = old_tables;
} else {
f(self)
f(self);
}
}

Expand Down
17 changes: 11 additions & 6 deletions src/librustc_save_analysis/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#[macro_use] extern crate log;
#[macro_use] extern crate syntax;
extern crate rustc_serialize;
extern crate rustc_typeck;
extern crate syntax_pos;

extern crate rls_data;
Expand All @@ -50,6 +51,7 @@ use rustc::hir::def_id::DefId;
use rustc::session::config::CrateType::CrateTypeExecutable;
use rustc::session::Session;
use rustc::ty::{self, TyCtxt};
use rustc_typeck::hir_ty_to_ty;

use std::env;
use std::fs::File;
Expand Down Expand Up @@ -606,11 +608,12 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
Def::Local(def_id)
}

Node::NodeTy(&hir::Ty { node: hir::TyPath(ref qpath), .. }) => {
match *qpath {
hir::QPath::Resolved(_, ref path) => path.def,
hir::QPath::TypeRelative(..) => {
if let Some(ty) = self.tcx.ast_ty_to_ty_cache.borrow().get(&id) {
Node::NodeTy(ty) => {
if let hir::Ty { node: hir::TyPath(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::TyProjection(proj) = ty.sty {
for item in self.tcx.associated_items(proj.trait_ref.def_id) {
if item.kind == ty::AssociatedKind::Type {
Expand All @@ -620,9 +623,11 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
}
}
}
Def::Err
}
Def::Err
}
} else {
Def::Err
}
}

Expand Down

0 comments on commit 3039398

Please sign in to comment.