Rustc pull update#2102
Open
workflows-stdarch[bot] wants to merge 22 commits intomainfrom
Open
Conversation
Pull recent changes from https://github.com/rust-lang/rust via Josh. Upstream ref: rust-lang/rust@0e95a0f Filtered ref: rust-lang/compiler-builtins@84dcb0e Upstream diff: rust-lang/rust@db3e99b...0e95a0f This merge was created using https://github.com/rust-lang/josh-sync.
…, r=JonathanBrouwer
Remove `HashStable` impl for `[hir::Attribute]`.
This impl skips:
- All doc comments
- A handful of other attributes, mostly `rustc_*` ones related to incremental compilation testing.
This skipping originated in rust-lang/rust#36025 and was extended a couple of times, e.g. in rust-lang/rust#36370. Those PRs don't have any explanation of why the skipping exists. Perhaps the reasoning was that doc comments should only affect rustdoc and rustdoc doesn't use incremental compilation? But doc comments end up in metadata, and there is a query `attrs_for_def` that returns a `&'tcx [hir::Attribute]`. So skipping some attributes just seems plainly wrong.
This commit removes the impl, which means `[hir::Attribute]` hashing falls back to the default impl for `[T]`. This has no noticeable effect on the test suite. It does slightly hurt performance, because of the doc comments. This perf regression seems worth it for the correctness benefits.
… r=saethlin
Fix performance regression introduced in #142531 by excluding `Storage{Live,Dead}` from CGU size estimation
Fix performance regression introduced in rust-lang/rust#142531 ([rust-timer comment](rust-lang/rust#142531 (comment))) by excluding `Storage{Live,Dead}` from CGU size estimation.
Also, avoid unneeded work for storage removal in non-opt builds in CopyProp and GVN
by allocating local sets for the storage accounting only when `tcx.sess.emit_lifetime_markers()`.
r? saethlin
codegen: Copy to an alloca when the argument is neither by-val nor by-move for indirect pointer. Fixes rust-lang/rust#155241. When a value is passed via an indirect pointer, the value needs to be copied to a new alloca. For x86_64-unknown-linux-gnu, `Thing` is the case: ```rust #[derive(Clone, Copy)] struct Thing(usize, usize, usize); pub fn foo() { let thing = Thing(0, 0, 0); bar(thing); assert_eq!(thing.0, 0); } #[inline(never)] #[unsafe(no_mangle)] pub fn bar(mut thing: Thing) { thing.0 = 1; } ``` Before passing the thing to the bar function, the thing needs to be copied to an alloca that is passed to bar. ```llvm %0 = alloca [24 x i8], align 8 call void @llvm.memcpy.p0.p0.i64(ptr align 8 %0, ptr align 8 %thing, i64 24, i1 false) call void @bar(ptr %0) ``` This patch applies the rule to the untupled arguments as well. ```rust #![feature(fn_traits)] #[derive(Clone, Copy)] struct Thing(usize, usize, usize); #[inline(never)] #[unsafe(no_mangle)] pub fn foo() { let thing = (Thing(0, 0, 0),); (|mut thing: Thing| { thing.0 = 1; }).call(thing); assert_eq!(thing.0.0, 0); } ``` For this case, this patch changes from ```llvm ; call example::foo::{closure#0} call void @_RNCNvCs15qdZVLwHPA_7example3foo0B3_(ptr ..., ptr %thing) ``` to ```llvm %0 = alloca [24 x i8], align 8 call void @llvm.memcpy.p0.p0.i64(ptr align 8 %0, ptr align 8 %thing, i64 24, i1 false) ; call example::foo::{closure#0} call void @_RNCNvCs15qdZVLwHPA_7example3foo0B3_(ptr ..., ptr %0) ``` However, the same rule cannot be applied to tail calls that would be unsound, because the caller's stack frame is overwritten by the callee's stack frame. Fortunately, rust-lang/rust#151143 has already handled the special case. We must not copy again. No copy is needed for by-move arguments, because the argument is passed to the called "in-place". No copy is also needed for by-val arguments, because the attribute implies that a hidden copy of the pointee is made between the caller and the callee. NOTE: The patch has a trick for tail calls that we pass by-move. We can choose to copy an alloca even for by-move arguments, but tail calls require MUST-by-move.
Update to wasi-sdk-32 in CI/releases Similar to prior updates such as rust-lang/rust#149037. This notably pulls in some bug fixes for wasi-libc around nonblocking I/O and networking.
…=tgross35 compiler-builtins subtree update Subtree update of `compiler-builtins` to rust-lang/compiler-builtins@4d3ab86. Created using https://github.com/rust-lang/josh-sync. Closes: rust-lang/rust#155653
Do not run jump-threading for GPUs GPU targets have convergent operations that must not be duplicated or moved in or out of control-flow. An example convergent operation is a barrier/syncthreads. The only MIR pass affected by this is jump-threading, it can duplicate calls. Disable jump-hreading for GPU targets to prevent generating incorrect code. This affects the amdgpu and nvptx targets. Fixes rust-lang/rust#137086, see this issue for details. Tracking issue: rust-lang/rust#135024 cc @RDambrosio016 @kjetilkjeka for nvptx cc @ZuseZ4
Verify that penultimate segment of enum variant path refers to enum if it has args Fixes rust-lang/rust#154962.
…=folkertdev,WaffleLapkin
Avoid loop_match self-assignment in MIR lowering
Transform
```
bb2: {
PlaceMention(_1);
_1 = copy _1;
goto -> bb7;
}
```
to
```
bb2: {
PlaceMention(_1);
_4 = copy _1;
_1 = copy _4;
goto -> bb7;
}
```
Closes rust-lang/rust#143806
<details>
<summary>Previous MIR</summary>
```
fn helper() -> u8 {
let mut _0: u8;
let mut _1: u8;
let mut _2: !;
let mut _3: !;
scope 1 {
debug state => _1;
}
bb0: {
StorageLive(_1);
_1 = const 0_u8;
FakeRead(ForLet(None), _1);
StorageLive(_2);
goto -> bb1;
}
bb1: {
falseUnwind -> [real: bb2, unwind: bb11];
}
bb2: {
PlaceMention(_1);
_1 = copy _1;
goto -> bb7;
}
bb3: {
FakeRead(ForMatchedPlace(None), _1);
unreachable;
}
bb4: {
unreachable;
}
bb5: {
goto -> bb6;
}
bb6: {
goto -> bb8;
}
bb7: {
goto -> bb8;
}
bb8: {
goto -> bb1;
}
bb9: {
unreachable;
}
bb10: {
StorageDead(_2);
StorageDead(_1);
return;
}
bb11 (cleanup): {
resume;
}
}
```
</details>
<details>
<summary>Current MIR</summary>
```
fn helper() -> u8 {
let mut _0: u8;
let mut _1: u8;
let mut _2: !;
let mut _3: !;
let mut _4: u8;
scope 1 {
debug state => _1;
}
bb0: {
StorageLive(_1);
_1 = const 0_u8;
FakeRead(ForLet(None), _1);
StorageLive(_2);
goto -> bb1;
}
bb1: {
falseUnwind -> [real: bb2, unwind: bb11];
}
bb2: {
PlaceMention(_1);
_4 = copy _1;
_1 = copy _4;
goto -> bb7;
}
bb3: {
FakeRead(ForMatchedPlace(None), _1);
unreachable;
}
bb4: {
unreachable;
}
bb5: {
goto -> bb6;
}
bb6: {
goto -> bb8;
}
bb7: {
goto -> bb8;
}
bb8: {
goto -> bb1;
}
bb9: {
unreachable;
}
bb10: {
StorageDead(_2);
StorageDead(_1);
return;
}
bb11 (cleanup): {
resume;
}
}
```
</details>
…chenkov,mu001999 Fix order-dependent visibility diagnostics Fixes rust-lang/rust#40066. Fixes rust-lang/rust#109657. Delay visibility path diagnostics until module collection has finished, so paths to later non-ancestor modules report E0742 instead of an unresolved path error.
ssa-range-prop: fix ICE when encountering self-domiating bb - **Add `strictly_dominates` method** - **fix ice in ssa-range-prop** Fixes rust-lang/rust#155836 r? dianqk
…ts, r=jackh726 Adds a couple UI tests for polonius I went through all the open issues labeled `fixed-by-polonius` and from that created two UI tests based on issues that seemed a little novel. One for rust-lang/rust#92038 and another for rust-lang/rust#70044. Both tests fail under NLL but pass with polonius (legacy and alpha).
… r=oli-obk
-Zembed-source: also embed external source
Hi,
I've been using `-Zembed-source` for a while and noticed that some sources are not embedded when compiling in release mode. See the minimal reproducer below for missing embedded source code.
The current implementation only emits source from the `src` field in `SourceFile`, but for multi-codegen-unit scenarios the source might only be available via the `external_src` field.
I've updated the LLVM and Cranelift backends to fall back to `external_src` if `src` is not available.
Minimal reproducer:
```console
$ cat Cargo.toml
[package]
name = "repro"
version = "0.0.1"
edition = "2021"
[profile.release]
strip = "none"
debug = true
$ cat src/lib.rs
// marker comment
pub fn foo() -> u64 { 42 }
$ cat src/main.rs
fn main() {
println!("{}", repro::foo());
}
$ RUSTFLAGS="-g -Zembed-source=yes -Zdwarf-version=5" cargo build -r
Compiling repro v0.0.1 (/tmp/repro)
Finished `release` profile [optimized + debuginfo] target(s) in 0.08s
$ # Note: Source for lib.rs is missing here:
$ llvm-dwarfdump --debug-line target/release/repro | grep "marker comment"
$ RUSTFLAGS="-g -Zembed-source=yes -Zdwarf-version=5" cargo +stage1 build -r
Finished `release` profile [optimized + debuginfo] target(s) in 0.04s
$ llvm-dwarfdump --debug-line target/release/repro | grep "marker comment"
source: "// marker comment\npub fn foo() -> u64 { 42 }\n"
```
Thanks!
Feed cleanups Two minor improvements. Details in the individual commits. r? @oli-obk
Return a single diagnostic from `lex_token_trees`. It currently returns a `Vec` but in practice it always has one diagnostic in it. LLM disclosure: Claude Code identified this when I asked it to review `tokentrees.rs`. I made the change by hand and tested it myself. r? @chenyukang
…uwer Rollup of 9 pull requests Successful merges: - rust-lang/rust#149637 (Do not run jump-threading for GPUs) - rust-lang/rust#154971 (Verify that penultimate segment of enum variant path refers to enum if it has args) - rust-lang/rust#155186 (Avoid loop_match self-assignment in MIR lowering) - rust-lang/rust#155948 (Fix order-dependent visibility diagnostics) - rust-lang/rust#156001 (ssa-range-prop: fix ICE when encountering self-domiating bb) - rust-lang/rust#155600 (Adds a couple UI tests for polonius) - rust-lang/rust#155995 (-Zembed-source: also embed external source) - rust-lang/rust#156019 (Feed cleanups) - rust-lang/rust#156031 (Return a single diagnostic from `lex_token_trees`.)
linker-messages is warn-by-default again cc rust-lang/rust#136096 I ended up keeping it a lint and adding an option for lints to ignore `-Dwarnings` (there was already a lint that did that actually, it was just hard-coded in rustc_middle instead of in rustc_lint_defs like I'd expect). This allows people to actually see the warnings without them failing the build in CI.
Validate source snippet when format input is raw string Fixes rust-lang/rust#114865 The issue occurred because the user's proc macro respanned the format arg to an unrelated multi-byte string and we ICE'd by landing in the middle of a multi-byte char. This PR adds validation that prevents the parser from trying to walk such obviously wrong snippets. Such validation already existed for non-raw strings. This PR adds it for raw strings as well.
Clippy subtree update r? Manishearth
This updates the rust-version file to 045b17737dab5fcc28e4cbee0cfe2ce4ed363b32.
Pull recent changes from https://github.com/rust-lang/rust via Josh. Upstream ref: rust-lang/rust@045b177 Filtered ref: 65061a8 Upstream diff: rust-lang/rust@e22c616...045b177 This merge was created using https://github.com/rust-lang/josh-sync.
Collaborator
|
r? @sayantn rustbot has assigned @sayantn. Use Why was this reviewer chosen?The reviewer was selected based on:
|
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.
Latest update from rustc.