Skip to content

Commit 3039398

Browse files
committed
convert save-analysis to use ItemCtxt and not ast_ty_to_ty_cache
1 parent 196c98d commit 3039398

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

src/Cargo.lock

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/librustc_save_analysis/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ crate-type = ["dylib"]
1111
[dependencies]
1212
log = "0.3"
1313
rustc = { path = "../librustc" }
14+
rustc_typeck = { path = "../librustc_typeck" }
1415
syntax = { path = "../libsyntax" }
1516
syntax_pos = { path = "../libsyntax_pos" }
1617
rls-data = "0.1"

src/librustc_save_analysis/dump_visitor.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
122122
f(self);
123123
self.save_ctxt.tables = old_tables;
124124
} else {
125-
f(self)
125+
f(self);
126126
}
127127
}
128128

src/librustc_save_analysis/lib.rs

+11-6
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#[macro_use] extern crate log;
2828
#[macro_use] extern crate syntax;
2929
extern crate rustc_serialize;
30+
extern crate rustc_typeck;
3031
extern crate syntax_pos;
3132

3233
extern crate rls_data;
@@ -50,6 +51,7 @@ use rustc::hir::def_id::DefId;
5051
use rustc::session::config::CrateType::CrateTypeExecutable;
5152
use rustc::session::Session;
5253
use rustc::ty::{self, TyCtxt};
54+
use rustc_typeck::hir_ty_to_ty;
5355

5456
use std::env;
5557
use std::fs::File;
@@ -606,11 +608,12 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
606608
Def::Local(def_id)
607609
}
608610

609-
Node::NodeTy(&hir::Ty { node: hir::TyPath(ref qpath), .. }) => {
610-
match *qpath {
611-
hir::QPath::Resolved(_, ref path) => path.def,
612-
hir::QPath::TypeRelative(..) => {
613-
if let Some(ty) = self.tcx.ast_ty_to_ty_cache.borrow().get(&id) {
611+
Node::NodeTy(ty) => {
612+
if let hir::Ty { node: hir::TyPath(ref qpath), .. } = *ty {
613+
match *qpath {
614+
hir::QPath::Resolved(_, ref path) => path.def,
615+
hir::QPath::TypeRelative(..) => {
616+
let ty = hir_ty_to_ty(self.tcx, ty);
614617
if let ty::TyProjection(proj) = ty.sty {
615618
for item in self.tcx.associated_items(proj.trait_ref.def_id) {
616619
if item.kind == ty::AssociatedKind::Type {
@@ -620,9 +623,11 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
620623
}
621624
}
622625
}
626+
Def::Err
623627
}
624-
Def::Err
625628
}
629+
} else {
630+
Def::Err
626631
}
627632
}
628633

0 commit comments

Comments
 (0)