about summary refs log tree commit diff
path: root/compiler/rustc_data_structures/src/intern.rs
AgeCommit message (Collapse)AuthorLines
2025-02-17Enforce T: Hash for Interned<...>Mark Rousskov-1/+4
This adds panicking Hash impls for several resolver types that don't actually satisfy this condition. It's not obvious to me that rustc_resolve actually upholds the Interned guarantees but fixing that seems pretty hard (the structures have at minimum some interior mutability, so it's not really recursively hashable in place...).
2024-07-29Reformat `use` declarations.Nicholas Nethercote-1/+2
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2023-06-09Don't print Interned or PrivateZstMichael Goulet-1/+7
2022-12-06Rollup merge of #104898 - oli-obk:group_all_the_things, r=wesleywiserMatthias Krüger-83/+0
Put all cached values into a central struct instead of just the stable hash cc `@nnethercote` this allows re-use of the type for Predicate without duplicating all the logic for the non-hash cached fields
2022-12-01Remove useless borrows and derefsMaybe Waffle-2/+2
2022-11-30move WithCachedTypeInfo to rustc_type_irOli Scherer-83/+0
2022-11-30s/WithStableHash/WithCachedTypeInfo/Oli Scherer-10/+10
2022-11-11Use the interned stable hash as plain hash.Camille GILLOT-1/+5
2022-11-11Hash spans when interning.Camille GILLOT-7/+2
2022-04-07Document and rename the new wrapper typeOli Scherer-10/+17
2022-03-31Check that the cached stable hash is the right one if debug assertions are ↵Oli Scherer-4/+8
enabled
2022-03-31Move stable hash from TyS into a datastructure that can be shared with other ↵Oli Scherer-0/+73
interned types.
2022-03-07Clarify `Layout` interning.Nicholas Nethercote-0/+10
`Layout` is another type that is sometimes interned, sometimes not, and we always use references to refer to it so we can't take any advantage of the uniqueness properties for hashing or equality checks. This commit renames `Layout` as `LayoutS`, and then introduces a new `Layout` that is a newtype around an `Interned<LayoutS>`. It also interns more layouts than before. Previously layouts within layouts (via the `variants` field) were never interned, but now they are. Hence the lifetime on the new `Layout` type. Unlike other interned types, these ones are in `rustc_target` instead of `rustc_middle`. This reflects the existing structure of the code, which does layout-specific stuff in `rustc_target` while `TyAndLayout` is generic over the `Ty`, allowing the type-specific stuff to occur in `rustc_middle`. The commit also adds a `HashStable` impl for `Interned`, which was needed. It hashes the contents, unlike the `Hash` impl which hashes the pointer.
2022-03-07Introduce `ConstAllocation`.Nicholas Nethercote-6/+10
Currently some `Allocation`s are interned, some are not, and it's very hard to tell at a use point which is which. This commit introduces `ConstAllocation` for the known-interned ones, which makes the division much clearer. `ConstAllocation::inner()` is used to get the underlying `Allocation`. In some places it's natural to use an `Allocation`, in some it's natural to use a `ConstAllocation`, and in some places there's no clear choice. I've tried to make things look as nice as possible, while generally favouring `ConstAllocation`, which is the type that embodies more information. This does require quite a few calls to `inner()`. The commit also tweaks how `PartialOrd` works for `Interned`. The previous code was too clever by half, building on `T: Ord` to make the code shorter. That caused problems with deriving `PartialOrd` and `Ord` for `ConstAllocation`, so I changed it to build on `T: PartialOrd`, which is slightly more verbose but much more standard and avoided the problems.
2022-02-25Switch bootstrap cfgsMark Rousskov-1/+1
2022-02-15Address review comments.Nicholas Nethercote-11/+7
2022-02-15Rename `PtrKey` as `Interned` and improve it.Nicholas Nethercote-0/+102
In particular, there's now more protection against incorrect usage, because you can only create one via `Interned::new_unchecked`, which makes it more obvious that you must be careful. There are also some tests.