Skip to content
This repository has been archived by the owner on Mar 1, 2019. It is now read-only.

Add crate disambiguators #11

Merged
merged 3 commits into from
Oct 27, 2017
Merged
Changes from 1 commit
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
15 changes: 11 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ pub struct Id {
pub index: u32,
}

/// This represents a globally unique crate identifier, which should allow
/// for differentiation between different crate targets or versions and should
/// point to the same crate when pulled by different other, dependent crates.
#[derive(Debug, Clone, RustcDecodable, RustcEncodable, PartialEq, Eq, Hash)]
pub struct GlobalCrateId {
pub name: String,
pub disambiguator: String,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you document what the disambiguator looks like please? What are the valid values?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nrc so the disambiguator was changed internally from a hex-string to a 128 bit number (Fingerprint(u64, u64), here), as it was effectively a hex-formatted 128 bit value in a string.
Should I change it to use a u128 or (u64, u64) here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't see where Fingerprint was defined. Ideally, you would use FingerPrint here, but that would probably mean pulling it into rls-data which might not be practical. If FingerPrint is defined as (u64, u64) then I'd use that, otherwise u128.

}

#[derive(Debug, Clone, RustcDecodable, RustcEncodable)]
pub struct SpanData {
pub file_name: PathBuf,
Expand All @@ -95,9 +104,8 @@ pub struct SpanData {

#[derive(Debug, Clone, RustcDecodable, RustcEncodable)]
pub struct CratePreludeData {
pub crate_name: String,
pub crate_id: GlobalCrateId,
pub crate_root: String,
pub crate_disambiguator: String,
pub external_crates: Vec<ExternalCrateData>,
pub span: SpanData,
}
Expand All @@ -111,8 +119,7 @@ pub struct ExternalCrateData {
/// always 0, so these should start from 1 and range should be contiguous,
/// e.g. from 1 to n for n external crates.
pub num: u32,
pub name: String,
pub disambiguator: String,
pub id: GlobalCrateId,
}

#[derive(Debug, Clone, RustcDecodable, RustcEncodable)]
Expand Down