-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Just derive Hashstable in librustc #66457
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
Changes from all commits
e00ebd7
c4bc3f0
781866f
e1522fa
d9eaaf5
7db84e8
4da5fe7
579625b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1590,12 +1590,11 @@ rustc_index::newtype_index! { | |
/// type -- an idealized representative of "types in general" that we | ||
/// use for checking generic functions. | ||
pub struct UniverseIndex { | ||
derive [HashStable] | ||
DEBUG_FORMAT = "U{}", | ||
} | ||
} | ||
|
||
impl_stable_hash_for!(struct UniverseIndex { private }); | ||
|
||
impl UniverseIndex { | ||
pub const ROOT: UniverseIndex = UniverseIndex::from_u32_const(0); | ||
|
||
|
@@ -1839,7 +1838,7 @@ bitflags! { | |
} | ||
|
||
/// Definition of a variant -- a struct's fields or a enum variant. | ||
#[derive(Debug)] | ||
#[derive(Debug, HashStable)] | ||
pub struct VariantDef { | ||
/// `DefId` that identifies the variant itself. | ||
/// If this variant belongs to a struct or union, then this is a copy of its `DefId`. | ||
|
@@ -1848,6 +1847,7 @@ pub struct VariantDef { | |
/// If this variant is a struct variant, then this is `None`. | ||
pub ctor_def_id: Option<DefId>, | ||
/// Variant or struct name. | ||
#[stable_hasher(project(name))] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @michaelwoerister Why are we hashing only the name and not the span here? Was this something needed for gensyms? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it was somehow related to gensyms. Looks like we can just hash the entire There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In an earlier draft, I forgot the projection attribute. As a result, some tests failed: #66279 (comment) . I did not investigate further. |
||
pub ident: Ident, | ||
/// Discriminant of this variant. | ||
pub discr: VariantDiscr, | ||
|
@@ -1927,17 +1927,6 @@ impl<'tcx> VariantDef { | |
} | ||
} | ||
|
||
impl_stable_hash_for!(struct VariantDef { | ||
def_id, | ||
ctor_def_id, | ||
ident -> (ident.name), | ||
discr, | ||
fields, | ||
ctor_kind, | ||
flags, | ||
recovered | ||
}); | ||
|
||
#[derive(Copy, Clone, Debug, PartialEq, Eq, RustcEncodable, RustcDecodable, HashStable)] | ||
pub enum VariantDiscr { | ||
/// Explicit value for this variant, i.e., `X = 123`. | ||
|
@@ -2061,7 +2050,7 @@ impl Into<DataTypeKind> for AdtKind { | |
} | ||
|
||
bitflags! { | ||
#[derive(RustcEncodable, RustcDecodable, Default)] | ||
#[derive(RustcEncodable, RustcDecodable, Default, HashStable)] | ||
pub struct ReprFlags: u8 { | ||
const IS_C = 1 << 0; | ||
const IS_SIMD = 1 << 1; | ||
|
@@ -2076,26 +2065,16 @@ bitflags! { | |
} | ||
} | ||
|
||
impl_stable_hash_for!(struct ReprFlags { | ||
bits | ||
}); | ||
|
||
/// Represents the repr options provided by the user, | ||
#[derive(Copy, Clone, Debug, Eq, PartialEq, RustcEncodable, RustcDecodable, Default)] | ||
#[derive(Copy, Clone, Debug, Eq, PartialEq, RustcEncodable, RustcDecodable, | ||
Default, HashStable)] | ||
pub struct ReprOptions { | ||
pub int: Option<attr::IntType>, | ||
pub align: Option<Align>, | ||
pub pack: Option<Align>, | ||
pub flags: ReprFlags, | ||
} | ||
|
||
impl_stable_hash_for!(struct ReprOptions { | ||
align, | ||
pack, | ||
int, | ||
flags | ||
}); | ||
|
||
impl ReprOptions { | ||
pub fn new(tcx: TyCtxt<'_>, did: DefId) -> ReprOptions { | ||
let mut flags = ReprFlags::empty(); | ||
|
@@ -3439,17 +3418,13 @@ pub struct CrateInherentImpls { | |
pub inherent_impls: DefIdMap<Vec<DefId>>, | ||
} | ||
|
||
#[derive(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable)] | ||
#[derive(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable, HashStable)] | ||
pub struct SymbolName { | ||
// FIXME: we don't rely on interning or equality here - better have | ||
// this be a `&'tcx str`. | ||
pub name: Symbol | ||
} | ||
|
||
impl_stable_hash_for!(struct self::SymbolName { | ||
name | ||
}); | ||
|
||
impl SymbolName { | ||
pub fn new(name: &str) -> SymbolName { | ||
SymbolName { | ||
|
Uh oh!
There was an error while loading. Please reload this page.