summary refs log tree commit diff
path: root/compiler/rustc_data_structures/src/lib.rs
AgeCommit message (Collapse)AuthorLines
2025-03-10Convert `ShardedHashMap` to use `hashbrown::HashTable`Josh Stone-1/+0
The `hash_raw_entry` feature has finished fcp-close, so the compiler should stop using it to allow its removal. Several `Sharded` maps were using raw entries to avoid re-hashing between shard and map lookup, and we can do that with `hashbrown::HashTable` instead.
2025-03-04Adapt `librustdoc` to 2024 edition lifetieme capture rulesYotam Ofek-1/+0
Get rid of the `Captures` hack
2025-02-16Move hashes from rustc_data_structure to rustc_hashes so they can be shared ↵Ben Kimock-1/+0
with rust-analyzer
2025-01-31Overhaul `to_readable_str`.Nicholas Nethercote-0/+1
It's a function that prints numbers with underscores inserted for readability (e.g. "1_234_567"), used by `-Zmeta-stats` and `-Zinput-stats`. It's the only thing in `rustc_middle::util::common`, which is a bizarre location for it. This commit: - moves it to `rustc_data_structures`, a more logical crate for it; - puts it in a module `thousands`, like the similar crates.io crate; - renames it `format_with_underscores`, which is a clearer name; - rewrites it to be more concise; - slightly improves the testing.
2024-11-19Auto merge of #124780 - Mark-Simulacrum:lockless-cache, r=lcnrbors-0/+2
Improve VecCache under parallel frontend This replaces the single Vec allocation with a series of progressively larger buckets. With the cfg for parallel enabled but with -Zthreads=1, this looks like a slight regression in i-count and cycle counts (~1%). With the parallel frontend at -Zthreads=4, this is an improvement (-5% wall-time from 5.788 to 5.4688 on libcore) than our current Lock-based approach, likely due to reducing the bouncing of the cache line holding the lock. At -Zthreads=32 it's a huge improvement (-46%: 8.829 -> 4.7319 seconds). try-job: i686-gnu-nopt try-job: dist-x86_64-linux
2024-11-15Improve VecCache under parallel frontendMark Rousskov-0/+2
This replaces the single Vec allocation with a series of progressively larger buckets. With the cfg for parallel enabled but with -Zthreads=1, this looks like a slight regression in i-count and cycle counts (<0.1%). With the parallel frontend at -Zthreads=4, this is an improvement (-5% wall-time from 5.788 to 5.4688 on libcore) than our current Lock-based approach, likely due to reducing the bouncing of the cache line holding the lock. At -Zthreads=32 it's a huge improvement (-46%: 8.829 -> 4.7319 seconds).
2024-11-12Delete the `cfg(not(parallel))` serial compilerNoratrieb-1/+0
Since it's inception a long time ago, the parallel compiler and its cfgs have been a maintenance burden. This was a necessary evil the allow iteration while not degrading performance because of synchronization overhead. But this time is over. Thanks to the amazing work by the parallel working group (and the dyn sync crimes), the parallel compiler has now been fast enough to be shipped by default in nightly for quite a while now. Stable and beta have still been on the serial compiler, because they can't use `-Zthreads` anyways. But this is quite suboptimal: - the maintenance burden still sucks - we're not testing the serial compiler in nightly Because of these reasons, it's time to end it. The serial compiler has served us well in the years since it was split from the parallel one, but it's over now. Let the knight slay one head of the two-headed dragon!
2024-10-21move strict provenance lints to new feature gate, remove old feature gatesRalf Jung-1/+0
2024-10-12Add ExtractIf for ThinVecGnomedDev-0/+1
2024-09-24Dogfood `feature(file_buffered)`Josh Stone-0/+1
2024-08-11Use assert_matches around the compilerMichael Goulet-0/+1
2024-07-30Auto merge of #128083 - Mark-Simulacrum:bump-bootstrap, r=albertlarsan68bors-1/+0
Bump bootstrap compiler to new beta https://forge.rust-lang.org/release/process.html#master-bootstrap-update-t-2-day-tuesday
2024-07-29Reformat `use` declarations.Nicholas Nethercote-5/+3
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-28step cfg(bootstrap)Mark Rousskov-1/+0
2024-07-11Use uplifted `rustc-stable-hash` crate in `rustc_data_structures`Urgau-2/+0
2024-06-25RFC 2383: Stabilize `lint_reasons` :tada:xFrednet-1/+1
2024-06-24Replace `MaybeUninit::uninit_array()` with array repeat expression.Kevin Reid-1/+0
This is possible now that inline const blocks are stable; the idea was even mentioned as an alternative when `uninit_array()` was added: <https://github.com/rust-lang/rust/pull/65580#issuecomment-544200681> > if it’s stabilized soon enough maybe it’s not worth having a > standard library method that will be replaceable with > `let buffer = [MaybeUninit::<T>::uninit(); $N];` Const array repetition and inline const blocks are now stable (in the next release), so that circumstance has come to pass, and we no longer have reason to want `uninit_array()` other than convenience. Therefore, let’s evaluate the inconvenience by not using `uninit_array()` in the standard library, before potentially deleting it entirely.
2024-02-20Stabilize `LazyCell` and `LazyLock` (`lazy_cell`)Peter Jaszkowiak-1/+0
2024-05-09Remove `enum_from_u32`.Nicholas Nethercote-1/+0
It's a macro that just creates an enum with a `from_u32` method. It has two arms. One is unused and the other has a single use. This commit inlines that single use and removes the whole macro. This increases readability because we don't have two different macros interacting (`enum_from_u32` and `language_item_table`).
2024-05-09Remove `vec_linked_list`.Nicholas Nethercote-1/+0
It provides a way to effectively embed a linked list within an `IndexVec` and also iterate over that list. It's written in a very generic way, involving two traits `Links` and `LinkElem`. But the `Links` trait is only impl'd for `IndexVec` and `&IndexVec`, and the whole thing is only used in one module within `rustc_borrowck`. So I think it's over-engineered and hard to read. Plus it has no comments. This commit removes it, and adds a (non-generic) local iterator for the use within `rustc_borrowck`. Much simpler.
2024-05-09Remove `TinyList`.Nicholas Nethercote-1/+0
It is optimized for lists with a single element, avoiding the need for an allocation in that case. But `SmallVec<[T; 1]>` also avoids the allocation, and is better in general: more standard, log2 number of allocations if the list exceeds one item, and a much more capable API. This commit removes `TinyList` and converts the two uses to `SmallVec<[T; 1]>`. It also reorders the `use` items in the relevant file so they are in just two sections (`pub` and non-`pub`), ordered alphabetically, instead of many sections. (This is a relevant part of the change because I had to decide where to add a `use` item for `SmallVec`.)
2024-05-08Remove `extern crate tracing`.Nicholas Nethercote-3/+0
`use` is a nicer way of doing things.
2024-05-07Reorder top-level crate items.Nicholas Nethercote-29/+29
- `use` before `mod` - `pub` before `non-pub` - Alphabetical order within sections
2024-05-07Remove `macro_use` from `stable_hasher`.Nicholas Nethercote-4/+3
Normal `use` items are nicer.
2024-05-03Auto merge of #123441 - saethlin:fixed-len-file-names, r=oli-obkbors-0/+2
Stabilize the size of incr comp object file names The current implementation does not produce stable-length paths, and we create the paths in a way that makes our allocation behavior is nondeterministic. I think `@eddyb` fixed a number of other cases like this in the past, and this PR fixes another one. Whether that actually matters I have no idea, but we still have bimodal behavior in rustc-perf and the non-uniformity in `find` and `ls` was bothering me. I've also removed the truncation of the mangled CGU names. Before this PR incr comp paths look like this: ``` target/debug/incremental/scratch-38izrrq90cex7/s-gux6gz0ow8-1ph76gg-ewe1xj434l26w9up5bedsojpd/261xgo1oqnd90ry5.o ``` And after, they look like this: ``` target/debug/incremental/scratch-035omutqbfkbw/s-gux6borni0-16r3v1j-6n64tmwqzchtgqzwwim5amuga/55v2re42sztc8je9bva6g8ft3.o ``` On the one hand, I'm sure this will break some people's builds because they're on Windows and only a few bytes from the path length limit. But if we're that seriously worried about the length of our file names, I have some other ideas on how to make them smaller. And last time I deleted some hash truncations from the compiler, there was a huge drop in the number if incremental compilation ICEs that were reported: https://github.com/rust-lang/rust/pull/110367https://github.com/rust-lang/rust/pull/110367 --- Upon further reading, this PR actually fixes a bug. This comment says the CGU names are supposed to be a fixed-length hash, and before this PR they aren't: https://github.com/rust-lang/rust/blob/ca7d34efa94afe271accf2bd3d44152a5bd6fff1/compiler/rustc_monomorphize/src/partitioning.rs#L445-L448
2024-05-02Add `UnordMap::try_insert`Waffle Lapkin-0/+1
2024-04-30Give an item related to issue 27438 a more meaningful nameLeón Orell Valerian Liehr-2/+2
2024-04-29Remove `extern crate rustc_macros` from numerous crates.Nicholas Nethercote-2/+0
2024-04-22Stabilize generic `NonZero`.Markus Reiter-1/+0
2024-04-22Stabilize the size of incr comp object file namesBen Kimock-0/+2
2024-02-15Use generic `NonZero` internally.Markus Reiter-0/+1
2024-02-09Rollup merge of #120693 - nnethercote:invert-diagnostic-lints, r=davidtwcoMatthias Krüger-2/+0
Invert diagnostic lints. That is, change `diagnostic_outside_of_impl` and `untranslatable_diagnostic` from `allow` to `deny`, because more than half of the compiler has been converted to use translated diagnostics. This commit removes more `deny` attributes than it adds `allow` attributes, which proves that this change is warranted. r? ````@davidtwco````
2024-02-06Invert diagnostic lints.Nicholas Nethercote-2/+0
That is, change `diagnostic_outside_of_impl` and `untranslatable_diagnostic` from `allow` to `deny`, because more than half of the compiler has be converted to use translated diagnostics. This commit removes more `deny` attributes than it adds `allow` attributes, which proves that this change is warranted.
2024-02-05Rollup merge of #119600 - aDotInTheVoid:comment-fix, r=compiler-errorsMatthias Krüger-1/+1
Remove outdated references to librustc_middle The relevant comment is now in https://github.com/rust-lang/rust/blob/791a53f380d5cf800191f25941c94ace5099876e/compiler/rustc_middle/src/tests.rs#L3-L13
2024-01-25Remove unused featuresclubby789-1/+1
2024-01-19Add Pu128 = #[repr(packed(8))] u128Josh Stone-0/+1
2024-01-05Remove outdated references to `librustc_middle`.Alona Enraght-Moony-1/+1
2023-12-30Update to bitflags 2 in the compilerNilstrieb-0/+11
This involves lots of breaking changes. There are two big changes that force changes. The first is that the bitflag types now don't automatically implement normal derive traits, so we need to derive them manually. Additionally, bitflags now have a hidden inner type by default, which breaks our custom derives. The bitflags docs recommend using the impl form in these cases, which I did.
2023-11-15Bump cfg(bootstrap)sMark Rousskov-2/+2
2023-11-03Make `FatalErrorMarker` lower priority than other panicsJohn Kåre Alsaker-0/+3
2023-10-19Initiate the inner usage of `cfg_match`Caio-16/+17
2023-10-18Auto merge of #116830 - nnethercote:rustc_type_ir, r=compiler-errorsbors-5/+0
Remove `IdFunctor` trait. It's defined in `rustc_data_structures` but is only used in `rustc_type_ir`. The code is shorter and easier to read if we remove this layer of abstraction and just do the things directly where they are needed. r? `@BoxyUwU`
2023-10-17Remove `IdFunctor` trait.Nicholas Nethercote-3/+0
It's defined in `rustc_data_structures` but is only used in `rustc_type_ir`. The code is shorter and easier to read if we remove this layer of abstraction and just do the things directly where they are needed.
2023-10-17Remove unused features from `rustc_data_structures`.Nicholas Nethercote-2/+0
2023-10-16docs: add Rust logo to more compiler cratesMichael Howell-0/+2
c6e6ecb1afea9695a42d0f148ce153536b279eb5 added it to some of the compiler's crates, but avoided adding it to all of them to reduce bit-rot. This commit adds to more.
2023-09-25Rename `cold_path` to `outline`John Kåre Alsaker-1/+2
2023-09-19use pretty_print_const_value from MIR constant 'extra' printingRalf Jung-0/+19
2023-08-23Bump cfg(bootstrap)Mark Rousskov-1/+1
2023-08-03Add `internal_features` lintNilstrieb-0/+1
It lints against features that are inteded to be internal to the compiler and standard library. Implements MCP #596. We allow `internal_features` in the standard library and compiler as those use many features and this _is_ the standard library from the "internal to the compiler and standard library" after all. Marking some features as internal wasn't exactly the most scientific approach, I just marked some mostly obvious features. While there is a categorization in the macro, it's not very well upheld (should probably be fixed in another PR). We always pass `-Ainternal_features` in the testsuite About 400 UI tests and several other tests use internal features. Instead of throwing the attribute on each one, just always allow them. There's nothing wrong with testing internal features^^
2023-06-29Remove `SmallStr`.Nicholas Nethercote-1/+0
It no longer has any uses. If it's needed in the future, it can be easily reinstated. Or a crate such as `smallstr` can be used, much like we use `smallvec`.