Emit crate disambiguators in save-analysis data
This commit is contained in:
parent
f7b080b38e
commit
e3afba5b7b
3 changed files with 15 additions and 13 deletions
|
|
@ -15,7 +15,7 @@ rustc_data_structures = { path = "../librustc_data_structures" }
|
|||
rustc_typeck = { path = "../librustc_typeck" }
|
||||
syntax = { path = "../libsyntax" }
|
||||
syntax_pos = { path = "../libsyntax_pos" }
|
||||
rls-data = "0.11"
|
||||
rls-data = { git = "https://github.com/Xanewok/rls-data", branch = "crate-source" }
|
||||
rls-span = "0.4"
|
||||
# FIXME(#40527) should move rustc serialize out of tree
|
||||
rustc-serialize = "0.3"
|
||||
|
|
|
|||
|
|
@ -46,8 +46,8 @@ use json_dumper::{JsonDumper, DumpOutput};
|
|||
use span_utils::SpanUtils;
|
||||
use sig;
|
||||
|
||||
use rls_data::{CratePreludeData, Import, ImportKind, SpanData, Ref, RefKind,
|
||||
Def, DefKind, Relation, RelationKind};
|
||||
use rls_data::{CratePreludeData, GlobalCrateId, Import, ImportKind, SpanData,
|
||||
Ref, RefKind, Def, DefKind, Relation, RelationKind};
|
||||
|
||||
macro_rules! down_cast_data {
|
||||
($id:ident, $kind:ident, $sp:expr) => {
|
||||
|
|
@ -131,7 +131,10 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
|
|||
});
|
||||
|
||||
let data = CratePreludeData {
|
||||
crate_name: name.into(),
|
||||
crate_id: GlobalCrateId {
|
||||
name: name.into(),
|
||||
disambiguator: self.tcx.sess.local_crate_disambiguator().to_string(),
|
||||
},
|
||||
crate_root: crate_root.unwrap_or("<no source>".to_owned()),
|
||||
external_crates: self.save_ctxt.get_external_crates(),
|
||||
span: self.span_from_span(krate.span),
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ use dump_visitor::DumpVisitor;
|
|||
use span_utils::SpanUtils;
|
||||
|
||||
use rls_data::{Ref, RefKind, SpanData, MacroRef, Def, DefKind, Relation, RelationKind,
|
||||
ExternalCrateData};
|
||||
ExternalCrateData, GlobalCrateId};
|
||||
use rls_data::config::Config;
|
||||
|
||||
|
||||
|
|
@ -82,10 +82,6 @@ pub enum Data {
|
|||
RelationData(Relation),
|
||||
}
|
||||
|
||||
macro_rules! option_try(
|
||||
($e:expr) => (match $e { Some(e) => e, None => return None })
|
||||
);
|
||||
|
||||
impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
||||
fn span_from_span(&self, span: Span) -> SpanData {
|
||||
use rls_span::{Row, Column};
|
||||
|
|
@ -119,9 +115,12 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
|||
};
|
||||
let lo_loc = self.span_utils.sess.codemap().lookup_char_pos(span.lo());
|
||||
result.push(ExternalCrateData {
|
||||
name: self.tcx.crate_name(n).to_string(),
|
||||
num: n.as_u32(),
|
||||
file_name: SpanUtils::make_path_string(&lo_loc.file.name),
|
||||
num: n.as_u32(),
|
||||
id: GlobalCrateId {
|
||||
name: self.tcx.crate_name(n).to_string(),
|
||||
disambiguator: self.tcx.crate_disambiguator(n).to_string(),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -725,8 +724,8 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
|||
// macro uses.
|
||||
let callsite = span.source_callsite();
|
||||
let callsite_span = self.span_from_span(callsite);
|
||||
let callee = option_try!(span.source_callee());
|
||||
let callee_span = option_try!(callee.span);
|
||||
let callee = span.source_callee()?;
|
||||
let callee_span = callee.span?;
|
||||
|
||||
// Ignore attribute macros, their spans are usually mangled
|
||||
if let MacroAttribute(_) = callee.format {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue