Skip to content

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

Merged
merged 8 commits into from
Nov 20, 2019
Merged
Show file tree
Hide file tree
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
Prev Previous commit
Next Next commit
Derive HashStable more.
  • Loading branch information
cjgillot committed Nov 19, 2019
commit e1522fa1832a0e82d235e6fb9f15d9d2647ff5aa
2 changes: 1 addition & 1 deletion src/librustc/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1215,7 +1215,7 @@ impl UnOp {
}

/// A statement.
#[derive(RustcEncodable, RustcDecodable)]
#[derive(RustcEncodable, RustcDecodable, HashStable)]
pub struct Stmt {
pub hir_id: HirId,
pub kind: StmtKind,
Expand Down
7 changes: 0 additions & 7 deletions src/librustc/ich/impls_hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,6 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::Ty {

impl_stable_hash_for_spanned!(hir::BinOpKind);

impl_stable_hash_for!(struct hir::Stmt {
hir_id,
kind,
span,
});


impl_stable_hash_for_spanned!(ast::Name);

impl<'a> HashStable<StableHashingContext<'a>> for hir::Expr {
Expand Down
23 changes: 4 additions & 19 deletions src/librustc/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1589,13 +1589,12 @@ rustc_index::newtype_index! {
/// declared, but a type name in a non-zero universe is a placeholder
/// type -- an idealized representative of "types in general" that we
/// use for checking generic functions.
#[derive(HashStable)]
pub struct UniverseIndex {
DEBUG_FORMAT = "U{}",
}
}

impl_stable_hash_for!(struct UniverseIndex { private });

impl UniverseIndex {
pub const ROOT: UniverseIndex = UniverseIndex::from_u32_const(0);

Expand Down Expand Up @@ -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`.
Expand All @@ -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)]
pub ident: Ident,
/// Discriminant of this variant.
pub discr: VariantDiscr,
Expand Down Expand Up @@ -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`.
Expand Down Expand Up @@ -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;
Expand All @@ -2076,10 +2065,6 @@ 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, HashStable)]
Expand Down
3 changes: 1 addition & 2 deletions src/librustc/ty/sty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1204,6 +1204,7 @@ rustc_index::newtype_index! {
/// is the outer fn.
///
/// [dbi]: http://en.wikipedia.org/wiki/De_Bruijn_index
#[derive(HashStable)]
pub struct DebruijnIndex {
DEBUG_FORMAT = "DebruijnIndex({})",
const INNERMOST = 0,
Expand Down Expand Up @@ -1517,8 +1518,6 @@ impl DebruijnIndex {
}
}

impl_stable_hash_for!(struct DebruijnIndex { private });

/// Region utilities
impl RegionKind {
/// Is this region named by the user?
Expand Down