Upgrade `thin-vec` to 0.2.21, including fix for `.collect()` capacity
This includes https://github.com/mozilla/thin-vec/pull/99 , which makes thin-vec respect size_hint when collecting.
In particular, this causes collections of 1-3 items to not be grown to a capacity of 4. The compiler has a lot of `TinyVec`s in the 1-3 range, so this substantially helps memory, and seems neutral on instructions.
For aws-sdk-ec2 full check, this saves 30.69 MiB max-rss (0.55% of peak RSS).
---
Merging this avoids the need to work around it in other work (e.g. by replacing `.collect()` with something calling `ThinVec::with_capacity(...)` first).
This includes https://github.com/mozilla/thin-vec/pull/99 , which makes
thin-vec respect size_hint when collecting.
In particular, this causes collections of 1-3 items to not be grown to a
capacity of 4. The compiler has a lot of `TinyVec`s in the 1-3 range, so
this substantially helps memory, and seems neutral on instructions.
For aws-sdk-ec2 full check, this saves 30.69 MiB max-rss (0.55% of peak
RSS).
perf:cache FFI safety results in improper_ctypes lint
This PR cache FFI safety results in improper_ctypes lint .
ImproperCTypesVisitor's cache field is recreated empty at every call site, so a struct type gets fully re-walked from scratch each time instead of once .
The implementation here moves the cache onto ImproperCtypesLint, so it remembers types we already checked and found FFI-safe, so we don't check the same type again every time it shows up in another function. We only remember "safe" types, never "unsafe" ones. That way we never need to keep the actual type around, just a fingerprint of it.Thus it persists across a whole module worth of foreign items.
When requested through an internal rustc attribute, include dataflow
results in MIR output, i.e., `-Zunpretty=mir` or `--emit mir`.
For now, supported dataflows are:
* `#[rustc_mir(rustc_pretty_live_locals)]`
* `#[rustc_mir(rustc_pretty_transitive_live_locals)]`
The mechanism is intended to supersede existing `rustc_peek` intrinsic.
For demonstration also migrates one of tests based on `rustc_peek`:
tests/ui/mir-dataflow/liveness-projection.rs.
Deterministic encoding of `DefPathHashMap`
This PR splits DefPathHashMap into two parts: deterministic (`det_part`) and non-deterministic (`non_det_part`). `det_part` is used while we sure that allocation and insertion order of def ids is deterministic, at the moment of writing it happens before we start parallel checks after prefetch of `hir_crate_items` in `run_required_analysis`. Up until this point of compilation the allocation of def ids and their insertion order into `det_part` should be the same between different compilations.
Next, when non-determinism starts due to parallel compilation we put all mapping between local hash and def ids into a `SortedMap` which gives us ready-to-use sorted by local hash slice of pairs to encode while encoding metadata.
Note, that this PR does not solve the problem of allocation of different def indices to same code entities (meaning same local hash), this problem is solved in rust-lang/rust#162809 by remapping needed local def indices.
Also note that we serialize `det_part` as a raw bytes sequence, so during remapping if we do not place all def indices that are needed to be remapped into separate container we will end up with copying `det_part`, changing some entries in it and then serialize it as a bytes sequence. With the approach in this PR we do not copy and modify `det_part`, instead we do all modifications in `non_det_part`.
r? @petrochenkov
Remove `PartialOrd`/`Ord` impls for `Span`/`SpanData`
Because they are inconsistent with the `PartialEq`/`Eq` impls, and span ordering is inherently dubious. Details in individual commits.
r? @oli-obk
`Span` and `SpanData` encode four fields: `lo`/`hi`, `ctxt`, and
`parent`. `ctxt` and `parent` have unorderable types.
Both types ignore `ctxt` and `parent` for `PartialOrd`/`Ord`. But their
`PartialEq`/`Eq` impls do *not* ignore those fields. This eq/ord
inconsistency is a bug. It was introduced in #123165.
The idea of ordering spans in general is dubious, because of `ctxt` and
`parent`. But the idea of ordering spans just with `lo`/`hi` is fine.
Therefore, this commit does the following.
- Removes the `PartialOrd`/`Ord` impls for `Span`/`SpanData`
- Adds a `Span::lo_hi` method which can be used in lots of places where
span locations are involved in sorting. E.g.
`xs.sort_by_key(|span| span.lo_hi())`
- Adds `OrdSpan`, a newtype around `Span` that impls
`PartialEq`/`Eq`/`PartialOrd`/`Ord` using `lo_hi`. This is for storing
spans in ordered types like `BTreeMap<OrdSpan, T>`.
Note also that some `sort`+`dedup` combinations might not remove all
duplicates with the old eq/ord inconsistency. These now all do the right
thing, which could affect some error messages, though in practice
nothing in the test suite is affected.
The SVH is computed by hashing the entire encoded metadata blob, and
SipHash-128 (~2.5 Ir/byte) dominated the cost — it accounted for the whole
of the measured regression on metadata-heavy crates. Switch the byte pass to
XXH3-128, which is ~10x cheaper per byte on its runtime-detected AVX2 path.
XXH3 is non-cryptographic, which is fine here: the SVH is only a change
detector, must be reproducible (so it is never keyed secretly, meaning even
the previous SipHash use was not collision-resistant), and compiling a crate
already executes its build scripts and proc-macros, so the crate author is
trusted regardless. The untracked supplements (dep-tracking hash and the HIR
hash for e.g. DefKind::GlobalAsm) are still folded in via a StableHasher
fingerprint, so coverage is unchanged.
twox-hash 2.x is already in the dependency graph via ruzstd; this only adds a
direct edge (xxhash3_128 + std features for the runtime SIMD dispatch).
Some were wholly unused, others were unused other than as dev-deps but
specified as regular dependencies. This cleans things up a little bit.
I used an LLM to smoke out the candidates for this cleanup, but the rest
was done by hand.
librustdoc: remove stale dep on base64
This appears to have become unused in August 2025. I noticed today because of trying to consolidate versions of things in the toolchain.
Rollup of 10 pull requests
Successful merges:
- rust-lang/rust#161987 (fix `is_single_fp_element` for `s390x` and `x86`)
- rust-lang/rust#162366 (Replace hard linked `metadata.rmeta` with a copy when finalizing the incremental compilation session dir fails)
- rust-lang/rust#162552 (RISC-V: Add Zmmul target feature)
- rust-lang/rust#162602 (Ensure concurrent rustc instances in the same process correctly lock the session dir)
- rust-lang/rust#162885 (Remove one remaining use of `Level::Help`)
- rust-lang/rust#162606 (c-b: Export `fmaf16` now that we have an implementation)
- rust-lang/rust#162817 (rustc_{codegen_,}llvm: adapt to new ThreadModel API)
- rust-lang/rust#162860 (offload: add libLLVM rpath for libomptarget)
- rust-lang/rust#162895 (Avoid derive edits on macro-generated types)
- rust-lang/rust#162899 (Error on invalid placements of the `cfi_encoding` attribute.)
Ensure concurrent rustc instances in the same process correctly lock the session dir
This introduces a global lock registry for the `fcntl` lock fallback to allow emulating fd based locks (like `flock()`) on top of the `fcntl(F_SETLK)` process based locks, thereby ensuring that concurrent rustc instances inside the same process don't break the incr comp locking scheme.
Based on https://github.com/rust-lang/rust/pull/162584
Generally `rustc_middle::query` has types while `rustc_query_impl` has
operations. So this commit moves some operations from the former to the
latter. Some of them are just moved, while others are inlined and
removed.
The direct dependency from `rustc_codegen_ssa` to `rustc_mir_transform` allowed
codegen to reuse some MIR-transform code for identifying unnecessary landing
pads.
However, we can achieve the same result by calling through a hook on `TyCtxt`,
eliminating the crate dependency.
Update `windows-bindgen` to 0.100.0
This release represents a major change in the way bindings are generated. See https://github.com/microsoft/windows-rs/issues/4867 for details.
In short, it now more directly follows the C headers. For the standard library's purposes this is mostly reflected in relatively minor type changes or with some `const` pointers becoming `mut`.
There is however one big change that affects a lot of types. In the headers there are a lot of `#define`s like this:
```c
#define GENERIC_READ (0x80000000L)
#define GENERIC_WRITE (0x40000000L)
```
These are constants for the access mode. In this case they're explicitly declared as `L` (aka signed long) integer types (in other cases there's no type at all). However, this conflicts with how access mode constants are actually used. E.g., see `CreateFileW`:
```c
WINBASEAPI
HANDLE
WINAPI
CreateFileW(
_In_ LPCWSTR lpFileName,
_In_ DWORD dwDesiredAccess,
_In_ DWORD dwShareMode,
_In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes,
_In_ DWORD dwCreationDisposition,
_In_ DWORD dwFlagsAndAttributes,
_In_opt_ HANDLE hTemplateFile
);
```
Here `dwDesiredAccess` is a `DWORD`, which in rust equates to `u32`. The constant being signed but the usage being unsigned is not a problem for C/C++. They will happily convert between types at the drop of a hat. Rust however is stricter, as you know.
The old metadata used by `windows-bindgen` tried to try to fixup this mismatch but the new one goes strictly by what can be inferred from the headers. The hope in the future is that the headers themselves will be updated so better bindings can be directly derived from them.
traits: Represent live alias arguments as bitsets
Split out of rust-lang/rust#160212 per review / Zulip: https://rust-lang.zulipchat.com/#narrow/channel/364551-t-types.2Ftrait-system-refactor/topic/rigid.20aliases.20in.20region.20handling/near/615557841
`live_args_for_alias_from_outlives_bounds` and `args_known_to_outlive_alias_params` now return identity arg indices (`DenseBitSet`) instead of `EarlyBinder<GenericArg>`. Callers just do `args[idx].visit_with(...)`, so we stop laundering rigidness through binder instantiate. Also drops the old BitSet FIXME.
imo this is worth doing on its own even without the ICE fix. every time we shoved identity params through `EarlyBinder` we were writing down something we don't actually know, and this module is only going to grow. better to make the invariant explicit now than keep paying for it later.
No behavioral change intended. the rigid-alias ICE / `extract_verify_if_eq` bits stay on rust-lang/rust#160212. btw if that one should stack on this instead of staying independent, lmk and I'll rebase it asap.
sanitizers: Implement support for the sanitize ignorelist
The sanitize ignorelist gives central controls over which functions, files, etc. should be ignored and not sanitized. It is a common file format for clang and explained here:
https://clang.llvm.org/docs/SanitizerSpecialCaseList.html. This change adds support for this list in Rust as well.
r? @rcvalle
The sanitize ignorelist gives central controls over which functions,
files, etc. should be ignored and not sanitized. It is a common file
format for clang and explained here:
https://clang.llvm.org/docs/SanitizerSpecialCaseList.html. This change
adds support for this list in Rust as well.
Clippy subtree update
r? Manishearth
2 days early, as cargo needs a fix that landed in Clippy last week and @weihanglo pointed out to me that I might run into bors queue stalls on Thursday with the 1.98.1 release.
Update `icu_list` dependency to 2.3
This removes the `icu_collections` transitive dependency, and uses the smaller `icu_locale_fallback` instead of `icu_locale`.
r? manishearth
Deduplicate `InstrumentFnAttr`
cc @pmur
Instead of having a `Default` variant (which can't be specified in the attribute, it only does on/off), use an Option to model "no attribute used".