Commit Graph

1413 Commits

Author SHA1 Message Date
Jonathan Brouwer
df04ad29b7 Rollup merge of #159746 - folkertdev:stabilize-c-variadic-naked-functions, r=tiif
stabilize `c_variadic_naked_functions`

tracking issue: https://github.com/rust-lang/rust/issues/148767
reference PR: https://github.com/rust-lang/reference/pull/2321

# Stabilization report

## Summary

Stabilize the ability to use `#[unsafe(naked)]` functions to define c-variadic functions. These c-variadic naked functions accept the same set of ABIs as c-variadic foreign functions, this set is larger than what we currently accept for c-variadic definitions.

```rust
#[unsafe(naked)]
unsafe extern "aapcs" fn variadic_aapcs(_: f64, _: ...) -> f64 {
    core::arch::naked_asm!(
        r#"
        sub     sp, sp, #12
        stmib   sp, {{r2, r3}}
        vmov    d0, r0, r1
        add     r0, sp, #4
        vldr    d1, [sp, #4]
        add     r0, r0, #15
        bic     r0, r0, #7
        vadd.f64        d0, d0, d1
        add     r1, r0, #8
        str     r1, [sp]
        vldr    d1, [r0]
        vadd.f64        d0, d0, d1
        vmov    r0, r1, d0
        add     sp, sp, #12
        bx      lr
    "#,
    )
}
```

## Accepted ABIs

The set of accepted ABIs is the same as for c-variadic foreign functions, defined as rule [`items.extern.variadic.conventions`](https://doc.rust-lang.org/nightly/reference/items/external-blocks.html?highlight=externblo#r-items.extern.variadic.conventions):

- `"aapcs"`
- `"C"`
- `"cdecl"`
- `"efiapi"`
- `"system"`
- `"sysv64"`
- `"win64"`

And their corresponding `-unwind` variants. Given that naked functions desugar to a block of module assembly and a foreign definition, it makes sense to support the same set as source-level foreign definitions.

For c-variadic definitions we only accept `"C"` and `"C-unwind"`.

## Multiple c-variadic ABIs in the same program

LLVM supports c-variadic calls of different ABIs in the same program. We test both an arm and x86 configuration

- 771916f902/tests/ui/c-variadic/same-program-multiple-abis-arm.rs
- 771916f902/tests/ui/c-variadic/same-program-multiple-abis-x86_64.rs

Note that GCC, Clang and LLVM do not support c-variadic definitions of multiple ABIs: the `va_start`, `va_arg` etc. macros are always expanded using the default C calling convention. Clang and GCC reject a variable argument list on definitions that use a non-default calling convention.

## History

- [#t-lang > C-variadic naked functions](https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/C-variadic.20naked.20functions/with/554593886)
- https://github.com/rust-lang/rust/pull/148770

The stabilization report of `feature(c_variadic)` mentions this feature:

- https://github.com/rust-lang/rust/pull/155697

## Unresolved questions

None.
2026-08-09 18:22:26 +02:00
Jacob Pratt
3820cc943d Rollup merge of #158517 - JonathanBrouwer:named_fn_trait_parameters, r=JohnTitor
Initial implementation of named `Fn` trait parameters

This is an initial implementation of the feature `named_fn_trait_parameters`.
This implementation is incomplete (and also marked as such) , and needs significant further changes to be implemented correctly. To keep the size of this PR managable, I propose we do this in follow-up PRs.
I've added a test that shows the current behaviour, with `FIXME` comments where the test output is currently incorrect.

Tracking issue: https://github.com/rust-lang/rust/issues/158499
Accepted RFC: https://github.com/rust-lang/rfcs/pull/3955
2026-08-08 23:51:55 -04:00
Jieyou Xu
0a0f6df1d5 Rename #[unroll] => #[rustc_unroll] to mitigate nameres ambiguity
Mitigation for [RUST-159429].

The recurring problem is that built-in attributes are treated
differently compared to ordinary prelude attributes, built-in
attributes, even while unstable, can name-collide with stable macro
re-exports of the same name (and proc-macro helper attributes of the
same name), which can break stable code. See [RUST-134964].

[RUST-159429]: https://github.com/rust-lang/rust/issues/159429
[RUST-134963]: https://github.com/rust-lang/rust/issues/134963
2026-08-06 09:23:24 +08:00
mejrs
73f94b6b9f Make the rustc_unsafe_specialization_marker attribute actually unsafe
Also renames it to `rustc_specialization_ignore_lifetime_constraints`
2026-08-04 19:04:05 +02:00
Jonathan Brouwer
6c901cee79 Mark named_fn_trait_parameters as incomplete 2026-08-02 12:29:03 +02:00
CoCo-Japan-pan
490f95cd6b Remove the incomplete marker from mut restrictions 2026-08-01 17:02:23 +09:00
Jonathan Brouwer
0efc299ce6 Add named_fn_trait_parameters feature gate 2026-07-31 13:27:22 +02:00
teor
e574edfbac Automatically rename rustc_splat attribute
fastmod --fixed-strings '#[splat]' '#[rustc_splat]'
fastmod --fixed-strings '`splat` attribute' '`rustc_splat` attribute'
fastmod --fixed-strings '$splat$' '$rustc_splat$'
fastmod 'v0(.*)#\[rustc_splat\]' 'v0${1}#[splat]' tests/ui/splat/splat-mangling.rs
2026-07-30 10:59:40 +10:00
teor
cb797b89ce Rename splat attribute to rustc_splat 2026-07-30 10:58:18 +10:00
Jonathan Brouwer
bca856424e Rollup merge of #158038 - nbdd0121:register_tool, r=mejrs
Split register_tool into register_attribute_tool and register_lint_tool

Tracking issue: rust-lang/rust#66079

This implements the attribute parsing part of RFC 3808. The resolution part is yet to be implemented.

cc @jyn514
2026-07-28 21:07:45 +02:00
Urgau
73d7d8dc85 Add #[rustc_panics_when_zero] attribute 2026-07-27 22:44:12 +02:00
Gary Guo
75999c498f Split register_tool into register_attribute_tool and register_lint_tool
This splits the functionality to two parts per RFC. The `#![register_tool]`
attribute registers the tool in both ways.

Semantics remain unchanged and will be adjusted in later commit.
2026-07-27 19:06:33 +01:00
Gary Guo
c8238fadb1 Stop mentioning register_attr feature from custom_attribute
It is also removed.
2026-07-27 17:42:46 +01:00
Jacob Pratt
0e238fd6c3 Rollup merge of #138618 - nbdd0121:asm_const_ptr, r=bjorn3
Support using const pointers in asm `const` operand

Implements [RFC#3848](https://github.com/rust-lang/rfcs/pull/3848) with tracking issue rust-lang/rust#128464

This adds support of const pointers for asm `const` in addition to plain integers.

The inline `asm!` support is implemented using `i` constraint, and the `global_asm!` and `naked_asm!` support is implemented by inserting `symbol + offset` and make `symbol` compiler-used. For unnamed consts, it will create additional internal & hidden symbols so that they can be referenced by global_asm.

~~The feature is also implemented for GCC backend but it's untested.~~ Tested now.
2026-07-26 00:21:39 -04:00
Gary Guo
73ff59fce9 Implement asm_const_ptr feature
The backend now fully supports codegen of const pointers, remove the
block inside typeck behind a new feature gate. Tests are also added.
2026-07-23 18:51:29 +01:00
Folkert de Vries
6a8ef66f48 stabilize c_variadic_naked_functions 2026-07-22 23:57:08 +02:00
Folkert de Vries
d7ea382797 Stabilize c_variadic 2026-07-22 11:42:09 +02:00
Jonathan Brouwer
fd4b1d563d Rollup merge of #159058 - khyperia:macroless_generic_const_args, r=BoxyUwU
implement #![feature(macroless_generic_const_args)]

tracking issue: https://github.com/rust-lang/rust/issues/159006

lots of description of what is happening here in the tracking issue, not gonna copypaste it into here :)

the test situation is that after discussion with boxy of whether our mgca tests should be:

- keep them under only `min_generic_const_args`, and add `direct_const_arg!()` where it's needed
- keep the code contents as-is, and add `#![feature(macroless_generic_const_args)]` where it's needed

the second seems more desirable, so that's what I did. There are still quite a few tests that only have `min_generic_const_args` without `macroless_generic_const_args` (140 of them, to be exact - `rg --files-without-match macroless_generic_const_args $(rg -g '*.rs' --files-with-matches min_generic_const_args tests) | wc -l`, and now 90 with `macroless_generic_const_args`)

r? @BoxyUwU
2026-07-21 12:24:55 +02:00
khyperia
a388f03123 macroless_generic_const_args 2026-07-20 18:24:17 +02:00
Urgau
4006ba35cb Add #[rustc_canonical_symbol] attribute 2026-07-19 17:38:51 +02:00
bors
656ccbe796 Auto merge of #159266 - nnethercote:rm-AttrItemKind, r=petrochenkov,JonathanBrouwer
Overhaul `CfgTrace`/`CfgAttrTrace` handling



I noticed that `AttrItemKind` was a bit clunky and by the time I was finished I had a PR that:
- removes `AttrItemKind`;
- removes `sym::cfg_trace` and `sym::cfg_attr_trace`;
- overhauls how these attributes are handled;
- changes the terminology used for these attributes;
- fixes some erroneous comments;
- and a few other small improvements.

It's a sizeable change but I think it makes things a lot clearer. Details in individual commits.

r? @petrochenkov
2026-07-17 13:18:23 +00:00
Nicholas Nethercote
1a8ecb0b5b Remove sym::cfg_trace and sym::cfg_attr_trace
This commit pushes further than the previous one, relying more heavily
on looking directly at `AttrKind::Parsed` to handle various cases.

Note that the removed clippy code was actually dead.
2026-07-17 08:59:25 +10:00
Nicholas Nethercote
b357c7c0ff Remove AttrItemKind
`AttrItem` currently contains an `AttrItemKind` which is either `Parsed`
or `Unparsed`. In the `Parsed` case the surrounding `AttrItem` is
basically fake, with a meaningless `unsafety` field, a synthetic
(non-ident) symbol, and an empty `tokens`.

This commit moves `Parsed` up one level to become a new variant of
`AttrKind`. It no longer needs to pretend to be an `AttrKind::Normal`,
and makes a number of things simpler:
- No `unparsed_ref` calls needed.
- Replaces the `attr_into_trace` and `Attribute::replace_args` mess with
  the much simpler `convert_normal_to_parsed`.

The commit converts a numberof non-exhaustive `AttrKind` matches (those
that don't involve matching a single attribute) to exhaustive, for
future-proofing. It uses `unreachable!` on all the `AttrKind::Parsed`
cases that aren't hit by the full test suite.
2026-07-17 08:59:24 +10:00
Nicholas Nethercote
d0042c3c7c Expand some comments about cfg_trace/cfg_attr_trace
To explain some things that weren't obvious to me.
2026-07-17 08:55:42 +10:00
Jose Torres
526787dbbc rename from lazy_type_alias to checked_type_aliases
Co-authored-by: lcnr <rust@lcnr.de>
2026-07-15 11:50:42 -04:00
Jacob Pratt
2d4ae662df Rollup merge of #158608 - mejrs:opaque, r=estebank
Implement `#[diagnostic::opaque]` attribute to hide backtraces of macros.

r? @estebank

There are some more places where we can use this, for example 345632878c/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs (L623-L639) but those turned out to be a little complicated so are left for followup prs.

Tracking issue: rust-lang/rust#158813
2026-07-14 23:23:07 -04:00
bors
55b6bd8ecb Auto merge of #158888 - Mark-Simulacrum:bump-bootstrap, r=jieyouxu
Bump bootstrap to 1.98 beta



https://forge.rust-lang.org/release/process.html#default-branch-bootstrap-update-and-crater-tuesday
2026-07-13 23:28:03 +00:00
Mark Rousskov
61a4e6029c replace-version-placeholder 2026-07-13 18:04:39 -04:00
Jana Dönszelmann
e0f9f8c1a8 introduce a test entrypoint marker for tools 2026-07-13 10:47:09 +02:00
Jacob Pratt
beeaa7ab0b Rollup merge of #158782 - Mark-Simulacrum:expose-no-threads, r=Urgau
Add and use cfg(target_has_threads) to enforce no_thread impl usage

The standard library has fallback code for targets without threads (e.g., using a Cell-based Mutex and similar). Today there's no enforcement in std that those targets truly don't have threads which makes that code potentially unsound. This will let us add a static assertion that the target spec agrees that the target is non-threaded. Getting the target spec wrong is already unsound (e.g., LLVM can make use of that) so it's a reasonable source of truth. This pulls in the atomics target feature into the target code and makes the field itself private to encourage going via the method.

For now the cfg is added as unstable but if we have a use case for user code to use this, happy to cut a tracking issue and make it a regular unstable feature.

Setting a compiler reviewer since the std changes are pretty trivial, and I think anyone can review those reasonably.

cc rust-lang/rust#156366 which prompted looking into this

r? compiler
2026-07-06 04:33:09 -04:00
Mark Rousskov
26e35d93dc Add and use cfg(target_has_threads) to enforce no_thread impl usage
The standard library has fallback code for targets without threads
(e.g., using a Cell-based Mutex and similar). Today there's no
enforcement in std that those targets truly don't have threads which
makes that code potentially unsound. This will let us add a
static assertion that the target spec agrees that the target is
non-threaded.
2026-07-05 15:29:08 -04:00
mejrs
7f3569b174 Implement diagnostic::opaque attribute 2026-07-05 15:11:36 +02:00
Jonathan Brouwer
a9eeba2ab9 Rollup merge of #157857 - TimNN:macro-mod, r=petrochenkov
Stabilize `#[my_macro] mod foo;` (part of `proc_macro_hygiene`)

# Stabilization report

## Summary

Allow `mod foo;` (an "outlined" module) in the input of attribute and derive (proc) macros.

Tracking:

- https://github.com/rust-lang/rust/issues/54727
    - The `proc_macro_hygiene` feature covers multiple related features. This PR proposes only a partial stabilization

Reference PRs:

- https://github.com/rust-lang/reference/pull/2284

### What is stabilized

> Describe each behavior being stabilized and give a short example of code that will now be accepted.

Currently, `mod foo;` (an outlined / non-inline) module is explicitly rejected in the input of derive and attribute (proc) macros.

This PR removes the check, allowing `mod foo;`.

The module is provided to the macro as it is written in the source code, that is in its "not-yet-loaded" form without a body.

```rust
// The following was previously rejected and will now compile.

#[my_proc_macro]
mod foo;

#[my_proc_macro]
fn bar() {
    #[path = "foo.rs"]
    mod foo;
}

#[derive(MyTrait)]
struct Foo([u8; {
    #[path = "foo.rs"]
    mod foo;
    0
}]);
```

### What isn't stabilized

> Describe any parts of the feature not being stabilized. Talk about what we might want to do later and what doors are being left open for that. If what we're not stabilizing might lead to surprises for users, talk about that in particular.

The remaining parts of `proc_macro_hygiene` are not stabilized (specifically, attribute macros in places where they aren't currently allowed).

## Design

### Reference

> What updates are needed to the Reference? Link to each PR. If the Reference is missing content needed for describing this feature, discuss that.

https://github.com/rust-lang/reference/pull/2284

### RFC history

> What RFCs have been accepted for this feature?

This feature has not been explicitly specified by any RFC.

- Ahead of the `proc_macro` stabilization, `#[my_macro] mod foo;` specifically was feature gated.
- As a side effect of https://github.com/rust-lang/rust/pull/52319, the (unstable) behavior changed:
    - Before that PR, `mod foo;` was actually provided to macros as the loaded `mod foo { ... }`
    - After that PR, `mod foo;` was provided to macros as-is.
- In 2019 (after the `proc_macro` stabilization, https://github.com/rust-lang/rust/pull/66078 made `mod foo` _**anywhere**_ in the input to derive or attribute proc macros unstable.
    - Before that PR, only proc macros directly applied to `mod foo;` were unstable.

### Answers to unresolved questions

> What questions were left unresolved by the RFC? How have they been answered? Link to any relevant lang decisions.

N/A

### Post-RFC changes

> What other user-visible changes have occurred since the RFC was accepted? Describe both changes that the lang team accepted (and link to those decisions) as well as changes that are being presented to the team for the first time in this stabilization report.

See the RFC history above.

### Key points

> What decisions have been most difficult and what behaviors to be stabilized have proved most contentious? Summarize the major arguments on all sides and link to earlier documents and discussions.

The main design decision is whether outlined modules should be passed to proc macros with or without their body.

Arguments in favor of "without their body":

- (To the best of my knowledge) the current compiler architecture makes "without their body" the natural choice.
    - To [quote](https://github.com/rust-lang/rust/issues/54727#issuecomment-4643290397) @petrochenkov, "it's clear that the current behavior of `#[my_macro] mod foo;` (the "not-yet-loaded" version of the module is passed to the macro) is natural to the current setup, stable and is not going to change".
- At least I would be somewhat surprised to see a macro (which is operating on the AST) able to see or affect code outside the current file. I would assume by default that they get as input exactly what I have written.
- Function-like procedural macros operate on arbitrary token trees. `mod foo;` in their input is not even recognized by the compiler and thus not expanded. Attribute and derive proc macros also receiving the unexpanded `mod foo;` in their input makes the two consistent.
- Other syntactic constructs, e.g. other macros like `inlcude!("foo.rs")`, are also not expanded before being passed to proc macros. Providing modules without their body would be consistent with that.
- Providing `mod foo;` to proc macros with its body would (as far as I know) be the only case where a proc macro would not get exactly what is written in the source code as its input.

Arguments in favor of "with their body":

- `#[my_macro] mod foo;` and `#[my_macro] mod foo {}` would have different behavior, which means that in the presence of proc macros, migrating an inline module to an outlined one would no longer be a purely syntactic change, but could affect the behavior of the proc macro.
- `#[my_macro] mod foo;` and `#![my_macro]` in `foo.rs` ([currently unstable](https://github.com/rust-lang/rust/issues/54726)) would have different behavior.
    - Other attributes already have different behaviors depending on whether they are applied as inner vs outer attributes. For example `#[cfg(false)]` on a module as an outer attribute means the corresponding file can be missig or have syntax errors, while using it as an inner attribute requires the file to be syntactically valid.
- Some macros may need access to (or change) the module body to function properly.

### Nightly extensions

> Are there extensions to this feature that remain unstable? How do we know that we are not accidentally committing to those?

No.

### Doors closed

> What doors does this stabilization close for later changes to the language? E.g., does this stabilization make any other RFCs, lang experiments, or known in-flight proposals more difficult or impossible to do later?

None.

If, in the future, there is a desire to make the module body of outlined modules available to proc macros, there are multiple ways to add that in a backward-compatible way (e.g. an explicit opt-in during the proc macro registration, or an API in the `proc_macro` crate).

## Feedback

### Call for testing

> Has a "call for testing" been done? If so, what feedback was received?

No.

### Nightly use

> Do any known nightly users use this feature? Counting instances of `#![feature(FEATURE_NAME)]` on GitHub with grep might be informative.

Searching Github [produces](https://github.com/search?q=%22feature%28proc_macro_hygiene%29%22+language%3ARust+&type=code) 4.4k files. Reviewing the first page of results shows many repositories that haven't been updated in multiple years, so it is unclear which part of the `proc_macro_hygiene` feature they actually use (other parts of the feature were previously stabilized).

## Implementation

### Major parts

> Summarize the major parts of the implementation and provide links into the code and to relevant PRs.

The restriction is currently implemented as an explicit visitor of the proc macro input, rejecting outlined modules. The visitor is removed in this PR.

### Coverage

> Summarize the test coverage of this feature.

See the test changes attached to this PR. The added tests explicitly verify that proc macros receive `mod foo;` as an input without its body, to ensure that the behavior doesn't unintentionally change in the future.

### Outstanding bugs

> What outstanding bugs involve this feature? List them. Should any block the stabilization? Discuss why or why not.

None.

### Outstanding FIXMEs

> What FIXMEs are still in the code for that feature and why is it OK to leave them there?

None.

### Tool changes

> What changes must be made to our other tools to support this feature. Has this work been done? Link to any relevant PRs and issues.

Generally none. The feature is a minor addition to the inputs that (proc) macros accept, and should not require special handling in any of the tools.

rust-analyzer has some existing limitations around handling modules transformed by proc macros (e.g. (on stable) auto-complete does not work if a proc macro transforms `mod foo {}` to `mod foo;`). It works fine for simple case where the the proc macro leaves the `mod foo;` mostly unmodified.

### Breaking changes

> If this stabilization represents a known breaking change, link to the crater report, the analysis of the crater report, and to all PRs we've made to ecosystem projects affected by this breakage. Discuss any limitations of what we're able to know about or to fix.

N/A: The feature is not expected to cause any breakage.

## Type system, opsem

N/A: This feature only affects the AST, not type checking.

## Common interactions

### Temporaries

> Does this feature introduce new expressions that can produce temporaries? What are the scopes of those temporaries?

No.

### Drop order

> Does this feature raise questions about the order in which we should drop values? Talk about the decisions made here and how they're consistent with our earlier decisions.

No.

### Pre-expansion / post-expansion

> Does this feature raise questions about what should be accepted pre-expansion (e.g. in code covered by `#[cfg(false)]`) versus what should be accepted post-expansion? What decisions were made about this?

No. (At least nothing that doesn't equally apply to existing stable proc macros).

### Edition hygiene

> If this feature is gated on an edition, how do we decide, in the context of the edition hygiene of tokens, whether to accept or reject code. E.g., what token do we use to decide?

N/A: Not gated on an edition.

### SemVer implications

> Does this feature create any new ways in which library authors must take care to prevent breaking downstreams when making minor-version releases? Describe these. Are these new hazards "major" or "minor" according to [RFC 1105](https://rust-lang.github.io/rfcs/1105-api-evolution.html)?

No.

### Exposing other features

> Are there any other unstable features whose behavior may be exposed by this feature in any way? What features present the highest risk of that?

No.

## History

> List issues and PRs that are important for understanding how we got here.

See the RFC History section above.

## Acknowledgments

> Summarize contributors to the feature by name for recognition and so that those people are notified about the stabilization. Does anyone who worked on this _not_ think it should be stabilized right now? We'd like to hear about that if so.

- @alexcrichton for the work towards the initial proc-macro expansion.
- @petrochenkov for significant work on hygiene and expansion since then.

## Open items

> List any known items that have not yet been completed and that should be before this is stabilized.

None.

---

r? @petrochenkov for an initial review (feel free to edit the stabilization report if you like)
2026-07-05 14:12:05 +02:00
bors
8e150217ba Auto merge of #157384 - addiesh:turbofisherwoman, r=oli-obk
Add `#[rustc_dump_generics]` attribute





Added a rustc attribute to dump the generic parameters of a given item to the compiler output.
2026-06-19 02:01:26 +00:00
Jonathan Brouwer
854fdba980 Rollup merge of #157931 - mejrs:feature_macro, r=jieyouxu
Improve `declare_features!` macro error

I got mildly annoyed when I went to add a new feature, and the fix for this is relatively simple.

Current error:
```
error[E0425]: cannot find value `better_rust` in module `sym`
   --> compiler\rustc_feature\src\unstable.rs:240:16
    |
157 |                 name: sym::$feature,
    |                            -------- due to this macro variable
...
240 |     (internal, better_rust, "2.0.0", None),
    |                ^^^^^^^^^^^ not found in `sym`

For more information about this error, try `rustc --explain E0425`
```

Previous error:
```
error[E0425]: cannot find value `better_rust` in module `sym`
   --> compiler\rustc_feature\src\unstable.rs:240:16
    |
157 |                 name: sym::$feature,
    |                            -------- due to this macro variable
...
240 |     (internal, better_rust, "2.0.0", None),
    |                ^^^^^^^^^^^ not found in `sym`

error[E0531]: cannot find unit struct, unit variant or constant `better_rust` in module `sym`
   --> compiler\rustc_feature\src\unstable.rs:240:16
    |
157 |                 name: sym::$feature,
    |                            -------- due to this macro variable
...
240 |     (internal, better_rust, "2.0.0", None),
    |                ^^^^^^^^^^^ not found in `sym`

Some errors have detailed explanations: E0425, E0531.
```
2026-06-17 11:33:51 +02:00
Paul Murphy
f638abc260 Add instrument_fn attribute
This attribute enables or disables function instrumentation
when using `-Zinstrument-xray` or `-Zinstrument-mcount`.

It supports the following usage:

`#[instrument_fn = "on|off"]`

For XRay, "on" is equivalent to always instrument, and "off" is
equivalent to never instrumenting.

For mcount, "on" has no effect. "off" disables instrumentation
of the function.
2026-06-16 17:11:03 -05:00
bors
b998449636 Auto merge of #156816 - saethlin:loop-attributes, r=JonathanBrouwer,folkertdev
Add unstable loop unrolling hint attributes



Tracking issue: https://github.com/rust-lang/rust/issues/156874

This adds as new attribute `#[unroll]`/`#[unroll(full)]`/`#[unroll(never)]`/`#[unroll(16)]` (or any u32).

`#[unroll]` is behind a new feature gate `#![feature(loop_hints)]` because I intend to add an attribute for loop vectorization as well. If a user wants to turn off loop unrolling to locally minimize code size, LLVM may vectorize the loop even though it isn't unrolled which can produce a similar code size explosion.
2026-06-16 08:40:13 +00:00
mejrs
3ae0f01724 Improve declare_features! macro error 2026-06-15 20:59:41 +02:00
León Orell Valerian Liehr
69a17b186f Rename feature diagnostic_on_unmatch_args to diagnostic_on_unmatched_args 2026-06-14 15:24:01 +02:00
Tim Neumann
5e016b66c3 Stabilize #[my_macro] mod foo; (part of proc_macro_hygiene) 2026-06-13 12:44:34 +02:00
Usman Akinyemi
78d7543a54 Introduce #[diagnostic::on_type_error(note)]
Suggested-by: Esteban Küber <esteban@kuber.com.ar>
Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
2026-06-13 04:27:23 +05:30
Ben Kimock
321f54ca94 Add #![feature(loop_hints)] and #[unroll] 2026-06-11 20:32:52 -04:00
addie.sh
6f6f1570da Add #[rustc_dump_generics] attribute, tests 2026-06-11 05:08:40 +02:00
teor
2a3a8dd365 Add splat builtin attribute & feature gate 2026-06-09 09:38:00 +02:00
Jacob Pratt
ac3892573e Rollup merge of #157624 - ariagivens:move-attribute-template, r=JonathanBrouwer
Move AttributeTemplate from rustc_feature to rustc_attr_parsing

Refactor as discussed on zulip.

r? @JonathanBrouwer
2026-06-08 16:27:03 -04:00
Aria Givens
2258119981 Move AttributeTemplate to rustc_attr_parsing 2026-06-08 13:32:06 -04:00
Jonathan Brouwer
1419d3c381 Rollup merge of #148820 - oli-obk:comptime, r=fee1-dead
Add very basic "comptime" fn implementation

Implements functions that cannot be called at runtime (and thus also not from normal const functions, as those could be called from runtime).

This is done via the internal attribute `rustc_comptime` that can be added to normal functions, turning them into compile-time-only functions.

Because @fee1-dead and @compiler-errors did amazing work, we even get trait bounds that work inside comptime fns: via unconditionally-const `const Trait` bounds.

Use cases are

* https://github.com/rust-lang/rust/pull/146923
* const heap intrinsics
* and the other various intrinsics (e.g. size_of 😆) that will just ICE in codegen or panic at runtime if they actually end up in runtime code

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

no tracking issue until we have a feature gate and some sort of syntax

cc @scottmcm as the T-lang goal champion
2026-06-08 17:11:06 +02:00
Jonathan Brouwer
de70798fa7 Rollup merge of #147302 - esp-rs:xtensa-asm, r=Amanieu
asm! support for the Xtensa architecture

This implements the asm! support for Xtensa. We've been using this code for a few years in [our fork](https://github.com/esp-rs/rust) and it's been working well. I finally found some time to clean it up a bit and start the upstreaming process. This should be one of the final PRs for Xtensa support on the Rust side (minus bug fixes of course). After this, we're mostly just waiting on the LLVM upstreaming which is going well. This PR doesn't cover all possible asm options for Xtensa, but the base ISA plus a few extras that are used in Espressif chips.

r? Amanieu
2026-06-08 17:11:05 +02:00
Scott Mabin
768fc10e9d asm! support for the Xtensa architecture
Co-authored-by: Taiki Endo <te316e89@gmail.com>
Co-authored-by: Kerry Jones <kerry@iodrive.co.za>
2026-06-08 11:53:15 +01:00
Oli Scherer
322a5402f8 Check comptime fns 2026-06-08 12:34:45 +02:00