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

Commit 64cc7c2

Browse files
authored
Merge pull request #11 from Xanewok/crate-source
Add crate disambiguators
2 parents 20ee392 + 61ead8e commit 64cc7c2

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rls-data"
3-
version = "0.11.0"
3+
version = "0.12.0"
44
authors = ["Nick Cameron <[email protected]>"]
55
description = "Data structures used by the RLS and Rust compiler"
66
license = "Apache-2.0/MIT"

src/lib.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,16 @@ pub struct Id {
8181
pub index: u32,
8282
}
8383

84+
/// Crate name, along with its disambiguator (128-bit hash) represents a globally
85+
/// unique crate identifier, which should allow for differentiation between
86+
/// different crate targets or versions and should point to the same crate when
87+
/// pulled by different other, dependent crates.
88+
#[derive(Debug, Clone, RustcDecodable, RustcEncodable, PartialEq, Eq, Hash)]
89+
pub struct GlobalCrateId {
90+
pub name: String,
91+
pub disambiguator: (u64, u64),
92+
}
93+
8494
#[derive(Debug, Clone, RustcDecodable, RustcEncodable)]
8595
pub struct SpanData {
8696
pub file_name: PathBuf,
@@ -95,7 +105,7 @@ pub struct SpanData {
95105

96106
#[derive(Debug, Clone, RustcDecodable, RustcEncodable)]
97107
pub struct CratePreludeData {
98-
pub crate_name: String,
108+
pub crate_id: GlobalCrateId,
99109
pub crate_root: String,
100110
pub external_crates: Vec<ExternalCrateData>,
101111
pub span: SpanData,
@@ -104,9 +114,13 @@ pub struct CratePreludeData {
104114
/// Data for external crates in the prelude of a crate.
105115
#[derive(Debug, Clone, RustcDecodable, RustcEncodable)]
106116
pub struct ExternalCrateData {
107-
pub name: String,
108-
pub num: u32,
117+
/// Source file where the external crate is declared.
109118
pub file_name: String,
119+
/// A crate-local crate index of an external crate. Local crate index is
120+
/// always 0, so these should start from 1 and range should be contiguous,
121+
/// e.g. from 1 to n for n external crates.
122+
pub num: u32,
123+
pub id: GlobalCrateId,
110124
}
111125

112126
#[derive(Debug, Clone, RustcDecodable, RustcEncodable)]

0 commit comments

Comments
 (0)