Commit graph

313959 commits

Author SHA1 Message Date
Jonathan Brouwer
e156286fa5
Rollup merge of #150130 - aerooneqq:delegation-one-line-trait-impl, r=petrochenkov
Support syntax for one-line trait reuse

This PR adds support for reusing the whole trait with a one-line reuse syntax and is part of the delegation feature rust-lang/rust#118212:
```rust
trait T {
  fn foo(&self);
}

struct S;
impl T for S { ... }

struct Wrapper(S);
reuse impl T for Wrapper { self.0 }
```

The core idea is that we already have support for glob reuse, so in this scenario we want to transform one-line reuse into a trait impl block with a glob reuse in the following way:
```rust
//Before
reuse impl T for Wrapper { self.0 }

//After
impl T for Wrapper {
  reuse T::* { self.0 }
}
```

It seems like this task can be solved during parsing stage, when we encountered a one-line trait reuse, we can expand into this impl block right away, and the code which was already written to expand glob delegations will take care about the rest. We will copy trait path into glob reuse path.

The implementation of the transformation reuses already existing methods for `impl` parsing, however, we do not parse inner `impl` items, instead we parse "inner items" as delegation body. Thus, we do not have to deal with generics, consts, unsafe and other `impl` related features.

Other syntax possibility is trying to shorten one-line reuse by replacing `impl` keyword with `reuse` keyword:
```rust
reuse T for Wrapper { self.0 }
```
In this case implementation may become more complicated, and the syntax more confusing, as keywords such as `const` or `unsafe` will precede `reuse`, and there are also generics:
```rust
unsafe reuse<T1, T2> T for Wrapper { self.0 }
```

In the first (currently implemented) version reuse is placed in the beginning of the item, and it is clear that we will reuse trait implementation, while in the second, shorter version, the `reuse` keyword may be lost in generics and keywords that may precede `impl`.

r? ``@petrochenkov``
2025-12-23 12:01:01 +01:00
aerooneqq
1de1885a63 Support syntax for one-line trait reuse 2025-12-23 10:34:23 +03:00
bors
0ac9e59d8f Auto merge of #150291 - alexcrichton:wasi-use-usleep, r=ChrisDenton
std: Use `usleep` temporarily on WASI targets

This fixes some fallout from rust-lang/rust#147572 where the `thread::sleep` function is is broken on `wasm32-wasip2` after that PR. The cause for this is a broken implementation of `nanosleep` in wasi-libc itself which is being fixed in WebAssembly/wasi-libc#696. Similar to rust-lang/rust#149864 this avoids the problematic function for now while the wasi-libc changes take some time to propagate into a wasi-sdk release.

Closes rust-lang/rust#150290
2025-12-23 06:26:53 +00:00
bors
5c53093374 Auto merge of #150133 - ZuseZ4:enzyme-frontend-nightly, r=jieyouxu
remove llvm_enzyme and enzyme fallbacks from most places

Using dlopen to get symbols has the nice benefit that rustc itself doesn't depend on libenzyme symbols anymore. We can therefore delete most fallback implementations in the backend (independently of whether we enable enzyme or not). When trying to use autodiff on nightly, we will now fail with a nice error if and only if we fail to load libEnzyme-21.so in our backend.

Verified:
Build as nightly, without Enzyme
Build as nightly, with Enzyme
Build as stable (without Enzyme)

With this PR we will now run `tests/ui/autodiff` on nightly, the tests are passing.

r? `@kobzol`
2025-12-23 02:49:04 +00:00
bors
a0c97e3255 Auto merge of #150217 - notriddle:stringdex-0.0.4, r=yotamofek,GuillaumeGomez
rustdoc: upgrade to stringdex 0.0.4

- code cleanup
- smaller encoding for runs
- fast path for the common encoding case
2025-12-22 23:19:14 +00:00
Alex Crichton
dfbb0fd7dc std: Use usleep temporarily on WASI targets
This fixes some fallout from 147572 where the `thread::sleep` function
is is broken on `wasm32-wasip2` after that PR. The cause for this is a
broken implementation of `nanosleep` in wasi-libc itself which is being
fixed in WebAssembly/wasi-libc/696. Similar to 149999 this avoids the
problematic function for now while the wasi-libc changes take some time
to propagate into a wasi-sdk release.
2025-12-22 13:13:50 -08:00
bors
4f14395c37 Auto merge of #150284 - JonathanBrouwer:rollup-yeibc0p, r=JonathanBrouwer
Rollup of 3 pull requests

Successful merges:

 - rust-lang/rust#149928 (Detail expectation on non-`()` block tail in `if` then condition with no `else`)
 - rust-lang/rust#150166 (Don't lint on interior mutable `const` item coming from derefs)
 - rust-lang/rust#150281 (miri subtree update)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-12-22 20:09:56 +00:00
Jonathan Brouwer
92c0c3581c
Rollup merge of #150281 - RalfJung:miri, r=RalfJung
miri subtree update

Subtree update of `miri` to 4a8db0f1f0.

Created using https://github.com/rust-lang/josh-sync.

r? `@ghost`
2025-12-22 20:11:54 +01:00
Jonathan Brouwer
a65fa4a357
Rollup merge of #150166 - Urgau:const-item-lint-150157, r=Kivooeo
Don't lint on interior mutable `const` item coming from derefs

This PR fixes the `const_item_interior_mutations` lint so we don't lint on interior mutable `const` item coming from derefs.

Fixes https://github.com/rust-lang/rust/issues/150157
2025-12-22 20:11:54 +01:00
Jonathan Brouwer
9175089439
Rollup merge of #149928 - estebank:if-no-else, r=fee1-dead
Detail expectation on non-`()` block tail in `if` then condition with no `else`

When encountering an `if` expression with no `else` where the then block has a tail expression, we emit an E0308 type error. We now explain why `()` was expected.

Partially address rust-lang/rust#144911.
2025-12-22 20:11:53 +01:00
bors
04813e4de8 Auto merge of #150277 - JonathanBrouwer:rollup-gvmdw36, r=JonathanBrouwer
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#150098 (remove `legacy_const_generic_args` cache)
 - rust-lang/rust#150155 (fix ICE when {{root}} appears in import suggestions)
 - rust-lang/rust#150267 (`rust-analyzer` subtree update)
 - rust-lang/rust#150274 (Fix typo)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-12-22 17:03:07 +00:00
Ralf Jung
9d52e4bcbf
Merge pull request #4783 from RalfJung/android
readme: update android state
2025-12-22 16:49:01 +00:00
Jonathan Brouwer
bfca3ee37f
Rollup merge of #150274 - ada4a:patch-4, r=Kivooeo
Fix typo
2025-12-22 17:33:38 +01:00
Jonathan Brouwer
4271f82315
Rollup merge of #150267 - lnicola:sync-from-ra, r=lnicola
`rust-analyzer` subtree update

Subtree update of `rust-analyzer` to 31d2019672.

Created using https://github.com/rust-lang/josh-sync.

r? `@ghost`
2025-12-22 17:33:37 +01:00
Jonathan Brouwer
520a3c41cd
Rollup merge of #150155 - Aditya-PS-05:fix/ice-150103-root-in-suggestions, r=estebank
fix ICE when {{root}} appears in import suggestions

Fixes rust-lang/rust#150103

When wrong nested imports like `use A::{::Fish}` were used, the internal {{root}} would appear in diagnostic suggestions, causing an ICE in `join_path_idents` which asserted that **{{root}} should only appear at the start of a path**.

r? ``@matthiaskrgr``
2025-12-22 17:33:37 +01:00
Jonathan Brouwer
aa93a61eb2
Rollup merge of #150098 - Bryntet:perf-testing, r=JonathanBrouwer
remove `legacy_const_generic_args` cache

putting this here to run perf
2025-12-22 17:33:36 +01:00
Ralf Jung
9ae46aa9a3 readme: update android state 2025-12-22 17:23:53 +01:00
Ralf Jung
37e6101bb8
Merge pull request #4757 from royAmmerschuber/feature/multi_exposed_main
Tree Borrows: multiple invalid exposed nodes on main subtree
2025-12-22 16:23:05 +00:00
Ada Alakbarova
3f8b25771d
Fix typo 2025-12-22 16:50:41 +01:00
Roy Ammerschuber
26ef77a94a tree borrows: detect no_valid_exposed_references errors accurately 2025-12-22 16:30:34 +01:00
Laurențiu Nicola
7eeaa7ad48 Fix name collision warning 2025-12-22 16:44:06 +02:00
Esteban Küber
42ec5c7b32 Detail expectation on non-() block tail in if then condition with no else
When encountering an `if` expression with no `else` where the then
block has a tail expression, we emit an E0308 type error. We now explain
why `()` was expected.
2025-12-22 13:55:49 +00:00
bors
e1212ea79b Auto merge of #150187 - RalfJung:visitor-in-mem-order, r=nnethercote
interpreter/visitor: always iterate in in-memory order

Now that this is directly available in the type, there's no reason to ever iterate in any other order.
2025-12-22 13:52:39 +00:00
Lukas Wirth
894881f07c
Merge pull request #20521 from A4-Tacks/suggest-break-expr
Add BreakExpr completion suggest
2025-12-22 12:36:29 +00:00
A4-Tacks
7b427ce474
Add BreakExpr completion suggest
- Move `ide::goto_definition::find_loops`
  into `ide_db::syntax_helpers::node_ext::find_loops`
2025-12-22 20:13:56 +08:00
bors
e951f470d7 Auto merge of #150240 - JonathanBrouwer:rollup-anx8c35, r=JonathanBrouwer
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#149840 (Update comment for `STAGE0_MISSING_TARGETS`)
 - rust-lang/rust#150109 (crash test readme: point to rustc-dev-guide)
 - rust-lang/rust#150204 (Port `#[cfi_encoding]` to attribute parser)
 - rust-lang/rust#150237 (Skip tidy target-specific check for `run-make-cargo` too)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-12-22 10:45:04 +00:00
Lukas Wirth
8bc2265529
Merge pull request #20595 from A4-Tacks/conv-iter-for-to-for-indent
Fix indent for convert_iter_for_each_to_for
2025-12-22 07:51:03 +00:00
Jonathan Brouwer
fdc84e8aa5
Rollup merge of #150237 - jieyouxu:tidy-run-make-cargo, r=Zalathar
Skip tidy target-specific check for `run-make-cargo` too

I forgot to change this when implementing the run-make fission.

Noticed in https://github.com/rust-lang/rust/pull/149624#issuecomment-3609640422.
2025-12-22 07:58:50 +01:00
Jonathan Brouwer
d31a2bedfb
Rollup merge of #150204 - Bryntet:parse_cfi_encoding, r=JonathanBrouwer
Port `#[cfi_encoding]` to attribute parser

The error message is kind of saying the same thing twice, would like input on which .expect function I should use instead to not have it be double, otherwise this passes all tests locally where this attribute is used

r? `@JonathanBrouwer`
2025-12-22 07:58:49 +01:00
Jonathan Brouwer
43f270a0ef
Rollup merge of #150109 - tshepang:patch-1, r=jieyouxu
crash test readme: point to rustc-dev-guide

There is information that is duplicated here and in rustc-dev-guide, and the latter is more comprehensive, so point there.
2025-12-22 07:58:48 +01:00
Jonathan Brouwer
e1f41dc84b
Rollup merge of #149840 - jieyouxu:bootstrap-missing-stage0, r=Zalathar
Update comment for `STAGE0_MISSING_TARGETS`
2025-12-22 07:58:48 +01:00
bors
000ccd651d Auto merge of #148766 - cjgillot:mir-const-runtime-checks, r=RalfJung,saethlin
Replace Rvalue::NullaryOp by a variant in mir::Operand.

Based on https://github.com/rust-lang/rust/pull/148151

This PR fully removes the MIR `Rvalue::NullaryOp`. After rust-lang/rust#148151, it was only useful for runtime checks like `ub_checks`, `contract_checks` and `overflow_checks`.

These are "runtime" checks, boolean constants that may only be `true` in codegen. It depends on a rustc flag passed to codegen, so we need to represent those flags cross-crate.

This PR replaces those runtime checks by special variants in MIR `ConstValue`. This allows code that expects constants to manipulate those as such, even if we may not always be able to evaluate them to actual scalars.
2025-12-22 06:58:28 +00:00
A4-Tacks
1c26670e64
Fix indent for convert_iter_for_each_to_for
Example
---
```rust
fn main() {
    {
        let it = core::iter::repeat(92);
        it.$0for_each(|param| match param {
            (x, y) => println!("x: {}, y: {}", x, y),
        });
    }
}
```

**Before this PR**:

```rust
fn main() {
    {
        let it = core::iter::repeat(92);
        for param in it {
            match param {
                    (x, y) => println!("x: {}, y: {}", x, y),
                }
        }
    }
}
```

**After this PR**:

```rust
fn main() {
    {
        let it = core::iter::repeat(92);
        for param in it {
            match param {
                (x, y) => println!("x: {}, y: {}", x, y),
            }
        }
    }
}
```
2025-12-22 14:47:27 +08:00
Jieyou Xu
de0945b2a7
bootstrap: update comment for STAGE0_MISSING_TARGETS 2025-12-22 10:54:07 +08:00
Michael Howell
0596552986 Use arithmetic instead of bitshifts
Co-authored-by: Yotam Ofek <yotam.ofek@gmail.com>
2025-12-21 19:35:57 -07:00
bors
acfd264f4d Auto merge of #150228 - matthiaskrgr:rollup-ymp54q0, r=matthiaskrgr
Rollup of 11 pull requests

Successful merges:

 - rust-lang/rust#146377 (Don't strip shebang in expr-ctxt `include!(…)`)
 - rust-lang/rust#149812 (Add const default for OnceCell and OnceLock)
 - rust-lang/rust#149882 (miri: add -Zbinary-dep-depinfo to dependency builds)
 - rust-lang/rust#150009 (Enable llvm-libunwind by default for Hexagon targets)
 - rust-lang/rust#150035 (fix docustring on fetch_or)
 - rust-lang/rust#150082 (tests/ui/traits/fmt-pointer-trait.rs: Add HRTB fn pointer case)
 - rust-lang/rust#150160 (Fix ICE (rust-lang/rust#149980) for invalid EII in statement position)
 - rust-lang/rust#150184 (mir_build: Use the same length type for `TestableCase::Slice` and `TestKind::Len`)
 - rust-lang/rust#150185 ([rustdoc] Add missing close tags in extern crate reexports)
 - rust-lang/rust#150191 (change non-canonical clone impl to {*self}, fix some doc comments)
 - rust-lang/rust#150203 (Drop the From derive macro from the v1 prelude)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-12-22 01:58:47 +00:00
Jieyou Xu
5fc00306a8
tidy: skip target-specific check for run-make-cargo too
I forgot to change this when implementing the run-make fission.
2025-12-22 09:40:21 +08:00
bors
f41f40408d Auto merge of #150231 - JonathanBrouwer:rollup-btei0hm, r=JonathanBrouwer
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#149512 (Fix d32 usage in Arm target specs )
 - rust-lang/rust#150210 (tests/debuginfo/function-arg-initialization.rs: Stop disabling SingleUseConsts MIR pass)
 - rust-lang/rust#150221 (rustdoc: handle macro expansions in types)
 - rust-lang/rust#150223 (GVN: Adds the `insert_unique` method)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-12-21 22:49:21 +00:00
Edvin Bryntesson
d719a49b28
Port #[cfi_encoding] to attribute parser 2025-12-21 22:11:33 +01:00
Edvin Bryntesson
38c667265b
add expected_non_empty_string_literal to attribute parser
Signed-off-by: Edvin Bryntesson <epost@edvinbryntesson.se>
2025-12-21 21:45:38 +01:00
Michael Howell
d2eaec9e25 Clean up needlessly complex math and conditions
Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
2025-12-21 13:26:43 -07:00
Jonathan Brouwer
4b94235a66
Rollup merge of #150223 - dianqk:gvn-insert_unique, r=cjgillot
GVN: Adds the `insert_unique` method

The new `insert_unique` method is used to handle `IndexVec<VnIndex, T>` such as `evaluated` and `rev_locals`.
2025-12-21 21:16:36 +01:00
Jonathan Brouwer
e0dba518b5
Rollup merge of #150221 - el-ev:missing-par-ice-150154, r=fmease
rustdoc: handle macro expansions in types

- Closes rust-lang/rust#150154.
- Closes rust-lang/rust#150197.

This PR implements `visit_ty` in `ExpandedCodeVisitor` to correctly handle macro expansions in type positions (e.g., `let _: foo!();`). This also fixes a crash in rustdoc caused by the same issue.

Before:
<img width="419" height="182" alt="image" src="https://github.com/user-attachments/assets/89627230-032d-4ba1-af2e-8aa9a9cc6627" />
After:
<img width="288" height="107" alt="image" src="https://github.com/user-attachments/assets/c06caeda-28b7-45b8-845a-e7fe784a82e4" />
2025-12-21 21:16:35 +01:00
Jonathan Brouwer
0177e98a6d
Rollup merge of #150210 - Enselic:run-mir-pass, r=saethlin
tests/debuginfo/function-arg-initialization.rs: Stop disabling SingleUseConsts MIR pass

This test passes locally for me. Let's see if it passes CI too.

Discovered while I worked on https://github.com/rust-lang/rust/pull/150201.

CC rust-lang/rust#128945
2025-12-21 21:16:34 +01:00
Jonathan Brouwer
81b81faac1
Rollup merge of #149512 - adamgemmell:dev/adagem01/armv7-d32-fix, r=Amanieu
Fix d32 usage in Arm target specs

Fixes https://github.com/rust-lang/rust/issues/149399 - after checking with an LLVM engineer Rust's feature implications do correctly map to LLVM's. The target specs originally had +vfp3,+d16, but were mistakenly fixed to +vfp3,-d32 which disables vfp3 again.

Some targets specify +vfp2,-d32, and since vfp2 shouldn't imply d32 the -d32 is unneeded.

The list of Arm features is quite old and since Arm is now a target maintainer of many of them we'll go in and update them. We should probably add vfp3d16 and similar as rust has no way to express these right now after d16 was removed.

The LLVM features expand like this:

```
vfp4 -> vfp3 + fp16 + vfp4d16 + vfp4sp
vfp4d16 -> vfp3d16 + fp16 + fp64 + vfp4d16sp
vfp4sp -> vfp3sp + fp16 + d32 + vfp4d16sp
vfp4d16sp -> vfp3d16sp + fp16
vfp3 -> vfp2 + vfp3d16 + vfp3sp
vfp3d16 -> vfp2 + fp64 + vfp3d16sp
vfp3sp -> vfp2 + d32 + vfp3d16sp
vfp3d16sp -> vfp2sp
vfp2 -> vfp2sp + fp64
vfp2sp -> fpregs
```

`-neon` might be unnecessary too in many of these cases, but some default CPUs that Rust specifies will turn Neon on so that needs a bit more care. I can't see any LLVM cpus that enable D32.

Old description:

> Fixes https://github.com/rust-lang/rust/issues/149399 - this implication was likely a mistake and isn't enforced by LLVM. This is is a breaking change and any users specifying `vfp2/3/4` via `-Ctarget-features` or the `target_feature` attribute will need to add `d32` in to get the same behaviour. The target features are unstable so this is ok for Rust, and this is necessary as otherwise there's no way to specify a `vfp2-d16` configuration, for example.
>
> I expect these targets would have been broken by https://github.com/rust-lang/rust/pull/149173 as `-d32` would have disabled any `+vfpX` feature before it. With the removal of the implication the `-d32` went back to being unnecessary, but I've removed it anyway.
>
> As ``@RalfJung`` pointed out, thumbv7a-nuttx-eabihf looks to have been relying on this implication so I've added `+d32` to it's target spec.
2025-12-21 21:16:33 +01:00
Matthias Krüger
c91cbcd49c
Rollup merge of #150203 - jtgeibel:drop-From-derive-macro-from-prelude, r=jdonszelmann
Drop the From derive macro from the v1 prelude

This was accidentally added to the prelude in 3f4dc1e02d.

Fixes: rust-lang/rust#150165

r? `````@jdonszelmann`````
2025-12-21 18:50:47 +01:00
Matthias Krüger
87457c563f
Rollup merge of #150191 - hkBst:clippy-fix-15, r=Kivooeo
change non-canonical clone impl to {*self}, fix some doc comments
2025-12-21 18:50:46 +01:00
Matthias Krüger
d107e95043
Rollup merge of #150185 - lambda:rustdoc-missing-close-tags-reexport, r=GuillaumeGomez
[rustdoc] Add missing close tags in extern crate reexports

Fixes rust-lang/rust#150176
2025-12-21 18:50:45 +01:00
Matthias Krüger
e0b5d9364b
Rollup merge of #150184 - Zalathar:slice-len, r=saethlin
mir_build: Use the same length type for `TestableCase::Slice` and `TestKind::Len`

If we convert the minimum length to `u64` up-front when creating `TestableCase::Slice`, we can avoid more conversions to `u64` later.

There should be no change to compiler behaviour.
2025-12-21 18:50:44 +01:00
Matthias Krüger
5e365fd9de
Rollup merge of #150160 - jdonszelmann:fix-149980, r=Kivooeo
Fix ICE (#149980) for invalid EII in statement position

Based on https://github.com/rust-lang/rust/pull/150159

Fixes rust-lang/rust#149980
2025-12-21 18:50:44 +01:00