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

Commit

Permalink
Merge pull request #11 from Xanewok/crate-source
Browse files Browse the repository at this point in the history
Add crate disambiguators
  • Loading branch information
nrc committed Oct 27, 2017
2 parents 20ee392 + 61ead8e commit 64cc7c2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rls-data"
version = "0.11.0"
version = "0.12.0"
authors = ["Nick Cameron <ncameron@mozilla.com>"]
description = "Data structures used by the RLS and Rust compiler"
license = "Apache-2.0/MIT"
Expand Down
20 changes: 17 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@ pub struct Id {
pub index: u32,
}

/// Crate name, along with its disambiguator (128-bit hash) 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: (u64, u64),
}

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

#[derive(Debug, Clone, RustcDecodable, RustcEncodable)]
pub struct CratePreludeData {
pub crate_name: String,
pub crate_id: GlobalCrateId,
pub crate_root: String,
pub external_crates: Vec<ExternalCrateData>,
pub span: SpanData,
Expand All @@ -104,9 +114,13 @@ pub struct CratePreludeData {
/// Data for external crates in the prelude of a crate.
#[derive(Debug, Clone, RustcDecodable, RustcEncodable)]
pub struct ExternalCrateData {
pub name: String,
pub num: u32,
/// Source file where the external crate is declared.
pub file_name: String,
/// A crate-local crate index of an external crate. Local crate index is
/// 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 id: GlobalCrateId,
}

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

0 comments on commit 64cc7c2

Please sign in to comment.