Commit Graph

323047 Commits

Author SHA1 Message Date
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
Jonathan Brouwer 1d0d17207c Rollup merge of #154912 - GuillaumeGomez:migrate-diag, r=JonathanBrouwer
Remove `BuiltinLintDiag`

Part of https://github.com/rust-lang/rust/issues/153099.

We're finally getting rid of `BuiltinLintDiag`! \o/

Next step, `AttributeLint`. :3

r? @JonathanBrouwer
2026-04-08 23:04:32 +02:00
bors 033b9255d4 Auto merge of #154987 - weihanglo:update-cargo, r=weihanglo
Cargo submodule update

11 commits in a357df4c26fc14514e66aae2a269456b5545c7db..101549dddbd2b08e806f50154e3aa4cb3374cc21
2026-04-03 16:47:15 +0000 to 2026-04-08 12:51:20 +0000
- Never include use extra-filename in build scripts (rust-lang/cargo#16855)
- fix(toml): Force script edition warnings on quiet  (rust-lang/cargo#16848)
- GitHub fast path uses `http_async` (rust-lang/cargo#16847)
- feat(manifest): allow git dependency alongside alternate registry (rust-lang/cargo#16810)
- fix(auth): add auth scheme hint to token rejected error for alt registries (rust-lang/cargo#16794)
- Warn on invalid jobserver file descriptors (rust-lang/cargo#16843)
- docs(unstable): List the minimum required MSRV for 'public' field (rust-lang/cargo#16841)
- feat(lints): Emit unused_dependencies lint (rust-lang/cargo#16600)
- fix(tree): clarify error message when `-i` is used without a package name (rust-lang/cargo#16818)
- fix: Typo in target.<cfg>.linker (rust-lang/cargo#16839)
- Send Content-Type header with cargo publish requests (rust-lang/cargo#16832)

r? ghost
2026-04-08 16:54:41 +00:00
Weihang Lo a7c49ec700 Cargo submodule update 2026-04-08 10:11:15 -04: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 aa6dfed2d6 Rollup merge of #154980 - tshepang:rdg-sync, r=tshepang
rustc-dev-guide subtree update

Subtree update of `rustc-dev-guide` to https://github.com/rust-lang/rustc-dev-guide/commit/912f6c606ab85868f773db8ee72605f957103da5.

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

r? @ghost
2026-04-08 14:22:08 +02:00
Jonathan Brouwer 5ef7a3d73f Rollup merge of #154961 - mejrs:yeet_the_fixme, r=Nadrieril
Use derived impl for `GappedRange` subdiagnostic
2026-04-08 14:22:07 +02: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 e1b15f4397 Rollup merge of #154934 - ChayimFriedman2:export-pat-slice, r=Nadrieril
Add getters for `rustc_pattern_analysis::constructor::Slice` fields

rust-analyzer needs that.

r? @Nadrieril
2026-04-08 14:22:05 +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 03cf715a05 Rollup merge of #154879 - Zalathar:pattern-ty, r=Nadrieril
Don't store `pattern_ty` in `TestableCase`

This field's only remaining use was in an assertion, but we can perform the same assertion earlier when constructing `TestableCase::Range`.

---

For background, the `pattern_ty` field was introduced in https://github.com/rust-lang/rust/pull/136435 to replace a reference to the full THIR pattern node. Since then, most uses of `pattern_ty` were removed by https://github.com/rust-lang/rust/pull/150238.
2026-04-08 14:22:03 +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 404ee74367 Rollup merge of #154235 - bb1yd:simplify-delim-check, r=fmease
remove unnecessary variables and delimiter check

Zulip discussion: https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/question.20about.20lex_token_tree_open_delim.20in.20rustc_parse/with/580552157

In `lex_token_tree_open_delim`, after calling `self.lex_token_trees(/* is_delimited */ true)`:
 - If the delimiters are well-balanced, the value  popped from the stack will always equal to `open_delim` and `pre_span`.
 - If the delimiters are not balanced, `self.lex_token_trees(/* is_delimited */ true)` will return an error so this branch will not be reached

Therefore `open_delimiter` and `open_delimiter_span` can be removed.

Test `tests/ui/parser` all passed
2026-04-08 14:22:00 +02:00
Jonathan Brouwer c8b04b6468 Rollup merge of #151898 - Randl:const-double-iter, r=oli-obk
constify DoubleEndedIterator

The only functions that can't be constified are `advance_back_by` (requires const range or const-hack), `nth_back` (requires `advance_back_by`), and `rfind` (requires const closures).

I've put it under `const_iter`, but I can open a separate tracking issue, though I think tracking all `Iterator` traits separately would be quite annoying, and we probably would prefer to constify them together anyway.
2026-04-08 14:21:59 +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
Waffle Lapkin dd19e01165 drive-by cleanup 2026-04-08 13:32:36 +02:00
b1yd 6f033416f3 remove unnecessary variables and delimiter check 2026-04-08 13:02:39 +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
Tshepang Mbambo ee33056fc7 Merge pull request #2825 from rust-lang/tshepang/sembr
sembr a few files
2026-04-08 09:01:44 +02:00
Tshepang Mbambo 5f8694755c Merge pull request #2826 from rust-lang/tshepang/nits
missing pause
2026-04-08 09:00:50 +02:00
Tshepang Mbambo 050110d507 re-flow 2026-04-08 08:57:19 +02:00
Tshepang Mbambo da97a7f7bb sembr src/tests/adding.md 2026-04-08 08:52:00 +02:00
Tshepang Mbambo 9c0a07250f re-wrap 2026-04-08 08:50:45 +02:00
Tshepang Mbambo d82e7c1172 sembr src/rustdoc-internals.md 2026-04-08 08:48:20 +02:00
Tshepang Mbambo 9634bb7e6b re-wrap 2026-04-08 08:47:51 +02:00
Tshepang Mbambo 2554c21df2 sembr src/hir.md 2026-04-08 08:45:18 +02:00
Tshepang Mbambo 7440567b40 re-wrap 2026-04-08 08:44:26 +02:00
Tshepang Mbambo b03b12e6a8 sembr src/ty-module/generic-arguments.md 2026-04-08 08:41:25 +02:00
Tshepang Mbambo 425b2b3850 skipped by sembr tool (due to "e.g.") 2026-04-08 08:40:47 +02:00
Tshepang Mbambo 66bf17e1ef slight improvements 2026-04-08 08:39:46 +02:00
Tshepang Mbambo 67ce02bb3b sembr src/traits/separate-projection-bounds.md 2026-04-08 08:37:03 +02:00
Tshepang Mbambo 238aabb2bf whitespace 2026-04-08 08:35:36 +02:00
Tshepang Mbambo 91cfd3b869 sembr src/const-eval/interpret.md 2026-04-08 08:27:18 +02:00
Tshepang Mbambo 49b1d75ba2 re-wrap 2026-04-08 08:26:24 +02:00
Tshepang Mbambo 97eb1be510 sembr src/appendix/code-index.md 2026-04-08 08:24:24 +02:00
Tshepang Mbambo f803c18f19 Merge pull request #2800 from reddevilmidzy/ast-low
Document AST lowering implementation
2026-04-08 08:20:50 +02:00
Tshepang Mbambo fdb83d4203 Merge pull request #2824 from rust-lang/rustc-pull
Rustc pull update
2026-04-08 08:17:43 +02:00
The rustc-josh-sync Cronjob Bot 444452b606 Merge ref '30d0309fa821' from rust-lang/rust
Pull recent changes from https://github.com/rust-lang/rust via Josh.

Upstream ref: rust-lang/rust@30d0309fa8
Filtered ref: rust-lang/rustc-dev-guide@8572b41699
Upstream diff: https://github.com/rust-lang/rust/compare/9602bda1dd0c1bbf5787e398385bbac81fd532f8...30d0309fa821f7a0984a9629e0d227ca3c0d2eda

This merge was created using https://github.com/rust-lang/josh-sync.
2026-04-08 06:16:49 +00:00
The rustc-josh-sync Cronjob Bot 1b09ce5272 Prepare for merging from rust-lang/rust
This updates the rust-version file to 30d0309fa8.
2026-04-08 06:16:43 +00:00