diff --git a/src/Cargo.lock b/src/Cargo.lock index ccdb24d737551..649c1bdd23aca 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -1681,6 +1681,15 @@ dependencies = [ "serde_derive 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rls-data" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rls-rustc" version = "0.2.2" @@ -2108,7 +2117,7 @@ name = "rustc_save_analysis" version = "0.0.0" dependencies = [ "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rls-data 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rls-data 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", "rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc 0.0.0", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3134,6 +3143,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum rls-analysis 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b339561571efd8d2d4ae1b16eb27f760cad46907d49e9726242844dbbde14e79" "checksum rls-blacklist 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e4a9cc2545ccb7e05b355bfe047b8039a6ec12270d5f3c996b766b340a50f7d2" "checksum rls-data 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bea04462e94b5512a78499837eecb7db182ff082144cd1b4bc32ef5d43de6510" +"checksum rls-data 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3dd20763e1c60ae8945384c8a8fa4ac44f8afa7b0a817511f5e8927e5d24f988" "checksum rls-rustc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "885f66b92757420572cbb02e033d4a9558c7413ca9b7ac206f28fd58ffdb44ea" "checksum rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5d7c7046dc6a92f2ae02ed302746db4382e75131b9ce20ce967259f6b5867a6a" "checksum rls-vfs 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "be231e1e559c315bc60ced5ad2cc2d7a9c208ed7d4e2c126500149836fda19bb" diff --git a/src/librustc_save_analysis/Cargo.toml b/src/librustc_save_analysis/Cargo.toml index 976614c9542a8..7b94170ef6d99 100644 --- a/src/librustc_save_analysis/Cargo.toml +++ b/src/librustc_save_analysis/Cargo.toml @@ -16,7 +16,7 @@ rustc_target = { path = "../librustc_target" } rustc_typeck = { path = "../librustc_typeck" } syntax = { path = "../libsyntax" } syntax_pos = { path = "../libsyntax_pos" } -rls-data = "0.15" +rls-data = "0.16" rls-span = "0.4" # FIXME(#40527) should move rustc serialize out of tree rustc-serialize = "0.3" diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index abaa02a856e9c..2ef294fe43089 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -268,80 +268,6 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { } } - fn process_def_kind( - &mut self, - ref_id: NodeId, - span: Span, - sub_span: Option, - def_id: DefId, - ) { - if self.span.filter_generated(sub_span, span) { - return; - } - - let def = self.save_ctxt.get_path_def(ref_id); - match def { - HirDef::Mod(_) => { - let span = self.span_from_span(sub_span.expect("No span found for mod ref")); - self.dumper.dump_ref(Ref { - kind: RefKind::Mod, - span, - ref_id: ::id_from_def_id(def_id), - }); - } - HirDef::Struct(..) | - HirDef::Variant(..) | - HirDef::Union(..) | - HirDef::Enum(..) | - HirDef::TyAlias(..) | - HirDef::TyForeign(..) | - HirDef::TraitAlias(..) | - HirDef::Trait(_) => { - let span = self.span_from_span(sub_span.expect("No span found for type ref")); - self.dumper.dump_ref(Ref { - kind: RefKind::Type, - span, - ref_id: ::id_from_def_id(def_id), - }); - } - HirDef::Static(..) | - HirDef::Const(..) | - HirDef::StructCtor(..) | - HirDef::VariantCtor(..) => { - let span = self.span_from_span(sub_span.expect("No span found for var ref")); - self.dumper.dump_ref(Ref { - kind: RefKind::Variable, - span, - ref_id: ::id_from_def_id(def_id), - }); - } - HirDef::Fn(..) => { - let span = self.span_from_span(sub_span.expect("No span found for fn ref")); - self.dumper.dump_ref(Ref { - kind: RefKind::Function, - span, - ref_id: ::id_from_def_id(def_id), - }); - } - // With macros 2.0, we can legitimately get a ref to a macro, but - // we don't handle it properly for now (FIXME). - HirDef::Macro(..) => {} - HirDef::Local(..) | - HirDef::Upvar(..) | - HirDef::SelfTy(..) | - HirDef::Label(_) | - HirDef::TyParam(..) | - HirDef::Method(..) | - HirDef::AssociatedTy(..) | - HirDef::AssociatedConst(..) | - HirDef::PrimTy(_) | - HirDef::GlobalAsm(_) | - HirDef::Err => { - span_bug!(span, "process_def_kind for unexpected item: {:?}", def); - } - } - } - fn process_formals(&mut self, formals: &'l [ast::Arg], qualname: &str) { for arg in formals { self.visit_pat(&arg.pat); @@ -1348,29 +1274,17 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { }; let sub_span = self.span.span_for_last_ident(path.span); - let mod_id = match self.lookup_def_id(id) { - Some(def_id) => { - self.process_def_kind(id, path.span, sub_span, def_id); - Some(def_id) - } - None => None, - }; - - // 'use' always introduces an alias, if there is not an explicit - // one, there is an implicit one. - let sub_span = match self.span.sub_span_after_keyword(use_tree.span, - keywords::As) { - Some(sub_span) => Some(sub_span), - None => sub_span, - }; + let alias_span = self.span.sub_span_after_keyword(use_tree.span, keywords::As); + let ref_id = self.lookup_def_id(id); if !self.span.filter_generated(sub_span, path.span) { - let span = - self.span_from_span(sub_span.expect("No span found for use")); + let span = self.span_from_span(sub_span.expect("No span found for use")); + let alias_span = alias_span.map(|sp| self.span_from_span(sp)); self.dumper.import(&access, Import { kind: ImportKind::Use, - ref_id: mod_id.map(|id| ::id_from_def_id(id)), + ref_id: ref_id.map(|id| ::id_from_def_id(id)), span, + alias_span, name: ident.to_string(), value: String::new(), parent, @@ -1407,6 +1321,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { kind: ImportKind::GlobUse, ref_id: None, span, + alias_span: None, name: "*".to_owned(), value: names.join(", "), parent, @@ -1500,6 +1415,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc kind: ImportKind::ExternCrate, ref_id: None, span, + alias_span: None, name: item.ident.to_string(), value: String::new(), parent,