Commit graph

1804 commits

Author SHA1 Message Date
Guillaume Gomez
820579243f Remove rustc_attr_parsing::SharedContext::target_id field 2026-01-15 15:39:00 +01: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
Jana Dönszelmann
322bbdfaaf
rename eii-extern-target 2026-01-12 08:07:23 +01: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
Urgau
a8028abedb
Rollup merge of #150822 - fix-149981, r=@Kivooeo
Fix for ICE: eii: fn / macro rules None in find_attr()

Closes rust-lang/rust#149981

This used to ICE:
```rust
macro_rules! foo_impl {}
#[eii]
fn foo_impl() {}
```

`#[eii]` generates a macro (called `foo_impl`) and a default impl. So the partial expansion used to roughly look like the following:

```rust
macro_rules! foo_impl {} // actually resolves here

extern "Rust" {
    fn foo_impl();
}

#[eii_extern_target(foo_impl)]
macro foo_impl {
    () => {};
}

const _: () = {
    #[implements_eii(foo_impl)] // assumed to name resolve to the macro v2 above
    fn foo_impl() {}
};
```

Now, shadowing rules for macrov2 and macrov1 are super weird! Take a look at this: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2024&gist=23f21421921360478b0ec0276711ad36

So instead of resolving to the macrov2, we resolve the macrov1 named the same thing.

A regression test was added to this, and some span_delayed_bugs were added to make sure we catch this in the right places. But that didn't fix the root cause.

To make sure this simply cannot happen again, I made it so that we don't even need to do a name resolution for the default. In other words, the new partial expansion looks more like:

```rust
macro_rules! foo_impl {}

extern "Rust" {
    fn foo_impl(); // resolves to here now!!!
}

#[eii_extern_target(foo_impl)]
macro foo_impl {
    () => {};
}

const _: () = {
    #[implements_eii(known_extern_target=foo_impl)] // still name resolved, but directly to the foreign function.
    fn foo_impl() {}
};
```

The reason this helps is that name resolution for non-macros is much more predictable. It's not possible to have two functions like that with the same name in scope.

We used to key externally implementable items off of the defid of the macro, but now the unique identifier is the foreign function's defid which seems much more sane.

Finally, I lied a tiny bit because the above partial expansion doesn't actually work.
```rust
extern "Rust" {
    fn foo_impl(); // not to here
}

const _: () = {
    #[implements_eii(known_extern_target=foo_impl)] // actually resolves to this function itself
    fn foo_impl() {} // <--- so to here
};
```

So the last few commits change the expansion to actually be this:

```rust
macro_rules! foo_impl {}

extern "Rust" {
    fn foo_impl(); // resolves to here now!!!
}

#[eii_extern_target(foo_impl)]
macro foo_impl {
    () => {};
}

const _: () = {
    mod dflt { // necessary, otherwise `super` doesn't work
        use super::*;
        #[implements_eii(known_extern_target=super::foo_impl)] // now resolves to outside the `dflt` module, so the foreign item.
        fn foo_impl() {}
    }
};
```

I apologize to whoever needs to review this, this is very subtle and I hope this makes it clear enough 😭.
2026-01-09 23:28:16 +01:00
Guillaume Gomez
0548617ca0
Rollup merge of #150829 - fix_generic_param_target, r=JonathanBrouwer
make attrs actually use `Target::GenericParam`

currently attributes lower `GenericParam` -> `Target::Param` this PR fixes this, so that `GenericParam` is lowered to `Target::GenericParam`

r? @JonathanBrouwer
2026-01-09 12:00:02 +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
Edvin Bryntesson
742d276dc1
make attrs actually use Target::GenericParam 2026-01-08 20:26:45 +01:00
human9000
9f3956f378 MGCA: literals support 2026-01-08 20:29:00 +05: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
reddevilmidzy
56cb5d598b rename the lower_anon_const_to_const_arg and
`lower_anon_const_to_const_arg_direct` to
`lower_anon_const_to_const_arg_and_alloc` and
`lower_anon_const_to_const_arg`
2026-01-06 09:24:41 +09:00
reddevilmidzy
b0a581d51d rename the lower_ty and lower_ty_direct to lower_ty_and_alloc and
`lower_ty`
2026-01-06 09:19:03 +09: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
Jacob Pratt
57b2e6579a
Rollup merge of #150073 - daxpedda:internal-unstable-asm-experimental-arch, r=nnethercote
Make `asm_experimental_arch` work in `allow_internal_unstable` macros

This change makes it possible to use unstable `asm!`, usually requiring `feature(asm_experimental_arch)`, in proc-macros with the `allow_internal_unstable` attribute.

The test was added on a target where `asm!` is unstable: Wasm. However, this affects *any* target with an unstable `asm!` implementation.
2026-01-01 23:27:54 -05:00
Jonathan Brouwer
ef835a83ee
Rollup merge of #149667 - Shinonn23:fix-ice-constblock-148138, r=dianne
Fix ICE by rejecting const blocks in patterns during AST lowering (closes #148138)

This PR fixes the ICE reported in rust-lang/rust#148138.

The root cause is that `const` blocks aren’t allowed in pattern position, but the AST lowering logic still attempted to create `PatExprKind::ConstBlock`, allowing invalid HIR to reach type checking and trigger a `span_bug!`.

Following the discussion in the issue, this patch removes the `ConstBlock` lowering path from `lower_expr_within_pat`. Any `ExprKind::ConstBlock` inside a pattern is now handled consistently with other invalid pattern expressions.

A new UI test is included to ensure the compiler reports a proper error and to prevent regressions.

Closes rust-lang/rust#148138.
2025-12-28 22:52:31 +01:00
Shinonn
a9442b4a2a Fix ICE by rejecting const blocks in patterns during AST lowering
This fixes the ICE reported by rejecting `const` blocks in
pattern position during AST lowering.

Previously, `ExprKind::ConstBlock` could reach HIR as `PatExprKind::ConstBlock`,
allowing invalid patterns to be type-checked and triggering an ICE.
This patch removes the lowering path for const blocks in patterns
and emits a proper diagnostic instead.

A new UI test is added to ensure the compiler reports a regular error
and to prevent regressions.
2025-12-26 18:14:42 +07:00
aerooneqq
3f477dd710 Recursive delegation improvements 2025-12-25 14:49:01 +03:00
Boxy Uwu
c65551e835 Introduce hir::ConstArgKind::Struct 2025-12-23 13:54:59 +00:00
Jonathan Brouwer
aa93a61eb2
Rollup merge of #150098 - Bryntet:perf-testing, r=JonathanBrouwer
remove `legacy_const_generic_args` cache

putting this here to run perf
2025-12-22 17:33:36 +01:00
Jonathan Brouwer
1e496bc9e6
Rollup merge of #150024 - aerooneqq:recursive-delegation-2, r=petrochenkov
Support recursive delegation

This PR adds support for recursive delegations and is a part of the delegation feature rust-lang/rust#118212.

r? ``@petrochenkov``
2025-12-18 18:37:17 +01:00
aerooneqq
ae5e0d5492 Support recursive delegation 2025-12-18 10:42:47 +03:00
Edvin Bryntesson
8fcddc6393
remove legacy_const_generic_args cache 2025-12-17 17:03:41 +01:00
daxpedda
96c165b111
Make asm_experimental_arch work in allow_internal_unstable macros 2025-12-16 22:39:31 +01:00
Edvin Bryntesson
4bd0e65bde
Port #[rustc_legacy_const_generics] to use attribute parser 2025-12-16 20:29:01 +01:00
bors
3f4dc1e02d Auto merge of #146348 - jdonszelmann:eiiv3, r=lcnr,oli-obk
Externally implementable items

Supersedes https://github.com/rust-lang/rust/pull/140010
Tracking issue: https://github.com/rust-lang/rust/issues/125418

Getting started:

```rust
#![feature(eii)]

#[eii(eii1)]
pub fn decl1(x: u64)
// body optional (it's the default)
{
    println!("default {x}");
}

// in another crate, maybe
#[eii1]
pub fn decl2(x: u64) {
    println!("explicit {x}");
}

fn main() {
    decl1(4);
}
```

- tiny perf regression, underlying issue makes multiple things in the compiler slow, not just EII, planning to solve those separately.
- No codegen_gcc support, they don't have bindings for weak symbols yet but could
- No windows support yet for weak definitions

This PR merges the implementation of EII for just llvm + not windows, doesn't yet contain like a new panic handler implementation or alloc handler. With this implementation, it would support implementing the panic handler in terms of EII already since it requires no default implementation so no weak symbols

The PR has been open in various forms for about a year now, but I feel that having some implementation merged to build upon
2025-12-14 04:20:26 +00:00
Jacob Pratt
e7ba4a5e6d
Rollup merge of #149843 - aerooneqq:inherit-attributes-in-delegation, r=petrochenkov
Inherit attributes in delegation

This PR adds support for inheriting attributes of the original function of the delegation and is a part of rust-lang/rust#118212, for now we inherit only #[must_use] attribute, but we can add other attributes to inherit. The list of processed attributes can be found [here](https://github.com/aerooneqq/public-docs/blob/master/rust/delegation/processed_attributes.md).

r? ``@petrochenkov``
2025-12-13 00:55:56 -05:00
aerooneqq
0a3fd24287 Support attribute inheritance in delegation 2025-12-12 20:34:54 +03:00
Boxy Uwu
acc3a0e2da Syntactically distinguish anon const const args 2025-12-12 15:45:37 +00:00
Jana Dönszelmann
b732030025
make EII iteration faster 2025-12-12 11:28:58 +01:00
Jana Dönszelmann
33df6ccb21
EII lowering 2025-12-12 11:28:58 +01:00
Jana Dönszelmann
2de02ac86e
EII ast changes 2025-12-12 11:17:33 +01:00
Matthias Krüger
02a58a9bee
Rollup merge of #149489 - scottmcm:try-bikeshed, r=nnethercote
Experimentally add *heterogeneous* `try` blocks

rust-lang/rust#148725 moved the default to being homogeneous; this adds heterogeneous ones back under an obvious-bikeshed syntax so people can experiment with that as well.

Essentially resolves rust-lang/rust#149025 by letting them move to this syntax instead.

New tracking issue: rust-lang/rust#149488
Related RFC: https://github.com/rust-lang/rfcs/pull/3721#issuecomment-3208342727 (specifically about experimenting)
2025-12-10 17:16:47 +01:00
Scott McMurray
4033d19b79 Experimentally add *heterogeneous* try blocks
148725 moved the default to being homogeneous; this adds heterogeneous ones back under an obvious-bikeshed syntax so people can experiment with that as well.

Essentially resolves 149025 by letting them move to this syntax instead.
2025-12-09 20:18:43 -08:00
Esteban Küber
20fabb48b9 Use return type Span on async fns instead of whole fn def Span 2025-12-09 16:46:33 +00:00
bors
e2893f7c95 Auto merge of #149757 - jdonszelmann:revert-duplicate-span-lowering, r=nnethercote
Revert "early return on duplicate span lowerings"

r? `@nnethercote`

reverts rust-lang/rust#149060 because of perf regressions that are still wild to me
2025-12-09 11:38:27 +00:00
Matthias Krüger
7c9c7ed5be
Rollup merge of #149763 - aerooneqq:add-inline-attribute, r=petrochenkov
Add inline attribute to generated delegation function if needed

This PR adds a functionality to add #[inline(always)] attribute to generated functions from delegation, if some #[inline(..)] attribute is already specified on the delegation then we do nothing. This PR is a part of the delegation feature rust-lang/rust#118212 and addresses `Add implicit #[inline] unless specified otherwise` item.

r? ``@petrochenkov``
2025-12-09 06:17:26 +01:00
aerooneqq
8cf942d89f Add inline attribute to generated delegation function if needed 2025-12-08 19:56:47 +03:00
Jana Dönszelmann
942a08b559
Revert "early return on duplicate span lowerings"
This reverts commit 0087253015.
2025-12-08 10:49:55 +01:00
Stuart Cook
3c2a5dbace
Rollup merge of #149722 - dawidl022:contracts/fix/parsing-compound-statements, r=jieyouxu
contracts: fix lowering final declaration without trailing semicolon

Lowering for contract delcarations introduced in rust-lang/rust#144444 incorrectly handled the final declaration statement when it didn't end in a semicolon. This change fixes the issue.

See the included regression test for the minimal reproducible example.

Contracts tracking issue: https://github.com/rust-lang/rust/issues/128044
2025-12-08 11:46:25 +11:00
bors
fa1f706fbd Auto merge of #149060 - jdonszelmann:duplicate-span-lowering, r=WaffleLapkin
early return on duplicate span lowerings

`@bors2` try
2025-12-07 16:56:12 +00:00
Dawid Lachowicz
d54fee82f4
contracts: fix lowering final declaration without trailing semicolon
Lowering for contract delcarations incorrectly handled the final
declaration statement when it didn't end in a semicolon. This
change fixes the issue.
2025-12-07 09:08:46 +00:00
aerooneqq
3e717121a1 Generate error delegation body when delegation is not resolved 2025-12-05 15:22:26 +03:00
lcnr
feb13036ef remove support for type-of 2025-11-25 10:19:44 +01:00
Jana Dönszelmann
0087253015
early return on duplicate span lowerings 2025-11-18 20:09:54 +01:00
Oli Scherer
2a36d33930 Give all impls a constness 2025-11-18 09:20:21 +00:00