1
Fork 0

Move hashes from rustc_data_structure to rustc_hashes so they can be shared with rust-analyzer

This commit is contained in:
Ben Kimock 2025-02-15 15:18:19 -05:00
parent 1d7cf0ff40
commit 4cf21866e8
50 changed files with 152 additions and 67 deletions

View file

@ -3317,6 +3317,7 @@ dependencies = [
"rand 0.8.5", "rand 0.8.5",
"rand_xoshiro", "rand_xoshiro",
"rustc_data_structures", "rustc_data_structures",
"rustc_hashes",
"rustc_index", "rustc_index",
"rustc_macros", "rustc_macros",
"rustc_serialize", "rustc_serialize",
@ -3544,6 +3545,7 @@ dependencies = [
"rustc_errors", "rustc_errors",
"rustc_fluent_macro", "rustc_fluent_macro",
"rustc_fs_util", "rustc_fs_util",
"rustc_hashes",
"rustc_hir", "rustc_hir",
"rustc_index", "rustc_index",
"rustc_llvm", "rustc_llvm",
@ -3586,6 +3588,7 @@ dependencies = [
"rustc_errors", "rustc_errors",
"rustc_fluent_macro", "rustc_fluent_macro",
"rustc_fs_util", "rustc_fs_util",
"rustc_hashes",
"rustc_hir", "rustc_hir",
"rustc_hir_pretty", "rustc_hir_pretty",
"rustc_incremental", "rustc_incremental",
@ -3658,6 +3661,7 @@ dependencies = [
"rustc-stable-hash", "rustc-stable-hash",
"rustc_arena", "rustc_arena",
"rustc_graphviz", "rustc_graphviz",
"rustc_hashes",
"rustc_index", "rustc_index",
"rustc_macros", "rustc_macros",
"rustc_serialize", "rustc_serialize",
@ -3768,6 +3772,7 @@ dependencies = [
"rustc_error_codes", "rustc_error_codes",
"rustc_error_messages", "rustc_error_messages",
"rustc_fluent_macro", "rustc_fluent_macro",
"rustc_hashes",
"rustc_hir", "rustc_hir",
"rustc_index", "rustc_index",
"rustc_lexer", "rustc_lexer",
@ -3840,6 +3845,13 @@ version = "0.0.0"
name = "rustc_graphviz" name = "rustc_graphviz"
version = "0.0.0" version = "0.0.0"
[[package]]
name = "rustc_hashes"
version = "0.0.0"
dependencies = [
"rustc-stable-hash",
]
[[package]] [[package]]
name = "rustc_hir" name = "rustc_hir"
version = "0.0.0" version = "0.0.0"
@ -3849,6 +3861,7 @@ dependencies = [
"rustc_arena", "rustc_arena",
"rustc_ast", "rustc_ast",
"rustc_data_structures", "rustc_data_structures",
"rustc_hashes",
"rustc_index", "rustc_index",
"rustc_macros", "rustc_macros",
"rustc_serialize", "rustc_serialize",
@ -4169,6 +4182,7 @@ dependencies = [
"rustc_feature", "rustc_feature",
"rustc_fluent_macro", "rustc_fluent_macro",
"rustc_graphviz", "rustc_graphviz",
"rustc_hashes",
"rustc_hir", "rustc_hir",
"rustc_hir_pretty", "rustc_hir_pretty",
"rustc_index", "rustc_index",
@ -4405,6 +4419,7 @@ dependencies = [
"measureme", "measureme",
"rustc_data_structures", "rustc_data_structures",
"rustc_errors", "rustc_errors",
"rustc_hashes",
"rustc_hir", "rustc_hir",
"rustc_index", "rustc_index",
"rustc_middle", "rustc_middle",
@ -4428,6 +4443,7 @@ dependencies = [
"rustc_errors", "rustc_errors",
"rustc_feature", "rustc_feature",
"rustc_fluent_macro", "rustc_fluent_macro",
"rustc_hashes",
"rustc_hir", "rustc_hir",
"rustc_index", "rustc_index",
"rustc_macros", "rustc_macros",
@ -4488,6 +4504,7 @@ name = "rustc_serialize"
version = "0.0.0" version = "0.0.0"
dependencies = [ dependencies = [
"indexmap", "indexmap",
"rustc_hashes",
"rustc_macros", "rustc_macros",
"smallvec", "smallvec",
"tempfile", "tempfile",
@ -4508,6 +4525,7 @@ dependencies = [
"rustc_feature", "rustc_feature",
"rustc_fluent_macro", "rustc_fluent_macro",
"rustc_fs_util", "rustc_fs_util",
"rustc_hashes",
"rustc_hir", "rustc_hir",
"rustc_lint_defs", "rustc_lint_defs",
"rustc_macros", "rustc_macros",
@ -4549,6 +4567,7 @@ dependencies = [
"md-5", "md-5",
"rustc_arena", "rustc_arena",
"rustc_data_structures", "rustc_data_structures",
"rustc_hashes",
"rustc_index", "rustc_index",
"rustc_macros", "rustc_macros",
"rustc_serialize", "rustc_serialize",
@ -4568,6 +4587,7 @@ dependencies = [
"rustc_abi", "rustc_abi",
"rustc_data_structures", "rustc_data_structures",
"rustc_errors", "rustc_errors",
"rustc_hashes",
"rustc_hir", "rustc_hir",
"rustc_middle", "rustc_middle",
"rustc_session", "rustc_session",
@ -4663,6 +4683,7 @@ dependencies = [
"rustc_data_structures", "rustc_data_structures",
"rustc_errors", "rustc_errors",
"rustc_fluent_macro", "rustc_fluent_macro",
"rustc_hashes",
"rustc_hir", "rustc_hir",
"rustc_index", "rustc_index",
"rustc_infer", "rustc_infer",

View file

@ -9,6 +9,7 @@ bitflags = "2.4.1"
rand = { version = "0.8.4", default-features = false, optional = true } rand = { version = "0.8.4", default-features = false, optional = true }
rand_xoshiro = { version = "0.6.0", optional = true } rand_xoshiro = { version = "0.6.0", optional = true }
rustc_data_structures = { path = "../rustc_data_structures", optional = true } rustc_data_structures = { path = "../rustc_data_structures", optional = true }
rustc_hashes = { path = "../rustc_hashes" }
rustc_index = { path = "../rustc_index", default-features = false } rustc_index = { path = "../rustc_index", default-features = false }
rustc_macros = { path = "../rustc_macros", optional = true } rustc_macros = { path = "../rustc_macros", optional = true }
rustc_serialize = { path = "../rustc_serialize", optional = true } rustc_serialize = { path = "../rustc_serialize", optional = true }

View file

@ -2,7 +2,7 @@ use std::fmt::{self, Write};
use std::ops::{Bound, Deref}; use std::ops::{Bound, Deref};
use std::{cmp, iter}; use std::{cmp, iter};
use rustc_data_structures::stable_hasher::Hash64; use rustc_hashes::Hash64;
use rustc_index::Idx; use rustc_index::Idx;
use tracing::debug; use tracing::debug;

View file

@ -48,9 +48,9 @@ use std::ops::{Add, AddAssign, Mul, RangeInclusive, Sub};
use std::str::FromStr; use std::str::FromStr;
use bitflags::bitflags; use bitflags::bitflags;
use rustc_data_structures::stable_hasher::Hash64;
#[cfg(feature = "nightly")] #[cfg(feature = "nightly")]
use rustc_data_structures::stable_hasher::StableOrd; use rustc_data_structures::stable_hasher::StableOrd;
use rustc_hashes::Hash64;
use rustc_index::{Idx, IndexSlice, IndexVec}; use rustc_index::{Idx, IndexSlice, IndexVec};
#[cfg(feature = "nightly")] #[cfg(feature = "nightly")]
use rustc_macros::{Decodable_Generic, Encodable_Generic, HashStable_Generic}; use rustc_macros::{Decodable_Generic, Encodable_Generic, HashStable_Generic};

View file

@ -25,6 +25,7 @@ rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" } rustc_errors = { path = "../rustc_errors" }
rustc_fluent_macro = { path = "../rustc_fluent_macro" } rustc_fluent_macro = { path = "../rustc_fluent_macro" }
rustc_fs_util = { path = "../rustc_fs_util" } rustc_fs_util = { path = "../rustc_fs_util" }
rustc_hashes = { path = "../rustc_hashes" }
rustc_hir = { path = "../rustc_hir" } rustc_hir = { path = "../rustc_hir" }
rustc_index = { path = "../rustc_index" } rustc_index = { path = "../rustc_index" }
rustc_llvm = { path = "../rustc_llvm" } rustc_llvm = { path = "../rustc_llvm" }

View file

@ -7,7 +7,8 @@ use rustc_abi::{AddressSpace, HasDataLayout};
use rustc_ast::Mutability; use rustc_ast::Mutability;
use rustc_codegen_ssa::common::TypeKind; use rustc_codegen_ssa::common::TypeKind;
use rustc_codegen_ssa::traits::*; use rustc_codegen_ssa::traits::*;
use rustc_data_structures::stable_hasher::{Hash128, HashStable, StableHasher}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_hashes::Hash128;
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
use rustc_middle::bug; use rustc_middle::bug;
use rustc_middle::mir::interpret::{ConstAllocation, GlobalAlloc, Scalar}; use rustc_middle::mir::interpret::{ConstAllocation, GlobalAlloc, Scalar};

View file

@ -25,6 +25,7 @@ rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" } rustc_errors = { path = "../rustc_errors" }
rustc_fluent_macro = { path = "../rustc_fluent_macro" } rustc_fluent_macro = { path = "../rustc_fluent_macro" }
rustc_fs_util = { path = "../rustc_fs_util" } rustc_fs_util = { path = "../rustc_fs_util" }
rustc_hashes = { path = "../rustc_hashes" }
rustc_hir = { path = "../rustc_hir" } rustc_hir = { path = "../rustc_hir" }
rustc_hir_pretty = { path = "../rustc_hir_pretty" } rustc_hir_pretty = { path = "../rustc_hir_pretty" }
rustc_incremental = { path = "../rustc_incremental" } rustc_incremental = { path = "../rustc_incremental" }

View file

@ -15,7 +15,8 @@ use std::fmt::Write;
use rustc_abi::Integer; use rustc_abi::Integer;
use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::stable_hasher::{Hash64, HashStable, StableHasher}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_hashes::Hash64;
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
use rustc_hir::definitions::{DefPathData, DefPathDataName, DisambiguatedDefPathData}; use rustc_hir::definitions::{DefPathData, DefPathDataName, DisambiguatedDefPathData};
use rustc_hir::{CoroutineDesugaring, CoroutineKind, CoroutineSource, Mutability}; use rustc_hir::{CoroutineDesugaring, CoroutineKind, CoroutineSource, Mutability};

View file

@ -18,6 +18,7 @@ rustc-rayon = { version = "0.5.1", features = ["indexmap"] }
rustc-stable-hash = { version = "0.1.0", features = ["nightly"] } rustc-stable-hash = { version = "0.1.0", features = ["nightly"] }
rustc_arena = { path = "../rustc_arena" } rustc_arena = { path = "../rustc_arena" }
rustc_graphviz = { path = "../rustc_graphviz" } rustc_graphviz = { path = "../rustc_graphviz" }
rustc_hashes = { path = "../rustc_hashes" }
rustc_index = { path = "../rustc_index", package = "rustc_index" } rustc_index = { path = "../rustc_index", package = "rustc_index" }
rustc_macros = { path = "../rustc_macros" } rustc_macros = { path = "../rustc_macros" }
rustc_serialize = { path = "../rustc_serialize" } rustc_serialize = { path = "../rustc_serialize" }

View file

@ -1,10 +1,9 @@
use std::hash::{Hash, Hasher}; use std::hash::{Hash, Hasher};
use rustc_hashes::Hash64;
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
use crate::stable_hasher::{ use crate::stable_hasher::{FromStableHash, StableHasherHash, impl_stable_traits_for_trivial_type};
FromStableHash, Hash64, StableHasherHash, impl_stable_traits_for_trivial_type,
};
#[cfg(test)] #[cfg(test)]
mod tests; mod tests;

View file

@ -84,7 +84,6 @@ pub mod vec_cache;
pub mod work_queue; pub mod work_queue;
mod atomic_ref; mod atomic_ref;
mod hashes;
/// This calls the passed function while ensuring it won't be inlined into the caller. /// This calls the passed function while ensuring it won't be inlined into the caller.
#[inline(never)] #[inline(never)]

View file

@ -10,12 +10,11 @@ use smallvec::SmallVec;
#[cfg(test)] #[cfg(test)]
mod tests; mod tests;
use rustc_hashes::{Hash64, Hash128};
pub use rustc_stable_hash::{ pub use rustc_stable_hash::{
FromStableHash, SipHasher128Hash as StableHasherHash, StableSipHasher128 as StableHasher, FromStableHash, SipHasher128Hash as StableHasherHash, StableSipHasher128 as StableHasher,
}; };
pub use crate::hashes::{Hash64, Hash128};
/// Something that implements `HashStable<CTX>` can be hashed in a way that is /// Something that implements `HashStable<CTX>` can be hashed in a way that is
/// stable across multiple compilation sessions. /// stable across multiple compilation sessions.
/// ///

View file

@ -1,7 +1,8 @@
use std::ptr; use std::ptr;
use rustc_hashes::Hash128;
use super::*; use super::*;
use crate::hashes::Hash128;
use crate::stable_hasher::{HashStable, StableHasher}; use crate::stable_hasher::{HashStable, StableHasher};
/// A tag type used in [`TaggedRef`] tests. /// A tag type used in [`TaggedRef`] tests.

View file

@ -14,6 +14,7 @@ rustc_data_structures = { path = "../rustc_data_structures" }
rustc_error_codes = { path = "../rustc_error_codes" } rustc_error_codes = { path = "../rustc_error_codes" }
rustc_error_messages = { path = "../rustc_error_messages" } rustc_error_messages = { path = "../rustc_error_messages" }
rustc_fluent_macro = { path = "../rustc_fluent_macro" } rustc_fluent_macro = { path = "../rustc_fluent_macro" }
rustc_hashes = { path = "../rustc_hashes" }
rustc_hir = { path = "../rustc_hir" } rustc_hir = { path = "../rustc_hir" }
rustc_index = { path = "../rustc_index" } rustc_index = { path = "../rustc_index" }
rustc_lexer = { path = "../rustc_lexer" } rustc_lexer = { path = "../rustc_lexer" }

View file

@ -58,12 +58,13 @@ pub use emitter::ColorConfig;
use emitter::{DynEmitter, Emitter, is_case_difference, is_different}; use emitter::{DynEmitter, Emitter, is_case_difference, is_different};
use rustc_data_structures::AtomicRef; use rustc_data_structures::AtomicRef;
use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet}; use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
use rustc_data_structures::stable_hasher::{Hash128, StableHasher}; use rustc_data_structures::stable_hasher::StableHasher;
use rustc_data_structures::sync::{DynSend, Lock}; use rustc_data_structures::sync::{DynSend, Lock};
pub use rustc_error_messages::{ pub use rustc_error_messages::{
DiagMessage, FluentBundle, LanguageIdentifier, LazyFallbackBundle, MultiSpan, SpanLabel, DiagMessage, FluentBundle, LanguageIdentifier, LazyFallbackBundle, MultiSpan, SpanLabel,
SubdiagMessage, fallback_fluent_bundle, fluent_bundle, SubdiagMessage, fallback_fluent_bundle, fluent_bundle,
}; };
use rustc_hashes::Hash128;
use rustc_lint_defs::LintExpectationId; use rustc_lint_defs::LintExpectationId;
pub use rustc_lint_defs::{Applicability, listify, pluralize}; pub use rustc_lint_defs::{Applicability, listify, pluralize};
use rustc_macros::{Decodable, Encodable}; use rustc_macros::{Decodable, Encodable};

View file

@ -0,0 +1,9 @@
[package]
name = "rustc_hashes"
version = "0.0.0"
edition = "2021"
[dependencies]
# tidy-alphabetical-start
rustc-stable-hash = { version = "0.1.0" }
# tidy-alphabetical-end

View file

@ -1,6 +1,8 @@
//! rustc encodes a lot of hashes. If hashes are stored as `u64` or `u128`, a `derive(Encodable)` //! rustc encodes a lot of hashes. If hashes are stored as `u64` or `u128`, a `derive(Encodable)`
//! will apply varint encoding to the hashes, which is less efficient than directly encoding the 8 //! will apply varint encoding to the hashes, which is less efficient than directly encoding the 8
//! or 16 bytes of the hash. //! or 16 bytes of the hash. And if that hash depends on the `StableCrateHash` (which most in rustc
//! do), the varint encoding will make the number of bytes encoded fluctuate between compiler
//! versions.
//! //!
//! The types in this module represent 64-bit or 128-bit hashes produced by a `StableHasher`. //! The types in this module represent 64-bit or 128-bit hashes produced by a `StableHasher`.
//! `Hash64` and `Hash128` expose some utility functions to encourage users to not extract the inner //! `Hash64` and `Hash128` expose some utility functions to encourage users to not extract the inner
@ -14,10 +16,9 @@
use std::fmt; use std::fmt;
use std::ops::BitXorAssign; use std::ops::BitXorAssign;
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; use rustc_stable_hash::{FromStableHash, SipHasher128Hash as StableHasherHash};
use crate::stable_hasher::{FromStableHash, StableHasherHash};
/// A `u64` but encoded with a fixed size; for hashes this encoding is more compact than `u64`.
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)] #[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
pub struct Hash64 { pub struct Hash64 {
inner: u64, inner: u64,
@ -49,20 +50,6 @@ impl BitXorAssign<u64> for Hash64 {
} }
} }
impl<S: Encoder> Encodable<S> for Hash64 {
#[inline]
fn encode(&self, s: &mut S) {
s.emit_raw_bytes(&self.inner.to_le_bytes());
}
}
impl<D: Decoder> Decodable<D> for Hash64 {
#[inline]
fn decode(d: &mut D) -> Self {
Self { inner: u64::from_le_bytes(d.read_raw_bytes(8).try_into().unwrap()) }
}
}
impl FromStableHash for Hash64 { impl FromStableHash for Hash64 {
type Hash = StableHasherHash; type Hash = StableHasherHash;
@ -84,6 +71,7 @@ impl fmt::LowerHex for Hash64 {
} }
} }
/// A `u128` but encoded with a fixed size; for hashes this encoding is more compact than `u128`.
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Default)] #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Default)]
pub struct Hash128 { pub struct Hash128 {
inner: u128, inner: u128,
@ -100,6 +88,11 @@ impl std::hash::Hash for Hash128 {
} }
impl Hash128 { impl Hash128 {
#[inline]
pub fn new(n: u128) -> Self {
Self { inner: n }
}
#[inline] #[inline]
pub fn truncate(self) -> Hash64 { pub fn truncate(self) -> Hash64 {
Hash64 { inner: self.inner as u64 } Hash64 { inner: self.inner as u64 }
@ -116,20 +109,6 @@ impl Hash128 {
} }
} }
impl<S: Encoder> Encodable<S> for Hash128 {
#[inline]
fn encode(&self, s: &mut S) {
s.emit_raw_bytes(&self.inner.to_le_bytes());
}
}
impl<D: Decoder> Decodable<D> for Hash128 {
#[inline]
fn decode(d: &mut D) -> Self {
Self { inner: u128::from_le_bytes(d.read_raw_bytes(16).try_into().unwrap()) }
}
}
impl FromStableHash for Hash128 { impl FromStableHash for Hash128 {
type Hash = StableHasherHash; type Hash = StableHasherHash;

View file

@ -10,6 +10,7 @@ rustc_abi = { path = "../rustc_abi" }
rustc_arena = { path = "../rustc_arena" } rustc_arena = { path = "../rustc_arena" }
rustc_ast = { path = "../rustc_ast" } rustc_ast = { path = "../rustc_ast" }
rustc_data_structures = { path = "../rustc_data_structures" } rustc_data_structures = { path = "../rustc_data_structures" }
rustc_hashes = { path = "../rustc_hashes" }
rustc_index = { path = "../rustc_index" } rustc_index = { path = "../rustc_index" }
rustc_macros = { path = "../rustc_macros" } rustc_macros = { path = "../rustc_macros" }
rustc_serialize = { path = "../rustc_serialize" } rustc_serialize = { path = "../rustc_serialize" }

View file

@ -1,4 +1,4 @@
use rustc_data_structures::stable_hasher::Hash64; use rustc_hashes::Hash64;
use rustc_span::def_id::DefIndex; use rustc_span::def_id::DefIndex;
#[derive(Clone, Default)] #[derive(Clone, Default)]

View file

@ -7,8 +7,9 @@
use std::fmt::{self, Write}; use std::fmt::{self, Write};
use std::hash::Hash; use std::hash::Hash;
use rustc_data_structures::stable_hasher::{Hash64, StableHasher}; use rustc_data_structures::stable_hasher::StableHasher;
use rustc_data_structures::unord::UnordMap; use rustc_data_structures::unord::UnordMap;
use rustc_hashes::Hash64;
use rustc_index::IndexVec; use rustc_index::IndexVec;
use rustc_macros::{Decodable, Encodable}; use rustc_macros::{Decodable, Encodable};
use rustc_span::{Symbol, kw, sym}; use rustc_span::{Symbol, kw, sym};

View file

@ -1,6 +1,6 @@
#![allow(rustc::symbol_intern_string_literal)] #![allow(rustc::symbol_intern_string_literal)]
use rustc_data_structures::stable_hasher::Hash64; use rustc_hashes::Hash64;
use rustc_span::def_id::{DefPathHash, StableCrateId}; use rustc_span::def_id::{DefPathHash, StableCrateId};
use rustc_span::edition::Edition; use rustc_span::edition::Edition;
use rustc_span::{Symbol, create_session_globals_then}; use rustc_span::{Symbol, create_session_globals_then};

View file

@ -22,6 +22,7 @@ rustc_errors = { path = "../rustc_errors" }
rustc_feature = { path = "../rustc_feature" } rustc_feature = { path = "../rustc_feature" }
rustc_fluent_macro = { path = "../rustc_fluent_macro" } rustc_fluent_macro = { path = "../rustc_fluent_macro" }
rustc_graphviz = { path = "../rustc_graphviz" } rustc_graphviz = { path = "../rustc_graphviz" }
rustc_hashes = { path = "../rustc_hashes" }
rustc_hir = { path = "../rustc_hir" } rustc_hir = { path = "../rustc_hir" }
rustc_hir_pretty = { path = "../rustc_hir_pretty" } rustc_hir_pretty = { path = "../rustc_hir_pretty" }
rustc_index = { path = "../rustc_index" } rustc_index = { path = "../rustc_index" }

View file

@ -6,8 +6,9 @@ use rustc_attr_parsing::InlineAttr;
use rustc_data_structures::base_n::{BaseNString, CASE_INSENSITIVE, ToBaseN}; use rustc_data_structures::base_n::{BaseNString, CASE_INSENSITIVE, ToBaseN};
use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fingerprint::Fingerprint;
use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::fx::FxIndexMap;
use rustc_data_structures::stable_hasher::{Hash128, HashStable, StableHasher, ToStableHashKey}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher, ToStableHashKey};
use rustc_data_structures::unord::UnordMap; use rustc_data_structures::unord::UnordMap;
use rustc_hashes::Hash128;
use rustc_hir::ItemId; use rustc_hir::ItemId;
use rustc_hir::def_id::{CrateNum, DefId, DefIdSet, LOCAL_CRATE}; use rustc_hir::def_id::{CrateNum, DefId, DefIdSet, LOCAL_CRATE};
use rustc_index::Idx; use rustc_index::Idx;

View file

@ -7,11 +7,11 @@ use rustc_abi::{
PointeeInfo, PointerKind, Primitive, ReprOptions, Scalar, Size, TagEncoding, TargetDataLayout, PointeeInfo, PointerKind, Primitive, ReprOptions, Scalar, Size, TagEncoding, TargetDataLayout,
TyAbiInterface, VariantIdx, Variants, TyAbiInterface, VariantIdx, Variants,
}; };
use rustc_data_structures::stable_hasher::Hash64;
use rustc_error_messages::DiagMessage; use rustc_error_messages::DiagMessage;
use rustc_errors::{ use rustc_errors::{
Diag, DiagArgValue, DiagCtxtHandle, Diagnostic, EmissionGuarantee, IntoDiagArg, Level, Diag, DiagArgValue, DiagCtxtHandle, Diagnostic, EmissionGuarantee, IntoDiagArg, Level,
}; };
use rustc_hashes::Hash64;
use rustc_hir::LangItem; use rustc_hir::LangItem;
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
use rustc_index::IndexVec; use rustc_index::IndexVec;

View file

@ -5,9 +5,10 @@ use std::{fmt, iter};
use rustc_abi::{ExternAbi, Float, Integer, IntegerType, Size}; use rustc_abi::{ExternAbi, Float, Integer, IntegerType, Size};
use rustc_apfloat::Float as _; use rustc_apfloat::Float as _;
use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::stable_hasher::{Hash128, HashStable, StableHasher}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::stack::ensure_sufficient_stack; use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_errors::ErrorGuaranteed; use rustc_errors::ErrorGuaranteed;
use rustc_hashes::Hash128;
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def::{CtorOf, DefKind, Res}; use rustc_hir::def::{CtorOf, DefKind, Res};
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId}; use rustc_hir::def_id::{CrateNum, DefId, LocalDefId};

View file

@ -8,6 +8,7 @@ edition = "2021"
measureme = "11" measureme = "11"
rustc_data_structures = { path = "../rustc_data_structures" } rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" } rustc_errors = { path = "../rustc_errors" }
rustc_hashes = { path = "../rustc_hashes" }
rustc_hir = { path = "../rustc_hir" } rustc_hir = { path = "../rustc_hir" }
rustc_index = { path = "../rustc_index" } rustc_index = { path = "../rustc_index" }
rustc_middle = { path = "../rustc_middle" } rustc_middle = { path = "../rustc_middle" }

View file

@ -4,10 +4,11 @@
use std::num::NonZero; use std::num::NonZero;
use rustc_data_structures::stable_hasher::{Hash64, HashStable, StableHasher}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::sync::Lock; use rustc_data_structures::sync::Lock;
use rustc_data_structures::unord::UnordMap; use rustc_data_structures::unord::UnordMap;
use rustc_errors::DiagInner; use rustc_errors::DiagInner;
use rustc_hashes::Hash64;
use rustc_index::Idx; use rustc_index::Idx;
use rustc_middle::bug; use rustc_middle::bug;
use rustc_middle::dep_graph::{ use rustc_middle::dep_graph::{

View file

@ -13,6 +13,7 @@ rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" } rustc_errors = { path = "../rustc_errors" }
rustc_feature = { path = "../rustc_feature" } rustc_feature = { path = "../rustc_feature" }
rustc_fluent_macro = { path = "../rustc_fluent_macro" } rustc_fluent_macro = { path = "../rustc_fluent_macro" }
rustc_hashes = { path = "../rustc_hashes" }
rustc_hir = { path = "../rustc_hir" } rustc_hir = { path = "../rustc_hir" }
rustc_index = { path = "../rustc_index" } rustc_index = { path = "../rustc_index" }
rustc_macros = { path = "../rustc_macros" } rustc_macros = { path = "../rustc_macros" }

View file

@ -11,9 +11,9 @@ mod caches;
pub use self::caches::{DefIdCache, DefaultCache, QueryCache, SingleCache, VecCache}; pub use self::caches::{DefIdCache, DefaultCache, QueryCache, SingleCache, VecCache};
mod config; mod config;
use rustc_data_structures::stable_hasher::Hash64;
use rustc_data_structures::sync::Lock; use rustc_data_structures::sync::Lock;
use rustc_errors::DiagInner; use rustc_errors::DiagInner;
use rustc_hashes::Hash64;
use rustc_hir::def::DefKind; use rustc_hir::def::DefKind;
use rustc_macros::{Decodable, Encodable}; use rustc_macros::{Decodable, Encodable};
use rustc_span::Span; use rustc_span::Span;

View file

@ -6,6 +6,7 @@ edition = "2021"
[dependencies] [dependencies]
# tidy-alphabetical-start # tidy-alphabetical-start
indexmap = "2.0.0" indexmap = "2.0.0"
rustc_hashes = { path = "../rustc_hashes" }
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] } smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
thin-vec = "0.2.12" thin-vec = "0.2.12"
# tidy-alphabetical-end # tidy-alphabetical-end

View file

@ -10,6 +10,7 @@ use std::path;
use std::rc::Rc; use std::rc::Rc;
use std::sync::Arc; use std::sync::Arc;
use rustc_hashes::{Hash64, Hash128};
use smallvec::{Array, SmallVec}; use smallvec::{Array, SmallVec};
use thin_vec::ThinVec; use thin_vec::ThinVec;
@ -716,3 +717,31 @@ impl<D: Decoder, T: Decodable<D>> Decodable<D> for Arc<[T]> {
vec.into() vec.into()
} }
} }
impl<S: Encoder> Encodable<S> for Hash64 {
#[inline]
fn encode(&self, s: &mut S) {
s.emit_raw_bytes(&self.as_u64().to_le_bytes());
}
}
impl<S: Encoder> Encodable<S> for Hash128 {
#[inline]
fn encode(&self, s: &mut S) {
s.emit_raw_bytes(&self.as_u128().to_le_bytes());
}
}
impl<D: Decoder> Decodable<D> for Hash64 {
#[inline]
fn decode(d: &mut D) -> Self {
Self::new(u64::from_le_bytes(d.read_raw_bytes(8).try_into().unwrap()))
}
}
impl<D: Decoder> Decodable<D> for Hash128 {
#[inline]
fn decode(d: &mut D) -> Self {
Self::new(u128::from_le_bytes(d.read_raw_bytes(16).try_into().unwrap()))
}
}

View file

@ -14,6 +14,7 @@ rustc_errors = { path = "../rustc_errors" }
rustc_feature = { path = "../rustc_feature" } rustc_feature = { path = "../rustc_feature" }
rustc_fluent_macro = { path = "../rustc_fluent_macro" } rustc_fluent_macro = { path = "../rustc_fluent_macro" }
rustc_fs_util = { path = "../rustc_fs_util" } rustc_fs_util = { path = "../rustc_fs_util" }
rustc_hashes = { path = "../rustc_hashes" }
rustc_hir = { path = "../rustc_hir" } rustc_hir = { path = "../rustc_hir" }
rustc_lint_defs = { path = "../rustc_lint_defs" } rustc_lint_defs = { path = "../rustc_lint_defs" }
rustc_macros = { path = "../rustc_macros" } rustc_macros = { path = "../rustc_macros" }

View file

@ -2934,9 +2934,9 @@ pub(crate) mod dep_tracking {
use rustc_abi::Align; use rustc_abi::Align;
use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::fx::FxIndexMap;
use rustc_data_structures::stable_hasher::Hash64;
use rustc_errors::LanguageIdentifier; use rustc_errors::LanguageIdentifier;
use rustc_feature::UnstableFeatures; use rustc_feature::UnstableFeatures;
use rustc_hashes::Hash64;
use rustc_span::RealFileName; use rustc_span::RealFileName;
use rustc_span::edition::Edition; use rustc_span::edition::Edition;
use rustc_target::spec::{ use rustc_target::spec::{

View file

@ -7,9 +7,9 @@ use std::str;
use rustc_abi::Align; use rustc_abi::Align;
use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::fx::FxIndexMap;
use rustc_data_structures::profiling::TimePassesFormat; use rustc_data_structures::profiling::TimePassesFormat;
use rustc_data_structures::stable_hasher::Hash64;
use rustc_errors::{ColorConfig, LanguageIdentifier, TerminalUrl}; use rustc_errors::{ColorConfig, LanguageIdentifier, TerminalUrl};
use rustc_feature::UnstableFeatures; use rustc_feature::UnstableFeatures;
use rustc_hashes::Hash64;
use rustc_macros::{Decodable, Encodable}; use rustc_macros::{Decodable, Encodable};
use rustc_span::edition::Edition; use rustc_span::edition::Edition;
use rustc_span::{RealFileName, SourceFileHashAlgorithm}; use rustc_span::{RealFileName, SourceFileHashAlgorithm};

View file

@ -12,6 +12,7 @@ itoa = "1.0"
md5 = { package = "md-5", version = "0.10.0" } md5 = { package = "md-5", version = "0.10.0" }
rustc_arena = { path = "../rustc_arena" } rustc_arena = { path = "../rustc_arena" }
rustc_data_structures = { path = "../rustc_data_structures" } rustc_data_structures = { path = "../rustc_data_structures" }
rustc_hashes = { path = "../rustc_hashes" }
rustc_index = { path = "../rustc_index" } rustc_index = { path = "../rustc_index" }
rustc_macros = { path = "../rustc_macros" } rustc_macros = { path = "../rustc_macros" }
rustc_serialize = { path = "../rustc_serialize" } rustc_serialize = { path = "../rustc_serialize" }

View file

@ -3,10 +3,9 @@ use std::hash::{BuildHasherDefault, Hash, Hasher};
use rustc_data_structures::AtomicRef; use rustc_data_structures::AtomicRef;
use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fingerprint::Fingerprint;
use rustc_data_structures::stable_hasher::{ use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableOrd, ToStableHashKey};
Hash64, HashStable, StableHasher, StableOrd, ToStableHashKey,
};
use rustc_data_structures::unhash::Unhasher; use rustc_data_structures::unhash::Unhasher;
use rustc_hashes::Hash64;
use rustc_index::Idx; use rustc_index::Idx;
use rustc_macros::{Decodable, Encodable, HashStable_Generic}; use rustc_macros::{Decodable, Encodable, HashStable_Generic};
use rustc_serialize::{Decodable, Encodable}; use rustc_serialize::{Decodable, Encodable};

View file

@ -33,9 +33,10 @@ use std::sync::Arc;
use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fingerprint::Fingerprint;
use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::stable_hasher::{Hash64, HashStable, HashingControls, StableHasher}; use rustc_data_structures::stable_hasher::{HashStable, HashingControls, StableHasher};
use rustc_data_structures::sync::{Lock, WorkerLocal}; use rustc_data_structures::sync::{Lock, WorkerLocal};
use rustc_data_structures::unhash::UnhashMap; use rustc_data_structures::unhash::UnhashMap;
use rustc_hashes::Hash64;
use rustc_index::IndexVec; use rustc_index::IndexVec;
use rustc_macros::{Decodable, Encodable, HashStable_Generic}; use rustc_macros::{Decodable, Encodable, HashStable_Generic};
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};

View file

@ -87,9 +87,10 @@ use std::sync::Arc;
use std::{fmt, iter}; use std::{fmt, iter};
use md5::{Digest, Md5}; use md5::{Digest, Md5};
use rustc_data_structures::stable_hasher::{Hash64, Hash128, HashStable, StableHasher}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::sync::{FreezeLock, FreezeWriteGuard, Lock}; use rustc_data_structures::sync::{FreezeLock, FreezeWriteGuard, Lock};
use rustc_data_structures::unord::UnordMap; use rustc_data_structures::unord::UnordMap;
use rustc_hashes::{Hash64, Hash128};
use sha1::Sha1; use sha1::Sha1;
use sha2::Sha256; use sha2::Sha256;

View file

@ -11,6 +11,7 @@ rustc-demangle = "0.1.21"
rustc_abi = { path = "../rustc_abi" } rustc_abi = { path = "../rustc_abi" }
rustc_data_structures = { path = "../rustc_data_structures" } rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" } rustc_errors = { path = "../rustc_errors" }
rustc_hashes = { path = "../rustc_hashes" }
rustc_hir = { path = "../rustc_hir" } rustc_hir = { path = "../rustc_hir" }
rustc_middle = { path = "../rustc_middle" } rustc_middle = { path = "../rustc_middle" }
rustc_session = { path = "../rustc_session" } rustc_session = { path = "../rustc_session" }

View file

@ -1,6 +1,7 @@
use std::fmt::Write; use std::fmt::Write;
use rustc_data_structures::stable_hasher::{Hash64, HashStable, StableHasher}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_hashes::Hash64;
use rustc_hir::def_id::CrateNum; use rustc_hir::def_id::CrateNum;
use rustc_middle::ty::{Instance, TyCtxt}; use rustc_middle::ty::{Instance, TyCtxt};

View file

@ -1,7 +1,8 @@
use std::fmt::{self, Write}; use std::fmt::{self, Write};
use std::mem::{self, discriminant}; use std::mem::{self, discriminant};
use rustc_data_structures::stable_hasher::{Hash64, HashStable, StableHasher}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_hashes::Hash64;
use rustc_hir::def_id::{CrateNum, DefId}; use rustc_hir::def_id::{CrateNum, DefId};
use rustc_hir::definitions::{DefPathData, DisambiguatedDefPathData}; use rustc_hir::definitions::{DefPathData, DisambiguatedDefPathData};
use rustc_middle::bug; use rustc_middle::bug;

View file

@ -11,6 +11,7 @@ rustc_ast_ir = { path = "../rustc_ast_ir" }
rustc_data_structures = { path = "../rustc_data_structures" } rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" } rustc_errors = { path = "../rustc_errors" }
rustc_fluent_macro = { path = "../rustc_fluent_macro" } rustc_fluent_macro = { path = "../rustc_fluent_macro" }
rustc_hashes = { path = "../rustc_hashes" }
rustc_hir = { path = "../rustc_hir" } rustc_hir = { path = "../rustc_hir" }
rustc_index = { path = "../rustc_index" } rustc_index = { path = "../rustc_index" }
rustc_infer = { path = "../rustc_infer" } rustc_infer = { path = "../rustc_infer" }

View file

@ -9,7 +9,7 @@ use rustc_abi::{
HasDataLayout, Layout, LayoutCalculatorError, LayoutData, Niche, ReprOptions, Scalar, Size, HasDataLayout, Layout, LayoutCalculatorError, LayoutData, Niche, ReprOptions, Scalar, Size,
StructKind, TagEncoding, VariantIdx, Variants, WrappingRange, StructKind, TagEncoding, VariantIdx, Variants, WrappingRange,
}; };
use rustc_data_structures::stable_hasher::Hash64; use rustc_hashes::Hash64;
use rustc_index::bit_set::DenseBitSet; use rustc_index::bit_set::DenseBitSet;
use rustc_index::{IndexSlice, IndexVec}; use rustc_index::{IndexSlice, IndexVec};
use rustc_middle::bug; use rustc_middle::bug;

View file

@ -14,6 +14,7 @@ use rustc_type_ir_macros::{Lift_Generic, TypeFoldable_Generic, TypeVisitable_Gen
use self::TyKind::*; use self::TyKind::*;
pub use self::closure::*; pub use self::closure::*;
use crate::inherent::*; use crate::inherent::*;
#[cfg(feature = "nightly")]
use crate::visit::TypeVisitable; use crate::visit::TypeVisitable;
use crate::{self as ty, DebruijnIndex, Interner}; use crate::{self as ty, DebruijnIndex, Interner};

View file

@ -9,6 +9,7 @@ use hir_expand::name::Name;
use intern::sym; use intern::sym;
use la_arena::Arena; use la_arena::Arena;
use rustc_abi::{Align, Integer, IntegerType, ReprFlags, ReprOptions}; use rustc_abi::{Align, Integer, IntegerType, ReprFlags, ReprOptions};
use rustc_hashes::Hash64;
use triomphe::Arc; use triomphe::Arc;
use tt::iter::TtElement; use tt::iter::TtElement;
@ -172,7 +173,7 @@ fn parse_repr_tt(tt: &TopSubtree) -> Option<ReprOptions> {
} }
} }
Some(ReprOptions { int, align: max_align, pack: min_pack, flags, field_shuffle_seed: 0 }) Some(ReprOptions { int, align: max_align, pack: min_pack, flags, field_shuffle_seed: Hash64::ZERO })
} }
impl StructData { impl StructData {

View file

@ -18,9 +18,15 @@ extern crate ra_ap_rustc_parse_format as rustc_parse_format;
#[cfg(feature = "in-rust-tree")] #[cfg(feature = "in-rust-tree")]
extern crate rustc_abi; extern crate rustc_abi;
#[cfg(feature = "in-rust-tree")]
extern crate rustc_hashes;
#[cfg(not(feature = "in-rust-tree"))] #[cfg(not(feature = "in-rust-tree"))]
extern crate ra_ap_rustc_abi as rustc_abi; extern crate ra_ap_rustc_abi as rustc_abi;
#[cfg(not(feature = "in-rust-tree"))]
extern crate ra_ap_rustc_hashes as rustc_hashes;
pub mod db; pub mod db;
pub mod attr; pub mod attr;

View file

@ -15,6 +15,7 @@ use hir_def::{
use la_arena::{Idx, RawIdx}; use la_arena::{Idx, RawIdx};
use rustc_abi::AddressSpace; use rustc_abi::AddressSpace;
use rustc_index::{IndexSlice, IndexVec}; use rustc_index::{IndexSlice, IndexVec};
use rustc_hashes::Hash64;
use triomphe::Arc; use triomphe::Arc;
@ -197,7 +198,7 @@ fn layout_of_simd_ty(
align, align,
max_repr_align: None, max_repr_align: None,
unadjusted_abi_align: align.abi, unadjusted_abi_align: align.abi,
randomization_seed: 0, randomization_seed: Hash64::ZERO,
})) }))
} }
@ -314,7 +315,7 @@ pub fn layout_of_ty_query(
size, size,
max_repr_align: None, max_repr_align: None,
unadjusted_abi_align: element.align.abi, unadjusted_abi_align: element.align.abi,
randomization_seed: 0, randomization_seed: Hash64::ZERO,
} }
} }
TyKind::Slice(element) => { TyKind::Slice(element) => {
@ -328,7 +329,7 @@ pub fn layout_of_ty_query(
size: Size::ZERO, size: Size::ZERO,
max_repr_align: None, max_repr_align: None,
unadjusted_abi_align: element.align.abi, unadjusted_abi_align: element.align.abi,
randomization_seed: 0, randomization_seed: Hash64::ZERO,
} }
} }
TyKind::Str => Layout { TyKind::Str => Layout {
@ -340,7 +341,7 @@ pub fn layout_of_ty_query(
size: Size::ZERO, size: Size::ZERO,
max_repr_align: None, max_repr_align: None,
unadjusted_abi_align: dl.i8_align.abi, unadjusted_abi_align: dl.i8_align.abi,
randomization_seed: 0, randomization_seed: Hash64::ZERO,
}, },
// Potentially-wide pointers. // Potentially-wide pointers.
TyKind::Ref(_, _, pointee) | TyKind::Raw(_, pointee) => { TyKind::Ref(_, _, pointee) | TyKind::Raw(_, pointee) => {

View file

@ -12,6 +12,9 @@ extern crate ra_ap_rustc_index as rustc_index;
#[cfg(feature = "in-rust-tree")] #[cfg(feature = "in-rust-tree")]
extern crate rustc_abi; extern crate rustc_abi;
#[cfg(feature = "in-rust-tree")]
extern crate rustc_hashes;
#[cfg(not(feature = "in-rust-tree"))] #[cfg(not(feature = "in-rust-tree"))]
extern crate ra_ap_rustc_abi as rustc_abi; extern crate ra_ap_rustc_abi as rustc_abi;
@ -21,6 +24,9 @@ extern crate rustc_pattern_analysis;
#[cfg(not(feature = "in-rust-tree"))] #[cfg(not(feature = "in-rust-tree"))]
extern crate ra_ap_rustc_pattern_analysis as rustc_pattern_analysis; extern crate ra_ap_rustc_pattern_analysis as rustc_pattern_analysis;
#[cfg(not(feature = "in-rust-tree"))]
extern crate ra_ap_rustc_hashes as rustc_hashes;
mod builder; mod builder;
mod chalk_db; mod chalk_db;
mod chalk_ext; mod chalk_ext;

View file

@ -35,6 +35,8 @@ fn main() {
"rustc_abi", "rustc_abi",
"-p", "-p",
"rustc_parse_format", "rustc_parse_format",
"-p",
"rustc_hashes",
]) ])
.run(); .run();
} }

View file

@ -2,5 +2,13 @@ error: crate `rustc_serialize` required to be available in rlib format, but was
| |
= help: try adding `extern crate rustc_driver;` at the top level of this crate = help: try adding `extern crate rustc_driver;` at the top level of this crate
error: crate `rustc_hashes` required to be available in rlib format, but was not found in this form
|
= help: try adding `extern crate rustc_driver;` at the top level of this crate
error: crate `rustc_stable_hash` required to be available in rlib format, but was not found in this form
|
= help: try adding `extern crate rustc_driver;` at the top level of this crate
error: aborting due to NUMBER previous errors error: aborting due to NUMBER previous errors