Commit Graph

1159 Commits

Author SHA1 Message Date
Guillaume Gomez e8d970b08a Rollup merge of #156988 - RalfJung:validate-uninhabited, r=oli-obk
interpret/validity: properly treat zero-variant enums so that we do not have to check layout.is_uninhabited

I am very happy to finally remove the last of these somewhat ad-hoc checks. :)

r? @oli-obk
2026-05-27 20:45:15 +02:00
Ralf Jung 59428e76e8 MIR inlining: allow backends to opt-in to inlining intrinsics 2026-05-27 13:59:25 +02:00
Ralf Jung e724fa6620 interpret/validity: properly treat zero-variant enums so that we do not have to check layout.is_uninhabited 2026-05-26 20:05:49 +02:00
Jonathan Brouwer ea21bcc942 Rollup merge of #156317 - lokirithm:reorg-tests-04, r=Kivooeo
Reorg tests 04

| old-name | new-sub-dir | new-name |
|-|-|-|
| `issue-27997.rs` [issue](https://github.com/rust-lang/rust/issues/27997) | `codegen/` | `correctly-monomorphize-generic-drop-impl.rs` |
| `issue-31299.rs` [issue](https://github.com/rust-lang/rust/issues/31299) | `associated-types/` | `sized-recursive-type-via-associated-type.rs` |
| `issue-35815.rs` [issue](https://github.com/rust-lang/rust/issues/35815) | `codegen/` | `dont-roundup-dst-prefix-size-to-alignment.rs` |
| `issue-46855.rs` [issue](https://github.com/rust-lang/rust/issues/46855) | `mir/` | `dont-use-operand-as-place-for-zst.rs` |
| `issue-47486.rs` [issue](https://github.com/rust-lang/rust/issues/47486) | `consts/` | `size_of-requires-type-annotation-in-const.rs` |
| `issue-47486.stderr` | `consts/` | `size_of-requires-type-annotation-in-const.stderr` |
| `issue-50811.rs` [issue](https://github.com/rust-lang/rust/issues/50811) | `mir/` | `validate-various-comparison-behavior.rs` |
2026-05-20 15:37:30 +02:00
许杰友 Jieyou Xu (Joe) 76d07a61f3 Rollup merge of #156531 - Zalathar:no-pass-override, r=jieyouxu
compiletest: Rename `//@ ignore-pass` to `//@ no-pass-override`

By convention, compiletest directives starting with `ignore-*` normally cause the test itself to be skipped under certain conditions.

The `//@ ignore-pass` directive was the only exception to that convention. The new name should hopefully do a better job of communicating its effect, which is to cause the `--pass` flag to not override the test's `build-pass` or `run-pass` directive.

The `//@ no-pass-override` directive is mainly useful for tests that expect warnings produced during codegen.

---
r? jieyouxu
2026-05-14 13:24:34 +08:00
Zalathar cda9a68248 Rename //@ ignore-pass to //@ no-pass-override
By convention, compiletest directives starting with `ignore-*` normally cause
the test itself to be skipped under certain conditions.

The `//@ ignore-pass` directive was the only exception to that convention. The
new name should hopefully do a better job of communicating its effect, which is
to cause the `--pass` flag to not override the test's `build-pass` or
`run-pass` directive.

The `//@ no-pass-override` directive is mainly useful for tests that expect
warnings produced during codegen.
2026-05-13 17:24:59 +10:00
Zalathar 0a5216b52a Remove some //@ ignore-pass directives that do nothing
The compiletest `--pass` flag only affects tests with a `*-pass` directive,
i.e. `check-pass`, `build-pass`, or `run-pass`.

It has no effect in `*-fail` tests, or in auxiliary crates.
2026-05-13 17:15:51 +10:00
Zalathar 38d2c11584 Enforce that directives are consistently used with or without a colon 2026-05-13 15:52:33 +10:00
lokirithm 664af6990b Update files 2026-05-13 01:26:32 +05:30
lokirithm ee5f63f888 Move test files from issues/ to appropriate subdirectories 2026-05-13 01:15:59 +05:30
Matthias Krüger b2cdfa26e4 Rollup merge of #156306 - danieljofficial:move-tests-consts, r=TaKO8Ki
Move tests consts

Hi I have moved some tests from ui/issues into the fitting ui/consts folder

Fixes a part of rust-lang/rust#133895
2026-05-08 20:39:26 +02:00
danieljofficial 2a119e8c4f add issue links and bless 2026-05-08 10:36:04 +01:00
danieljofficial dcaef5f688 move consts ui tests into its folder 2026-05-07 17:42:25 +01:00
Jonathan Brouwer ce44b53e77 Rollup merge of #154846 - Zoxc:ty-def-span, r=lcnr
Add better default spans for the `Ty` impl of `QueryKey`

This add default spans for `Ty` in its implementation of `QueryKey`. This is useful so we can get spans for the `layout_of`  query which shows up in cycle errors.
2026-05-07 14:13:52 +02:00
John Kåre Alsaker 25e018de2d Add better default spans for the Ty impl of QueryKey 2026-05-04 16:56:59 +02:00
Waffle Lapkin 40f3908f54 bless miri/codegen-llvm/ui tests 2026-05-04 15:35:40 +02:00
Oli Scherer 11d88ee42b Rip out rustc_layout_scalar_valid_range_* attribute support 2026-05-03 10:59:52 +02:00
Jonathan Brouwer a0ef691e5a Rollup merge of #155861 - oli-obk:effect-bound-suggestions, r=jdonszelmann
Suggest `[const] Trait` bounds in more places

Right now we have some special logic in the const checker for emitting `[const] Trait` suggestions, but I'm trying to handle that similarly to how it is handled for normal `Trait` clauses. This is just a small step in how it will look on the UX side, which should make my follow-up PRs affect tests less and just be a refactoring
2026-04-29 23:51:35 +02:00
Folkert de Vries c560774cf3 c-variadic: more precise compatibility check in const-eval 2026-04-29 17:45:39 +02:00
Jonathan Brouwer f7f266b2b1 Rollup merge of #155907 - oli-obk:push-nypowoyskzxp, r=Kivooeo
Handle hkl const closures

I severely overthought this in rust-lang/rust#153818 😆

The const closure trait solver impl is now in sync with the non-const closure trait solver impl.
2026-04-28 20:24:36 +02:00
Oli Scherer 61e876fe76 Suggest various missing trait bounds on HostEffect clauses not being satisfied 2026-04-28 12:54:55 +02:00
Oli Scherer 89cfc2273a Suggest const destruct bounds on Drop impls when they are missing 2026-04-28 12:54:55 +02:00
Jacob Pratt 8759017b1f Rollup merge of #155882 - pluiee:pluiee/101363-test, r=mu001999
Add regression test for #101363

Adds test for rust-lang/rust#101363

Since it's my first time adding tests, I'm not sure if the test itself, its location, or its name are appropriate.
2026-04-28 05:37:27 -04:00
Oli Scherer b465c5642b Handle hkl const closures 2026-04-28 10:36:32 +02:00
Oli Scherer 4d4058bfb4 Add regression test for hkl const closures 2026-04-28 10:27:20 +02:00
SangHun Kim 612afd1b49 Add regression test 2026-04-28 00:53:31 +09:00
Oli Scherer 8e1c34f5cc Check closure's constness validity in the constness query
instead of during ast lowering, where it's not easily possible to obtain all the right information in time
2026-04-27 07:44:19 +02:00
Oli Scherer 2b2f28d0ea Add regression test 2026-04-27 07:43:46 +02:00
Oli Scherer 7dcedafff2 Reject implementing const Drop for types that are not const Destruct already 2026-04-25 20:56:32 +02:00
Oli Scherer 642ee63c22 Add regression test 2026-04-25 20:55:51 +02:00
Folkert de Vries 84cd23b3c8 c-variadic: rename VaList::arg to VaList::next_arg 2026-04-22 16:02:11 +02:00
lapla a687f0b658 Fix incorrect let to const suggestion for pattern bindings 2026-04-22 00:24:08 +09:00
Jacob Pratt a8e1664fd8 Rollup merge of #154557 - Muhtasim-Rasheed:issue-147313-improve-help, r=chenyukang
Make E0284 generic argument suggestions more explicit

Closes rust-lang/rust#147313

Previously, when type annotations were missing for a function call, rust suggested: "consider specifying the generic argument". This PR improves the diagnostics:

- If only one generic type is missing:
  "consider specifying a concrete type for the generic type `<T>`" with the turbofish being "::\<SomeConcreteType>"
- If only one const generic is missing:
  "consider specifying a const for the const generic `<CONST>`" with the turbofish being "::<SOME_CONST>"

Multiple missing generics still produce the original more general suggestion
2026-04-20 20:50:21 -04:00
Muhtasim-Rasheed b1786813df Make E0284 generic argument suggestions more explicit 2026-04-20 16:46:57 +06:00
Jonathan Brouwer ce91732a75 Rollup merge of #155054 - Lars-Schumann:const-vec-ops, r=dtolnay
constify `Index(Mut)`, `Deref(Mut)` for `Vec`

Relevant tracking issues
const_convert: https://github.com/rust-lang/rust/issues/143773
const_index: https://github.com/rust-lang/rust/issues/143775
2026-04-20 08:14:09 +02:00
Scott McMurray 3efcdbc43c Require that a <_ as Try>::Residual implement Residual
The `Residual` trait was even more experimental than `Try`, but now that RFC3721 is merged, I think it would make sense to require this.
2026-04-15 18:09:52 -07:00
bors 338dff3e3a Auto merge of #136006 - oli-obk:push-tzonluoyuwkq, r=wesleywiser
Start using pattern types in libcore



cc rust-lang/rust#135996

Replaces the innards of `NonNull` with `*const T is !null`.

This does affect LLVM's optimizations, as now reading the field preserves the metadata that the field is not null, and transmuting to another type (e.g. just a raw pointer), will also preserve that information for optimizations. This can cause LLVM opts to do more work, but it's not guaranteed to produce better machine code.

Once we also remove all uses of rustc_layout_scalar_range_start from rustc itself, we can remove the support for that attribute entirely and handle all such needs via pattern types
2026-04-13 21:54:46 +00:00
Oli Scherer 834137afd7 Use !null pattern type in libcore 2026-04-13 17:23:03 +02:00
Lars Schumann 804f4953d2 constify Index(Mut), Deref(Mut) for Vec 2026-04-09 16:31:12 +00:00
Oli Scherer d37d2be395 Revert performing basic const checks in typeck on stable 2026-04-09 11:36:46 +02:00
Waffle Lapkin d5f98fbb27 implement StructuralPartialEq for MaybeDangling
This fixes a stable-to-stable regression where constants of type
`ManuallyDrop<T>` would not be allowed to be used as a pattern due to
`MaybeDangling<T>` in `ManuallyDrop<T>` not implementing
`StructuralPartialEq`.
2026-04-06 18:18:32 +02:00
enthropy7 a08257840b Fix ICE in read_discriminant for enums with non-contiguous discriminants 2026-04-03 22:36:53 +03:00
Jacob Adam d1f11b23ca Change the test comment per PR review feedback 2026-04-01 14:41:50 +01:00
Jacob Adam 253c03aa9d Add a test for a past ICE when calling a const fn with the wrong number of arguments 2026-04-01 10:17:57 +01:00
cyrgani bf42a53bf7 delete several ui/consts tests 2026-03-30 09:15:22 +00:00
Ralf Jung 7881a31ccf Rollup merge of #152880 - JohnTitor:tweak-assoc-item-note, r=fmease
Tweak incorrect assoc item note

Fix rust-lang/rust#142797
r? @fmease
2026-03-28 13:15:48 +01:00
Yuki Okushi 531631c7ad Make messages more generic 2026-03-28 16:18:11 +09:00
bors 3ea2fbcb2a Auto merge of #154010 - estebank:issue-42753, r=nnethercote
Suggest using equality comparison instead of pattern matching on non-structural constant in pattern

When encountering a pattern containing a non-structural constant (not marked as `#[derive(PartialEq)]` to make it suitable for pattern matching, `C` in the examples below), we would previously not provide additional guidance. With this PR, the `help` in the following examples are added:

```
error: constant of non-structural type `partial_eq::S` in a pattern
  --> $DIR/suggest_equality_comparison_instead_of_pattern_matching.rs:16:18
   |
LL |     struct S;
   |     -------- `partial_eq::S` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
...
LL |     const C: S = S;
   |     ---------- constant defined here
...
LL |             Some(C) => {}
   |                  ^ constant of non-structural type
   |
note: the `PartialEq` trait must be derived, manual `impl`s are not sufficient; see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
  --> $DIR/suggest_equality_comparison_instead_of_pattern_matching.rs:5:5
   |
LL |     impl PartialEq<S> for S {
   |     ^^^^^^^^^^^^^^^^^^^^^^^
help: add a condition to the match arm checking for equality
   |
LL -             Some(C) => {}
LL +             Some(binding) if binding == C => {}
   |
```

```
error: constant of non-structural type `partial_eq::S` in a pattern
  --> $DIR/suggest_equality_comparison_instead_of_pattern_matching.rs:22:18
   |
LL |     struct S;
   |     -------- `partial_eq::S` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
...
LL |     const C: S = S;
   |     ---------- constant defined here
...
LL |         let Some(C) = Some(S) else { return; };
   |                  ^ constant of non-structural type
   |
note: the `PartialEq` trait must be derived, manual `impl`s are not sufficient; see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
  --> $DIR/suggest_equality_comparison_instead_of_pattern_matching.rs:5:5
   |
LL |     impl PartialEq<S> for S {
   |     ^^^^^^^^^^^^^^^^^^^^^^^
help: check for equality instead of pattern matching
   |
LL -         let Some(C) = Some(S) else { return; };
LL +         if Some(C) == Some(S) { return; };
   |
```

The suggestion accounts for a few conditions:

 - if the type is not from the local crate and has no `PartialEq` impl, the user can't make it structural, so we don't provide the suggestion
 - regardless of whether the type is local or remote, if it has a manual `PartialEq`, explain that with a derived `PartialEq` you could use equality
 - if the type is local and has no impl, suggest adding a derived `PartialEq` and use equality check instead of pattern matching
 - when suggesting equality, account for `if-let` to suggest chaining (edition dependent), `match` arm with a present `if` check, `match` arm without an existing `if` check
 - when encountering `let-else`, we suggest turning it into an `if` expression instead (this doesn't check for additional bindings beyond the constant, which would suggest incorrect code in some more complex cases).

Fix rust-lang/rust#42753.
2026-03-26 05:30:08 +00:00
Jonathan Brouwer ab6401749a Rollup merge of #154097 - RalfJung:validity-error, r=oli-obk
improve validation error messages: show surrounding type

Also, for dyn-downcast show the type we're downcasting to.

r? @oli-obk
2026-03-24 18:14:15 +01:00
Jonathan Brouwer 62a3eab283 Rollup merge of #154093 - RalfJung:validity-maybedangling, r=WaffleLapkin
const validity checking: do not recurse to references inside MaybeDangling

This arguably should be allowed, but we currently reject it:
```rust
#![feature(maybe_dangling)]
use std::mem::MaybeDangling;

const X: MaybeDangling<&bool> = unsafe { std::mem::transmute(&5u8) };
```

r? @WaffleLapkin
2026-03-23 20:18:34 +01:00