about summary refs log tree commit diff
path: root/compiler/rustc_data_structures
AgeCommit message (Collapse)AuthorLines
2025-04-29Add a jobserver proxy to ensure at least one token is always heldJohn Kåre Alsaker-9/+93
2025-04-28Use associated types for SCC annotations, per code review suggestionAmanda Stjerna-39/+41
2025-04-28Decouple SCC annotations from SCCsAmanda Stjerna-138/+172
This rewires SCC annotations to have them be a separate, visitor-type data structure. It was broken out of #130227, which needed them to be able to remove unused annotations after computation without recomputing the SCCs themselves. As a drive-by it also removes some redundant code from the hot loop in SCC construction for a performance improvement.
2025-04-21Update !DynSend and !DynSync platform implsThalia Archibald-4/+18
These have grown out of sync with the platforms.
2025-04-14Add unit tests for minimal_scc_representativeMatthew Jasper-0/+41
2025-04-14Handle regions equivalent to 'static in non_local_boundsMatthew Jasper-0/+14
`non_local_bounds` would only find non local bounds that strictly bound a given region, but it's possible that a local region is equated to 'static when showing a type referencing a locally bound lifetime, such as `dyn Any + 'a` in the tests added, is well-formed. In this case we should return 'static.
2025-04-14Switch to `diagnostic::on_unimplemented`mejrs-2/+2
2025-04-11Rollup merge of #139584 - oli-obk:horrible-experiment-1, r=petrochenkovJacob Pratt-0/+10
Avoid a reverse map that is only used in diagnostics paths r? `@petrochenkov` iterating a map until a value matches and returning the key is bad obviously, but it happens very rarely and only on diagnostics paths. It would also be a lot cheaper with https://github.com/rust-lang/rust/pull/138995. Which is actually why I'm trying this out, that PR adds a new entry in `create_def`, which makes `create_def` show up in cachegrind. So I'm trying out if removing adding an entry in `create_def` is a perf improvement
2025-04-11Avoid a reverse map that is only used in diagnostics pathsOli Scherer-0/+10
2025-04-11Auto merge of #139011 - Zoxc:no-rayon-iters, r=oli-obkbors-30/+89
Remove the use of Rayon iterators This removes the use of Rayon iterators and the use of the `rustc-rayon` crate. `rustc-rayon-core` is still used however. In parallel loops, instead of a Rayon iterator a serial iterator are used to collect items into a `Vec` and we use a parallel loop over its elements using the new `par_slice` function which is built on `rustc-rayon-core`'s `join`. This change makes it easier to bring `rustc-rayon-core` in-tree. Tests using 7 threads: <table><tr><td rowspan="2">Benchmark</td><td colspan="1"><b>Before</b></th><td colspan="2"><b>After</b></th><td colspan="1"><b>Before</b></th><td colspan="2"><b>After</b></th><td colspan="1"><b>Before</b></th><td colspan="2"><b>After</b></th></tr><tr><td align="right">Time</td><td align="right">Time</td><td align="right">%</th><td align="right">Physical Memory</td><td align="right">Physical Memory</td><td align="right">%</th><td align="right">Committed Memory</td><td align="right">Committed Memory</td><td align="right">%</th></tr><tr><td>🟣 <b>clap</b>:check</td><td align="right">0.4827s</td><td align="right">0.4828s</td><td align="right"> 0.02%</td><td align="right">201.23 MiB</td><td align="right">201.31 MiB</td><td align="right"> 0.04%</td><td align="right">279.03 MiB</td><td align="right">279.46 MiB</td><td align="right"> 0.15%</td></tr><tr><td>🟣 <b>hyper</b>:check</td><td align="right">0.1443s</td><td align="right">0.1401s</td><td align="right">💚 -2.91%</td><td align="right">126.42 MiB</td><td align="right">126.70 MiB</td><td align="right"> 0.22%</td><td align="right">199.79 MiB</td><td align="right">199.99 MiB</td><td align="right"> 0.10%</td></tr><tr><td>🟣 <b>regex</b>:check</td><td align="right">0.3252s</td><td align="right">0.3065s</td><td align="right">💚 -5.78%</td><td align="right">161.87 MiB</td><td align="right">161.78 MiB</td><td align="right"> -0.05%</td><td align="right">229.59 MiB</td><td align="right">230.23 MiB</td><td align="right"> 0.28%</td></tr><tr><td>🟣 <b>syn</b>:check</td><td align="right">0.5845s</td><td align="right">0.5876s</td><td align="right"> 0.53%</td><td align="right">197.01 MiB</td><td align="right">196.89 MiB</td><td align="right"> -0.06%</td><td align="right">267.62 MiB</td><td align="right">267.47 MiB</td><td align="right"> -0.06%</td></tr><tr><td>Total</td><td align="right">1.5367s</td><td align="right">1.5169s</td><td align="right">💚 -1.29%</td><td align="right">686.53 MiB</td><td align="right">686.68 MiB</td><td align="right"> 0.02%</td><td align="right">976.04 MiB</td><td align="right">977.14 MiB</td><td align="right"> 0.11%</td></tr><tr><td>Summary</td><td align="right">1.0000s</td><td align="right">0.9796s</td><td align="right">💚 -2.04%</td><td align="right">1 byte</td><td align="right">1.00 bytes</td><td align="right"> 0.04%</td><td align="right">1 byte</td><td align="right">1.00 bytes</td><td align="right"> 0.12%</td></tr></table> <table><tr><td rowspan="2">Benchmark</td><td colspan="1"><b>Before</b></th><td colspan="2"><b>After</b></th><td colspan="1"><b>Before</b></th><td colspan="2"><b>After</b></th><td colspan="1"><b>Before</b></th><td colspan="2"><b>After</b></th></tr><tr><td align="right">Time</td><td align="right">Time</td><td align="right">%</th><td align="right">Physical Memory</td><td align="right">Physical Memory</td><td align="right">%</th><td align="right">Committed Memory</td><td align="right">Committed Memory</td><td align="right">%</th></tr><tr><td>🟠 <b>clap</b>:debug</td><td align="right">1.6371s</td><td align="right">1.6529s</td><td align="right"> 0.96%</td><td align="right">395.58 MiB</td><td align="right">396.21 MiB</td><td align="right"> 0.16%</td><td align="right">460.98 MiB</td><td align="right">461.52 MiB</td><td align="right"> 0.12%</td></tr><tr><td>🟠 <b>hyper</b>:debug</td><td align="right">0.3248s</td><td align="right">0.3210s</td><td align="right">💚 -1.16%</td><td align="right">155.16 MiB</td><td align="right">155.19 MiB</td><td align="right"> 0.02%</td><td align="right">219.21 MiB</td><td align="right">219.30 MiB</td><td align="right"> 0.04%</td></tr><tr><td>🟠 <b>regex</b>:debug</td><td align="right">1.0148s</td><td align="right">0.9929s</td><td align="right">💚 -2.16%</td><td align="right">297.96 MiB</td><td align="right">295.07 MiB</td><td align="right"> -0.97%</td><td align="right">354.53 MiB</td><td align="right">351.58 MiB</td><td align="right"> -0.83%</td></tr><tr><td>🟠 <b>syn</b>:debug</td><td align="right">1.3614s</td><td align="right">1.3717s</td><td align="right"> 0.76%</td><td align="right">319.10 MiB</td><td align="right">321.19 MiB</td><td align="right"> 0.65%</td><td align="right">378.90 MiB</td><td align="right">381.27 MiB</td><td align="right"> 0.62%</td></tr><tr><td>Total</td><td align="right">4.3381s</td><td align="right">4.3386s</td><td align="right"> 0.01%</td><td align="right">1.14 GiB</td><td align="right">1.14 GiB</td><td align="right"> -0.01%</td><td align="right">1.38 GiB</td><td align="right">1.38 GiB</td><td align="right"> 0.00%</td></tr><tr><td>Summary</td><td align="right">1.0000s</td><td align="right">0.9960s</td><td align="right"> -0.40%</td><td align="right">1 byte</td><td align="right">1.00 bytes</td><td align="right"> -0.03%</td><td align="right">1 byte</td><td align="right">1.00 bytes</td><td align="right"> -0.01%</td></tr></table>
2025-04-10Remove the use of Rayon iteratorsJohn Kåre Alsaker-30/+89
2025-04-10Rollup merge of #139502 - yaahc:still-mutable-ice, r=bjorn3Matthias Krüger-1/+1
fix "still mutable" ice while metrics are enabled Resolves "still mutable" ICE discovered by `@matthiaskrgr` here: [#t-docs-rs > metrics intitiative @ 💬](https://rust-lang.zulipchat.com/#narrow/channel/356853-t-docs-rs/topic/metrics.20intitiative/near/510490790) This was caused by invoking `crate_hash` before the `definitions` struct was frozen here: https://github.com/rust-lang/rust/blob/e643f59f6da3a84f43e75dea99afaa5b041ea6bf/compiler/rustc_interface/src/passes.rs#L951 resolved by moving metrics dumping to occur after `analysis` freezes the definitions I'm guessing we didn't discover this in CI because the problem only occurs when you try to calculate the crash hash with incremental compilation enabled when it tries to freeze the definitions here: https://github.com/rust-lang/rust/blob/e643f59f6da3a84f43e75dea99afaa5b041ea6bf/compiler/rustc_middle/src/hir/map.rs#L1172 my understanding is that this causes us to freeze the definitions too early in compilation, then we subsequently try to mutate them, likely during `analysis`, and this causes the ICE. r? `@bjorn3`
2025-04-09update cfgsBoxy-1/+1
2025-04-08fix "still mutable" ice while metrics are enabledJane Losare-Lusby-1/+1
2025-04-02Invalidate all dereferences for non-local assignmentsdianqk-0/+2
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-03-21Use hashbrown from crates.ioJohn Kåre Alsaker-2/+5
2025-03-21Optimize hash map operations in the query systemJohn Kåre Alsaker-6/+3
2025-03-16Auto merge of #137011 - LuuuXXX:promote-ohos-with-host-tools, r=Amanieubors-1/+1
Promote ohos targets to tier2 with host tools. ### What does this PR try to resolve? Try to promote the following [[Tier 2 without Host Tools](https://doc.rust-lang.org/rustc/platform-support.html#tier-2-without-host-tools)](https://doc.rust-lang.org/rustc/platform-support.html#tier-2-without-host-tools) targets to [[Tier 2 with Host Tools](https://doc.rust-lang.org/rustc/platform-support.html#tier-2-with-host-tools)](https://doc.rust-lang.org/rustc/platform-support.html#tier-2-with-host-tools): - `aarch64-unknown-linux-ohos` - `armv7-unknown-linux-ohos` - `x86_64-unknown-linux-ohos` ### More Information? see MCP: https://github.com/rust-lang/compiler-team/issues/811 ### Blockage to be solved? - [x] Submit an MCP - [x] Submit code of promote ohos targets - [x] Resolve related dependencies (`measureme`) The modified code of the measureme has been merged (see https://github.com/rust-lang/measureme/pull/238). [done] The new version will was released (https://github.com/rust-lang/measureme/pull/240). [done]
2025-03-15Auto merge of #138532 - matthiaskrgr:rollup-mgcynqu, r=matthiaskrgrbors-0/+6
Rollup of 5 pull requests Successful merges: - #138283 (Enforce type of const param correctly in MIR typeck) - #138439 (feat: check ARG_MAX on Unix platforms) - #138502 (resolve: Avoid some unstable iteration) - #138514 (Remove fake borrows of refs that are converted into non-refs in `MakeByMoveBody`) - #138524 (Mark myself as unavailable for reviews temporarily) r? `@ghost` `@rustbot` modify labels: rollup
2025-03-15Use {Decodable,Encodable}_NoContext in type_irMichael Goulet-8/+8
2025-03-14resolve: Avoid some unstable iterationVadim Petrochenkov-0/+6
2025-03-12Rollup merge of #138331 - nnethercote:use-RUSTC_LINT_FLAGS-more, ↵Matthias Krüger-6/+6
r=onur-ozkan,jieyouxu Use `RUSTC_LINT_FLAGS` more An alternative to the failed #138084. Fixes #138106. r? ````@jieyouxu````
2025-03-12Rollup merge of #137701 - cuviper:sharded-hashtable, r=fmeaseMatthias Krüger-18/+85
Convert `ShardedHashMap` to use `hashbrown::HashTable` The `hash_raw_entry` feature (#56167) 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-11Auto merge of #128440 - oli-obk:defines, r=lcnrbors-0/+1
Add `#[define_opaques]` attribute and require it for all type-alias-impl-trait sites that register a hidden type Instead of relying on the signature of items to decide whether they are constraining an opaque type, the opaque types that the item constrains must be explicitly listed. A previous version of this PR used an actual attribute, but had to keep the resolved `DefId`s in a side table. Now we just lower to fields in the AST that have no surface syntax, instead a builtin attribute macro fills in those fields where applicable. Note that for convenience referencing opaque types in associated types from associated methods on the same impl will not require an attribute. If that causes problems `#[defines()]` can be used to overwrite the default of searching for opaques in the signature. One wart of this design is that closures and static items do not have generics. So since I stored the opaques in the generics of functions, consts and methods, I would need to add a custom field to closures and statics to track this information. During a T-types discussion we decided to just not do this for now. fixes #131298
2025-03-11Implement `#[define_opaque]` attribute for functions.Oli Scherer-0/+1
2025-03-11Add `unreachable_pub` to `RUSTC_LINT_FLAGS` for `compiler/` crates.Nicholas Nethercote-6/+6
And fix the new errors in the handful of crates that didn't have a `#![warn(unreachable_pub)]`.
2025-03-10Convert `ShardedHashMap` to use `hashbrown::HashTable`Josh Stone-18/+85
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-10Revert "Use workspace lints for crates in `compiler/` #138084"许杰友 Jieyou Xu (Joe)-9/+6
Revert <https://github.com/rust-lang/rust/pull/138084> to buy time to consider options that avoids breaking downstream usages of cargo on distributed `rustc-src` artifacts, where such cargo invocations fail due to inability to inherit `lints` from workspace root manifest's `workspace.lints` (this is only valid for the source rust-lang/rust workspace, but not really the distributed `rustc-src` artifacts). This breakage was reported in <https://github.com/rust-lang/rust/issues/138304>. This reverts commit 48caf81484b50dca5a5cebb614899a3df81ca898, reversing changes made to c6662879b27f5161e95f39395e3c9513a7b97028.
2025-03-09Rollup merge of #138084 - nnethercote:workspace-lints, r=jieyouxuMatthias Krüger-6/+9
Use workspace lints for crates in `compiler/` This is nicer and hopefully less error prone than specifying lints via bootstrap. r? ``@jieyouxu``
2025-03-09Rollup merge of #138040 - thaliaarchi:use-prelude-size-of.compiler, ↵Matthias Krüger-11/+7
r=compiler-errors compiler: Use `size_of` from the prelude instead of imported Use `std::mem::{size_of, size_of_val, align_of, align_of_val}` from the prelude instead of importing or qualifying them. Apply this change across the compiler. These functions were added to all preludes in Rust 1.80. r? ``@compiler-errors``
2025-03-08Add `unreachable_pub` to the default lints for `compiler/` crates.Nicholas Nethercote-6/+6
And fix the new errors in the handful of crates that didn't have a `#![warn(unreachable_pub)]`.
2025-03-08Specify rust lints for `compiler/` crates via Cargo.Nicholas Nethercote-0/+3
By naming them in `[workspace.lints.rust]` in the top-level `Cargo.toml`, and then making all `compiler/` crates inherit them with `[lints] workspace = true`. (I omitted `rustc_codegen_{cranelift,gcc}`, because they're a bit different.) The advantages of this over the current approach: - It uses a standard Cargo feature, rather than special handling in bootstrap. So, easier to understand, and less likely to get accidentally broken in the future. - It works for proc macro crates. It's a shame it doesn't work for rustc-specific lints, as the comments explain.
2025-03-07compiler: Use size_of from the prelude instead of importedThalia Archibald-11/+7
Use `std::mem::{size_of, size_of_val, align_of, align_of_val}` from the prelude instead of importing or qualifying them. These functions were added to all preludes in Rust 1.80.
2025-03-06Rollup merge of #137764 - compiler-errors:always-applicable-negative-impl, ↵Michael Goulet-4/+6
r=lcnr Ensure that negative auto impls are always applicable r? lcnr (or reassign if you dont want to review) https://github.com/rust-lang/rust/issues/68318#issuecomment-2689265030
2025-03-05Auto merge of #138031 - workingjubilee:rollup-5bsotpz, r=workingjubileebors-5/+6
Rollup of 15 pull requests Successful merges: - #137829 (Stabilize [T]::split_off... methods) - #137850 (Stabilize `box_uninit_write`) - #137912 (Do not recover missing lifetime with random in-scope lifetime) - #137913 (Allow struct field default values to reference struct's generics) - #137923 (Simplify `<Postorder as Iterator>::size_hint`) - #137949 (Update MSVC INSTALL.md instructions to recommend VS 2022 + recent Windows 10/11 SDK) - #137963 (Add ``dyn`` keyword to `E0373` examples) - #137975 (Remove unused `PpMode::needs_hir`) - #137981 (rustdoc search: increase strictness of typechecking) - #137986 (Fix some typos) - #137991 (Add `avr-none` to SUMMARY.md and platform-support.md) - #137993 (Remove obsolete comment from DeduceReadOnly) - #137996 (Revert "compiler/rustc_data_structures/src/sync/worker_local.rs: delete "unsafe impl Sync"") - #138019 (Pretty-print `#[deprecated]` attribute in HIR.) - #138026 (Make CrateItem::body() function return an option) r? `@ghost` `@rustbot` modify labels: rollup
2025-03-04Ensure that negative auto impls are always applicableMichael Goulet-4/+6
2025-03-04Revert "compiler/rustc_data_structures/src/sync/worker_local.rs: delete ↵Askar Safin-5/+6
"unsafe impl Sync"" This reverts commit 02406903b0c26440428580a4bbaf30da973c5b23.
2025-03-04Adapt `librustdoc` to 2024 edition lifetieme capture rulesYotam Ofek-9/+0
Get rid of the `Captures` hack
2025-03-04use measureme-12.0.1LuuuXXX-2/+1
2025-03-04promote ohos targets to tier to with host toolsLuuuXXX-1/+2
2025-03-03Tidy imports in `rustc_data_structures::sync`Zalathar-27/+30
2025-03-03Remove some unnecessary aliases from `rustc_data_structures::sync`Zalathar-10/+0
With the removal of `cfg(parallel_compiler)`, these are always shared references and `std::sync::OnceLock`.
2025-03-03Remove leading underscores from parameter names in `Sharded`Zalathar-8/+8
With the removal of `cfg(parallel_compiler)`, these parameters are never considered unused.
2025-03-02Auto merge of #137704 - nnethercote:opt-empty-prov-range-checks, r=oli-obkbors-0/+33
Optimize empty provenance range checks. Currently it gets the pointers in the range and checks if the result is empty, but it can be done faster if you combine those two steps. r? `@oli-obk`
2025-02-27Rollup merge of #136579 - bjorn3:fix_thinvec_ext_ub, r=BoxyUwUMatthias Krüger-17/+25
Fix UB in ThinVec::flat_map_in_place `thin_vec.as_ptr()` goes through the `Deref` impl of `ThinVec`, which will not allow access to any memory as we did call `set_len(0)` first. Found in the process of investigating https://github.com/rust-lang/rust/issues/135870.
2025-02-27Optimize empty provenance range checks.Nicholas Nethercote-0/+33
Currently it gets the pointers in the range and checks if the result is empty, but it can be done faster if you combine those two steps.
2025-02-26Fix UB in ThinVec::flat_map_in_placebjorn3-17/+25
thin_vec.as_ptr() goes through the Deref impl of ThinVec, which will not allow access to any memory as we did call set_len(0) first.
2025-02-26Auto merge of #137354 - FractalFir:intern_with_cap, r=FractalFirbors-0/+3
Change interners to start preallocated with an increased capacity Inspired by https://github.com/rust-lang/rust/issues/137005. Added a `with_capacity` function to `InternedSet`. Changed the `CtxtInterners` to start with `InternedSets` preallocated with a capacity. This *does* increase memory usage at very slightly(by ~1 MB at the start), altough that increase quickly disaperars for larger crates(since they require such capacity anyway). A local perf run indicates this improves compiletimes for small crates(like `ripgrep`), without a negative effect on larger ones.
2025-02-25Changed interners to start with preallocated capacityMichał Kostrubiec-0/+3