Skip to content

Commit

Permalink
Stop ignoring Span field when hashing some Idents
Browse files Browse the repository at this point in the history
This causes us to miss legitimate evaluatiosn (e.g. an upstream
`ExpnId` no longer exists), leading to ICEs when decoding stale
values from the incremental cache.
  • Loading branch information
Aaron1011 committed Dec 22, 2021
1 parent e100ec5 commit 6fbc75b
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 11 deletions.
8 changes: 0 additions & 8 deletions compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ impl Path<'_> {
#[derive(Debug, HashStable_Generic)]
pub struct PathSegment<'hir> {
/// The identifier portion of this path segment.
#[stable_hasher(project(name))]
pub ident: Ident,
// `id` and `res` are optional. We currently only use these in save-analysis,
// any path segments without these will not have save-analysis info and
Expand Down Expand Up @@ -850,7 +849,6 @@ pub struct PatField<'hir> {
#[stable_hasher(ignore)]
pub hir_id: HirId,
/// The identifier for the field.
#[stable_hasher(project(name))]
pub ident: Ident,
/// The pattern the field is destructured to.
pub pat: &'hir Pat<'hir>,
Expand Down Expand Up @@ -2113,7 +2111,6 @@ pub const FN_OUTPUT_NAME: Symbol = sym::Output;
#[derive(Debug, HashStable_Generic)]
pub struct TypeBinding<'hir> {
pub hir_id: HirId,
#[stable_hasher(project(name))]
pub ident: Ident,
pub gen_args: &'hir GenericArgs<'hir>,
pub kind: TypeBindingKind<'hir>,
Expand Down Expand Up @@ -2501,7 +2498,6 @@ pub struct EnumDef<'hir> {
#[derive(Debug, HashStable_Generic)]
pub struct Variant<'hir> {
/// Name of the variant.
#[stable_hasher(project(name))]
pub ident: Ident,
/// Id of the variant (not the constructor, see `VariantData::ctor_hir_id()`).
pub id: HirId,
Expand Down Expand Up @@ -2591,7 +2587,6 @@ impl VisibilityKind<'_> {
#[derive(Debug, HashStable_Generic)]
pub struct FieldDef<'hir> {
pub span: Span,
#[stable_hasher(project(name))]
pub ident: Ident,
pub vis: Visibility<'hir>,
pub hir_id: HirId,
Expand Down Expand Up @@ -2850,7 +2845,6 @@ impl ItemKind<'_> {
#[derive(Encodable, Debug, HashStable_Generic)]
pub struct TraitItemRef {
pub id: TraitItemId,
#[stable_hasher(project(name))]
pub ident: Ident,
pub kind: AssocItemKind,
pub span: Span,
Expand All @@ -2866,7 +2860,6 @@ pub struct TraitItemRef {
#[derive(Debug, HashStable_Generic)]
pub struct ImplItemRef {
pub id: ImplItemId,
#[stable_hasher(project(name))]
pub ident: Ident,
pub kind: AssocItemKind,
pub span: Span,
Expand Down Expand Up @@ -2905,7 +2898,6 @@ impl ForeignItemId {
#[derive(Debug, HashStable_Generic)]
pub struct ForeignItemRef {
pub id: ForeignItemId,
#[stable_hasher(project(name))]
pub ident: Ident,
pub span: Span,
}
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_middle/src/ty/assoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ impl AssocItemContainer {
#[derive(Copy, Clone, Debug, PartialEq, HashStable, Eq, Hash)]
pub struct AssocItem {
pub def_id: DefId,
#[stable_hasher(project(name))]
pub ident: Ident,
pub kind: AssocKind,
pub vis: Visibility,
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_middle/src/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1502,7 +1502,6 @@ 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 @@ -1598,7 +1597,6 @@ pub enum VariantDiscr {
#[derive(Debug, HashStable, TyEncodable, TyDecodable)]
pub struct FieldDef {
pub did: DefId,
#[stable_hasher(project(name))]
pub ident: Ident,
pub vis: Visibility,
}
Expand Down
12 changes: 12 additions & 0 deletions src/test/incremental/issue-92192-expnid-hash/auxiliary/upstream.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
macro_rules! make_struct {
() => {
pub struct Foo;
}
}


#[cfg(rpass1)]
make_struct!();

#[cfg(rpass2)]
make_struct!();
14 changes: 14 additions & 0 deletions src/test/incremental/issue-92192-expnid-hash/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// aux-build:upstream.rs
// revisions: rpass1 rpass2

extern crate upstream;

struct Wrapper;

impl Wrapper {
fn bar() {
let val: upstream::Foo;
}
}

fn main() {}

0 comments on commit 6fbc75b

Please sign in to comment.