Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 1 addition & 2 deletions compiler/rustc_data_structures/src/intern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ where
{
#[inline]
fn hash<H: Hasher>(&self, s: &mut H) {
// Pointer hashing is sufficient, due to the uniqueness constraint.
ptr::hash(self.0, s)
Hash::hash(&self.0, s)
}
}

Expand Down
24 changes: 22 additions & 2 deletions compiler/rustc_resolve/src/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,31 @@ pub(crate) type Import<'ra> = Interned<'ra, ImportData<'ra>>;
// FIXME: We may wish to actually have at least debug-level assertions that Interned's guarantees
// are upheld.
impl std::hash::Hash for ImportData<'_> {
fn hash<H>(&self, _: &mut H)
fn hash<H>(&self, h: &mut H)
where
H: std::hash::Hasher,
{
unreachable!()
let ImportData {
kind: _,
root_id,
use_span,
use_span_with_attributes,
has_attributes,
span,
root_span,
parent_scope: _,
module_path: _,
imported_module: _,
vis,
} = self;

root_id.hash(h);
use_span.hash(h);
use_span_with_attributes.hash(h);
has_attributes.hash(h);
span.hash(h);
root_span.hash(h);
vis.hash(h);
}
}

Expand Down
24 changes: 17 additions & 7 deletions compiler/rustc_resolve/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ impl<'ra> PathResult<'ra> {
}
}

#[derive(Debug)]
#[derive(Debug, Hash, PartialEq, Eq)]
enum ModuleKind {
/// An anonymous module; e.g., just a block.
///
Expand Down Expand Up @@ -594,11 +594,15 @@ struct Module<'ra>(Interned<'ra, ModuleData<'ra>>);
// FIXME: We may wish to actually have at least debug-level assertions that Interned's guarantees
// are upheld.
impl std::hash::Hash for ModuleData<'_> {
fn hash<H>(&self, _: &mut H)
fn hash<H>(&self, h: &mut H)
where
H: std::hash::Hasher,
{
unreachable!()
self.parent.hash(h);
self.kind.hash(h);
self.no_implicit_prelude.hash(h);
self.span.hash(h);
self.expansion.hash(h);
}
}

Expand Down Expand Up @@ -757,11 +761,17 @@ type NameBinding<'ra> = Interned<'ra, NameBindingData<'ra>>;
// FIXME: We may wish to actually have at least debug-level assertions that Interned's guarantees
// are upheld.
impl std::hash::Hash for NameBindingData<'_> {
fn hash<H>(&self, _: &mut H)
fn hash<H>(&self, h: &mut H)
where
H: std::hash::Hasher,
{
unreachable!()
let NameBindingData { kind, ambiguity, warn_ambiguity, expansion, span, vis } = self;
kind.hash(h);
ambiguity.hash(h);
warn_ambiguity.hash(h);
expansion.hash(h);
span.hash(h);
vis.hash(h);
}
}

Expand All @@ -775,7 +785,7 @@ impl<'ra> ToNameBinding<'ra> for NameBinding<'ra> {
}
}

#[derive(Clone, Copy, Debug)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
enum NameBindingKind<'ra> {
Res(Res),
Module(Module<'ra>),
Expand Down Expand Up @@ -818,7 +828,7 @@ struct UseError<'a> {
is_call: bool,
}

#[derive(Clone, Copy, PartialEq, Debug)]
#[derive(Clone, Copy, PartialEq, Debug, Eq, Hash)]
enum AmbiguityKind {
BuiltinAttr,
DeriveHelper,
Expand Down
Loading