Commit graph

3623 commits

Author SHA1 Message Date
Jonathan Brouwer
a4c34b421c
Port #[rustc_dump_vtable] 2026-01-13 15:25:28 +01:00
Jonathan Brouwer
2a455409e3
Port #[rustc_dump_item_bounds] 2026-01-13 15:25:27 +01:00
Jonathan Brouwer
cf4d480eff
Port #[rustc_dump_def_parents] 2026-01-13 15:25:27 +01:00
reddevilmidzy
d616e6cb18 Emit error instead of delayed bug when meeting mismatch type for const
array
2026-01-13 21:36:53 +09:00
Jana Dönszelmann
b454f76bd1
ensure generics are still properly reported on EII *implementations*, and test this 2026-01-13 11:59:59 +01:00
Jana Dönszelmann
d25f4718ad
deduplicate error message when EII has generics 2026-01-13 11:59:59 +01:00
bors
2f1bd3f378 Auto merge of #150844 - fmease:mv-ace-tests, r=BoxyUwU
mGCA: Move tests for assoc const bindings (formerly ACE) into dedicated directory & replace more mentions of ACE

Split out of PR rust-lang/rust#150843.
As discussed.

Somewhat obvious underlying principle: If the test checks basic or core parts of assoc const bindings and nothing else, move it, otherwise leave it even if it contains ACEs.

Motivation: It makes a lot easier for me to continue working on ACE efficiently.

r? @BoxyUwU
2026-01-12 20:08:40 +00:00
bors
aefa10405d Auto merge of #151003 - matthiaskrgr:rollup-wvnF9sN, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - rust-lang/rust#150861 (Folding/`ReErased` cleanups)
 - rust-lang/rust#150869 (Emit error instead of delayed bug when meeting mismatch type for const tuple)
 - rust-lang/rust#150920 (Use a hook to decouple `rustc_mir_transform` from `rustc_mir_build`)
 - rust-lang/rust#150941 (rustc_parse_format: improve diagnostics for unsupported python numeric grouping)
 - rust-lang/rust#150972 (Rename EII attributes slightly (being consistent in naming things foreign items, not extern items))
 - rust-lang/rust#150980 (Use updated indexes to build reverse map for delegation generics)
 - rust-lang/rust#150986 (std: Fix size returned by UEFI tcp4 read operations)
 - rust-lang/rust#150996 (Remove `S-waiting-on-bors` after a PR is merged)

r? @ghost
2026-01-12 16:43:20 +00:00
bors
137716908d Auto merge of #150786 - reddevilmidzy:mgca-array, r=BoxyUwU
mGCA: Support array expression as direct const arguments

tracking issue: rust-lang/rust#132980
resolve: rust-lang/rust#150612

Support array expression as direct const arguments (e. g. [1, 2, N]) in min_generic_const_args.

todo:
* [x] Rebase another mGCA PR
* [x] Add more test case
* [x] Modify clippy code
2026-01-12 13:26:21 +00:00
Matthias Krüger
1ff682edcd
Rollup merge of #150980 - fix-ice-150673, r=fee1-dead
Use updated indexes to build reverse map for delegation generics

Fixes rust-lang/rust#150673.

This was a bug that built the `param_def_id_to_index` map with indexes before the new generics were renumbered.

r? @petrochenkov
2026-01-12 13:32:12 +01:00
Matthias Krüger
681058ee88
Rollup merge of #150972 - rename-attrs, r=kivooeo
Rename EII attributes slightly (being consistent in naming things foreign items, not extern items)

r? @Kivooeo
2026-01-12 13:32:11 +01:00
Matthias Krüger
43c084ea61
Rollup merge of #150869 - fix/150841, r=BoxyUwU
Emit error instead of delayed bug when meeting mismatch type for const tuple

And rename some tests

Fixes rust-lang/rust#150841

r? @BoxyUwU
2026-01-12 13:32:08 +01:00
Jana Dönszelmann
322bbdfaaf
rename eii-extern-target 2026-01-12 08:07:23 +01:00
Asuna
e555d2c44b Use updated indexes to build reverse map for delegation generics 2026-01-12 00:11:55 +01:00
Nicholas Nethercote
2ae298711f Replace two BottomUpFolders with fold_regions.
Because these folders only change regions.

Note: `BottomUpFolder` folds all regions, while `fold_regions` skips
some bound regions. But that's ok because these two folders only modify
`ReVar`s.
2026-01-12 08:51:49 +11:00
Matthias Krüger
83924065f7
Rollup merge of #150942 - port_more_attrs, r=jdonszelmann
Port `#[rustc_has_incoherent_inherent_impls]` to attribute parser

Tracking issue: rust-lang/rust#131229
no tests changed here at all, so maybe we should add some but would like to know what kind of tests would be good to add

r? @JonathanBrouwer
2026-01-11 09:56:52 +01:00
Stuart Cook
e25d7a898a
Rollup merge of #150799 - mcga, r=BoxyUwU
Fix ICE: can't type-check body of DefId  for issue #148729

This commit fixes https://github.com/rust-lang/rust/issues/148729 for min_const_generic_args https://github.com/rust-lang/rust/issues/132980.

It's pretty small PR. The first commit makes sure that the `type_const`s are made into normal consts in const expressions.

The next one just handles the case https://github.com/rust-lang/rust/issues/148729 of where the type of the const was omitted at which point it was trying to treat a `type_const` again as a regular const. That obviously will fail since a type_const does not have a body.

@rustbot label +F-associated_const_equality +F-min_generic_const_args +I-ICE
2026-01-11 14:27:56 +11:00
mu001999
8ca1c9eb8f Rename tests for const tuple properly 2026-01-11 11:26:10 +08:00
mu001999
9e0a27cfa9 Emit error instead of delayed bug when meeting mismatch type for const tuple 2026-01-11 11:26:10 +08:00
Edvin Bryntesson
76fcac2371
Port #[rustc_has_incoherent_inherent_impls] to attribute parser 2026-01-10 23:58:03 +01:00
rust-bors[bot]
f57eac1bf9
Auto merge of #146923 - oli-obk:comptime-reflect, r=BoxyUwU
Reflection MVP

I am opening this PR for discussion about the general design we should start out with, as there are various options (that are not too hard to transition between each other, so we should totally just pick one and go with it and reiterate later)

r? @scottmcm and @joshtriplett

project goal issue: https://github.com/rust-lang/rust-project-goals/issues/406
tracking issue: https://github.com/rust-lang/rust/issues/146922

The design currently implemented by this PR is

* `TypeId::info` (method, usually used as `id.info()` returns a `Type` struct
* the `Type` struct has fields that contain information about the type
* the most notable field is `kind`, which is a non-exhaustive enum over all possible type kinds and their specific information. So it has a `Tuple(Tuple)` variant, where the only field is a `Tuple` struct type that contains more information (The list of type ids that make up the tuple).
* To get nested type information (like the type of fields) you need to call `TypeId::info` again.
* There is only one language intrinsic to go from `TypeId` to `Type`, and it does all the work

An alternative design could be

* Lots of small methods (each backed by an intrinsic) on `TypeId` that return all the individual information pieces (size, align, number of fields, number of variants, ...)
* This is how C++ does it (see https://lemire.me/blog/2025/06/22/c26-will-include-compile-time-reflection-why-should-you-care/ and https://isocpp.org/files/papers/P2996R13.html#member-queries)
* Advantage: you only get the information you ask for, so it's probably cheaper if you get just one piece of information for lots of types (e.g. reimplementing size_of in terms of `TypeId::info` is likely expensive and wasteful)
* Disadvantage: lots of method calling (and `Option` return types, or "general" methods like `num_fields` returning 0 for primitives) instead of matching and field accesses
* a crates.io crate could implement `TypeId::info` in terms of this design

The backing implementation is modular enough that switching from one to the other is probably not an issue, and the alternative design could be easier for the CTFE engine's implementation, just not as nice to use for end users (without crates wrapping the logic)

One wart of this design that I'm fixing in separate branches is that `TypeId::info` will panic if used at runtime, while it should be uncallable
2026-01-10 15:00:14 +00:00
reddevilmidzy
618b0b5464 Lower hir::ConstArgKind::Array to a ValTree 2026-01-10 12:41:50 +09:00
reddevilmidzy
fc06a57a78 Introduce hir::ConstArgKind::Array 2026-01-10 12:41:50 +09:00
Keith-Cancel
f982bc6a2d Fix ICE: can't type-check body of DefId, since type_consts don't have a body.
Handling for inherent associated consts is missing elsewhere, remove so it can be handled later in that handling.

Diagnostic not always be emitted on associated constant

Add a test case and Fix for a different ICE I encountered.

I noticed when trying various permuations of the test case code to see if I could find anymore ICEs. I did, but not one that I expected. So in the instances of the a named const not having any args, insantiate it directly. Since it is likely an inherent assocaiated const.

Added tests.

Centralize the is_type_const() logic.

I also noticed basically the exact same check in other part the code.

Const blocks can't be a type_const, therefore this check is uneeded.

Fix comment spelling error.

get_all_attrs is not valid to call for all DefIds it seems.

Make sure that if the type is omitted for a type_const that we don't ICE.

Co-Authored-By: Boxy <rust@boxyuwu.dev>
2026-01-09 14:45:33 -08:00
Flakebi
91d4e40e02
Add amdgpu_dispatch_ptr intrinsic
Add a rustc intrinsic `amdgpu_dispatch_ptr` to access the kernel
dispatch packet on amdgpu.
The HSA kernel dispatch packet contains important information like the
launch size and workgroup size.

The Rust intrinsic lowers to the `llvm.amdgcn.dispatch.ptr` LLVM
intrinsic, which returns a `ptr addrspace(4)`, plus an addrspacecast to
`addrspace(0)`, so it can be returned as a Rust reference.

The returned pointer/reference is valid for the whole program lifetime,
and is therefore `'static`.

The return type of the intrinsic (`*const ()`) does not mention the
struct so that rustc does not need to know the exact struct type.
An alternative would be to define the struct as lang item or add a
generic argument to the function.

Short version:
```rust
#[cfg(target_arch = "amdgpu")]
pub fn amdgpu_dispatch_ptr() -> *const ();
```
2026-01-09 10:41:37 +01:00
Jana Dönszelmann
5ddda0c37b
fix up diagnostics referring to the right items 2026-01-09 09:29:02 +01:00
Jana Dönszelmann
e3cff18370
dont resolve defaults anymore, store foreign item defid instead of macro 2026-01-09 09:29:02 +01:00
Jana Dönszelmann
5e5c724194
turn panics into span_delayed_bug to make sure this pattern doesn't go unnoticed 2026-01-09 09:29:02 +01:00
León Orell Valerian Liehr
b144a11d2c
Replace more mentions of associated_const_equality 2026-01-09 00:32:37 +01:00
Matthias Krüger
0fbcfb9a05
Rollup merge of #150825 - move-items, r=JonathanBrouwer
Query associated_item_def_ids when needed

This commit moves a query to `associated_item_defs` from above an error condition caused independently of it to below it.

It looks generally cleaner and might potentially save some runtime in case the error condition is met, rendering `items` to be left unused, yet still queried.
2026-01-08 22:21:21 +01:00
Clara Engler
1eb605f634
Query associated_item_def_ids when needed
This commit moves a query to `associated_item_defs` from above an error
condition caused independently of it to below it.

It looks generally cleaner and might potentially save some runtime in
case the error condition is met, rendering `items` to be left unused,
yet still queried.
2026-01-08 19:41:24 +01:00
human9000
9f3956f378 MGCA: literals support 2026-01-08 20:29:00 +05:00
Oli Scherer
a3359bdd4f Compile-Time Reflection MVP: tuples 2026-01-08 11:41:00 +00:00
mu001999
cb1de29659 Use parent's identity_args to instantiate the type of const param 2026-01-07 08:44:32 +08:00
mu001999
d572e6d415 Add span field for ConstArg 2026-01-07 08:44:32 +08:00
mu001999
af76a2456d MGCA: Support tuple expressions as direct const arguments 2026-01-07 08:44:23 +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
Matthias Krüger
cd502ff78e
Rollup merge of #150589 - AprilNEA:remove-unneeded-forbid-generic-field, r=camelid,BoxyUwU
Remove unneeded `forbid_generic` field from `Res::SelfTyAlias`

Following rust-lang/rust#150519, the `forbid_generic` field in `Res::SelfTyAlias` is no longer needed and can be removed.

- Remove the `forbid_generic: bool` field from `Res::SelfTyAlias`
- Simplify the ConstantItem rib handling in `rustc_resolve` - no longer need to mutate res to set `forbid_generic: true`
- Update all pattern matches and constructors of `SelfTyAlias`

Closes rust-lang/rust#150579

r? ``@camelid``
2026-01-03 10:09:30 +01:00
AprilNEA
cc563d5315
Remove unneeded forbid_generic field from Res::SelfTyAlias
The `forbid_generic` field in `Res::SelfTyAlias` is no longer needed.
The check for generic `Self` types in anonymous constants is now handled
by `check_param_uses_if_mcg` in HIR type lowering, making this field
redundant.

This removes:
- The `forbid_generic` field from `Res::SelfTyAlias`
- The hack in `rustc_resolve` that set `forbid_generic: true` when
encountering `Self` in constant items
- Related pattern matching and field propagation code
2026-01-03 09:02:46 +08:00
Marcelo Domínguez
58e2610f71 Expose workgroup/thread dims as intrinsic args 2026-01-02 11:50:32 +01:00
Takayuki Maeda
2c31b0deb1 check if redundant args spans belong to the same context 2026-01-02 16:01:35 +09:00
bors
a47f4dfd7f Auto merge of #150519 - camelid:mgca-forbid-params-properly, r=BoxyUwU
Use more principled check for generics in const ops

Fixes rust-lang/rust#144547.
Fixes rust-lang/rust#140891.

In the future, we likely want to make the check less likely to be missed by reducing the number of external entry points to HIR type lowering.

Note: If this causes pass->error regressions (not truly regressions because those cases were mistakenly accepted), they can easily be avoided for the time being by only running the check if `is_self_alias` is true or mgca is enabled.

- **Fix parsing of mgca const blocks in array repeat exprs**
- **Use more principled check for generics in const ops**
2026-01-02 02:23:07 +00:00
Noah Lev
bad0c3230f mgca: Remove resolved FIXME 2026-01-01 18:12:34 -08: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
dianne
6b60e81e8c Rewrite a loop as tail recursion 2025-12-31 08:51:49 -08:00
Jonathan Brouwer
d63068b3b4
Rollup merge of #150405 - estebank:matches-could-be-equals, r=Kivooeo
Don't use `matches!` when `==` suffices

In the codebase we sometimes use `matches!` for values that can actually just be compared. Replace them with `==`.

Subset of rust-lang/rust#149933.
2025-12-27 13:42:01 +01:00