Rollup of 9 pull requests#154438
Closed
JonathanBrouwer wants to merge 27 commits intorust-lang:mainfrom
Closed
Conversation
…assume Co-authored-by: Scott McMurray <scottmcm@users.noreply.github.com>
Clang and gcc use this option to control linking behavior too. Some targets need to be linked against a special crt which enables profiling at runtime. This makes using gprof a little easier with Rust binaries. Otherwise, rustc must be passed `-Clink-args=-pg` to ensure the correct startup code is linked.
mingw exposes the `_mcount` symbol for profiling.
libgmon needs to be linked. This also requires readding a few other system libraries to satisfy its dependencies.
The warning has no error code, so in a `-D warnings` environment, it's impossible to ignore if it consistently breaks your build. Change it to a note so it is still visible, but doesn't break the build
Remove the confusing word "error". The diagnostic is already prefixed
with a level when it is displayed, so this is redundant and possibly
confusing ("warning: error ...").
Add some help text summarizing the impact of what happened: the next
build won't be able to reuse work from the current run.
…e fail Use a proc macro to observe the incremental session directory and do something platform specific so that renaming the '-working' session directory during finalize_session_directory will fail. On Unix, change the permissions on the parent directory to be read-only. On Windows, open and leak a file inside the `-working` directory.
``` error[E0061]: this method takes 0 arguments but 1 argument was supplied --> $DIR/shadowed-intrinsic-method.rs:18:7 | LL | a.borrow(()); | ^^^^^^ -- unexpected argument of type `()` | note: the `borrow` call is resolved to the method in `std::borrow::Borrow`, shadowing the method of the same name on the inherent impl for `A` --> $DIR/shadowed-intrinsic-method.rs:18:7 | LL | use std::borrow::Borrow; | ------------------- `std::borrow::Borrow` imported here ... LL | a.borrow(()); | ^^^^^^ refers to `std::borrow::Borrow::borrow` note: method defined here --> $SRC_DIR/core/src/borrow.rs:LL:COL help: you might have meant to call the other method; you can use the fully-qualified path to call it explicitly | LL - a.borrow(()); LL + A::borrow(&mut a, ()); | help: remove the extra argument | LL - a.borrow(()); LL + a.borrow(); | ```
Handle correct gramar in the face of a single other option, or many.
* Create GPU target notification group * Update triagebot.toml Co-authored-by: 许杰友 Jieyou Xu (Joe) <39484203+jieyouxu@users.noreply.github.com>
…ze-nuw-assume, r=scottmcm perf(codegen): Eliminate `size_of_val == 0` for DSTs with Non-zero-sized Prefix via NUW and Assume *[View all comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rust/pull/152843)* ### Summary: #### Problem: `size_of_val(p) == 0` fails to optimize away for DST types that have a statically-known non-zero-sized prefix: ```rust pub struct Foo<T: ?Sized>(pub [u32; 3], pub T); pub fn demo(p: &Foo<dyn std::fmt::Debug>) -> bool { std::mem::size_of_val(p) == 0 // always false, but LLVM can't prove it } ``` `Foo` has a 12-byte prefix, so its total size is always ≥ 12. Yet the comparison persists as a runtime computation in LLVM IR. This matters because `Box<dyn T>` drop emits this exact check to guard the deallocation call — for types with a guaranteed non-zero prefix, the branch should vanish but doesn't. The slice tail variant `Foo<[i32]>` already optimized correctly; `Foo<dyn Trait>` and `Foo<[u8]>` did not. #### Root Cause: In `size_and_align_of_dst` (the ADT/Tuple branch), the size computation is: ``` full_size = (offset + unsized_size + (align-1)) & -align ``` LLVM cannot prove `full_size > 0` because: 1. `offset + unsized_size` used plain `add` — no overflow flags, so LLVM cannot conclude the result is ≥ `offset`. 2. `(x + addend) & -align` — LLVM has no fold to prove that alignment rounding never reduces the value below `x`. #### Solution: Two changes: 1. **`add nuw nsw` on `offset + unsized_size`** — the sum is bounded by the rounded size ≤ `isize::MAX`, so neither signed nor unsigned overflow is possible. Tells LLVM: `unrounded_size ≥ offset`. 2. **`assume(full_size ≥ unrounded_size)`** — `round_up(x, a) ≥ x` is a mathematical identity for power-of-two `a`. Tells LLVM: `full_size ≥ unrounded_size ≥ offset`. If `offset > 0`, the chain proves `full_size > 0`. #### LLVM IR Comparison: `Foo<dyn Debug>` — before ([godbolt](https://rust.godbolt.org/z/r1d5n6Phe)): ```llvm define noundef zeroext i1 @demo(ptr %p.0, ptr %p.1) { start: %0 = getelementptr inbounds nuw i8, ptr %p.1, i64 8 %1 = load i64, ptr %0, align 8, !range !3, !invariant.load !4 %2 = getelementptr inbounds nuw i8, ptr %p.1, i64 16 %3 = load i64, ptr %2, align 8, !range !5, !invariant.load !4 %4 = tail call i64 @llvm.umax.i64(i64 %3, i64 4) %5 = add nuw i64 %1, 11 %6 = add i64 %5, %4 %7 = sub i64 0, %4 %8 = and i64 %6, %7 %_0 = icmp eq i64 %8, 0 ret i1 %_0 } ``` `Foo<dyn Debug>` — after: ```llvm define noundef zeroext i1 @demo(ptr %p.0, ptr %p.1) { start: ret i1 false } ``` `Foo<[u8]>` — before: ```llvm define noundef zeroext i1 @demo_lessalignedslice(ptr %p.0, i64 %p.1) { start: %0 = add i64 %p.1, 15 %_0 = icmp ult i64 %0, 4 ret i1 %_0 } ``` `Foo<[u8]>` — after: ```llvm define noundef zeroext i1 @demo_lessalignedslice(ptr %p.0, i64 %p.1) { start: ret i1 false } ``` ### Changes: - `compiler/rustc_codegen_ssa/src/size_of_val.rs`: `add` → `unchecked_suadd` (NUW+NSW) on `offset + unsized_size`; add `assume(full_size ≥ unrounded_size)`. - `tests/codegen-llvm/dst-size-of-val-not-zst.rs`: new codegen test verifying `size_of_val == 0` folds to `ret i1 false` for `Foo<dyn Debug>`, `Foo<[u8]>`, and `Foo<[i32]>`. Fixes rust-lang#152788.
…usize, r=scottmcm `Alignment`: move from `ptr` to `mem` and rename `as_nonzero` to `as_nonzero_usize` - tracking issue: rust-lang#102070 - split off from rust-lang#153261
Pass -pg to linker when using -Zinstrument-mcount This selects a slightly different crt on gnu targets which enables the profiler within glibc. This makes using gprof a little easier with Rust binaries. Otherwise, rustc must be passed `-Clink-args=-pg` to ensure the correct startup code is linked.
…rray-ice, r=chenyukang Remove divergence check from check_expr_array Fixes rust-lang#153695. `check_expr_array` currently assumes it should only be entered with` self.diverges == Diverges::Maybe`, but that assumption does not appear to hold in all valid cases. A never-pattern parameter can seed a function or closure body with inherited `Diverges::Always`, and exprs in that body are still typecked.
move many tests out of `ui/unsafe` `ui/unsafe` is a pretty big and generic directory. This PR moves some tests from it to `ui/union` and some others to a new `rustc_layout_scalar_valid_range` directory. r? @Kivooeo
…ath, r=davidtwco Suggest fully qualified path on method name collision Provide suggestion for using a fully qualified path when method names collide between traits and inherent impl. ``` error[E0061]: this method takes 0 arguments but 1 argument was supplied --> $DIR/shadowed-intrinsic-method.rs:20:7 | LL | a.borrow(()); | ^^^^^^ -- unexpected argument of type `()` | note: the `borrow` call is resolved to the method in `std::borrow::Borrow`, shadowing the method of the same name on the inherent impl for `A` --> $DIR/shadowed-intrinsic-method.rs:20:7 | LL | use std::borrow::Borrow; | ------------------- `std::borrow::Borrow` imported here ... LL | a.borrow(()); | ^^^^^^ refers to `std::borrow::Borrow::borrow` note: method defined here --> $SRC_DIR/core/src/borrow.rs:LL:COL help: you might have meant to call the other method; you can use the fully-qualified path to call it explicitly | LL - a.borrow(()); LL + A::borrow(&mut a, ()); | help: remove the extra argument | LL - a.borrow(()); LL + a.borrow(); | ``` Fix rust-lang#54103.
simd_add/sub/mul/neg: document overflow behavior `simd_neg` had an odd comment about overflow not being UB, without saying what the behavior is instead. Replace that by just saying this uses wrapping arithmetic, and add the same for add/sub/mul. div/rem are already documented to cause UB on div-by-zero and min-div-by-minus-one, and shl/shr cause UB on too large shift amounts.
…r=wesleywiser Change "error finalizing incremental compilation" text and emit it as a note, not a warning As mentioned in rust-lang#151181 (comment) and rust-lang#151181 (comment) the current message could be improved: 1. Right now it displays as "warning: error ..." which is confusing (is it an error or a warning) 2. It doesn't give the user a clear indication of what the consequences are 3. The _current_ build is successful. The _next_ build might be slower The new message is now ```text note: did not finalize incremental compilation session directory ... | = help: the next build will not be able to reuse work from this compilation ``` I started a zulip thread [#t-compiler/incremental > Ergonomics of "error finalizing incremental session"](https://rust-lang.zulipchat.com/#narrow/channel/241847-t-compiler.2Fincremental/topic/Ergonomics.20of.20.22error.20finalizing.20incremental.20session.22/with/580191447)
…roup, r=jieyouxu Create GPU target notification group Creating the notification group for the newly created GPU target (see [mcp#960](https://rust-lang.zulipchat.com/#narrow/channel/233931-t-compiler.2Fmajor-changes/topic/Create.20a.20GPU.20notification.20group.20compiler-team.23960/near/568629680)) I'm following these [steps](rust-lang#133334). (feel free to suggest a better wording) r? @jieyouxu
Contributor
Author
|
@bors r+ rollup=never p=5 |
Contributor
Contributor
Author
|
Trying commonly failed jobs |
This comment has been minimized.
This comment has been minimized.
rust-bors bot
pushed a commit
that referenced
this pull request
Mar 26, 2026
Rollup of 9 pull requests 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
Collaborator
|
The job Click to see the possible cause of the failure (guessed by this bot) |
Collaborator
|
The job Click to see the possible cause of the failure (guessed by this bot) |
Contributor
|
PR #152843, which is a member of this rollup, was unapproved. This rollup was thus unapproved. |
Contributor
|
💔 Test for 4411a48 failed: CI. Failed jobs:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Successful merges:
size_of_val == 0for DSTs with Non-zero-sized Prefix via NUW and Assume #152843 (perf(codegen): Eliminatesize_of_val == 0for DSTs with Non-zero-sized Prefix via NUW and Assume)Alignment: move fromptrtomemand renameas_nonzerotoas_nonzero_usize#154004 (Alignment: move fromptrtomemand renameas_nonzerotoas_nonzero_usize)ui/unsafe#154418 (move many tests out ofui/unsafe)r? @ghost
Create a similar rollup