Commit Graph

24856 Commits

Author SHA1 Message Date
Jacob Pratt 9ebe418dc6 Rollup merge of #153038 - pthariensflame:syncview-rename, r=Amanieu
core::sync: rename `Exclusive` to `SyncView` and make improvements

This PR implements the renaming of `core::sync::Exclusive` to `SyncView` as decided in rust-lang/rust#98407.  To preserve the ability to search for the old name, it adds `Exclusive` as a `doc_alias`.

It also makes the following additional changes:

- Converting the `get_mut` method to being an instance of `AsMut::as_mut`.  In the process, it makes both the new `impl AsMut` and the existing `impl AsRef` `const`, and it also renames `get_pin_mut` to `as_pin_mut` for consistency.  This direction follows a suggestion from rust-lang/rust#98407.
- Adding an `as_pin` method that can only be used when the wrapped type implements `Sync`, to complete the square of access methods.
- Making as many of the existing `impl`s `const` as possible; this involved making the existing `impl Default` no longer derived.
- Adding `impl`s for `AsyncFnOnce`, `AsyncFnMut`, and `AsyncFn`, akin to the existing `impls` for `FnOnce`, `FnMut`, and `Fn`.

It does not yet do the following, which may be desirable:

- Fixing/improving the documentation to address the concern pointed out in rust-lang/rust#146245.

It previously did the following, but this was removed after discussion:
- Adding an `impl` for (`const`) `Iterator`, which felt in line with the existing `impl`s for `Future` and `Coroutine`.
2026-04-09 02:31:08 -04:00
Jacob Pratt 1166f31d43 Rollup merge of #155017 - fmease:update-issue-number-unstable_syntax_pre_expansion, r=Kivooeo
Update tracking issue number of future-incompatibility lint `unstable_syntax_pre_expansion`

Issue rust-lang/rust#65860 has never been a proper tracking issue, it has always been a normal issue that reported a pass→fail regression which was subsequently fixed and which elicited a discussion spanning 50 comments. Years later the formerly offending errors were reintroduced as warnings which link to said issue (see section *Pre-History* in issue rust-lang/rust#154045 for details).

A few weeks ago I closed this issue (https://github.com/rust-lang/rust/issues/65860#issuecomment-4083652176) in favor of a new super focused & structured tracking issue, rust-lang/rust#154045. That means people now have to jump through hoops to arrive at the new tracking issue which is less than ideal (it's very likely that this user had to do so: https://github.com/rust-lang/rust/issues/154045#issuecomment-4207339422), let's fix that.

Part of rust-lang/rust#154045.
2026-04-08 23:04:02 -04:00
Jacob Pratt 6bd1a6cd31 Rollup merge of #154991 - cijiugechu:fix/next-solver-transmutefrom-ice, r=Kivooeo
Fix ICE in next-solver TransmuteFrom candidate

Treat TransmuteFrom goals with non-region inference variables as ambiguous before running transmutability, matching the old solver.

Closes rust-lang/rust#153370 .
2026-04-08 23:03:59 -04:00
Jacob Pratt defee2995b Rollup merge of #153888 - MaximilianAzendorf:issue-153583, r=Kivooeo
Avoid stack overflow in FindExprBySpan

Fixes rust-lang/rust#153583.

Deeply nested `?` desugarings can build a very deep HIR expression spine.
When `FindExprBySpan` walks that expression during error reporting, the
recursive `visit_expr` traversal can overflow the stack before rustc emits the
actual diagnostic.

This wraps the recursive expression walk in `ensure_sufficient_stack`, which
lets the compiler report the expected E0277 instead of crashing.

Added a UI regression test for a deeply nested `?` chain.
2026-04-08 23:03:58 -04:00
Jacob Pratt 827c27d39a Rollup merge of #154856 - bjorn3:fix_dylib_profiler_builtins, r=mati865
Fix linking two dylibs together when both depend on profiler_builtins

See the comment inside this commit for why.

Fixes a regression from https://github.com/rust-lang/rust/pull/150014 reported at [#t-compiler > 1.94 profiler_builtin linkage in dylibs](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/1.2E94.20profiler_builtin.20linkage.20in.20dylibs/with/583704962).
2026-04-08 23:03:57 -04:00
Jacob Pratt bcb5909a14 Rollup merge of #152859 - ShoyuVanilla:issue-152789, r=lcnr
`-Znext-solver` use the trait object's own bounds instead of goal when considering builtin object bounds

Fixes https://github.com/rust-lang/rust/issues/152789 and fixes https://github.com/rust-lang/rust/issues/151329

r? lcnr
2026-04-08 23:03:57 -04:00
Jacob Pratt 9eb03e5bd2 Rollup merge of #150316 - ShoyuVanilla:fudge-checks, r=lcnr
Do not use non-wf input expectations from fudge when checking function calls

cc https://github.com/rust-lang/rust/issues/149379

r? lcnr

# FCP: Do not use non-wf input expectations from fudge when checking function calls

## What is fudging?

https://github.com/rust-lang/rust/blob/71e00273c0921e1bc850ae8cc4161fbb44cfa848/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs#L168-L170

Consider this coercion site:

`let _: Box<dyn Fn(&str) -> usize> = Box::new(|s| s.len());`

We rely on the expectation to eagerly infer the type of `s` to be `&str`. However, `dyn Fn(&str) -> usize` is not a valid type as the argument of `Box::new`, as it is not `Sized`.

*Fudging* is the mechanism we use to propagate the expectation through the `Box::new` call without constraining its generic parameter.

Fudging computes the expected argument types by acting as if we're able to propagate the expected return type directly through the function, without any coercions on the return site.

Given that we may actually want to coerce afterwards, we cannot actually commit any constraints here. We therefore compute the expectations for the function arguments in a `probe` and rely on *fudging* to be able to name any inference variables created inside of the probe.

After the fudging step, we weaken the resulting expectation if it is an unsized type in the following lines:
https://github.com/rust-lang/rust/blob/71e00273c0921e1bc850ae8cc4161fbb44cfa848/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs#L354
https://github.com/rust-lang/rust/blob/71e00273c0921e1bc850ae8cc4161fbb44cfa848/compiler/rustc_hir_typeck/src/expectation.rs#L77-L89

Because function arguments must be `Sized`, this weakening prevents us from applying wrong, unsized coercions to them.

## How fudging currently goes wrong

We have an opened issue for tracking such cases: https://github.com/rust-lang/rust/issues/149379.

Broadly, the failures seem to fall into two buckets.

### We may end up with non–well-formed expectations

Fudging can produce an expected type that is not well-formed.

That would eventually result in an error failing the well-formedness check, either when we do the coercion with the expected argument types, or when we select the remaining obligations.

```rust
fn foo<T>(x: (T, ())) -> Box<T> {
    Box::new(x.0)
}

fn main() {
    // We use `(dyn Send, ())` as the expectation the argument.
    let _: Box<dyn Send> = foo(((), ()));
}
```

### Weakening fudged expectation is not covering all the cases

```rust
fn field_to_box<T>(x: &(T,)) -> &T {
    &x.0
}
fn main() {
    // `Expectation::rvalue_hint` only checks whether the whole argument
    // itself is `Sized`. It does not check whether the function requires
    // its generic parameters to be `Sized`.
    let _: &dyn Send = field_to_box(&(1,));
}
```

## What this PR fixes

### One of the problematic cases of the issue

This PR fixes the first case, by simply checking well-formedness of the each expected argument types inside the fudge scope.

This is a reasonable change because:
- Non well-formed expectation would result in a well-formedness error so not using such expectation wouldn't make any previously compiled code being not compiled anymore
- Dropping a non well-formed expectation does not mean we stop providing expectations for argument coercions altogether.
  If fudging fails, we still fall back to using the types from the function signature as expectations in the usual path:
  https://github.com/rust-lang/rust/blob/71e00273c0921e1bc850ae8cc4161fbb44cfa848/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs#L330-L336

#### Related tests

- Fixes [tests/ui/coercion/fudge-inference/fn-ret-trait-object-propagated-to-inputs-issue-149379-1.rs](https://github.com/rust-lang/rust/pull/150316/commits/5668ad597d8293dcfd8917ca6e8f78d2c06555d3#diff-1468a6d8495f7adfb4a64508f002bb934c13d13871662de6efd60433649401fd)

### Limited for `-Znext-solver`

Separately (and not directly tied to the above issue), this PR also fixes a next-solver regression tracked at: https://github.com/rust-lang/trait-system-refactor-initiative/issues/259.

That regression was introduced by https://github.com/rust-lang/rust/pull/149320, which started normalizing expected function input types inside the fudge scope.
Because all inference-variable relationships and pending obligations are dropped out when we exit the fudge scope, we drop the ambiguous goal used to normalize, leaving us with an unconstrained inference variable in the expectation.

This PR fixes that by normalizing the expectation outside the fudge scope, so the resulting normalization obligations are preserved to the `InferCtxt`'s `ObligationCtxt`.

#### Related tests

- Fixes [tests/ui/traits/next-solver/fudge-inference/do-not-drop-ambig-normalization.rs](https://github.com/rust-lang/rust/pull/150316/files#diff-42e97f178fbdee7c3405ae12409eb0bca4eec92488971c703b26c083eadf728a)

## Does this PR break anything

I don't think there should be any breakage affecting the old solver.

The separate expectation normalization change only affecting the new solver does break an existing [test](https://github.com/rust-lang/rust/pull/150316/files#diff-3b946a09e063aad2a4fa6b0893508d5ffab78763b8465abfe1f689d349fda815).
This is unfortunate but I think this change should be done because

- The broken test also doesn't compile with the old solver
- The expectation normalization change is necessary to compile stuff supported on stable

## What this PR doesn't fix

This PR doesn't fix the second case -- *Weakening fudged expectation is not covering all the cases*.

@lcnr has [suggested](https://rust-lang.zulipchat.com/#narrow/channel/144729-t-types/topic/expectations.20from.20fudging.20are.20a.20mess.20.23149379/near/560625205) the following solution for that problem:
> check whether a function where-bound errors without an out coercion, if so, weaken the expectation to `ExpectRvalueLikeUnsized`

I experimented with this and it works well in many cases.
However, on the old solver, checking where-bounds cannot reliably be treated as speculative: if we hit an overflow while checking the where-bounds, the old solver can fail the entire compilation rather than merely treating the check as failed and relaxing the expectation.

Since this second class of issues affects both the old solver and the next-solver, it seems preferable to keep the conservative behavior for now, at least until the next-solver is stabilized, rather than introducing a next-solver-only relaxation that might create new regressions and complicate stabilization efforts.

#### Related tests

- Does NOT Fix [tests/ui/coercion/fudge-inference/expectated-input-not-satisfying-fn-bounds-issue-89299.rs](https://github.com/rust-lang/rust/pull/150316/files#diff-fdcfa8ab660c052dbe246db279d167ea8a309bfe10ca6163f7fa1836be2b30d6)
- Does NOT Fix [tests/ui/coercion/fudge-inference/expectated-input-not-satisfying-fn-bounds-issue-149881.rs](https://github.com/rust-lang/rust/pull/150316/files#diff-1ccbb181cbf164841ca5af350ecf903c802a4854bda309e83e91c3b917809a55)
- Does NOT Fix [tests/ui/coercion/fudge-inference/fn-ret-trait-object-propagated-to-inputs-issue-149379-3.rs](https://github.com/rust-lang/rust/pull/150316/files#diff-b12e01cc3c265db42f135d67425d8b2bd0d9c44c680b3e8c49d1f845a0b25d09)
2026-04-08 23:03:56 -04:00
cijiugechu ee135be041 Fix ICE in next-solver TransmuteFrom candidate
Treat TransmuteFrom goals with non-region inference variables as ambiguous before running transmutability, instead of computing layouts for unresolved types. The old solver already treated these goals as ambiguous, so only the next solver could hit this ICE.
2026-04-09 10:12:18 +08:00
bors d0442e2800 Auto merge of #155011 - JonathanBrouwer:rollup-9GJWM3g, r=JonathanBrouwer
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#154912 (Remove `BuiltinLintDiag`)
 - rust-lang/rust#154598 (test `#[naked]` with `#[link_section = "..."]` on windows)
 - rust-lang/rust#154719 (Hexagon inline asm: add reg_pair, vreg, vreg_pair, and qreg register classes)
 - rust-lang/rust#154057 (Parenthesize block-like expressions in index base of pretty printer)
 - rust-lang/rust#154893 (make `expected_literal` positive)
 - rust-lang/rust#155002 (Clarify that `core::range` ranges do not have special syntax)
2026-04-08 23:20:07 +00:00
León Orell Valerian Liehr 2d33b30eb1 Update tracking issue number of future-incompatibility lint unstable_syntax_pre_expansion 2026-04-09 01:08:52 +02:00
Jonathan Brouwer 8be4c463be Rollup merge of #154057 - aytey:fix-block-index-paren, r=fmease
Parenthesize block-like expressions in index base of pretty printer

The AST pretty printer produces invalid Rust when a block expression is the base of an index operation inside a macro expansion. This is a gap in the parenthesization fix from rust-lang/rust#119105 — the `FixupContext` approach handles statement position but not the case where a block-index is nested inside another expression.

The following is a correct program:

```rust
macro_rules! block_arr {
    () => {{ [0u8; 4] }};
}

macro_rules! as_slice {
    () => {{ &block_arr!()[..] }};
}

fn main() { let _: &[u8] = as_slice!(); }
```

But `rustc -Zunpretty=expanded` produces output that is not valid Rust, because the closing brace of `{ [0u8; 4] }` creates a statement boundary, causing the parser to treat `[..]` as a separate expression:

```rust
fn main() { let _: &[u8] = { &{ [0u8; 4] }[..] }; }
```

```
error: expected one of `.`, `;`, `?`, `}`, or an operator, found `[`
```

Fixed output after this change:

```rust
fn main() { let _: &[u8] = { &({ [0u8; 4] })[..] }; }
```

Since `{ ... }[...]` never parses as indexing a block regardless of context, the fix unconditionally parenthesizes "complete" expressions (block, match, if, loop, etc.) when they appear as the base of an index operation.
2026-04-08 23:04:35 +02:00
Jonathan Brouwer 3fb712c80a Rollup merge of #154719 - androm3da:hexagon-inline-asm-register-classes, r=JohnTitor
Hexagon inline asm: add reg_pair, vreg, vreg_pair, and qreg register classes

Add three new register classes for the Hexagon inline assembly backend:

* `reg_pair`: GPR double registers (r1:0 through r27:26)
* `vreg`: HVX vector registers (v0-v31)
* `qreg`: HVX predicate registers (q0-q3), clobber-only for now
2026-04-08 23:04:34 +02:00
Jonathan Brouwer b040d5493e Rollup merge of #154598 - folkertdev:windows-naked-link-section, r=mati865
test `#[naked]` with `#[link_section = "..."]` on windows

As a part of https://github.com/rust-lang/rust/pull/147811 I ran into that we actually don't match (current) LLVM output.

r? @mati865
2026-04-08 23:04:33 +02:00
bors 9004856428 Auto merge of #153838 - oli-obk:use-tree-span, r=davidtwco
Use fine grained component-wise span tracking in use trees

This often produces nicer spans and even doesn't need a Span field anymore (not that I expect the unused field to affect any perf, but still neat).
2026-04-08 20:09:27 +00:00
Shoyu Vanilla ba3b486c3c Use the trait object's own bounds instead of goal when considering builtin object bounds 2026-04-09 02:13:55 +09:00
Shoyu Vanilla bec43041b3 Clarify old solver behavior with revisions in a test 2026-04-09 01:57:29 +09:00
Andrew V. Teylu 27e3d26dfb rename test 2026-04-08 15:01:38 +01:00
Andrew V. Teylu 56f43b5142 Parenthesize block-like expressions in call callee of pretty printer
When a macro expands to a call whose callee is a block (or other
"complete" expression like `match`, `if`, `loop`), the AST pretty
printer emits the callee without parentheses. In statement position
the closing brace ends the expression and the argument list is parsed
as a separate tuple expression, producing a parse error.
2026-04-08 14:52:01 +01:00
bors c771f6ee80 Auto merge of #154985 - JonathanBrouwer:rollup-a467ECK, r=JonathanBrouwer
Rollup of 15 pull requests

Successful merges:

 - rust-lang/rust#153995 (Use convergent attribute to funcs for GPU targets)
 - rust-lang/rust#154184 (stabilize s390x vector registers)
 - rust-lang/rust#151898 (constify DoubleEndedIterator)
 - rust-lang/rust#154235 (remove unnecessary variables and delimiter check)
 - rust-lang/rust#154473 (move borrow checker tests)
 - rust-lang/rust#154745 (Replace span_look_ahead with span_followed_by)
 - rust-lang/rust#154778 (make field representing types invariant over the base type)
 - rust-lang/rust#154867 (Fix private fields diagnostics and improve error messages)
 - rust-lang/rust#154879 (Don't store `pattern_ty` in `TestableCase`)
 - rust-lang/rust#154910 (Suppress `unreachable_code` lint in `derive(PartialEq, Clone)`)
 - rust-lang/rust#154923 (Fix ICE in next-solver dyn-compatibility check)
 - rust-lang/rust#154934 (Add getters for `rustc_pattern_analysis::constructor::Slice` fields)
 - rust-lang/rust#154938 (match exhaustiveness: Show the guard exhaustivity note only when it's the guards alone that cause non-exhaustiveness)
 - rust-lang/rust#154961 (Use derived impl for `GappedRange` subdiagnostic)
 - rust-lang/rust#154980 (rustc-dev-guide subtree update)
2026-04-08 13:30:13 +00:00
Jonathan Brouwer 6b8320f4b7 Rollup merge of #154938 - jakubadamw:issue-104653, r=Nadrieril
match exhaustiveness: Show the guard exhaustivity note only when it's the guards alone that cause non-exhaustiveness

Only show the "match arms with guards don't count towards exhaustivity" note when removing all guards would make the match exhaustive, but also in the cases when the match contains arms without guards. Previously, this note was shown only if all arms had guards, but even if the patterns themselves were insufficient to cover all valid values of a type.

Do this by rerunning the exhaustiveness analysis with guards stripped to determine whether the guards are actually the cause of non-exhaustiveness. This only happens on an actual exhaustiveness error, so should not be a performance concern.

This will make a program like:

```rust
fn main() {
    let some_condition = true;
    let some_option: Option<u8> = None;

    let _res = match some_option {
        Some(val) if some_condition => val,
        None => 0,
    };
}
```

produce the note ”match arms with guards don't count towards exhaustivity” that previously would not have been appearing.

Closes rust-lang/rust#104653 as I think this addresses the spirit of that issue. I don’t believe it’s necessary to be any more elaborate in the diagnostics here?
2026-04-08 14:22:06 +02:00
Jonathan Brouwer faefad7c24 Rollup merge of #154923 - cijiugechu:fix-ice-unsafe-binders-next-solver, r=TaKO8Ki
Fix ICE in next-solver dyn-compatibility check

The next solver treated error-containing dispatchability goals as proven and misclassified the trait as dyn compatible. Short-circuit receivers with type errors so object-method confirmation stays on the normal error path.

Tracking issue: rust-lang/rust#130516
Closes: rust-lang/rust#151311
2026-04-08 14:22:05 +02:00
Jonathan Brouwer 839aaee4c3 Rollup merge of #154910 - WaffleLapkin:unreachable-derive, r=nnethercote
Suppress `unreachable_code` lint in `derive(PartialEq, Clone)`

Resolves https://github.com/rust-lang/rust/issues/154900
2026-04-08 14:22:04 +02:00
Jonathan Brouwer 7300b254cd Rollup merge of #154867 - chenyukang:yukang-fix-151408-private-fields-diagnostic, r=Kivooeo
Fix private fields diagnostics and improve error messages

Fixes rust-lang/rust#151408

while the best solution may be check whether the code is under user's control, e.g. in the same workspace. but if user does not provide some fields, mention other private fields seems weird, see the test case:

```console
LL |     let _ = std::collections::HashMap {};
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: private field `base` that was not provided
```

since we already suggested to use associated function to construct, it's better to remove the note.

this fix only provide note on private fields when `did.is_local()` or user have already provide some fields.
2026-04-08 14:22:03 +02:00
Jonathan Brouwer 532c2b64d8 Rollup merge of #154778 - BennoLossin:frt-invariant, r=oli-obk
make field representing types invariant over the base type

We probably don't want to have any subtype relationship between any FRTs.

Reported-by: @dvdhrm "David Rheinsberg" <david@readahead.eu>
Link: https://rust-for-linux.zulipchat.com/#narrow/channel/288089-General/topic/Multiple.20LockedBy.20with.20Single.20Lock/near/579275908

r? @oli-obk
2026-04-08 14:22:02 +02:00
Jonathan Brouwer 4a3978abad Rollup merge of #154745 - chenyukang:yukang-fix-span-api, r=nnethercote
Replace span_look_ahead with span_followed_by

While reviewing that PR https://github.com/rust-lang/rust/pull/154703#discussion_r3031067780, I found that magic number 100, let's remove it, and seems `span_followed_by` is a better name.
2026-04-08 14:22:01 +02:00
Jonathan Brouwer 4ba9940cfc Rollup merge of #154473 - danieljofficial:move-tests-borrowck, r=Kivooeo
move borrow checker tests

Hi, I have moved some tests I think should be in the borrowck category. Please let me know if there are issues.  r? @Kivooeo
Related to rust-lang/rust#133895
2026-04-08 14:22:00 +02:00
Jonathan Brouwer 3e027ff0f0 Rollup merge of #154184 - folkertdev:stabilize-s390x-vector-registers, r=Amanieu
stabilize s390x vector registers

tracking issue: https://github.com/rust-lang/rust/issues/133416
reference PR: https://github.com/rust-lang/reference/pull/2215

Stabilizes s390x vector registers, e.g.

```rust
unsafe fn vreg_128(x: i128) -> i128 {
    let y;
    asm!("vlr {}, {}", out(vreg) y, in(vreg) x);
    y
}
```

The types that are accepted for vreg registers are

- all float types `f16`,  `f32`, `f64`, `f128`
- integer types `i32`, `i64` and `i128` and their unsigned counterparts
- integer vector types `i8x16`, `i16x8`, `i32x4`, `i64x2` and their unsigned counterparts
- float vector types `f16x8`, `f32x4` and `f64x2`

Support for all of these is tested in https://github.com/rust-lang/rust/blob/main/tests/assembly-llvm/asm/s390x-types.rs, and the types correspond with the LLVM definition in https://github.com/llvm/llvm-project/blob/df9eb79970c012990e829d174d181d575d414efe/llvm/lib/Target/SystemZ/SystemZRegisterInfo.td#L312-L339

The `f16`, `f16x8` and `f128` types are unstable, and so can't be used on stable in practice. They do show up in some error messages though.

`vreg` was previously only accepted as a clobber.

---

Currently the vector types in `core::arch::s390x` are still unstable. Separately stabilizing `vreg` is still useful because scalar types can also be put into `vreg`s.

## Implementation history

- https://github.com/rust-lang/rust/pull/131664
- https://github.com/rust-lang/rust/pull/150826

cc @uweigand @taiki-e
r? @Amanieu
2026-04-08 14:21:58 +02:00
Jonathan Brouwer 66a00ba2ef Rollup merge of #153995 - Flakebi:gpu-use-convergent, r=nnethercote
Use convergent attribute to funcs for GPU targets

On targets with convergent operations, we need to add the convergent attribute to all functions that run convergent operations. Following clang, we can conservatively apply the attribute to all functions when compiling for such a target and rely on LLVM optimizing away the attribute in cases where it is not necessary.

This affects the amdgpu and nvptx targets.

cc @kjetilkjeka, @kulst for nvptx
cc @ZuseZ4

r? @nnethercote, as you already reviewed this in the other PR

Split out from rust-lang/rust#149637, the part here should be uncontroversial.
2026-04-08 14:21:57 +02:00
Andrew V. Teylu 574d8774b9 Parenthesize block-like expressions in index base of pretty printer
The AST pretty printer produces invalid Rust when a block expression is
the base of an index operation inside a macro expansion. This is a gap
in the existing `FixupContext` parenthesization machinery — the approach
handles statement position but not the case where a block-index is
nested inside another expression.

The following is a correct program:

```rust
macro_rules! block_arr {
    () => {{ [0u8; 4] }};
}

macro_rules! as_slice {
    () => {{ &block_arr!()[..] }};
}

fn main() { let _: &[u8] = as_slice!(); }
```

But `rustc -Zunpretty=expanded` produces output that is not valid Rust,
because the closing brace of `{ [0u8; 4] }` creates a statement
boundary, causing the parser to treat `[..]` as a separate expression:

```rust
fn main() { let _: &[u8] = { &{ [0u8; 4] }[..] }; }
```

```
error: expected one of `.`, `;`, `?`, `}`, or an operator, found `[`
```

Fixed output after this change:

```rust
fn main() { let _: &[u8] = { &({ [0u8; 4] })[..] }; }
```

Since `{ ... }[...]` never parses as indexing a block regardless of
context, the fix unconditionally parenthesizes "complete" expressions
(block, match, if, loop, etc.) when they appear as the base of an index
operation.
2026-04-08 13:06:56 +01:00
Waffle Lapkin ddf9d4cfd5 suppress unreachable code lint in automatically derived impls
This is relevant for `derive(Clone, PartialEq)` on adts with fields of
type never.
2026-04-08 13:32:36 +02:00
Oli Scherer 9017621ace Use fine grained component-wise span tracking in use trees 2026-04-08 12:37:25 +02:00
bors e26dedca9d Auto merge of #154914 - Muscraft:update-annotate-snippets, r=jieyouxu
chore: Update annotate-snippets to 0.12.15

This PR updates `annotate-snippets` to [`0.12.15`](https://github.com/rust-lang/annotate-snippets-rs/blob/main/CHANGELOG.md#01215---2026-04-06), which includes a fix for rust-lang/rust#154258, as well as a number of other fixes over [`0.12.10`](https://github.com/rust-lang/annotate-snippets-rs/blob/main/CHANGELOG.md#01210---2025-12-01).

fixes rust-lang/rust#154258
2026-04-08 10:15:57 +00:00
bors c753cef0df Auto merge of #154976 - jhpratt:rollup-e8XWRVU, r=jhpratt
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#154460 (Deduplication: Pulled common logic out from lower_const_arg_struct)
 - rust-lang/rust#154609 (Enable `#[diagnostic::on_const]` for local impls)
 - rust-lang/rust#154678 (Introduce #[diagnostic::on_move] on `Rc`)
 - rust-lang/rust#154902 (rustdoc: Inherit inline attributes for declarative macros)
2026-04-08 05:22:42 +00:00
Jacob Pratt 084a82eec7 Rollup merge of #154902 - shivendra02467:fix-rustdoc-macro-inline, r=lolbinarycat
rustdoc: Inherit inline attributes for declarative macros

When explicitly re-exporting a declarative macro by name, rustdoc previously bypassed intermediate re-exports and dropped `#[doc(inline)]` attributes, causing the macro to be incorrectly stripped if the original definition was `#[doc(hidden)]`.

This updates `generate_item_with_correct_attrs` to walk the `reexport_chain` specifically for declarative macros, allowing them to inherit inline attributes exactly as glob imports do, while preserving strict visibility rules for standard items.

Fixes rust-lang/rust#154694
2026-04-07 23:05:32 -04:00
Jacob Pratt 3be7b83ddc Rollup merge of #154678 - rperier:diagnostic_on_move_for_the_rc_type, r=tgross35
Introduce #[diagnostic::on_move] on `Rc`

This is related to the tracking issue rust-lang/rust#154181 and to the original issue rust-lang/rust#149862.
2026-04-07 23:05:31 -04:00
Jacob Pratt a1f95873a8 Rollup merge of #154609 - mejrs:local_on_const, r=fmease
Enable `#[diagnostic::on_const]` for local impls

Previously this attribute only did something if it was on a foreign impl.
2026-04-07 23:05:30 -04:00
bors 30d0309fa8 Auto merge of #148486 - kpreid:vec-iter-drop, r=jhpratt
Explicitly forget the zero remaining elements in `vec::IntoIter::fold()`.



[Original description:] ~~This seems to help LLVM notice that dropping the elements in the destructor of `IntoIter` is not necessary. In cases it doesn’t help, it should be cheap since it is just one assignment.~~

This PR adds a function to `vec::IntoIter()` which is used used by `fold()` and `spec_extend()`, when those operations complete, to forget the zero remaining elements and only deallocate the allocation, ensuring that there will never be a useless loop to drop zero remaining elements when the iterator is dropped.

This is my first ever attempt at this kind of codegen micro-optimization in the standard library, so please let me know what should go into the PR or what sort of additional systematic testing might indicate this is a good or bad idea.
2026-04-08 02:06:51 +00:00
yukang ef9b7c2b8f replace span_look_ahead with span_followed_by 2026-04-08 09:34:24 +08:00
bors c756124775 Auto merge of #154958 - JonathanBrouwer:rollup-PEahluH, r=JonathanBrouwer
Rollup of 22 pull requests

Successful merges:

 - rust-lang/rust#150965 (Fix no results when searching for == in doc)
 - rust-lang/rust#153999 (Remove `TaggedQueryKey::def_kind`)
 - rust-lang/rust#154146 (Split out the creation of `Cycle` to a new `process_cycle` function)
 - rust-lang/rust#154147 (Do not attempt generating DllImport for extern types)
 - rust-lang/rust#154812 (Update Fira Mono License Information)
 - rust-lang/rust#154880 (bootstrap: minor improvements to download-rustc)
 - rust-lang/rust#154886 (Stabilize check-cfg suggestions for symbol)
 - rust-lang/rust#154889 (Update wasm-component-ld to 0.5.22)
 - rust-lang/rust#154928 (Fix pin docs)
 - rust-lang/rust#154942 (delegation: generate more verbose error delegation)
 - rust-lang/rust#153269 (GCI: During reachability analysis don't try to evaluate the initializer of overly generic free const items)
 - rust-lang/rust#154506 (Migrate some tests from `tests/ui/issues` to appropriate directories)
 - rust-lang/rust#154673 (Use a different name for fast try builds)
 - rust-lang/rust#154761 (coretests: add argument order regression tests for min_by/max_by/minmax_by)
 - rust-lang/rust#154795 (Add more info about where autodiff can be applied)
 - rust-lang/rust#154808 (Post-attribute ports cleanup pt. 1)
 - rust-lang/rust#154825 (constify `Step for NonZero<u*>`)
 - rust-lang/rust#154837 (library: std: motor: use OS' process::exit in abort_internal)
 - rust-lang/rust#154866 (add regression test for rust-lang/rust#146514)
 - rust-lang/rust#154922 (c-b: Export inverse hyperbolic trigonometric functions)
 - rust-lang/rust#154931 (delegation(small cleanup): remove not needed PhantomData)
 - rust-lang/rust#154950 (library: no `cfg(target_arch)` on scalable intrinsics)
2026-04-07 19:43:18 +00:00
Brian Cain aa9da4b859 Hexagon inline asm: add reg_pair, vreg, vreg_pair, and qreg register classes
Add new Hexagon inline asm register classes:
- reg_pair: GPR double registers (r1:0 through r27:26) for i64/f64 types
- vreg: HVX vector registers (v0-v31) for mode-dependent vector types
- vreg_pair: HVX vector pair registers (v1:0 through v31:30) for vector pairs
- qreg: HVX predicate registers (q0-q3), clobber-only

Key implementation details:
- GPR pairs use LLVM's 'd' register naming (d0-d13) for constraints
- HVX vector pairs use LLVM's 'w' register naming (w0-w15) for constraints
- Register overlap tracking for GPR pair<->single and HVX pair<->single conflicts
- HVX vector types are mode-dependent (64B vs 128B HVX length)

Note: vreg_quad (HVX vector quads) is not supported as LLVM's Hexagon
backend does not support vector quad types in inline asm constraints.
2026-04-07 09:27:32 -07:00
cijiugechu 89a4742773 Fix ICE in next-solver dyn-compatibility check
The next solver treated error-containing dispatchability goals as proven and misclassified the trait as dyn compatible. Short-circuit receivers with type errors so object-method confirmation stays on the normal error path.
2026-04-07 23:42:36 +08:00
Jonathan Brouwer 2c77e2474e Rollup merge of #154866 - Kcang-gna:add-regression-test-for-#146514, r=Kivooeo
add regression test for #146514

Fixes: rust-lang/rust#146514
2026-04-07 17:26:35 +02:00
Jonathan Brouwer 2875d8ef29 Rollup merge of #154506 - ujjwalvishwakarma2006:migrate-transmute-tests-02, r=Kivooeo
Migrate some tests from `tests/ui/issues` to appropriate directories

The following changes have been made in the pull request:

- `tests/ui/issues/issue-25746-bool-transmute.rs` ➝ `tests/ui/transmute/transmute-bool-u8.rs`
- `tests/ui/issues/issue-32377.{rs,stderr}` ➝ `tests/ui/intrinsics/transmute-phantomdata-generic-unequal-size.{rs,stderr}`

The issue links have also been added at the top of each `.rs` file.

r? Kivooeo
2026-04-07 17:26:28 +02:00
Jonathan Brouwer e3615a3c02 Rollup merge of #153269 - fmease:gci-reach-no-eval, r=BoxyUwU
GCI: During reachability analysis don't try to evaluate the initializer of overly generic free const items

We generally don't want the initializer of free const items to get evaluated if they have any non-lifetime generic parameters. However, while I did account for that in HIR analysis & mono item collection (rust-lang/rust#136168 & rust-lang/rust#136429), I didn't account for reachability analysis so far which means that on main we still evaluate such items if they are *public* for example.

The closed PR rust-lang/rust#142293 from a year ago did address that as a byproduct but of course it wasn't merged since its primary goal was misguided. This PR extracts & improves upon the relevant parts of that PR which are necessary to fix said issue.

Follow up to rust-lang/rust#136168 & rust-lang/rust#136429.
Partially supersedes rust-lang/rust#142293.
Part of rust-lang/rust#113521.

r? @BoxyUwU
2026-04-07 17:26:28 +02:00
Jonathan Brouwer e082227801 Rollup merge of #154942 - aerooneqq:delegation-unlowered-path-ice, r=petrochenkov
delegation: generate more verbose error delegation

After this PR we generate more verbose error delegation including path lowering, as there can be other code in generic args as in rust-lang/rust#154820. Now we access information for delegation lowering through ty-level queries and they require that the code should be lowered, even if it is in unresolved delegation.

Fixes rust-lang/rust#154820, part of rust-lang/rust#118212.

r? @petrochenkov
2026-04-07 17:26:27 +02:00
Jonathan Brouwer 70651e3f74 Rollup merge of #154886 - chenyukang:yukang-fix-cfg-sugg, r=JonathanBrouwer
Stabilize check-cfg suggestions for symbol

When I was working on https://github.com/rust-lang/rust/pull/154794, I found a weird CI fail https://github.com/rust-lang/rust/pull/154794#issuecomment-4192269333, I finally found this caused by unstable cfg suggestions by using `FxHashSet`(from PR https://github.com/rust-lang/rust/pull/154777). Because my PR by luck insert a new symbol, which makes the final diagnostic order changed.

It's a standalone issue, so it's better to fix in a separate PR.
2026-04-07 17:26:24 +02:00
Jonathan Brouwer edddc2137d Rollup merge of #154147 - mati865:raw-dylib-extern-types, r=petrochenkov
Do not attempt generating DllImport for extern types

Fixes https://github.com/rust-lang/rust/issues/154111
2026-04-07 17:26:22 +02:00
Jonathan Brouwer a5ff88b439 Rollup merge of #150965 - chenyukang:yukang-fix-doc-search-150921, r=notriddle,GuillaumeGomez
Fix no results when searching for == in doc

Fixes rust-lang/rust#150921

r? @GuillaumeGomez
2026-04-07 17:26:19 +02:00
danieljofficial d8c8028397 add issue links and blessborrowck tests 2026-04-07 15:35:24 +01:00
bors c3bd6289f6 Auto merge of #154758 - WaffleLapkin:aliassss, r=lcnr
`ty::Alias` refactor



This PR changes the following alias-related types from this:

```rust
pub enum AliasTyKind {
    Projection,
    Inherent,
    Opaque,
    Free,
}

pub struct AliasTy<I: Interner> {
    pub args: I::GenericArgs,
    pub def_id: I::DefId,
}

pub enum TyKind<I: Interner> {
    ...
    Alias(AliasTyKind, AliasTy<I>),
}
```
Into this:

```rust
pub enum AliasTyKind<I: Interner> {
    Projection { def_id: I::DefId },
    Inherent { def_id: I::DefId },
    Opaque { def_id: I::DefId },
    Free { def_id: I::DefId },
}

pub struct AliasTy<I: Interner> {
    pub args: I::GenericArgs,
    pub kind: AliasTyKind<I>,
}

pub enum TyKind<I: Interner> {
    ...
    Alias(AliasTy<I>),
}
```

... and then does a thousand other changes to accommodate for this change everywhere.

This brings us closer to being able to have `AliasTyKind`s which don't require a `DefId` (and thus can be more easily created, etc). Although notably we depend on both `AliasTyKind -> DefId` and `DefId -> AliasTyKind` conversions in a bunch of places still.

r? lcnr

----

A lot of these changes were done either by search & replace (via `ast-grep`) or on auto pilot, so I'm not quite sure I didn't mess up somewhere, but at least tests pass...
2026-04-07 12:56:57 +00:00