Commit Graph

55398 Commits

Author SHA1 Message Date
malezjaa 39f7cdb8e6 update thin-vec 2026-04-08 21:09:07 +02: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 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 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 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 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
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
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
Jacob Pratt 288406ae93 Rollup merge of #154460 - LaneAsade:lower-path-for-struct-expr, r=BoxyUwU
Deduplication: Pulled common logic out from lower_const_arg_struct

This PR aims to deduplicate the logic in the function `lower_const_arg_struct` by creating a helper function `lower_path_for_struct_expr` which is shared between `rustc_hir_ty_lowering `and `rustc_hir_typeck`.

Related: https://github.com/rust-lang/rust/issues/150621

Helper function code:

```
pub struct ResolvedStructPath<'tcx> {
    pub res: Result<Res, ErrorGuaranteed>,
    pub ty: Ty<'tcx>,
}

pub fn lower_path_for_struct_expr(
        &self,
        qpath: hir::QPath<'tcx>,
        path_span: Span,
        hir_id: HirId,
    ) -> ResolvedStructPath<'tcx> {
        match qpath {
            hir::QPath::Resolved(ref maybe_qself, path) => {
                let self_ty = maybe_qself.as_ref().map(|qself| self.lower_ty(qself));
                let ty = self.lower_resolved_ty_path(self_ty, path, hir_id, PermitVariants::Yes);
                ResolvedStructPath { res: Ok(path.res), ty }
            }
            hir::QPath::TypeRelative(hir_self_ty, segment) => {
                let self_ty = self.lower_ty(hir_self_ty);

                let result = self.lower_type_relative_ty_path(
                    self_ty,
                    hir_self_ty,
                    segment,
                    hir_id,
                    path_span,
                    PermitVariants::Yes,
                );
                let ty = result
                    .map(|(ty, _, _)| ty)
                    .unwrap_or_else(|guar| Ty::new_error(self.tcx(), guar));

                ResolvedStructPath {
                    res: result.map(|(_, kind, def_id)| Res::Def(kind, def_id)),
                    ty,
                }
            }
        }
    }
```

Thanks to @BoxyUwU for the guidance on this issue.
2026-04-07 23:05:30 -04:00
yukang ef9b7c2b8f replace span_look_ahead with span_followed_by 2026-04-08 09:34:24 +08:00
bors e5efd33d2d Auto merge of #147802 - nnethercote:chunk_domain_size, r=Mark-Simulacrum
Store `chunk_domain_size` explicitly in `Chunk`.



Currently we compute it on demand, but it's a little simpler and slightly faster to store it.

r? @ghost
2026-04-07 22:55:42 +00: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
mejrs 975761c64d Use derived impl for GappedRange subdiagnostic 2026-04-07 19:02:37 +02: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 3e14c2a135 Rollup merge of #154931 - aerooneqq:delegation-small-cleanup, r=petrochenkov
delegation(small cleanup): remove not needed PhantomData

r? @petrochenkov
2026-04-07 17:26:37 +02:00
Jonathan Brouwer 0c94559d48 Rollup merge of #154808 - JonathanBrouwer:attr_cleanup, r=jdonszelmann
Post-attribute ports cleanup pt. 1

r? @jdonszelmann

This cleans up some checks I could find were for non-parsed attributes, and works towards removing BUILTIN_ATTRIBUTES

All commits do one thing and every commit passes tests, so best reviewed commit by commit
2026-04-07 17:26:32 +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 180f3237d4 Rollup merge of #154146 - Zoxc:cycle-split-diag, r=petrochenkov
Split out the creation of `Cycle` to a new `process_cycle` function

This splits out the creation of `CycleError` to a new `process_cycle` function. This makes it a bit clearer which operations are done for diagnostic purposes vs. what's needed to break cycles.
2026-04-07 17:26:21 +02:00
Jonathan Brouwer 20bed53566 Rollup merge of #153999 - Zoxc:rem-TaggedQueryKey-def_kind-uses, r=petrochenkov
Remove `TaggedQueryKey::def_kind`

This removes `TaggedQueryKey::def_kind` by accessing the relevant query keys directly.
2026-04-07 17:26:20 +02: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
aerooneqq eacf5b8556 Generate more verbose error delegation 2026-04-07 13:04:59 +03:00
Jacob Adam b400f22c7b 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. Previously,
this note was shown whenever all arms had guards, even if the patterns
themselves were insufficient to cover all valid values of a type.

Re-run 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.
2026-04-07 10:08:11 +01:00
Chayim Refael Friedman 05320a26ed Add getters for rustc_pattern_analysis::constructor::Slice fields
rust-analyzer needs that.
2026-04-07 11:27:49 +03:00
Waffle Lapkin 6ab50d53e3 ty::Alias review comments 2026-04-07 10:08:12 +02:00
Waffle Lapkin 8c490f312c track caller
Add `#[track_caller]` to some functions which can panic b/c of the
caller's wrong index (this helped me debug some mistakes I did while
refactoring `ty::Alias`)
2026-04-07 10:08:12 +02:00
Waffle Lapkin 0f767084b8 ty::Alias refactor: fixup all the compiler code 2026-04-07 10:08:12 +02:00
aerooneqq 7f06f55bc2 Remove not needed PhantomData 2026-04-07 10:37:23 +03:00
Jonathan Brouwer 89db636d6f Reformat builtin_attrs.rs 2026-04-07 08:57:41 +02:00
Jonathan Brouwer 6b6bf8def8 Remove unused attribute check for unparsed builtin attributes 2026-04-07 08:57:33 +02:00
Nicholas Nethercote 72b8bc763d Store chunk_domain_size explicitly in Chunk.
Currently we compute it on demand, but it's a little simpler and
slightly faster to store it.
2026-04-07 16:50:19 +10:00
yukang 43ec6207bb stabilize check-cfg suggestions 2026-04-07 01:14:47 +00:00
Jacob Pratt 82bcdd18e6 Rollup merge of #154894 - WaffleLapkin:mplace_ptr_conversions, r=RalfJung
Slightly refactor mplace<->ptr conversions

split off of https://github.com/rust-lang/rust/pull/154327

r? RalfJung
2026-04-06 19:56:42 -04:00
Jacob Pratt b19364c4aa Rollup merge of #154627 - nnethercote:mv-rustc_middle-mir-mono, r=saethlin
Move `rustc_middle::mir::mono` to `rustc_middle::mono`

Because the things in this module aren't MIR and don't use anything from `rustc_middle::mir`. Also, modules that use `mono` often don't use anything else from `rustc_middle::mir`.

r? @saethlin
2026-04-06 19:56:40 -04:00
Nicholas Nethercote 3ff4201fd1 Move rustc_middle::mir::mono to rustc_middle::mono
Because the things in this module aren't MIR and don't use anything
from `rustc_middle::mir`. Also, modules that use `mono` often don't use
anything else from `rustc_middle::mir`.
2026-04-07 08:33:54 +10:00
Scott Schafer 63ed113d84 chore: Update annotate-snippets to 0.12.15 2026-04-06 14:48:52 -06:00
bors bcded33165 Auto merge of #154909 - JonathanBrouwer:rollup-44bqfTG, r=JonathanBrouwer
Rollup of 2 pull requests

Successful merges:

 - rust-lang/rust#154875 (Avoid duplicate diagnostic args in `RegionOriginNote::WithName`)
 - rust-lang/rust#154898 (Use debug! instead of info!)
2026-04-06 19:39:16 +00:00
Jonathan Brouwer 4be8f6588f Rollup merge of #154898 - mejrs:info_to_debug, r=JonathanBrouwer
Use debug! instead of info!

re: https://github.com/rust-lang/rust/pull/154858#discussion_r3039159140

r? @JonathanBrouwer
cc @jieyouxu
2026-04-06 20:59:00 +02:00