about summary refs log tree commit diff
path: root/compiler/rustc_data_structures/src/stable_hasher.rs
AgeCommit message (Collapse)AuthorLines
2025-03-26Add `TyCtx::env_var_os`Mads Marquart-0/+2
Along with `TyCtx::env_var` helper. These can be used to track environment variable accesses in the query system. Since `TyCtx::env_var_os` uses `OsStr`, this commit also adds the necessary trait implementations for that to work.
2025-02-16Move hashes from rustc_data_structure to rustc_hashes so they can be shared ↵Ben Kimock-2/+1
with rust-analyzer
2025-01-11rename `BitSet` to `DenseBitSet`Rémy Rakic-2/+2
This should make it clearer that this bitset is dense, with the advantages and disadvantages that it entails.
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-1/+1
2024-07-29Reformat `use` declarations.Nicholas Nethercote-7/+8
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-11Use uplifted `rustc-stable-hash` crate in `rustc_data_structures`Urgau-159/+3
2024-06-22Ensure careful consideration is given by implsAlan Egerton-7/+43
Added an associated `const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED` to the `StableOrd` trait to ensure that implementors carefully consider whether the trait's contract is upheld, as incorrect implementations can cause miscompilations.
2024-06-12Un-unsafe the `StableOrd` traitAlan Egerton-16/+17
Whilst incorrect implementations of this trait can cause miscompilation, they cannot cause memory unsafety in rustc.
2024-05-07Remove `macro_use` from `stable_hasher`.Nicholas Nethercote-0/+2
Normal `use` items are nicer.
2024-03-27Remove and disallow HashStable impl of HashMap.Michael Woerister-46/+2
2024-02-15Use generic `NonZero` internally.Markus Reiter-2/+3
2024-01-17Use UnhashMap for a few more mapsMark Rousskov-1/+13
This avoids hashing data that's already hashed.
2024-01-04Split StableCompare trait out of StableOrd trait.Michael Woerister-0/+26
StableCompare is a companion trait to `StableOrd`. Some types like `Symbol` can be compared in a cross-session stable way, but their `Ord` implementation is not stable. In such cases, a `StableOrd` implementation can be provided to offer a lightweight way for stable sorting. (The more heavyweight option is to sort via `ToStableHashKey`, but then sorting needs to have access to a stable hashing context and `ToStableHashKey` can also be expensive as in the case of `Symbol` where it has to allocate a `String`.)
2023-06-19Make closure_saved_names_of_captured_variables a query.Camille GILLOT-1/+13
2023-06-08Removed stable/unstable sort arg from into_sorted_stable_ord, fixed a few ↵Andrew Xie-8/+37
misc issues, added collect to UnordItems
2023-06-05Fixed to_sorted => to_sorted_stable_ordAndrew Xie-0/+11
2023-04-24Split `{Idx, IndexVec, IndexSlice}` into their own modulesMaybe Waffle-5/+5
2023-04-18Store hashes in special types so they aren't accidentally encoded as numbersBen Kimock-18/+9
2023-04-16Implement StableHasher::write_u128 via write_u64Ben Kimock-1/+2
2023-04-09Fix some clippy::complexityNilstrieb-2/+2
2023-03-01Do not implement HashStable for HashSet.Michael Woerister-12/+4
2023-02-10Resolve documentation links in rustc and store the results in metadataVadim Petrochenkov-0/+8
This commit implements MCP https://github.com/rust-lang/compiler-team/issues/584 It also removes code that is no longer used, and that includes code cloning resolver, so issue #83761 is fixed.
2022-12-25fix some typosKaDiWa-1/+1
2022-12-06Auto merge of #105175 - michaelwoerister:add-stable-ord-trait, r=nagisabors-29/+68
Add StableOrd trait as proposed in MCP 533. The `StableOrd` trait can be used to mark types as having a stable sort order across compilation sessions. Collections that sort their items in a stable way can safely implement HashStable by hashing items in sort order. See https://github.com/rust-lang/compiler-team/issues/533 for more information.
2022-12-05StableOrd: Address review comments.Michael Woerister-18/+18
2022-12-03Rollup merge of #105050 - WaffleLapkin:uselessrefign, r=jyn514Matthias Krüger-3/+3
Remove useless borrows and derefs They are nothing more than noise. <sub>These are not all of them, but my clippy started crashing (stack overflow), so rip :(</sub>
2022-12-02Add StableOrd trait as proposed in MCP 533.Michael Woerister-30/+69
The StableOrd trait can be used to mark types as having a stable sort order across compilation sessions. Collections that sort their items in a stable way can safely implement HashStable by hashing items in sort order.
2022-12-01Remove useless borrows and derefsMaybe Waffle-3/+3
2022-12-01rustc_hir: Change representation of import paths to support multiple resolutionsVadim Petrochenkov-1/+1
2022-07-29remove some manual hash stable implslcnr-0/+5
2022-05-30Fix typos in commentTobias Stoeckmann-2/+2
2022-05-06Add a dedicated length-prefixing method to `Hasher`Scott McMurray-0/+11
This accomplishes two main goals: - Make it clear who is responsible for prefix-freedom, including how they should do it - Make it feasible for a `Hasher` that *doesn't* care about Hash-DoS resistance to get better performance by not hashing lengths This does not change rustc-hash, since that's in an external crate, but that could potentially use it in future.
2022-04-19incr. comp.: Don't export impl_stable_hash_via_hash!() and warn about using it.Michael Woerister-3/+12
2022-04-12Remove NodeIdHashingMode.Camille GILLOT-7/+0
2022-03-30Spellchecking some commentsYuri Astrakhan-1/+1
This PR attempts to clean up some minor spelling mistakes in comments
2022-02-05Use const generics in SipHasher128's short_writeJakub Beránek-14/+10
2022-02-03Fix `isize` optimization in `StableHasher` for big-endian architecturesJakub Beránek-3/+7
2022-01-30Compress amount of hashed bytes for `isize` values in StableHasherJakub Beránek-1/+29
2022-01-05Ensure that `Fingerprint` caching respects hashing configurationAaron Hill-0/+19
Fixes #92266 In some `HashStable` impls, we use a cache to avoid re-computing the same `Fingerprint` from the same structure (e.g. an `AdtDef`). However, the `StableHashingContext` used can be configured to perform hashing in different ways (e.g. skipping `Span`s). This configuration information is not included in the cache key, which will cause an incorrect `Fingerprint` to be used if we hash the same structure with different `StableHashingContext` settings. To fix this, the configuration settings of `StableHashingContext` are split out into a separate `HashingControls` struct. This struct is used as part of the cache key, ensuring that our caches always produce the correct result for the given settings. With this in place, we now turn off `Span` hashing during the entire process of computing the hash included in legacy symbols. This current has no effect, but will matter when a future PR starts hashing more `Span`s that we currently skip.
2021-12-28Auto merge of #92130 - Kobzol:stable-hash-str, r=cjgillotbors-3/+2
Use hash_stable for hashing str This seemed like an oversight. With this change the hash can go through the `HashStable` machinery directly.
2021-12-21Auto merge of #91903 - tmiasko:bit-set-hash, r=jackh726bors-4/+4
Implement StableHash for BitSet and BitMatrix via Hash This fixes an issue where bit sets / bit matrices the same word content but a different domain size would receive the same hash.
2021-12-20Use hash_stable for hashing strJakub Beránek-3/+2
2021-12-18Implement StableHash for BitSet and BitMatrix via HashTomasz Miąsko-4/+4
This fixes an issue where bit sets / bit matrices the same word content but a different domain size would receive the same hash.
2021-12-13Add special case for length 1Jakub Beránek-9/+17
2021-12-13Remove sort from hashing hashset, treeset and treemapJakub Beránek-27/+29
2021-12-12Use modular arithmeticJakub Beránek-3/+3
2021-12-12Avoid sorting in hash map stable hashingJakub Beránek-4/+14
2021-12-12Auto merge of #89404 - Kobzol:hash-stable-sort, r=Mark-Simulacrumbors-1/+2
Slightly optimize hash map stable hashing I was profiling some of the `rustc-perf` benchmarks locally and noticed that quite some time is spent inside the stable hash of hashmaps. I tried to use a `SmallVec` instead of a `Vec` there, which helped very slightly. Then I tried to remove the sorting, which was a bottleneck, and replaced it with insertion into a binary heap. Locally, it yielded nice improvements in instruction counts and RSS in several benchmarks for incremental builds. The implementation could probably be much nicer and possibly extended to other stable hashes, but first I wanted to test the perf impact properly. Can I ask someone to do a perf run? Thank you!
2021-10-25Use SmallVec in Hash map stable hashingJakub Beránek-1/+2
2021-10-23Specialize HashStable for [u8] slicesMark Rousskov-0/+7
Particularly for ctfe-stress-4, the hashing of byte slices as part of the MIR Allocation is quite hot. Previously, we were falling back on byte-by-byte copying of the slice into the SipHash buffer (64 bytes long) before hashing a 64 byte chunk, and then doing that again and again. This should hopefully be an improvement for that code.