Skip to content

Emit crate disambiguators in save-analysis data #45468

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 13 additions & 29 deletions src/Cargo.lock

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

5 changes: 5 additions & 0 deletions src/librustc/ich/fingerprint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ impl Fingerprint {
self.0
}

#[inline]
pub fn as_value(&self) -> (u64, u64) {
(self.0, self.1)
}

#[inline]
pub fn combine(self, other: Fingerprint) -> Fingerprint {
// See https://stackoverflow.com/a/27952689 on why this function is
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_save_analysis/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "0.12"
rls-span = "0.4"
# FIXME(#40527) should move rustc serialize out of tree
rustc-serialize = "0.3"
10 changes: 7 additions & 3 deletions src/librustc_save_analysis/dump_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -131,7 +131,11 @@ 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_fingerprint().as_value(),
},
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),
Expand Down
18 changes: 9 additions & 9 deletions src/librustc_save_analysis/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;


Expand All @@ -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};
Expand Down Expand Up @@ -119,9 +115,13 @@ 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_fingerprint().as_value(),
},
});
}

Expand Down Expand Up @@ -725,8 +725,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 {
Expand Down
2 changes: 1 addition & 1 deletion src/tools/rls
Submodule rls updated from e03485 to 48fd42