Merged
Conversation
Pull recent changes from https://github.com/rust-lang/rust via Josh. Upstream ref: ffb9d94dcf4ade0d534842be3672d5e9f47e1333 Filtered ref: 2f31646593733abae36e4c05b5a54acfb9f1f6bc This merge was created using https://github.com/rust-lang/josh-sync.
Pull recent changes from https://github.com/rust-lang/rust via Josh. Upstream ref: d36f964125163c2e698de5559efefb8217b8b7f0 Filtered ref: 92461731ae79cfe5044e4826160665b77c0363a2 This merge was created using https://github.com/rust-lang/josh-sync.
Pull recent changes from https://github.com/rust-lang/rust via Josh. Upstream ref: caccb4d0368bd918ef6668af8e13834d07040417 Filtered ref: 3074203aaad351997a9863b04e251efa3e4b5f6e Upstream diff: rust-lang/rust@9385c64...caccb4d This merge was created using https://github.com/rust-lang/josh-sync.
Pull recent changes from https://github.com/rust-lang/rust via Josh. Upstream ref: 47cd7120d9b4e1b64eb27c87522a07888197fae8 Filtered ref: b5a5cb8beb5c1ac848a39bfcd0ccaad98015d017 Upstream diff: rust-lang/rust@caccb4d...47cd712 This merge was created using https://github.com/rust-lang/josh-sync.
Pull recent changes from https://github.com/rust-lang/rust via Josh. Upstream ref: 23d01cd2412583491621ab1ca4f1b01e37d11e39 Filtered ref: 5d28c73d267214190903896b4caf2e40a17a56cb Upstream diff: rust-lang/rust@2dc3024...23d01cd This merge was created using https://github.com/rust-lang/josh-sync.
Pull recent changes from https://github.com/rust-lang/rust via Josh. Upstream ref: rust-lang/rust@44e34e1 Filtered ref: rust-lang/compiler-builtins@94ca1ba Upstream diff: rust-lang/rust@23d01cd...44e34e1 This merge was created using https://github.com/rust-lang/josh-sync.
Pull recent changes from https://github.com/rust-lang/rust via Josh. Upstream ref: rust-lang/rust@db3e99b Filtered ref: rust-lang/compiler-builtins@970db0b Upstream diff: rust-lang/rust@44e34e1...db3e99b This merge was created using https://github.com/rust-lang/josh-sync.
(cherry picked from commit b90149755ad030e74bc3c198f8c4b90e08be8065)
…rtdev stdarch subtree update Subtree update of `stdarch` to 1a7cc47. Created using https://github.com/rust-lang/josh-sync. r? @ghost
Provide more context on trait bounds being unmet due to imperfect derive
When encountering a value that has a borrow checker error where the type was previously moved, when suggesting cloning verify that it is not already being derived. If it is, explain why the `derive(Clone)` doesn't apply:
```
note: if `TypedAddress<T>` implemented `Clone`, you could clone the value
--> $DIR/derive-clone-implicit-bound.rs:6:1
|
LL | #[derive(Clone, Copy)]
| ----- derived `Clone` adds implicit bounds on type parameters
LL | pub struct TypedAddress<T>{
| ^^^^^^^^^^^^^^^^^^^^^^^^-^
| | |
| | introduces an implicit `T: Clone` bound
| consider manually implementing `Clone` for this type
...
LL | let old = self.return_value(offset);
| ------ you could clone this value
```
When encountering a bound coming from a derive macro, suggest manual impl of the trait.
Use the span for the specific param when adding bounds in builtin derive macros, so the diagnostic will point at them as well as the derive macro itself.
```
note: required for `Id<SomeNode>` to implement `PartialEq`
--> $DIR/derive-implicit-bound.rs:5:10
|
LL | #[derive(PartialEq, Eq)]
| ^^^^^^^^^
LL | pub struct Id<T>(PhantomData<T>);
| - unsatisfied trait bound introduced in this `derive` macro
= help: consider manually implementing `PartialEq` to avoid undesired bounds
```
Mention that the trait could be manually implemented in E0599.
Fix rust-lang/rust#108894. Address rust-lang/rust#143714. Address #rust-lang/rust#146515 (but ideally would also suggest constraining the fn bound correctly as well).
escape symbol names in global asm copied from https://github.com/llvm/llvm-project/blob/main/llvm/lib/MC/MCSymbol.cpp closes rust-lang/rust#151950
Remove the 4 failing tests from rustdoc-gui These are the 4 tests that @Bryntet got to fail locally See [#t-infra > CI failure because `tests/rustdoc-gui/search-filter.goml`](https://rust-lang.zulipchat.com/#narrow/channel/242791-t-infra/topic/CI.20failure.20because.20.60tests.2Frustdoc-gui.2Fsearch-filter.2Egoml.60/with/572271674) r? @ghost
Rollup of 4 pull requests Successful merges: - rust-lang/rust#152174 (stdarch subtree update) - rust-lang/rust#151278 (Provide more context on trait bounds being unmet due to imperfect derive) - rust-lang/rust#151955 (escape symbol names in global asm) - rust-lang/rust#152194 (Remove the 4 failing tests from rustdoc-gui) Failed merges: - rust-lang/rust#152191 (Convert to inline diagnostics in `rustc_hir_analysis`)
Stable hashing cleanups I took a close look at `rustc_query_system::ich` and found a bunch of things to improve. r? @cjgillot
Update wasi-sdk used in CI/releases This is similar to prior updates such as rust-lang/rust#149037 in that this is just updating a URL. This update though has some technical updates accompanying it as well, however: * The `wasm32-wasip2` target no longer uses APIs from WASIp1 on this target, even for startup. This means that the final binary no longer has an "adapter" which can help making instantiation of a component a bit more lean. * In rust-lang/rust#147572 libstd was updated to use wasi-libc more often on the `wasm32-wasip2` target. This uncovered a number of bugs in wasi-libc such as rust-lang/rust#149864, rust-lang/rust#150291, and rust-lang/rust#151016. These are all fixed in wasi-sdk-30 so the workarounds in the standard library are all removed. Overall this is not expected to have any sort of major impact on users of WASI targets. Instead it's expected to be a normal routine update to keep the wheels greased and oiled.
GVN: Only propagate borrows from SSA locals Fixes rust-lang/rust#141313. This is a more principled fix than rust-lang/rust#147886. Using a reference that is not a borrowing of an SSA local at a new location may be UB. The PR has two major changes. The first one, when introducing a new dereference at a new location, is that the reference must point to an SSA local or be an immutable argument. `dereference_address` has handled SSA locals. The second one, if we cannot guard to the reference point to an SSA local in `visit_assign`, we have to rewrite the value to opaque. This avoids unifying the following dereferences that also are references: ```rust let b: &T = *a; // ... `a` is allowed to be modified. `c` and `b` have different borrowing lifetime. // Unifying them will extend the lifetime of `b`. let c: &T = *a; ``` See also rust-lang/rust#130853. This still allows unifying non-reference dereferences: ```rust let a: &T = ...; let b: T = *a; // ... a is NOT allowed to be modified. let c: T = *a; ``` r? @cjgillot
Handle race when coloring nodes concurrently as both green and red This fixes a race where a duplicate dep node gets written to the dep graph if a node was marked as green and promoted during execution, then marked as red after execution. This can occur when a `no_hash` query A depends on a query B which cannot be forced so it was not colored when starting execution of query A. During the execution of query A it will execute query B and color it green. Before A finishes another thread tries to mark A green, this time succeeding as B is now green, and A gets promoted and written to metadata. Execution of A then finishes and because it's `no_hash` we assume the result changed and thus we color the node again, now as red and write it to metadata again. This doesn't happen with non-`no_hash` queries as they will be green if all their dependencies are green. This changes the code coloring nodes red to also use `compare_exchange` to deal with this race ensuring that the coloring of nodes only happens once. Fixes rust-lang/rust#150018 Fixes rust-lang/rust#142778 Fixes rust-lang/rust#141540
Clean up query macros for `cache_on_disk_if` This PR aims to make the macros for dealing with `cache_on_disk_if` a bit easier to read and work with. There should be no change to compiler behaviour.
compiler-builtins subtree update Subtree update of `compiler-builtins` to rust-lang/compiler-builtins@6a67a9f. Created using https://github.com/rust-lang/josh-sync. r? @ghost
…ouwer,Nadrieril
Make operational semantics of pattern matching independent of crate and module
The question of "when does matching an enum against a pattern of one of its variants read its discriminant" is currently an underspecified part of the language, causing weird behavior around borrowck, drop order, and UB.
Of course, in the common cases, the discriminant must be read to distinguish the variant of the enum, but currently the following exceptions are implemented:
1. If the enum has only one variant, we currently skip the discriminant read.
- This has the advantage that single-variant enums behave the same way as structs in this regard.
- However, it means that if the discriminant exists in the layout, we can't say that this discriminant being invalid is UB. This makes me particularly uneasy in its interactions with niches – consider the following example ([playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=5904a6155cbdd39af4a2e7b1d32a9b1a)), where miri currently doesn't detect any UB (because the semantics don't specify any):
<details><summary>Example 1</summary>
```rust
#![allow(dead_code)]
use core::mem::{size_of, transmute};
#[repr(u8)]
enum Inner {
X(u8),
}
enum Outer {
A(Inner),
B(u8),
}
fn f(x: &Inner) {
match x {
Inner::X(v) => {
println!("{v}");
}
}
}
fn main() {
assert_eq!(size_of::<Inner>(), 2);
assert_eq!(size_of::<Outer>(), 2);
let x = Outer::B(42);
let y = &x;
f(unsafe { transmute(y) });
}
```
</details>
2. For the purpose of the above, enums with marked with `#[non_exhaustive]` are always considered to have multiple variants when observed from foreign crates, but the actual number of variants is considered in the current crate.
- This means that whether code has UB can depend on which crate it is in: rust-lang/rust#147722
- In another case of `#[non_exhaustive]` affecting the runtime semantics, its presence or absence can change what gets captured by a closure, and by extension, the drop order: rust-lang/rust#147722 (comment)
- Also at the above link, there is an example where removing `#[non_exhaustive]` can cause borrowck to suddenly start failing in another crate.
3. Moreover, we currently make a more specific check: we only read the discriminant if there is more than one *inhabited* variant in the enum.
- This means that the semantics can differ between `foo<!>`, and a copy of `foo` where `T` was manually replaced with `!`: rust-lang/rust#146803
- Moreover, due to the privacy rules for inhabitedness, it means that the semantics of code can depend on the *module* in which it is located.
- Additionally, this inhabitedness rule is even uglier due to the fact that closure capture analysis needs to happen before we can determine whether types are uninhabited, which means that whether the discriminant read happens has a different answer specifically for capture analysis.
- For the two above points, see the following example ([playground](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2024&gist=a07d8a3ec0b31953942e96e2130476d9)):
<details><summary>Example 2</summary>
```rust
#![allow(unused)]
mod foo {
enum Never {}
struct PrivatelyUninhabited(Never);
pub enum A {
V(String, String),
Y(PrivatelyUninhabited),
}
fn works(mut x: A) {
let a = match x {
A::V(ref mut a, _) => a,
_ => unreachable!(),
};
let b = match x {
A::V(_, ref mut b) => b,
_ => unreachable!(),
};
a.len(); b.len();
}
fn fails(mut x: A) {
let mut f = || match x {
A::V(ref mut a, _) => (),
_ => unreachable!(),
};
let mut g = || match x {
A::V(_, ref mut b) => (),
_ => unreachable!(),
};
f(); g();
}
}
use foo::A;
fn fails(mut x: A) {
let a = match x {
A::V(ref mut a, _) => a,
_ => unreachable!(),
};
let b = match x {
A::V(_, ref mut b) => b,
_ => unreachable!(),
};
a.len(); b.len();
}
fn fails2(mut x: A) {
let mut f = || match x {
A::V(ref mut a, _) => (),
_ => unreachable!(),
};
let mut g = || match x {
A::V(_, ref mut b) => (),
_ => unreachable!(),
};
f(); g();
}
```
</details>
In light of the above, and following the discussion at rust-lang/rust#138961 and rust-lang/rust#147722, this PR ~~makes it so that, operationally, matching on an enum *always* reads its discriminant.~~ introduces the following changes to this behavior:
- matching on a `#[non_exhaustive]` enum will always introduce a discriminant read, regardless of whether the enum is from an external crate
- uninhabited variants now count just like normal ones, and don't get skipped in the checks
As per the discussion below, the resolution for point (1) above is that it should land as part of a separate PR, so that the subtler decision can be more carefully considered.
Note that this is a breaking change, due to the aforementioned changes in borrow checking behavior, new UB (or at least UB newly detected by miri), as well as drop order around closure captures. However, it seems to me that the combination of this PR with rust-lang/rust#138961 should have smaller real-world impact than rust-lang/rust#138961 by itself.
Fixes rust-lang/rust#142394
Fixes rust-lang/rust#146590
Fixes rust-lang/rust#146803 (though already marked as duplicate)
Fixes parts of rust-lang/rust#147722
Fixes rust-lang/miri#4778
r? @Nadrieril @RalfJung
@rustbot label +A-closures +A-patterns +T-opsem +T-lang
…rtdev stdarch subtree update Subtree update of `stdarch` to 1239a9f. Created using https://github.com/rust-lang/josh-sync. r? @ghost
mGCA: Validate const literal against expected type close: rust-lang/rust#151625 close: rust-lang/rust#150983 also fix: rust-lang/rust#133966 (moved crashes test)
Don't ICE on layout error in vtable computation Fixes rust-lang/rust#152030. Note: I'm including a more general testcase that doesn't use the feature in the original report, but only reproduces with debuginfo disabled. Does it make sense to also include the original testcase?
`proc_macro::bridge`: simplify `ExecutionStrategy` and `DispatcherTrait` Also includes another tiny cleanup (functions can only have one return type).
Port #[rustc_proc_macro_decls] to the new attribute parser. Tracking issue: rust-lang/rust#131229 r? @JonathanBrouwer
Port #[rustc_test_marker] to the attribute parser Tracking issue: rust-lang/rust#131229 Targets: Const is for normal tests (const test::TestDescAndFn is inserted before the test fn) Const/Static/Fn is for custom_test_framework's #[test_case] e.g. tests/ui/custom_test_frameworks/full.rs r? @JonathanBrouwer Again I left the use-sites as is since they are early uses.
DepGraphQuery: correctly skip adding edges with not-yet-added nodes Fixes rust-lang/rust#142152. The current logic already skips some edges, so I'm not sure how critical it is to have *all* the edges recorded, the logic seems to only be used for debug dumping. Recording all edges requires supporting holes in the `LinkedGraph` data structure, to add nodes and edges out of order, rust-lang/rust#151821 implements that at cost of complicating the data structure.
Rename `inline_fluent!` to `msg!` This was the most popular name for the macro as voted in [#t-compiler > Bikeshed the new `inline_fluent!` macro @ 💬](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Bikeshed.20the.20new.20.60inline_fluent!.60.20macro/near/572751863)
…uwer Rollup of 8 pull requests Successful merges: - rust-lang/rust#152618 (stdarch subtree update) - rust-lang/rust#152001 (mGCA: Validate const literal against expected type) - rust-lang/rust#152120 (Don't ICE on layout error in vtable computation) - rust-lang/rust#152531 (`proc_macro::bridge`: simplify `ExecutionStrategy` and `DispatcherTrait`) - rust-lang/rust#152577 (Port #[rustc_proc_macro_decls] to the new attribute parser.) - rust-lang/rust#152570 (Port #[rustc_test_marker] to the attribute parser) - rust-lang/rust#152590 (DepGraphQuery: correctly skip adding edges with not-yet-added nodes) - rust-lang/rust#152612 (Rename `inline_fluent!` to `msg!`)
Shallow resolve ty and const vars to their root vars Continuation of rust-lang/rust#147193
diagnostics: add note when param-env shadows global impl This PR adds a diagnostics note when param-env shadows global impl as discussed in rust-lang/rust#149910 It adds a note explaining that the definition is hidden by the generic bound. r?lcnr
implement `carryless_mul` tracking issue: rust-lang/rust#152080 ACP: rust-lang/libs-team#738 This defers to LLVM's `llvm.clmul` when available, and otherwise falls back to a method from the `polyval` crate ([link](https://github.com/RustCrypto/universal-hashes/blob/master/polyval/src/field_element/soft/soft64.rs)). Some things are missing, which I think we can defer: - the ACP has some discussion about additional methods, but I'm not sure exactly what is wanted or how to implement it efficiently - the SIMD intrinsic is not yet `const` (I think I ran into a bootstrapping issue). That is fine for now, I think in `stdarch` we can't really use this intrinsic at the moment, we'd only want the scalar version to replace some riscv intrinsics. - the SIMD intrinsic is not implemented for the gcc and cranelift backends. That should be reasonably straightforward once we have a const eval implementation though.
…r=Mark-Simulacrum Improve write! and writeln! error when called without destination Fixes rust-lang/rust#152493 Adds catch-all arms to `write!` and `writeln!` macros so that calling them without a destination (e.g., `write!("S")` instead of `write!(f, "S")`) gives a clear error instead of the cryptic "unexpected end of macro invocation" pointing at macro internals. r? @estebank
…imulacrum Test(lib/win/net): Skip UDS tests when under Win7 Unix Domain Socket support has only been added to Windows since Windows 10 Insider Preview Build 17063. Thus, it has no chance of ever being supported under Windows 7, making current tests fail. This therefore adds the necessary in order to make the tests dynamically skip when run under Windows 7, 8, and early 10, as it does not trigger linker errors. cc rust-lang/rust#150487 @roblabla @rustbot label T-libs A-io O-windows-7
ci: Lock cross toolchain version and update docs This PR locks the cross-toolchain component version to avoid unexpected changes when bumping crosstool-ng, and updates the toolchain configuration in the docs to match the actual setup. try-job: dist-arm-linux-musl try-job: dist-loongarch64-linux try-job: dist-loongarch64-musl try-job: dist-powerpc64-linux-musl try-job: dist-powerpc64le-linux-gnu try-job: dist-powerpc64le-linux-musl
Include `library/stdarch` for `CURRENT_RUSTC_VERSION` updates Our tool `replace-version-placeholder` uses the `tidy` file walker and its directory filter, but that skips `library/stdarch` which we do need for public stability markers. This PR adds a local filter function that explicitly allows that path. The commit for 1.94 `stdarch` updates is coming from beta rust-lang/rust#152187.
…y-len, r=BoxyUwU Add regression test for #141738 Closes rust-lang/rust#141738 - Add a regression test for rust-lang/rust#141738 - Using a struct constructor (`DefKind::Ctor(Struct, Const)`) as an array repeat count with `#![feature(min_generic_const_args)]` used to ICE in const alias normalization - Fixed by rust-lang/rust#150704, which added const constructor support for mGCA. This test covers the **error path** (struct ctor where `usize` is expected), which was not covered by the tests in rust-lang/rust#150704
unwind/wasm: fix compile error by wrapping wasm_throw in unsafe block This fix rust-std compile error on wasm32-unknown-unknown with panic=unwind because of `#![deny(unsafe_op_in_unsafe_fn)]`
…y789 Exchange js_lint message between bless and non-bless The message `applying suggestions` should be emitted when bless is enabled.
Rollup of 9 pull requests Successful merges: - rust-lang/rust#150424 (diagnostics: add note when param-env shadows global impl) - rust-lang/rust#152132 (implement `carryless_mul`) - rust-lang/rust#152508 (Improve write! and writeln! error when called without destination) - rust-lang/rust#152534 (Test(lib/win/net): Skip UDS tests when under Win7) - rust-lang/rust#152578 (ci: Lock cross toolchain version and update docs) - rust-lang/rust#152188 (Include `library/stdarch` for `CURRENT_RUSTC_VERSION` updates) - rust-lang/rust#152402 (Add regression test for rust-lang/rust#141738) - rust-lang/rust#152472 (unwind/wasm: fix compile error by wrapping wasm_throw in unsafe block) - rust-lang/rust#152610 (Exchange js_lint message between bless and non-bless)
Use `scope` for `par_slice` instead of `join` This uses `scope` instead of nested `join`s in `par_slice` so that each group of items are independent and do not end up blocking on another.
Pass alignments through the shim as `Alignment` (not `usize`) We're using `Layout` on both sides, so might as well skip the transmutes back and forth to `usize`. The mir-opt test shows that doing so allows simplifying the boxed-slice drop slightly, for example.
This updates the rust-version file to 139651428df86cf88443295542c12ea617cbb587.
Pull recent changes from https://github.com/rust-lang/rust via Josh. Upstream ref: rust-lang/rust@1396514 Filtered ref: b1e0e47 Upstream diff: rust-lang/rust@db3e99b...1396514 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.