about summary refs log tree commit diff
path: root/compiler/rustc_data_structures
AgeCommit message (Collapse)AuthorLines
2024-06-12Docstring for for `Annotation`Amanda Stjerna-2/+12
Note that this changes no executing code. The change is 100% in documentation.
2024-06-12Formatting, weird because I just did thatAmanda Stjerna-2/+3
2024-06-12Simplify path compression logicAmanda Stjerna-17/+2
2024-06-12Documentation fixesAmanda Stjerna-8/+7
2024-06-12Extend SCC construction to enable extra functionalityAmanda Stjerna-129/+472
This patch has been extracted from #123720. It specifically enhances `Sccs` to allow tracking arbitrary commutative properties of SCCs, including - reachable values (max/min) - SCC-internal values (max/min) This helps with among other things universe computation: we can now identify SCC universes as a straightforward "find max/min" operation during SCC construction. It's also more or less zero-cost; don't use the new features, don't pay for them. This commit also vastly extends the documentation of the SCCs module, which I had a very hard time following.
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-06-12Require any function with a tait in its signature to actually constrain a ↵Oli Scherer-11/+16
hidden type
2024-06-10Remove some unused crate dependencies.Nicholas Nethercote-2/+1
I found these by setting the `unused_crate_dependencies` lint temporarily to `Warn`.
2024-05-30Apply x clippy --fix and x fmtr0cky-8/+8
2024-02-20Stabilize `LazyCell` and `LazyLock` (`lazy_cell`)Peter Jaszkowiak-1/+0
2024-05-11Rollup merge of #124818 - compiler-errors:ena, r=Mark-SimulacrumMatthias Krüger-1/+1
Update ena to 0.14.3 Includes https://github.com/rust-lang/ena/pull/53, which removes a trivial `Self: Sized` bound that prevents `ena` from building on the new solver.
2024-05-09Remove `enum_from_u32`.Nicholas Nethercote-38/+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-71/+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-236/+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-09Document `Pu128`.Nicholas Nethercote-1/+3
And move the `repr` line after the `derive` line, where it's harder to overlook. (I overlooked it initially, and didn't understand how this type worked.)
2024-05-08Remove `extern crate tracing`.Nicholas Nethercote-4/+6
`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/+6
Normal `use` items are nicer.
2024-05-06Update ena to 0.14.3Michael Goulet-1/+1
2024-05-03Auto merge of #123441 - saethlin:fixed-len-file-names, r=oli-obkbors-26/+102
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-02Auto merge of #124521 - Mark-Simulacrum:bootstrap-bump, r=albertlarsan68bors-0/+6
Bump bootstrap compiler to latest beta https://forge.rust-lang.org/release/process.html#master-bootstrap-update-t-2-day-tuesday This also cherry-picks d716d72586548963f32e5c8d57c41db0065fa6e0 from the beta branching, to continue to workaround #122758. r? bootstrap
2024-05-02Add `UnordMap::try_insert`Waffle Lapkin-0/+7
2024-05-01Mark more entries in rustc_data_structures as no_inline for docsMark Rousskov-0/+6
This is a workaround for #122758, but it's not clear why 1.79 requires a more extensive amount of no_inline than the previous release. Seems like there's something relatively subtle happening here.
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-4/+4
2024-04-22Stabilize generic `NonZero`.Markus Reiter-1/+0
2024-04-22Stabilize the size of incr comp object file namesBen Kimock-26/+102
2024-04-18Add tests for predecessor-aware `VecGraph` modeMaybe Waffle-0/+33
2024-04-15Add `graph::depth_first_search_as_undirected`Maybe Waffle-0/+26
2024-04-15Make `graph::DepthFirstSearch` accept `G` by valueMaybe Waffle-13/+13
It's required for the next commit. Note that you can still have `G = &H`, since there are implementations of all the graph traits for references.
2024-04-15Add an opt-in to store incoming edges in `VecGraph` + some docsMaybe Waffle-56/+192
2024-04-15Rollup merge of #123934 - WaffleLapkin:graph-mini-refactor, r=fmease许杰友 Jieyou Xu (Joe)-126/+59
`rustc_data_structures::graph` mini refactor Who doesn't love to breathe dust from the ancient times?
2024-04-15Use RPITIT for `Successors` and `Predecessors` traitsMaybe Waffle-30/+8
Now with RPITIT instead of GAT!
2024-04-14Make `depth_first_search` into a standalone functionMaybe Waffle-5/+10
Does not necessarily change much, but we never overwrite it, so I see no reason for it to be in the `Successors` trait. (+we already have a similar `is_cyclic`)
2024-04-14Document `ControlFlowGraph`Maybe Waffle-4/+2
2024-04-14Rename `WithNumEdges` => `NumEdges` and `WithStartNode` => `StartNode`Maybe Waffle-16/+16
2024-04-14Merge `{With,Graph}{Successors,Predecessors}` into `{Successors,Predecessors}`Maybe Waffle-88/+53
Now with GAT!
2024-04-14Merge `WithNumNodes` into DirectedGraphMaybe Waffle-40/+27
2024-04-13Auto merge of #123175 - Nilstrieb:debug-strict-overflow, r=wesleywiserbors-17/+21
Add add/sub methods that only panic with debug assertions to rustc This mitigates the perf impact of enabling overflow checks on rustc. The change to use overflow checks will be done in a later PR. For rust-lang/compiler-team#724, based on data gathered in #119440.
2024-04-13Add add/sub methods that only panic with debug assertions to rustcNilstrieb-17/+21
This mitigates the perf impact of enabling overflow checks on rustc. The change to use overflow checks will be done in a later PR.
2024-04-03rustc_index: Add a `ZERO` constant to index typesVadim Petrochenkov-4/+4
It is commonly used.
2024-03-31Auto merge of #121851 - michaelwoerister:mcp-533-effective-vis, r=cjgillotbors-46/+2
Use FxIndexMap instead FxHashMap to stabilize iteration order in EffectiveVisibilities Part of [MCP 533](https://github.com/rust-lang/compiler-team/issues/533).
2024-03-29Add support for NonNull in ambiguous_wide_ptr_comparisionsUrgau-0/+1
2024-03-27Remove and disallow HashStable impl of HashMap.Michael Woerister-46/+2
2024-03-21Auto merge of #122568 - RalfJung:mentioned-items, r=oli-obkbors-3/+6
recursively evaluate the constants in everything that is 'mentioned' This is another attempt at fixing https://github.com/rust-lang/rust/issues/107503. The previous attempt at https://github.com/rust-lang/rust/pull/112879 seems stuck in figuring out where the [perf regression](https://perf.rust-lang.org/compare.html?start=c55d1ee8d4e3162187214692229a63c2cc5e0f31&end=ec8de1ebe0d698b109beeaaac83e60f4ef8bb7d1&stat=instructions:u) comes from. In https://github.com/rust-lang/rust/pull/122258 I learned some things, which informed the approach this PR is taking. Quoting from the new collector docs, which explain the high-level idea: ```rust //! One important role of collection is to evaluate all constants that are used by all the items //! which are being collected. Codegen can then rely on only encountering constants that evaluate //! successfully, and if a constant fails to evaluate, the collector has much better context to be //! able to show where this constant comes up. //! //! However, the exact set of "used" items (collected as described above), and therefore the exact //! set of used constants, can depend on optimizations. Optimizing away dead code may optimize away //! a function call that uses a failing constant, so an unoptimized build may fail where an //! optimized build succeeds. This is undesirable. //! //! To fix this, the collector has the concept of "mentioned" items. Some time during the MIR //! pipeline, before any optimization-level-dependent optimizations, we compute a list of all items //! that syntactically appear in the code. These are considered "mentioned", and even if they are in //! dead code and get optimized away (which makes them no longer "used"), they are still //! "mentioned". For every used item, the collector ensures that all mentioned items, recursively, //! do not use a failing constant. This is reflected via the [`CollectionMode`], which determines //! whether we are visiting a used item or merely a mentioned item. //! //! The collector and "mentioned items" gathering (which lives in `rustc_mir_transform::mentioned_items`) //! need to stay in sync in the following sense: //! //! - For every item that the collector gather that could eventually lead to build failure (most //! likely due to containing a constant that fails to evaluate), a corresponding mentioned item //! must be added. This should use the exact same strategy as the ecollector to make sure they are //! in sync. However, while the collector works on monomorphized types, mentioned items are //! collected on generic MIR -- so any time the collector checks for a particular type (such as //! `ty::FnDef`), we have to just onconditionally add this as a mentioned item. //! - In `visit_mentioned_item`, we then do with that mentioned item exactly what the collector //! would have done during regular MIR visiting. Basically you can think of the collector having //! two stages, a pre-monomorphization stage and a post-monomorphization stage (usually quite //! literally separated by a call to `self.monomorphize`); the pre-monomorphizationn stage is //! duplicated in mentioned items gathering and the post-monomorphization stage is duplicated in //! `visit_mentioned_item`. //! - Finally, as a performance optimization, the collector should fill `used_mentioned_item` during //! its MIR traversal with exactly what mentioned item gathering would have added in the same //! situation. This detects mentioned items that have *not* been optimized away and hence don't //! need a dedicated traversal. enum CollectionMode { /// Collect items that are used, i.e., actually needed for codegen. /// /// Which items are used can depend on optimization levels, as MIR optimizations can remove /// uses. UsedItems, /// Collect items that are mentioned. The goal of this mode is that it is independent of /// optimizations: the set of "mentioned" items is computed before optimizations are run. /// /// The exact contents of this set are *not* a stable guarantee. (For instance, it is currently /// computed after drop-elaboration. If we ever do some optimizations even in debug builds, we /// might decide to run them before computing mentioned items.) The key property of this set is /// that it is optimization-independent. MentionedItems, } ``` And the `mentioned_items` MIR body field docs: ```rust /// Further items that were mentioned in this function and hence *may* become monomorphized, /// depending on optimizations. We use this to avoid optimization-dependent compile errors: the /// collector recursively traverses all "mentioned" items and evaluates all their /// `required_consts`. /// /// This is *not* soundness-critical and the contents of this list are *not* a stable guarantee. /// All that's relevant is that this set is optimization-level-independent, and that it includes /// everything that the collector would consider "used". (For example, we currently compute this /// set after drop elaboration, so some drop calls that can never be reached are not considered /// "mentioned".) See the documentation of `CollectionMode` in /// `compiler/rustc_monomorphize/src/collector.rs` for more context. pub mentioned_items: Vec<Spanned<MentionedItem<'tcx>>>, ``` Fixes #107503
2024-03-20Workaround for rustdoc bug in new betaMark Rousskov-0/+1
Filed #122758 to track a proper fix, but this seems to solve the problem in the meantime and is probably OK in terms of impact on (internal) doc quality.
2024-03-20collector: recursively traverse 'mentioned' items to evaluate their constantsRalf Jung-3/+6
2024-03-15Issue 122262: MAP_PRIVATE for more reliability on virtualised filesystems.Guillaume Yziquel-2/+8
Adding support of quirky filesystems occuring in virtualised settings not having full POSIX support for memory mapped files. Example: current virtiofs with cache disabled, occuring in Incus/LXD or Kata Containers. Has been hitting various virtualised filesystems since 2016, depending on their levels of maturity at the time. The situation will perhaps improve when virtiofs DAX support patches will have made it into the qemu mainline. On a reliability level, using the MAP_PRIVATE sycall flag instead of the MAP_SHARED syscall flag for the mmap() system call does have some undefined behaviour when the caller update the memory mapping of the mmap()ed file, but MAP_SHARED does allow not only the calling process but other processes to modify the memory mapping. Thus, in the current context, using MAP_PRIVATE copy-on-write is marginally more reliable than MAP_SHARED. This discussion of reliability is orthogonal to the type system enforced safety policy of rust, which does not claim to handle memory modification of memory mapped files triggered through the operating system and not the running rust process.
2024-03-04Rollup merge of #120976 - matthiaskrgr:constify_TL_statics, r=lcnrMatthias Krüger-1/+1
constify a couple thread_local statics
2024-02-24compiler: use `addr_of!`Pavel Grigorenko-1/+1