Commit Graph

1157 Commits

Author SHA1 Message Date
Jonathan Brouwer
4482d08f64 Rollup merge of #161821 - steffahn:self-profile-help-message, r=tiif
Add missing option to `-Zself-profile-event` help message as well as information about what the default options are

The `query-cache-hit-count` option was forgotten to be added to the help text when it was added.

The new help text also documents which of the options are part of `default`, and now conveys the information that `args` is also a compound/group option and what it contains.
2026-09-09 15:01:29 +02:00
Jonathan Brouwer
5bd43f35e5 Do the same optimization in more places 2026-09-08 20:46:38 +02:00
Frank Steffahn
ac12e6fd52 Improve keep-in-sync comments 2026-09-07 14:46:05 -04:00
Frank Steffahn
9a1ef58bc1 Add missing self-profile-event option and information about default options to help message
The `query-cache-hit-count` option was forgotten to be added to the help text when it was added.

The new help text also documents which of the options are part of `default`,
and now conveys the information that `args` is also a compound/group option as well as what it contains.
2026-08-26 17:10:40 +02:00
Jonathan Brouwer
2e33de1a15 Rollup merge of #161744 - nnethercote:rm-RawDefPathHash, r=fee1-dead
Remove `RawDefPathHash`

`RawSpan`, `RawDefId`, and `RawDefPathHash` were all introduced to work around the fact that `StableHashCtxt` in `rustc_data_structure` is upstream of `rustc_span`. However, `DefPathHash` is just a newtype around `Fingerprint`, which is defined  in `rustc_data_structure`. So by working directly with `Fingerprint` we can remove `RawDefPathHash`, which is a nice simplification.

r? @fee1-dead
2026-08-26 08:00:58 +02:00
Jonathan Brouwer
f6d0a0ada9 Rollup merge of #161684 - maxdexh:smoke-trees, r=nia-e
Replace `Allocator + Clone` with `AllocatorClone` in btree

powered by ripgrep

r? nia-e
2026-08-25 23:01:09 +02:00
Nicholas Nethercote
ad2aa1ccb2 Remove RawDefPathHash
`RawSpan`, `RawDefId`, and `RawDefPathHash` were all introduced to work
around the fact that `StableHashCtxt` in `rustc_data_structure` is
upstream of `rustc_span`. However, `DefPathHash` is just a newtype
around `Fingerprint`, which is defined  in `rustc_data_structure`. So by
working directly with `Fingerprint` we can remove `RawDefPathHash`,
which is a nice simplification.
2026-08-25 21:54:16 +10:00
Max Dexheimer
bd72f7ac4c Replace Allocator + Clone with AllocatorClone in btree 2026-08-24 19:21:59 +02:00
Waffle Lapkin
f34322b0dc remove #![feature(never_type)] from the compiler
The reason `rustc_ast_ir` and `rustc_pattern_analysis` have nested
`cfg_attr`s is so that they don't mention `cfg(bootstrap)` when nightly
or rustc cargo feature turned on. If you don't do it like that, they stop
compiling on stable (or rather, they emit unexpected cfg warnings...).
2026-08-24 19:04:00 +02:00
mejrs
589bb91122 Move Limit 2026-08-21 10:33:56 +02:00
Ada Alakbarova
7b5c7097c8 rename TraitPredicate to TraitClause 2026-08-19 11:50:26 +02:00
John Kåre Alsaker
76c314fd0b Make ShardedHashMap::with_capacity split capacity between shards 2026-08-15 10:28:18 +02:00
Chris Denton
4641990929 Remove ensure_sufficient_stack 2026-08-09 19:58:29 +00:00
mejrs
196dd2a174 Fix up lang_items import paths 2026-08-09 15:20:29 +02:00
bors
22950ab9e2 Auto merge of #159026 - WaffleLapkin:fallback-refactorings, r=lcnr
Type fallback refactorings





- Don't merge different kinds of infer variables into `Ty` before matching them back
- Do fallback only on root vars (this is semantically equivalent to what we currently do; unifying any of the infer vars from the same equivalence class necesserily affects all of them) (this makes https://github.com/rust-lang/rust/pull/159003 a bit less hacky though)
- Do some simplification that has been allowed by the previous changes

cc @lcnr
2026-08-05 11:34:06 +00:00
Vadim Petrochenkov
a77b6c7844 rustc_data_structures: Cleanup jobserver initialization 2026-08-02 15:41:37 +03:00
bors
b6a3d7965e Auto merge of #160310 - jhpratt:rollup-0apoMmQ, r=jhpratt
Rollup of 14 pull requests

Successful merges:

 - rust-lang/rust#159245 (Emit retags in codegen to support BorrowSanitizer (part 5))
 - rust-lang/rust#159864 (Report "capacity overflow" for oversized Rc<[T]>/Arc<[T]>)
 - rust-lang/rust#160079 (make atomic operations const)
 - rust-lang/rust#160124 (Structurally prevent zero-count `BackendRepr::SimdVector`s)
 - rust-lang/rust#160162 (Make `#[fundamental]` only apply to the first argument of `Box`)
 - rust-lang/rust#160210 (Remove an outdated FIXME)
 - rust-lang/rust#160282 (Improve diagnostic for patterns in function pointer types)
 - rust-lang/rust#157928 (Eagerly fetch typeck results when linting)
 - rust-lang/rust#159672 (Improve suggestions when multiples tuples implement the same trait)
 - rust-lang/rust#159861 (Add documentation for the `non_exhaustive` attribute)
 - rust-lang/rust#159907 (Fix `hidden_glob_reexports` in `rustc_ast`)
 - rust-lang/rust#159998 (Align expect messages with guidance)
 - rust-lang/rust#160145 (Expand checks for register_tool)
 - rust-lang/rust#160307 (Update `minifier` version to `0.4.0`)
2026-08-01 04:46:16 +00:00
Jacob Pratt
31e12ee467 Rollup merge of #160124 - scottmcm:simd-count, r=oli-obk
Structurally prevent zero-count `BackendRepr::SimdVector`s

This is already *supposed* to be impossible in layout, but this emphasizes that better.  This PR makes no behaviour changes; just `BackendLaneCount` instead of `u64` in https://doc.rust-lang.org/nightly/nightly-rustc/rustc_abi/enum.BackendRepr.html

Ironically I was inspired to do this as part of [looking at making `Simd<T, 0>` *work*](https://rust-lang.zulipchat.com/#narrow/channel/257879-project-portable-simd/topic/Allow.20N.3D.3D0.3F/with/613345298), but importantly if that's going to happen I think it should be `BackendRepr::Memory` like other ZSTs, *not* a `BackendRepr::ScalarVector` that would need to carry around a useless LLVM value in `OperandValue::Immediate` (where it's not even clear what the LLVM type of that value would be).
2026-07-31 22:25:12 -04:00
bors
cb9d1b0640 Auto merge of #160193 - nnethercote:improve-cfg-traversal, r=cjgillot
Improve CFG traversal

This PR implements a new CFG traversal algorithm in `iterate_to_fixpoint` that drastically speeds up a pathological case in `cranelift-codegen`.

r? @cjgillot
2026-08-01 01:28:09 +00:00
Scott McMurray
6da3077db9 Structurally prevent zero-count BackendRepr::SimdVectors
This is already *supposed* to be impossible in layout, but this emphasizes that better.

Ironically I was inspired to do this as part of looking at making `Simd<T, 0>` *work*, but importantly if that's going to happen I think it should be `BackendRepr::Memory` like other ZSTs, *not* a `BackendRepr::ScalarVector` that would need to carry around a useless LLVM value in `OperandValue::Immediate` (where it's not even clear what the LLVM type of that value would be).
2026-07-30 19:48:24 -07:00
Nicholas Nethercote
ac49776130 Remove rustc_data_structures::work_queue
It's no longer used.
2026-07-31 09:19:02 +10:00
Vadim Petrochenkov
2b4375dadc rustc: Support --jobs options for limiting parallelism in various parts of the compiler 2026-07-29 15:22:16 +03:00
Jonathan Brouwer
447eef1523 Rollup merge of #159974 - panstromek:update-thin-vec, r=mejrs
Update thinvec to 0.2.19

It contains `may_dangle` Drop impl under a feature flag. This allows us to use it in a lot more places, notable in types that hold `&'tcx` references. This would previously fail in borrowck in arena code.

We have to enable  its "unstable" feature for this. That also enables `TrustedLen` impl, which is behind unstable flag, too. I left the flag disabled, because it regressed next-solver benchmarks, but that will be fixed in PR that needs this flag (see the comment: https://github.com/rust-lang/rust/pull/159974#issuecomment-5091132427)
2026-07-27 19:24:50 +02:00
panstromek
02a54aa3ed update thinvec to latest version 2026-07-27 10:33:18 +02:00
mejrs
acb9407597 Split multiline derives into std/rustc macros 2026-07-25 12:01:39 +02:00
Folkert de Vries
7490d8ef3a add difference method to range_set 2026-07-23 12:52:59 +02:00
Jonathan Brouwer
92190394b9 Rollup merge of #159659 - mejrs:limit, r=petrochenkov
Move `Limit` out of `rustc_hir`

It feels rather out of place in `rustc_hir`, so this PR moves it to `rustc_data_structures`. Part of hopefully moving attributes from `rustc_hir` to their own crate.

~~This also lets `rustc_type_ir` use it~~ actually rustc_type_ir needs to compile on stable and `rustc_data_structures` uses like 30 features 😢
2026-07-22 18:02:21 +02:00
Shoyu Vanilla
997bde3d79 Bump ena 2026-07-22 13:47:20 +02:00
mejrs
ac91844c53 Fixup Limit imports 2026-07-21 15:26:08 +02:00
mejrs
57fca5a708 Move limit file 2026-07-21 13:19:55 +02:00
bors
f65b272fc9 Auto merge of #159440 - LorrensP-2158466:inplace-import-res, r=petrochenkov
Resolve: more preperation work for parallelizing the import resolution loop




This is basically rust-lang/rust#158845 but we do not:
- actually use `par_slice` because:
- we do not migrate `CmRefCell` to use `RwLocks` (yet) because of perf reasons.

The resolution loop is now in place instead of recollecting indeterminate imports.


r? @petrochenkov
2026-07-21 10:04:40 +00:00
LorrensP-2158466
2f3022a932 Preperation work for parallelizing the import resolution loop using par_slice.
Currently it is all still single threaded, but almost everything needed to make the loop use multithreaded code is done in this commit.

For performance reasons we do the resolution now in place instead of recollecting the indeterminate imports ([see benchmark pr](https://github.com/rust-lang/rust/pull/159387) and pr of this commit).

Populating external resolution tables now use `Once` to ensure only 1 thread builds the table and all others wait if they need it, this has no impact on single threaded behaviour.

`Cache(Ref)Cells` are not tackled yet because they are not needed here (and require extra work).
2026-07-18 10:57:47 +02:00
Vadim Petrochenkov
eb9dd038d7 rustc_data_structures: Expand documentation for rustc jobserver APIs 2026-07-17 14:13:27 +03:00
Nicholas Nethercote
fdfba6737d Clarify some interning details
`Interned` does pointer equality/hashing, which is valid in two cases.
- The values are guaranteed to be unique (e.g. via interning, or
  construction). This is how `rustc_middle` uses `Interned`.
- The type has "identity" and different values should be considered
  distinct even if they are identical. This is how `rustc_resolve` uses
  `Interned`.

PR 137202 tried to clarify things by adding a `T: Hash` constraint to
`Interned<'a, T>`. This constraint isn't actually used, because
`Interned` is hashed based on pointer value, not contents. But it was
intended to communicate the idea that a type stored in `Interned` is
actually interned, which is likely to be done with hashing. Panicking
impls of `Hash` were added for the relevant `rustc_resolve` types to
work around the fact that it doesn't use hashing-based interning.

In my opinion PR 137202 didn't improve things. The `T: Hash` constraint
is only aimed at the interning case, and even for that case it's not
quite right because you could use a `BTreeMap` to intern instead of a
`HashMap`.

This commit does several things.
- Removes the `T: Hash` constraint and the `Hash` impls for
  `rustc_resolve` types added in PR 137202.
- Improves the comments on `Interned` to cover the non-interning cases.
- Removes the `PartialOrd`/`Ord` impls on `Interned` because (a) they're
  not used, and (b) their meaning is unclear for the "identity" case.
- Improves the documentation in `rustc_resolve` to explain how
  `Interned` usage is valid there.
2026-07-02 17:10:35 +10:00
Folkert de Vries
5f34c5074a deduplicate RangeSet 2026-06-25 13:24:36 +02:00
Tobias Bieniek
7786ffce5b Bump thin-vec to 0.2.18 to address RUSTSEC-2026-0103
thin-vec versions before 0.2.16 have a use-after-free / double-free in
`IntoIter::drop` and `ThinVec::clear` when an element's `Drop` panics
(RUSTSEC-2026-0103). The requirement now sits past the affected range.
2026-06-18 11:57:21 +02:00
Ben Kimock
321f54ca94 Add #![feature(loop_hints)] and #[unroll] 2026-06-11 20:32:52 -04:00
Jacob Pratt
976acb04b6 Rollup merge of #157620 - Daniel-B-Smith:smithdb3/fileencoder-strategy, r=cjgillot
Add a strategy FnMut to inject behavior into the flush cycle

This PR adds the interface needed to avoid forking FileEncoder in https://github.com/rust-lang/rust/pull/154724.

This adds a FnMut used as a strategy/observer to see the bytes being flushed to disk. For https://github.com/rust-lang/rust/pull/154724, that would be used to calculate the metadata hash on the raw metadata bytes.

The 'static hack is pretty ugly, but otherwise, the FileEncoder lifetime goes exceptionally viral and requires some very unfortunate workarounds to avoid self referential lifetimes. That's a bit of a timebomb if the wrong FileEncoder client tries to use the new API, but the worst case outcome is a wild goose chase of lifetime chasing.

Full disclosure: I used Claude Code to generate much of the PR. I have fully reviewed the code and stand behind it.

r? @cjgillot
2026-06-11 00:34:03 -04:00
Daniel Smith
6324b4afbf Add flush strategy to allow observing bytes before they are flushed. 2026-06-09 20:49:39 -04:00
xmakro
51001cf7ef Make the retained dep graph deterministic under the parallel frontend
The in-memory dep graph kept for `-Zquery-dep-graph` is built by
`GraphEncoder::record`, which pushed each node using `try_lock` and
silently dropped the node when the lock was contended. Single-threaded
the only contention is a query forced re-entrantly from within
`with_retained_dep_graph`, so dropping was harmless. Under the parallel
frontend several encoder threads record nodes at the same time, so a
contended `try_lock` dropped nodes and edges at random, leaving the
retained graph nondeterministic and making the dep-graph ui tests, which
assert on its contents, fail intermittently.

Remove that reentrancy in `check_paths`: read the graph into owned
results while the lock is held, then emit the diagnostics afterwards.
The only query forced inside the old closure was `def_path_str` (for the
error messages), which can create dep nodes and re-enter the encoder;
doing the emission after the lock is released means `record` never
re-enters while the lock is held. `record` can then block on the lock
unconditionally instead of using `try_lock`, so concurrent encoders
never drop a node or edge.

This only affects compilation with `-Zquery-dep-graph`; with the flag
off the retained graph is absent and nothing changes.
2026-06-04 08:40:28 -07:00
Josh Stone
4294891f47 Reformat with the new stage0 2026-05-31 06:58:19 -07:00
Scott McMurray
f7cf361f3c compiler: ops::RangeInclusive → range::RangeInclusive
The type's been stable for over 6 weeks now, so let's use it!  It's better for cases like this one where it's stored in a data structure.

Probably won't be materially faster, but does make the variant slightly smaller and lets some more things be `Copy`.
2026-05-29 21:57:45 -07:00
Oli Scherer
66a2b8565f Make UnordItems::flat_map take UnordItems as args, too 2026-05-13 08:47:29 +02:00
Nicholas Nethercote
45efffcc4d Rename various things relating to the StableHash derive macros.
Including the `stable_hasher` attribute and the `HashStableMode` enum.

Part of MCP 983.
2026-05-08 15:22:39 +10:00
Nicholas Nethercote
33cd10a881 Rename rustc_data_structures::stable_hasher as stable_hash.
Part of MCP 983.
2026-05-08 15:10:33 +10:00
Nicholas Nethercote
1869ac887d Rename the HashingControls struct as StableHashControls.
Plus two related methods.

Part of MCP 983.
2026-05-08 15:06:09 +10:00
Nicholas Nethercote
ad6647f904 Rename the span_hash_stable method as stable_hash_span.
Likewise for the corresponding incremental test.

Part of MCP 983.
2026-05-08 14:37:20 +10:00
Nicholas Nethercote
769f2f16fe Remove unused ToStableHashKey impls.
There are quite a few.
2026-05-07 14:41:12 +10:00
Nicholas Nethercote
e7d28d3e9b Rename the HashStable* trait/derives as StableHash*.
Specifically:
- `HashStable` -> `StableHash` (trait)
- `HashStable` -> `StableHash` (derive)
- `HashStable_NoContext` -> `StableHash_NoContext` (derive)

Note: there are some names in `compiler/rustc_macros/src/hash_stable.rs`
that are still to be renamed, e.g. `HashStableMode`.

Part of MCP 983.
2026-05-02 10:16:40 +02:00
Nicholas Nethercote
846267e725 Rename the HashStableContext trait as StableHashCtxt.
Part of MCP 983.
2026-05-02 10:16:39 +02:00