Skip to content

Rustc pull update#2941

Merged
tshepang merged 19 commits into
mainfrom
rustc-pull
Jul 23, 2026
Merged

Rustc pull update#2941
tshepang merged 19 commits into
mainfrom
rustc-pull

Conversation

@workflows-rustc-dev-guide

Copy link
Copy Markdown

Latest update from rustc.

Zoxc and others added 19 commits July 18, 2026 13:08
Replace weak only lang items with a custom attribute



When I added the `invalid_runtime_symbol_definitions` and `suspicious_runtime_symbol_definitions` lints in rust-lang/rust#155521 I added the concept of "weak only" lang item.

It's a `LangItem` that has no implementation, this is useful because the `core` symbols where not directly called, they were inserted by the compiler.

This mechanism work well, but T-lang [approved](rust-lang/rust#158522 (comment)) the extension to "all extern functions referenced by the standard library", which makes the lang item approach impractical as we needs to update 5 files just to declare them. I'm not sure we can ask library contributor to do the dance for each `extern "C"` functions.

But the most problematic thing is that many extern functions in `std` come from `libc` not `std`, and adding lang items there is just no feasible I think.

Instead this PR proposed that we introduce a proper mechanism for them by adding a attribute `#[rustc_canonical_symbol = "..."]`, which is encoded and decoded in `rmeta` like lang items and diagnostics items.

This simplifies the declaration as we only need to put the attribute to be effective `#[rustc_canonical_symbol = "open"]`. It also opens up many possibilities (none implemented here) like putting them on `use` statements (so we don't need to modify `libc`) or having the attribute be placed on a module. The table may also be useful on it's own if we want someday to do it for all crates, not just the standard library.

Follow up to rust-lang/rust#155521 and rust-lang/rust#158522
…henkov

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
…acrum,Kobzol

Replace `jemalloc` bootstrap options with `override-allocator`

I want to make [use of `mimalloc` on Windows](rust-lang/rust#138764) so this renames `jemalloc` bootstrap options to `override-allocator` so we can reuse the same flag for this purpose.
…ription, r=dtolnay

feat(num): improve error messages for `TryFromIntError`

- Tracking issue: rust-lang/rust#153978

This pull request improves the `Display` trait implementation for `TryFromIntError` by providing more specific error messages based on the underlying `IntErrorKind`.

Currently, the error message is always `"out of range integral type conversion attempted"`. This makes debugging difficult because users cannot distinguish the detailed cause of the error from the error message.

`IntErrorKind::Empty` and `IntErrorKind::InvalidDigit` should be unreachable.

I don't think this is breaking changes, because similar changes were made in the past in rust-lang/rust#96168.

See also: <https://users.rust-lang.org/t/are-changes-to-fmt-display-considered-breaking/59775>
…xyUwU

implement #![feature(macroless_generic_const_args)]

tracking issue: rust-lang/rust#159006

lots of description of what is happening here in the tracking issue, not gonna copypaste it into here :)

the test situation is that after discussion with boxy of whether our mgca tests should be:

- keep them under only `min_generic_const_args`, and add `direct_const_arg!()` where it's needed
- keep the code contents as-is, and add `#![feature(macroless_generic_const_args)]` where it's needed

the second seems more desirable, so that's what I did. There are still quite a few tests that only have `min_generic_const_args` without `macroless_generic_const_args` (140 of them, to be exact - `rg --files-without-match macroless_generic_const_args $(rg -g '*.rs' --files-with-matches min_generic_const_args tests) | wc -l`, and now 90 with `macroless_generic_const_args`)

r? @BoxyUwU
core: implement `Rng` for references

Tracking issue: rust-lang/rust#130703

Just like `Iterator` `Rng` should be implemented for references to RNGs. Aside from the functionality this adds, it also prevents inconsistent implementations.

I've not added a `by_ref` method here since such a method can easily be added later and arguably should be `final`.

r? libs-api
Make `Global` and `System` allocators unstably implement `const Clone + const Default`.

Allocators implementing `const Default` is useful for generically constructing empty collections inside of constants:

```rust
struct Foo<A: Allocator>(Vec<i32, A>);
impl<A: Allocator + const Default> Foo<A> {
    pub const EMPTY: Self = Self(Vec::new_in(A::default()));
}
```

`const Clone` is not strictly necessary to permit such constants to exist, but may make more complex code easier to write (e.g. so a const constructor can accept one allocator and clone it).

@rustbot label +A-allocators
Remove some dead code

Leftover from a previous revision of `#[unsafe(no_mangle)]`. All call sites disallowed it anyway, and the real handling is in the parser.
Improve some comments (and an error message)

Details in individual commits.

r? @petrochenkov
…uwer

Rollup of 7 pull requests

Successful merges:

 - rust-lang/rust#155617 (Replace `jemalloc` bootstrap options with `override-allocator`)
 - rust-lang/rust#156225 (feat(num): improve error messages for `TryFromIntError`)
 - rust-lang/rust#159058 (implement #![feature(macroless_generic_const_args)])
 - rust-lang/rust#159435 (core: implement `Rng` for references)
 - rust-lang/rust#159471 (Make `Global` and `System` allocators unstably implement `const Clone + const Default`.)
 - rust-lang/rust#159590 (Remove some dead code)
 - rust-lang/rust#159636 (Improve some comments (and an error message))
Move Region from rustc_middle to rustc_type_ir



## General notes
Probably best reviewed commit by commit. I've tried where to make the changes as isolated as possible.
- For the `pub struct Region` if we use `Interned<...>` in the definition then we'd need to add a lifetime to the `Interner` trait. As such I opted for a type `InternedRegionKind` which is `Interned<'tcx, RegionKind<'tcx>>` in the implementation. To allow calling the `kind()` method I implemented `inherent::IntoKind` for `Interned<'tcx, T>`.
- All methods from the `Region` trait in `inherent` have been moved to `compiler/rustc_type_ir/src/sty/mod.rs`.
- Had to implement `Lift` manually for `Interned<RegionKind>` (`I::InternedRegionKind`) which is a no-op.
- I'm not sure the implementation of `kind()` is correct or even should be implemented for `Interned<...>`?
- Add a small abstraction needed for decode to still re-intern `Region` and moved this along with other `encode/decode` implementations into a `serialize` file.
```
error[E0210]: type parameter `E` must be used as the type parameter for some local type (e.g., `MyStruct<E>`)
   --> compiler/rustc_middle/src/ty/codec.rs:162:12
    |
162 | impl<'tcx, E: TyEncoder<'tcx>> Encodable<E> for ty::Region<'tcx> {
    |            ^ type parameter `E` must be used as the type parameter for some local type
    |
    = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local
    = note: only traits defined in the current crate can be implemented for a type parameter

error[E0210]: type parameter `D` must be used as the type parameter for some local type (e.g., `MyStruct<D>`)
   --> compiler/rustc_middle/src/ty/codec.rs:301:12
    |
301 | impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for ty::Region<'tcx> {
    |            ^ type parameter `D` must be used as the type parameter for some local type
    |
    = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local
    = note: only traits defined in the current crate can be implemented for a type parameter
```

## `compiler/rustc_middle/src/ty/region.rs`
Generally anything that needed to access fields on `TyCtxt` have been made methods on the interner.
- `interner.lifetimes.anon_re_bounds.get(debruijn.as_usize())` for getting an interned lifetime, is now a trait method on `Interner`; `fn get_anon_re_bounds_lifetime(...)`
- `fn intern_region(...)` now a trait method on `Interner`
- `interner.lifetimes.anon_re_canonical_bounds.get(debruijn.as_usize())` required
   for `fn new_canonical_bound(...)`. Is now `fn get_anon_re_canonical_bounds_lifetime(...)`
- `interner.lifetimes.re_static` has become `fn get_re_static_lifetime()` for method `fn new_static((..)`

r? @lcnr
rustfmt subtree update

## Summary

Part of rust-lang/rustfmt#6965.
Closes rust-lang/rustfmt#6965.

Corresponding subtree pushes:

- rust-lang/rustfmt#6966
- rust-lang/rustfmt#6939

Merge conflicts were trivial (just the CI workflows and leftover pattern rewrite helper function).

## Additional context

- [#t-rustfmt > Sync to rust-lang/rust](https://rust-lang.zulipchat.com/#narrow/channel/357797-t-rustfmt/topic/Sync.20to.20rust-lang.2Frust/with/611624237)

r? @ytmimi
Optimize escape_string_symbol()

Going through escape_default() + to_string(), which involves going through formatting machinery and a flat_map of a complex iterator, ends up being quite slow. Directly pushing to a string, even with a naive implementation, is significantly faster.

This shows up in the include-blob benchmark, which mostly exercises this one function.
rustdoc: Only build extern trait impls if needed



or, finally remove the `BadImplStripper`!

Building inlined impls is expensive, and most of them end up being
unneeded and stripped later in this function. So we should filter them
ahead of time. This requires inlining external auto traits when we
construct auto impls, since this no longer happens as a side effect.

We inline external impls when they are
* for generics (i.e., blanket impls)
* for primitive types (probably this should be handled below really)
* for a type (inlined) in the current crate
* of a trait (inlined) in the current crate
* of `Deref`
These rules are based on the existing filtering rules that are applied
after building the inlined impls.

After doing the filtering ahead of time, we can remove the downstream
filtering. Thus, we can finally remove `BadImplStripper` and unused
deref-following logic. It appears that all this `Deref` logic was pointless
in the first place since following derefs already happens elsewhere in
rustdoc, where it is actually needed.
Apply RemoveNoopLandingPads post-monomorphization



On Cargo this cuts ~5% of the LLVM IR lines we generate (measured with -Cno-prepopulate-passes).

Closes rust-lang/rust#159399.
codegen: skip stores for entirely-uninit constant aggregate fields



MIR GVN (since rust-lang/rust#147827) propagates MaybeUninit::uninit() as `const <uninit>` in aggregate constructions. Without this fix, codegen would emit a memcpy from an `[N x i8] undef` global for each such field, which LLVM materializes as zero-initialization.

This mirrors the existing `all_bytes_uninit` skip already present for `Rvalue::Use` (added in rust-lang/rust#147827) into the `Rvalue::Aggregate` field loop.

Fixes: rust-lang/rust#157743
This updates the rust-version file to 390279b302ca98ae270f434100ae3730531d1246.
@rustbot

rustbot commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the PR. If you have write access, feel free to merge this PR if it does not need reviews. You can request a review using r? rustc-dev-guide or r? <username>.

@rustbot rustbot added the S-waiting-on-review Status: this PR is waiting for a reviewer to verify its content label Jul 23, 2026
@tshepang
tshepang merged commit a6e0ea1 into main Jul 23, 2026
1 check passed
@rustbot rustbot removed the S-waiting-on-review Status: this PR is waiting for a reviewer to verify its content label Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants