Skip to content

Rollup of 10 pull requests#159080

Closed
JonathanBrouwer wants to merge 37 commits into
rust-lang:mainfrom
JonathanBrouwer:rollup-qKmYNKr
Closed

Rollup of 10 pull requests#159080
JonathanBrouwer wants to merge 37 commits into
rust-lang:mainfrom
JonathanBrouwer:rollup-qKmYNKr

Conversation

@JonathanBrouwer

Copy link
Copy Markdown
Contributor

Successful merges:

Failed merges:

r? @ghost

Create a similar rollup

jdonszelmann and others added 30 commits July 7, 2026 11:40
Signed-off-by: Amirhossein Akhlaghpour <m9.akhlaghpoor@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.
Since PR 154149, when one item is glob-imported into a module twice with
different visibilities, the first-arrived declaration stays in the
resolution slot and the most visible declaration of the ambiguous glob
set is only recorded in `ambiguity_vis_max`. `DeclData::vis()` returns
the max, so name resolution, metadata reexports and
`cross_crate_inlinable` export the item at the maximum visibility, but
`set_bindings_effective_visibilities` walked only the slot-resident
declaration's reexport chain. When the restricted route arrives first,
the definition's effective visibility caps at the restricted
visibility while the item is still exported: spurious dead_code, the
item missing from reachable_set, should_encode_mir returning false, and
downstream crates failing with "missing optimized MIR" (a 1.96.1 ->
1.97.0 stable-to-stable regression).

Generalize the one-level `ambiguity_vis_max` update that PR 154149 added
in `update_import` (to keep the most visible import from being reported
as unused) into a walk of that declaration's whole reexport chain:
extract the chain walk into `update_decl_chain` and recurse into
`ambiguity_vis_max` at every hop, so the most visible declaration
drives the effective visibility of everything on its route, including
the final definition. Updates are monotone, so the dual walk is
order-independent. The `ambiguous_import_visibilities` lint and the
PR 156284 diagnostic suppression are untouched.
…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.
Use `as_lang_item` instead of repeatedly matching

drive-by fix I noticed while reviewing https://github.com/rust-lang/rust/pull/157489/changes#r3550851573
@rustbot rustbot added A-rustdoc-search Area: Rustdoc's search feature A-test-infra-minicore Area: `minicore` test auxiliary and `//@ add-core-stubs` A-testsuite Area: The testsuite used to check the correctness of rustc A-tidy Area: The tidy tool O-windows Operating system: Windows PG-exploit-mitigations Project group: Exploit mitigations 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-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-infra Relevant to the infrastructure 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. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Jul 10, 2026
@JonathanBrouwer

Copy link
Copy Markdown
Contributor Author

@bors r+ rollup=never p=5

@rust-bors

rust-bors Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

📌 Commit bf34815 has been approved by JonathanBrouwer

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 10, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jul 10, 2026
…uwer

Rollup of 10 pull requests

Successful merges:

 - #157690 (codegen_ssa: pack small const aggregates into immediate stores)
 - #157706 (Deny `todo!()` in tidy)
 - #159005 (Use `as_lang_item` instead of repeatedly matching)
 - #156735 (Move NativeLib::filename to the rmeta-link archive member)
 - #159039 (resolve: fix effective visibilities for items in ambiguous glob sets)
 - #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)

Failed merges:

 - #158732 (Apply MCP 1003 and move diagnostics.rs into its own module)
@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job x86_64-gnu failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
---- [coverage-run] tests/coverage/long_and_wide.rs stdout ----
Saved the actual coverage to `/checkout/obj/build/x86_64-unknown-linux-gnu/test/coverage/long_and_wide.coverage-run/long_and_wide.coverage`
diff of coverage:

1    LL|       |//@ edition: 2021
-    LL|       |// ignore-tidy-linelength
+    LL|       |// ignore-tidy-file-linelength
3    LL|       |
4    LL|       |// This file deliberately contains line and column numbers larger than 127,
5    LL|       |// to verify that `coverage-dump`'s ULEB128 parser can handle them.


The actual coverage differed from the expected coverage

error: an error occurred comparing coverage output.
status: exit status: 0
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/ci-llvm/bin/llvm-cov" "show" "--format=text" "--show-line-counts-or-regions" "--Xdemangler" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools-bin/coverage-dump" "--Xdemangler" "--demangle" "--instr-profile" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/coverage/long_and_wide.coverage-run/default.profdata" "--object" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/coverage/long_and_wide.coverage-run/a"
--- stdout -------------------------------
    1|       |//@ edition: 2021
    2|       |// ignore-tidy-file-linelength
    3|       |
    4|       |// This file deliberately contains line and column numbers larger than 127,
    5|       |// to verify that `coverage-dump`'s ULEB128 parser can handle them.
    6|       |
    7|      1|fn main() {
    8|      1|    wide_function();
    9|      1|    long_function();
   10|      1|    far_function();
   11|      1|}
   12|       |
   13|       |#[rustfmt::skip]
   14|      1|fn wide_function() { /*                                                                                                           */ (); }
   15|       |
   16|      1|fn long_function() {
   17|       |    //
   18|       |    //
   19|       |    //
---
  146|       |    //
  147|       |    //
  148|      1|}
  149|       |
  150|      1|fn far_function() {}
------------------------------------------
stderr: none

---- [coverage-run] tests/coverage/long_and_wide.rs stdout end ----

@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 10, 2026
@rust-bors

rust-bors Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

💔 Test for dd442ab failed: CI. Failed job:

@rust-bors rust-bors Bot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 10, 2026
@rust-bors

rust-bors Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

PR #157706, which is a member of this rollup, was unapproved.

@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jul 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CI Area: Our Github Actions CI A-run-make Area: port run-make Makefiles to rmake.rs A-rustdoc-js Area: Rustdoc's JS front-end A-rustdoc-json Area: Rustdoc JSON backend A-rustdoc-search Area: Rustdoc's search feature A-test-infra-minicore Area: `minicore` test auxiliary and `//@ add-core-stubs` A-testsuite Area: The testsuite used to check the correctness of rustc A-tidy Area: The tidy tool O-windows Operating system: Windows PG-exploit-mitigations Project group: Exploit mitigations rollup A PR which is a rollup T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-infra Relevant to the infrastructure 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. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. 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.