Skip to content

Rollup of 15 pull requests#159113

Open
jhpratt wants to merge 35 commits into
rust-lang:mainfrom
jhpratt:rollup-xqDDX7W
Open

Rollup of 15 pull requests#159113
jhpratt wants to merge 35 commits into
rust-lang:mainfrom
jhpratt:rollup-xqDDX7W

Conversation

@jhpratt

@jhpratt jhpratt commented Jul 11, 2026

Copy link
Copy Markdown
Member

Successful merges:

r? @ghost

Create a similar rollup

joboet and others added 30 commits June 21, 2026 19:15
Signed-off-by: Amirhossein Akhlaghpour <m9.akhlaghpoor@gmail.com>
Co-authored-by: lolbinarycat <dogedoge61+github@gmail.com>
For small repr(C) aggregates with padding, direct constant
initialization can still lower into field-wise construction plus
memcpy. That leaves the backend to rediscover that the whole object
is a single constant byte pattern.

This is especially visible for non-zero constant aggregates. Instead
of materializing them as separate field stores, we want codegen_ssa to
emit the packed value directly. For example, a value like

    InnerPadded { a: 0, b: 1, c: 0 }

can otherwise lower to something like

    store i16 0, ptr %val, align 4
    store i8 1, ptr %val_plus_2, align 2
    store i32 0, ptr %val_plus_4, align 4
    call void @llvm.memcpy(..., ptr %val, ...)

while this change produces

    store i64 65536, ptr %val, align 4
    call void @llvm.memcpy(..., ptr %val, ...)

Why not solve this in LLVM?

At the problematic lowering point, rustc still knows that the MIR
aggregate is small and fully constant. LLVM only sees a lowered stack
temporary built from per-field stores and then copied out. Recovering
that packed constant there would require rediscovering front-end
aggregate semantics after lowering, so emitting the packed store in
rustc is the simpler and more local fix.

Why not keep the previous typed-copy approach?

An earlier approach zeroed padding on typed copies whose source could
be traced back to a constant assignment. That helped some cases, but it
also widened the optimization to runtime copy paths and could introduce
extra runtime stores purely to maintain padding knowledge. That is not
an acceptable tradeoff here.

Keep the scope narrow instead: only handle direct MIR aggregates whose
fields are all constants, and pack them according to the target
endianness before emitting a single integer store.

Add a focused codegen test covering the original PR 157690 entry
points together with non-zero constant cases. The test uses
-Cno-prepopulate-passes so it checks the immediate-store shape directly
at rustc codegen time, instead of depending on later LLVM store
merging.
`EIO` decoded to `ErrorKind::Uncategorized`, so a low-level I/O
failure could only be detected through `raw_os_error()`. Map it, and
the equivalent codes on Windows (`ERROR_IO_DEVICE`) and VEXos
(`FR_DISK_ERR`), to a new unstable `InputOutputError` variant.
…alfJung

codegen_ssa: pack small const aggregates into immediate stores

Close rust-lang#157373

For small repr(C) aggregates with padding, direct constant
initialization can still lower into field-wise construction plus
memcpy. That leaves the backend to rediscover that the whole object
is a single constant byte pattern.

This is especially visible for non-zero constant aggregates. Instead
of materializing them as separate field stores, we want codegen_ssa to
emit the packed value directly. For example, a value like

    InnerPadded { a: 0, b: 1, c: 0 }

can otherwise lower to something like

    store i16 0, ptr %val, align 4
    store i8 1, ptr %val_plus_2, align 2
    store i32 0, ptr %val_plus_4, align 4
    call void @llvm.memcpy(..., ptr %val, ...)

while this change produces

    store i64 65536, ptr %val, align 4
    call void @llvm.memcpy(..., ptr %val, ...)

Why not solve this in LLVM?

At the problematic lowering point, rustc still knows that the MIR
aggregate is small and fully constant. LLVM only sees a lowered stack
temporary built from per-field stores and then copied out. Recovering
that packed constant there would require rediscovering front-end
aggregate semantics after lowering, so emitting the packed store in
rustc is the simpler and more local fix.

Why not keep the previous typed-copy approach?

An earlier approach zeroed padding on typed copies whose source could
be traced back to a constant assignment. That helped some cases, but it
also widened the optimization to runtime copy paths and could introduce
extra runtime stores purely to maintain padding knowledge. That is not
an acceptable tradeoff here.

Keep the scope narrow instead: only handle direct MIR aggregates whose
fields are all constants, and pack them according to the target
endianness before emitting a single integer store.
…ochenkov

Move NativeLib::filename to the rmeta-link archive member

Second PR in rust-lang#138243
Moves `NativeLib::filename` out of `rmeta` into `lib.rmeta-link` archive member that was introduced in the first PR. Filename is a link time only data so requiring a full metadata decode should be avoided.  It is stored as `(name, filename)` pairs keyed by name, the new `MetadataLoader::get_rlib_native_lib_filenames` patches it back on decode.  Also bumped `METADATA_VERSION` from version 10 to 11. Added also new round trip test and existing bundled-libs tests still pass.
allow `Allocator`s to be used as `#[global_allocator]`s

The (hopefully) immanent stabilisation of the `Allocator` trait raises the question of what is to be done about the older, already-stable `GlobalAlloc` trait. In my opinion, having two nearly-identical traits for the same purpose is needlessly confusing. Going forward, `Allocator` as the more modern interface should be _the_ allocator trait.

With `Allocator` being currently unstable, there is the possibility of implementing `GlobalAlloc` for all `Allocator`s, thereby allowing them to be used as `#[global_allocator]` and allowing crates to seamlessly (and semver-compatibly) switch to `Allocator`. However, unconditionally implementing `GlobalAlloc` presents a footgun to users, as e.g. using `Global` as `#[global_allocator]` will lead to infinite recursion. @nia-e initially tried to resolve this in e1b7097 (rust-lang#156882) by using weird trait trickery to implement `GlobalAlloc` for every allocator except `Global`. But this does not go far enough, e.g. a bump allocator that itself allocates from `Global` is similarly unsuitable as global allocator.

Thus, with this PR, I'd like to propose adding a new marker trait for allocators that can be used as `#[global_allocator]`:
```rust
// in core::alloc

trait GlobalAllocator: Allocator {}
```
`GlobalAlloc` can then be implemented for all `GlobalAllocator`s:
```rust
impl<A> GlobalAlloc for A
where
    A: GlobalAllocator
{
    /* ... */
}
```

This provides a backwards-compatible way for allocator libraries to switch to the new interface and allows deprecating `GlobalAlloc` (not done here). Over time, I expect that `GlobalAlloc` will become more and more of an implementation detail of the `#[global_allocator]` macro (for instance, one might add perma-unstable, hidden methods for things like `grow_zeroed` that are customised only by the blanket implementation).

With regards to naming, I chose `GlobalAllocator` to mirror `Allocator`. `GlobalAlloc` should probably be deprecated quickly after stabilising `GlobalAllocator` to avoid confusion. For the same reason, I think it'd be better to add `GlobalAllocator` before stabilising `Allocator` – but that is not a necessity.

r? @nia-e
@rustbot label +I-libs-api-nominated
jq directives for jsondocck

Closes rust-lang#142479.

Adds `jq` directives for `jsondocck`.

I decided to add jq instead of replacing jsonpath entirely so that migration could happen incrementally. In theory, it should be possible to replace every jsonpath test case with the new `jq` directives. Moving forward, this might put more burden on reviewers as test case writers would have the option to use jq or jsonpath or even both. ~~Note that you cannot use `jq_set` with jsonpath directives or `set`  with jq directives~~. Diff should be reviewed without whitespace.

r? @aDotInTheVoid
merge DefKind::InlineConst into AnonConst

This is a closely related followup to rust-lang#158375 (a condition of merging that PR was doing this as a followup)

This merge conflicts with rust-lang#158617 ; prefer merging that one first please~

This PR is within the general goal of const generics / `generic_const_args` and perhaps specifically rust-lang/project-const-generics#108 but is mostly a code cleanup rather than implementing any particular feature

---

Anon consts (the `1 + 2` in `let x: [u8; 1 + 2];`) are closely related to inline consts (the `const {}` in `let x = const { 1 + 2 };`). They are especially related now that both can be used in the type system (by the above PR) and should be treated identically in that scenario. In general, they should be treated the same, as evidenced by the number of matches touched in this PR that just match on both. This PR merges the two DefKinds into one, mostly arbitrarily and bikesheddily choosing to use the name `AnonConst` for the merged concept (e.g. both `DefKind::InlineConst` and `DefKind::AnonConst` used `ast::AnonConst`, so `ast::AnonConst` should probably be named whatever the merged `DefKind` concept is named).

When you absolute must distinguish between the two, `tcx.anon_const_kind` allows you to do so - however, anon consts/inline consts in the type system intentionally appear identically under `anon_const_kind`. Indeed, the places where we distinguish between the two raised my eyebrows a few times when doing this PR, and being a little more explicit and loud about it is helpful for code clarity, IMO.

r? @BoxyUwU
Stabilize String::from_utf8_lossy_owned

Passed FCP in rust-lang#129436. Closes rust-lang#129436.

r? libs
…s-ok-unwrap, r=nnethercote

Add codegen test for Result is_ok unwrap

Closes rust-lang#85771
@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-rustdoc-json Area: Rustdoc JSON backend A-testsuite Area: The testsuite used to check the correctness of rustc A-tidy Area: The tidy tool S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Jul 11, 2026
@jhpratt

jhpratt commented Jul 11, 2026

Copy link
Copy Markdown
Member Author

@bors r+ rollup=never p=5

@bors try jobs=dist-various-1,test-various,x86_64-gnu-aux,x86_64-gnu-llvm-21-3,x86_64-msvc-1,aarch64-apple,x86_64-mingw-1,i686-msvc-*

@rust-bors

rust-bors Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 3657ecd has been approved by jhpratt

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 11, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jul 11, 2026
Rollup of 15 pull requests


try-job: dist-various-1
try-job: test-various
try-job: x86_64-gnu-aux
try-job: x86_64-gnu-llvm-21-3
try-job: x86_64-msvc-1
try-job: aarch64-apple
try-job: x86_64-mingw-1
try-job: i686-msvc-*
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jul 11, 2026
Rollup of 15 pull requests

Successful merges:

 - #159106 (Update LLVM)
 - #157690 (codegen_ssa: pack small const aggregates into immediate stores)
 - #159005 (Use `as_lang_item` instead of repeatedly matching)
 - #156735 (Move NativeLib::filename to the rmeta-link archive member)
 - #157153 (allow `Allocator`s to be used as `#[global_allocator]`s)
 - #158269 (jq directives for jsondocck)
 - #158767 (merge DefKind::InlineConst into AnonConst)
 - #159099 (Stabilize String::from_utf8_lossy_owned)
 - #158930 (Reorganize `tests/ui/issues` [20/N])
 - #158965 (Add codegen test for Result is_ok unwrap)
 - #158979 (Reorganize `tests/ui/issues` [21/N])
 - #159050 (assert only opaques with sub unified hidden infer are non-rigid)
 - #159062 (Remove unused WEAK_ONLY_LANG_ITEMS static)
 - #159070 (Add `io::ErrorKind::InputOutputError`)
 - #159092 (make volatile operations const)
@rust-bors

rust-bors Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 9a4ce0c (9a4ce0cf7cc9b0a06ecfa4354c30451fdd6f1300)
Base parent: 375b143 (375b1431b7d89d1c2e2bc168c011848ae12b7d14)

@rust-bors rust-bors Bot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 11, 2026
@rust-bors

rust-bors Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

💔 Test for 5543890 failed: CI. Failed job:

@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job dist-aarch64-apple failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
[RUSTC-TIMING] arrayvec test:false 0.226
   Compiling either v1.15.0
error: linking with `cc` failed: exit status: 1
  |
  = note:  "cc" "/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage1-rustc/release/build/blake3/8bbce82c0cc62026/out/rustcwwVMUJ/symbols.o" "<2 object files omitted>" "/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage1-rustc/release/build/cc/f5f3db14ca6f290d/out/libcc-f5f3db14ca6f290d.rlib" "/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage1-rustc/release/build/shlex/2455ab951a4a1513/out/libshlex-2455ab951a4a1513.rlib" "<sysroot>/lib/rustlib/aarch64-apple-darwin/lib/{libstd-*,libpanic_unwind-*,libobject-*,libmemchr-*,libaddr2line-*,libgimli-*,libcfg_if-*,librustc_demangle-*,libstd_detect-*,libhashbrown-*,librustc_std_workspace_alloc-*,libminiz_oxide-*,libadler2-*,libunwind-*,liblibc-*,librustc_std_workspace_core-*,liballoc-*,libcore-*,libcompiler_builtins-*}.rlib" "-lSystem" "-lc" "-lm" "-arch" "arm64" "-mmacosx-version-min=11.0.0" "-o" "/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage1-rustc/release/build/blake3/8bbce82c0cc62026/out/build_script_build" "-Wl,-dead_strip" "-nodefaultlibs"
  = note: some arguments are omitted. use `--verbose` to show all linker arguments
  = note: clang: error: unable to execute command: Segmentation fault: 11
          clang: error: linker command failed due to signal (use -v to see invocation)
          Apple clang version 17.0.0 (clang-1700.6.3.2)
          Target: arm64-apple-darwin24.6.0
          Thread model: posix
          InstalledDir: /Applications/Xcode_26.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
          clang: note: diagnostic msg: 
          ********************
          
          PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
          Linker snapshot containing input(s) and associated run script(s) are located at:
          clang: note: diagnostic msg: /var/folders/k8/j7r3p6cx43xdqhzy2rmp6tqr0000gn/T/linker-crash-708f86
          clang: note: diagnostic msg: 
          
          ********************
          

[RUSTC-TIMING] build_script_build test:false 3.406
error: could not compile `blake3` (build script) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
[RUSTC-TIMING] either test:false 0.137
[RUSTC-TIMING] rustc_macros test:false 4.987
Bootstrap failed while executing `dist bootstrap enzyme --include-default-paths --host=aarch64-apple-darwin --target=aarch64-apple-darwin`
Currently active steps:

@jhpratt

jhpratt commented Jul 11, 2026

Copy link
Copy Markdown
Member Author

@bors retry

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 11, 2026
@rust-bors rust-bors Bot mentioned this pull request Jul 11, 2026
@rust-bors

rust-bors Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

⌛ Testing commit 3657ecd with merge ad49852...

Workflow: https://github.com/rust-lang/rust/actions/runs/29140927215

rust-bors Bot pushed a commit that referenced this pull request Jul 11, 2026
Rollup of 15 pull requests

Successful merges:

 - #159106 (Update LLVM)
 - #157690 (codegen_ssa: pack small const aggregates into immediate stores)
 - #159005 (Use `as_lang_item` instead of repeatedly matching)
 - #156735 (Move NativeLib::filename to the rmeta-link archive member)
 - #157153 (allow `Allocator`s to be used as `#[global_allocator]`s)
 - #158269 (jq directives for jsondocck)
 - #158767 (merge DefKind::InlineConst into AnonConst)
 - #159099 (Stabilize String::from_utf8_lossy_owned)
 - #158930 (Reorganize `tests/ui/issues` [20/N])
 - #158965 (Add codegen test for Result is_ok unwrap)
 - #158979 (Reorganize `tests/ui/issues` [21/N])
 - #159050 (assert only opaques with sub unified hidden infer are non-rigid)
 - #159062 (Remove unused WEAK_ONLY_LANG_ITEMS static)
 - #159070 (Add `io::ErrorKind::InputOutputError`)
 - #159092 (make volatile operations const)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-compiletest Area: The compiletest test runner A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-rustdoc-json Area: Rustdoc JSON backend A-testsuite Area: The testsuite used to check the correctness of rustc A-tidy Area: The tidy tool rollup A PR which is a rollup S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)

Projects

None yet

Development

Successfully merging this pull request may close these issues.