586 Commits

Author SHA1 Message Date
Oli Scherer d37d2be395 Revert performing basic const checks in typeck on stable 2026-04-09 11:36:46 +02:00
Trevor Gross 3479a1d553 Rollup merge of #153574 - TaKO8Ki:self-referential-param-env-normalization-ice, r=lcnr
Avoid ICE when param-env normalization leaves unresolved inference variables

Fixes rust-lang/rust#153354

Because the impl is already ill-formed, those variables are not fully constrained, so zfully_resolve` fails. We previously treated that as an immediate compiler bug with `span_bug!`, which caused an ICE on invalid input.
2026-03-31 05:08:23 -04:00
Takayuki Maeda d29c489599 add self-referential param-env normalization regression
avoid ICE on invalid param-env normalization

remove 120033 crash test

fix comments

use rustc_no_implicit_bounds

set #![allow(incomplete_features)]
2026-03-30 22:50:31 +09:00
Yuki Okushi b4c1677fff Do not lint for-loops-over-fallibles on external macros 2026-03-18 06:37:38 +09:00
Padraic Fanning 13a5c24606 Fix compile flags 2026-03-09 18:51:25 -04:00
Padraic Fanning 3ea17bec62 Add high-priority ICE: 150263 2026-03-09 18:44:50 -04:00
Padraic Fanning 141b0d8757 Add high-priority ICE: 146965 2026-03-09 18:44:50 -04:00
Jonathan Brouwer 0381e24e37 Rollup merge of #152165 - JohnTitor:issue-151579, r=lcnr
Normalize capture place `ty`s to prevent ICE

Fixes rust-lang/rust#151579
Fixes https://github.com/rust-lang/rust/issues/120811
r? @lcnr
2026-02-28 12:52:53 +01:00
Folkert de Vries 31ae3d2be8 guaranteed tail calls: support indirect arguments 2026-02-27 10:24:39 +01:00
Makai b6083435d8 implement debuginfo for unsafe binders 2026-02-23 23:32:56 +08:00
bors 7f99507f57 Auto merge of #149375 - oli-obk:const_typeck, r=fee1-dead
Perform many const checks in typeck

Some smaller diagnostic changes, the biggest ones avoided by https://github.com/rust-lang/rust/pull/148641

We should be able to move various checks in mir const checking to using `span_bug!` instead of reporting an error, just like mir typeck does as a sanity check. I would like to start doing so separately though, as this PR is a big enough (in what effects it causes, pun intended).

r? @fee1-dead
2026-02-19 18:41:36 +00:00
Yuki Okushi 82b09a177c Normalize the whole Place 2026-02-17 20:32:17 +09:00
Jubilee Young 18a707fc8e Revert "Fix an ICE in the vtable iteration for a trait reference"
The ICE fix appears to be unsound, causing a miscompilation involving
`dyn Trait` and `async {}` which induces segfaults in safe Rust code.
As the patch only hid an ICE, it does not seem worth the risk.

This reverts commit 8afd63610b, reversing
changes made to 19122c03c7.
2026-02-16 17:52:06 -08:00
Jonathan Brouwer 5ae6bb3faf Rollup merge of #152001 - reddevilmidzy:mgca-i, r=BoxyUwU
mGCA: Validate const literal against expected type

close: rust-lang/rust#151625
close: rust-lang/rust#150983

also fix: https://github.com/rust-lang/rust/issues/133966 (moved crashes test)
2026-02-14 18:55:35 +01:00
reddevilmidzy b4ee9953d8 modify error comment and bless test, delete tests/ui/const-generics/generic_const_exprs/lit_type_mismatch.rs 2026-02-14 04:12:46 +00:00
Yuki Okushi 7d7b381660 Fix ICE in borrowck when recovering fn_sig for -> _ 2026-02-13 12:26:16 +09:00
bors f21b4c0888 Auto merge of #152412 - JonathanBrouwer:rollup-hShycIY, r=JonathanBrouwer
Rollup of 7 pull requests

Successful merges:

 - rust-lang/rust#151960 (rustc_parse: improve the error diagnostic for "missing let")
 - rust-lang/rust#152157 (Fix error spans for `asm!()` args that are macros)
 - rust-lang/rust#152317 (fix: sup_trace to sub_trace)
 - rust-lang/rust#150897 (rustc_parse_format: improve diagnostics for unsupported debug = syntax)
 - rust-lang/rust#151154 (Add `s390x-unknown-none-softfloat` with `RustcAbi::Softfloat`)
 - rust-lang/rust#152013 (Update to Xcode 26.2)
 - rust-lang/rust#152326 (Remove the compiler adhoc group)
2026-02-10 02:25:24 +00:00
Jonathan Brouwer e0c8737f8a Rollup merge of #152157 - gurry:131292-asm-concat-unicode, r=petrochenkov
Fix error spans for `asm!()` args that are macros

Fixes rust-lang/rust#131292 which is exactly the same issue as rust-lang/rust#129503 but for [`err.secondary_label`](https://github.com/rust-lang/rust/blob/9f4b56a5aed81e8c36cc26b3c1b4666ead6b71fc/compiler/rustc_builtin_macros/src/asm.rs#L399-L401) instead of [`err.span`](https://github.com/rust-lang/rust/blob/9f4b56a5aed81e8c36cc26b3c1b4666ead6b71fc/compiler/rustc_builtin_macros/src/asm.rs#L385-L391). The latter issue was fixed in https://github.com/rust-lang/rust/pull/130917 so see that PR for context.

In addition to the above, the current PR also proactively fixes potential future issues of the same kind which would have occurred over [here ](https://github.com/rust-lang/rust/blob/9f4b56a5aed81e8c36cc26b3c1b4666ead6b71fc/compiler/rustc_builtin_macros/src/asm.rs#L478-L482)and [here](https://github.com/rust-lang/rust/blob/9f4b56a5aed81e8c36cc26b3c1b4666ead6b71fc/compiler/rustc_builtin_macros/src/asm.rs#L493-L497).
2026-02-09 23:37:45 +01:00
bors 381e9ef09e Auto merge of #152324 - Keith-Cancel:mgca4, r=BoxyUwU
Update mgca to use `type const` syntax instead of the `#[type_const]` attribute. 

This PR changes the `#[type_const]` attribute to the `type const` syntax for  https://github.com/rust-lang/rust/issues/132980.

This will fixes https://github.com/rust-lang/rust/issues/151273 and similar issues, since we need to check `type const` of items before expansion. The move to add a syntax was mentioned here: https://github.com/rust-lang/rust/pull/151289#issuecomment-3765241397

The first part of this PR adds support by allowing `type const <IDENT>: <TYPE> { = <EXPR> };` syntax in `rustc_parse/src/parser/item.rs`.

The next part since the AST item does not contain enough information to determine if we have a `type const` was rework `ConstItemRhs` into `ConstItemRhsKind` to store the information since we no longer have the attribute acting as a source of extra data/metadata. 

The hir node `ConstItemRhsKind` current shape mostly works, except in the case of `TraitItemKind` where it is an option. I initially went about giving `hir::ConstItemRhsKind` a similar form the AST, but it touches a lot more lines of code and files so because of that, the less invasive option was to add a simple boolean flag to `TraitItemKind`. 

The forth part of this PR includes adding a query I called `is_rhs_type_const` so that we can handle both local and foreign def_ids. 

The fifth aspect of the PR is adding a `mgca_type_const_syntax` feature gate that is checked before expansion. The standard mgca feature gate is ran after expansion. This feature gate allows for conditional compilation (e.g #[cfg(..)]) of the `type const` syntax  in nightly without `min_generic_const_args` being enabled. 

The last bit is updating all the the tests that used the `#[type_const]` attribute to use the new syntax that failed because of the changes. This is the bulk of touched/edited files in the PR. 

r? @BoxyUwU 
@rustbot label +F-associated_const_equality +F-min_generic_const_args
2026-02-09 22:37:29 +00:00
Matthias Krüger 1f0e21584e Rollup merge of #152327 - adwinwhite:fix-non-defining-use-ices-ready, r=lcnr
Check stalled coroutine obligations eagerly

Fixes rust-lang/rust#151322
Fixes rust-lang/rust#151323
Fixes rust-lang/rust#137916
Fixes rust-lang/rust#138274

The problem is that stalled coroutine obligations can't be satisifed so that they cause normalization to fail in `mir_borrowck`.
Thus, we failed to register any opaque to storage in the next solver.
I fix it by checking these obligations earlier in `mir_borrowck`.

r? @lcnr
2026-02-09 18:39:43 +01:00
Keith-Cancel 73a991fb9d Allow provisional mgca syntax of type const <IDENT> = <EXPR> to be reconized.
Revert, but without type const.

Update symbol for feature err, then update suggestion output, and lastly update tests that change because of those.

Update these new tests with the correct syntax, and few existing tests with the new outputs the merge with main added.

Fix for tidyfmt and some errors when manually resolving a merge conflicts.

Update these tests to use update error messages and type const syntax.

Update comments and error message to use new syntax instead of old type_const attribute.

Remove the type_const attribute

update some more tests to use the new syntax.

Update these test cases.

update feature gate test

Change gate logic for `mgca_type_const_syntax` to work also if `min_generic_const_args` is enabled.

Create a new feature gate that checks for the feature before expansion.

Make rustfmt handle the `type const` syntax correctly.

Add a convience method to check if a RhsKind is type const.

Rename `Const` discriminant to `Body` for `ConstItemRhsKind`

Give the `TraitItemKind` flag an enum instead of a simple bool to better describe what the flag is for.

Update formatting for these match statements.

Update clippy test to use type const syntax.

Update test to use type const syntax.

update rustfmt to match ast items.

Update clippy to match ast and hir items.

Few more test cases that used old attribute, instead of 'type const'

Update to match the output from the feature gate checks.

tidyfmt adjustments.

Update the is_type_const, so I can constrain record!(..) in encoder.rs

Update conditional compilation test.

Move the feature gate to after expansion to allow for cfg(...) to work.

Update some more tests to use the new syntax.

Update type const tests in associated-const-bindings to use new syntax.

Don't check based off the attribute, but the item here.

Update some tests outside of the const_generics folder that were using #[type_const]

update the tests in associated consts that use #[type_const] to use type const

Update these mgca tests with the type const syntax.

Add a flag to TraitItemKind for detecting type const for now. Maybe later change ItemConstRhs to have optional consts but that touches a lot more lines of code.

Don't need into for these now that it's a query.

Add is_type_const query to handle foreign def ids.

update this test to use type const syntax.

Fix logic here, we only want to lower if there is expression in this case.

Update built-in macros to use ConstItemRhsKind

Update more instance of the old ConstItemRhs.

Rename ConstItemKind to ConstItemRhsKind, I noticed there is a typed called ConstantItemKind, so add the Rhs to the name to avoid confusion.

Update lower to use ConstItemKind

Add an other helper method to check if the rhs kinda has an expr.

Update item parse to use ConstItemKind enum.

Felt the field name could a be little clear when editing a few other things.

Change the ConstItem struct see know if we have a type const or regular const.

Make sure this syntax is properly feature gated.
2026-02-09 07:59:24 -08:00
Adwin White f248395394 bless tests 2026-02-09 15:09:43 +08:00
Jacob Adam 6af91c56d1 Move tests from tests/crashes to tests/ui now that they don't ICE 2026-02-07 14:09:01 +01:00
Oli Scherer 3127e9258f Perform many const checks in typeck 2026-02-06 19:38:43 +00:00
lapla 22885d2526 Reorganize tests that no longer crash 2026-02-06 14:44:04 +09:00
Gurinder Singh 17305da24f Fix error spans for asm!() args that are macros 2026-02-05 13:32:35 +05:30
khyperia c7c3266b8a error on unsized AnonConsts 2026-02-02 20:48:14 +01:00
bors b765963267 Auto merge of #150843 - fmease:dyn-ace, r=BoxyUwU
mGCA: Make trait object types with type-level associated consts dyn compatible

Under feature `min_generic_const_args` (mGCA) (rust-lang/rust#132980), render traits with non-parametrized type-level associated constants (i.e., `#[type_const]` ones) dyn compatible but force the user to specify all type-level associated consts in the trait object type via bindings (either directly, via supertrait bounds and/or behind trait aliases) just like associated types, their sibling.

Fixes rust-lang/rust#130300 (feature request).
Fixes rust-lang/rust#136063 (bug).
Fixes rust-lang/rust#137260 (bug).
Fixes rust-lang/rust#137514 (bug).

While I'm accounting for most illegal `Self` references via const projections & params, I'm intentionally ignoring RUST-123140 (and duplicates) in this PR which is to be tackled some other time.

Additional context: Crate `rustc-demangle` had to be updated to fix v0 demangling. I've patched it in PR https://github.com/rust-lang/rustc-demangle/pull/87 which was was released in version 0.1.27 via PR https://github.com/rust-lang/rustc-demangle/pull/88.
2026-01-22 01:56:41 +00:00
Jonathan Brouwer afc18426cb Rollup merge of #151219 - enthropy7:main, r=BoxyUwU
Fixed ICE when using function pointer as const generic parameter

added bounds check in prohibit_explicit_late_bound_lifetimes to prevent index out of bounds panic when args.args is empty. also regression test here to ensure function pointers in const generics produce proper error messages instead of ICE.

Fixes rust-lang/rust#151186
Fixes rust-lang/rust#137084
2026-01-21 22:24:03 +01:00
enthropy7 4131674f49 Fix ICE when using function pointer as const generic parameter 2026-01-21 16:31:22 +03:00
León Orell Valerian Liehr 233a45c41a Fix handling of const params defaults that ref Self & generalize diag
We used to lower such bad defaulted const args in trait object types to
`{type error}`; now correctly lower them to `{const error}`.

The added tests used to ICE prior to this change.
2026-01-21 12:53:47 +01:00
Jonathan Brouwer 9f49af87cb Rollup merge of #151275 - fix/151251, r=BoxyUwU
Normalize type_const items even with feature `generic_const_exprs`

Fixes rust-lang/rust#151251

With feature `generic_const_exprs` enabled, consts with `#[type_const]` won't be normalized even if they need. Then ICE happens when CTFE tries to evaluate such const without body.

Fix this by normalizing such consts even with feature `generic_const_exprs` enabled.

r? @BoxyUwU
2026-01-18 18:26:06 +01:00
mu001999 7510f747a8 Normalize type_const items even with feature generic_const_exprs 2026-01-18 12:46:42 +08:00
reddevilmidzy 6166b61979 Add crashes mGCA tests 2026-01-14 06:52:58 +09:00
mu001999 6c2dc40666 Bless other tests 2026-01-07 09:33:40 +08:00
Kivooeo d32f1c695f add const ctor support 2026-01-06 15:04:25 +00:00
bors da476f1942 Auto merge of #150640 - AprilNEA:mgca-merge-associated-const-equality, r=BoxyUwU
Merge `associated_const_equality` feature gate into MGCA

Tracking Issues: rust-lang/rust#132980 rust-lang/rust#92827

Merge `associated_const_equality`(ACE) feature gate into `min_generic_const_args`(MGCA).

- Replaces `features().associated_const_equality()` checks with `features().min_generic_const_args()`
- Updates the parser to gate associated const equality under `min_generic_const_args`
- Moves `associated_const_equality` to the removed features list
- Removes the `associated_const_equality` method from the `Features` trait
- Updates all affected tests and tools (rust-analyzer, clippy)

Closes rust-lang/rust#150617

r? `@BoxyUwU`
2026-01-06 01:36:53 +00:00
AprilNEA 4421270516 Merge associated_const_equality feature gate into MGCA
This removes `associated_const_equality` as a separate feature gate and makes it part of `min_generic_const_args` (mgca).

Key changes:
  - Remove `associated_const_equality` from unstable features, add to removed
  - Update all test files to use `min_generic_const_args` instead
  - Preserve the original "associated const equality is incomplete" error message by specially handling `sym::associated_const_equality` spans in `feature_gate.rs`
  - Rename FIXME(associated_const_equality) to FIXME(mgca)
2026-01-05 12:31:42 +08:00
bors 6885bdf1af Auto merge of #150603 - Kivooeo:tuple-struct, r=BoxyUwU
MGCA: Support for tuple constructors

r? BoxyUwU

part of https://github.com/rust-lang/rust/issues/132980

fixes rust-lang/rust#136379
fixes rust-lang/rust#138132

i tried to keep implementation very minimal and it's very similar to how structs was implemented with small adjustments

this does not make const constructor like None works, just something like Some(n)

todo:
* ~~tests~~
* write a better description (not sure if needed)
* add more comments and FIXMEs from structs code
2026-01-05 01:45:18 +00:00
Kivooeo 05afcb6d26 init impl 2026-01-04 15:12:39 +00:00
Noah Lev c7e368543c Use more principled check for generics in const ops
Instead of using a visitor in typeck, we just check, whenever lowering a
use of a param, whether the parent item is an MCG anon const during hir
ty lowering (and instantiate_value_path). If so, we report an error
since MCG anon consts should never be able to use generics. All other
kinds of anon consts are at least syntactically allowed to use generic
params.

We use a `TypeFolder` to accomplish this; this way, we look at the
fully explicit semantic representation of the type/const/whatever and
don't miss subtle cases like `Self` type aliases.
2026-01-01 18:12:34 -08:00
Jonathan Brouwer 1117bd9e78 Rollup merge of #150411 - Kivooeo:somefunnystuff, r=BoxyUwU
refactor `destructure_const`

r? BoxyUwU

as you suggested yesterday (will add more context like links when it stops being a draft)

tried to split this into some meaningful commits hope it help ^^
2025-12-28 22:52:33 +01:00
Jonathan Brouwer 32e848163c Rollup merge of #149947 - cyrgani:crashtests, r=Mark-Simulacrum
add several older crashtests

Includes rust-lang/rust#114880, rust-lang/rust#119940, rust-lang/rust#138274, rust-lang/rust#138660.
Since their issue numbers are all smaller than 140000, this has no conflicts with rust-lang/rust#147857.
2025-12-28 22:52:32 +01:00
Kivooeo b29cc9860b refactor destructure_const 2025-12-28 16:12:27 +00:00
cyrgani 053597f464 add several older crashtests 2025-12-25 12:27:17 +00:00
Boxy Uwu 484480412e Lower hir::ConstArgKind::Struct to a ValTree 2025-12-23 13:54:59 +00:00
Jonathan Brouwer 43f270a0ef Rollup merge of #150109 - tshepang:patch-1, r=jieyouxu
crash test readme: point to rustc-dev-guide

There is information that is duplicated here and in rustc-dev-guide, and the latter is more comprehensive, so point there.
2025-12-22 07:58:48 +01:00
Maja Kądziołka 3d5d1d72e0 Mark crash 140011 as fixed 2025-12-17 20:47:48 +01:00
Maja Kądziołka e25803acea ExprUseVisitor: remove maybe_read_scrutinee
The split between walk_pat and maybe_read_scrutinee has now become
redundant.

Due to this change, one testcase within the testsuite has become similar
enough to a known ICE to also break. I am leaving this as future work,
as it requires feature(type_alias_impl_trait)
2025-12-17 20:47:47 +01:00
Maja Kądziołka 9cb47c6e8e ExprUseVisitor: properly report discriminant reads
This solves the "can't find the upvar" ICEs that resulted from
`maybe_read_scrutinee` being unfit for purpose.
2025-12-17 20:47:47 +01:00