Commit Graph

1449 Commits

Author SHA1 Message Date
James Barford-Evans
df1b5c9671 f16b Implementation and documentation 2026-09-21 08:57:51 +01:00
Jonathan Brouwer
fa6e214d31 Rollup merge of #162634 - JonathanBrouwer:named-fn-trait-params-semantics, r=folkertdev
Implement semantic analysis for named `Fn` trait params

This PR can be reviewed commit by commit.
Every commit passes uitests individually.

The goal of this PR is to make the semantic of named fn trait parameters match those of `fn` pointers, which is what was decided on the RFC: https://github.com/rust-lang/rfcs/pull/3955.
This is achieved, which can be observed by the fact that the output of the `named-fn-trait-params.rs` test matches that of `fn-ptr-pattern.rs`.

This PR also marks the feature as complete.

Tracking issue: https://github.com/rust-lang/rust/issues/158499
2026-09-14 15:15:58 +02:00
khyperia
f5eb9e4005 yeet mgca_type_const_syntax 2026-09-11 17:08:12 +02:00
khyperia
5c5de6eae5 implement #[rustc_always_gca] 2026-09-11 17:08:12 +02:00
Jonathan Brouwer
930507ec76 No longer mark named_fn_trait_parameters as incomplete 2026-09-11 13:25:24 +02:00
Jonathan Brouwer
84f09c7144 Rollup merge of #162541 - BoxyUwU:twos_a_crowd, r=khyperia
split `macroless_generic_const_args` in two

Two's a crowd! But One's a lonely.

Having `macroless_generic_const_args` apply to const items was quite annoying for users especially as we moved away from `type const` to just regular const items. We would quite commonly be "guessing wrong" with no easy way for users to opt out of `const ASSOC: usize = ...` being represented directly instead of an opaque body

I just swapped any failing tests over to using macroless_const_item_generic_const_args, didnt look through the whole set :>

We should probably bikeshed the feature name rn because it's currently inconsistent with what we wanted to rename all of the other gca features too :> Maybe this should be `gca_macroless_const_items`

cc rust-lang/rust#162540

r? khyperia
2026-09-11 12:45:06 +02:00
Boxy Uwu
15d08109c4 split macroless_generic_const_args in two 2026-09-10 19:47:14 +01:00
Stuart Cook
467fe699f7 Rollup merge of #162122 - malezjaa:gate-enzyme-intrinsics, r=bjorn3
Put manual calls of Enzyme intrinsics behind a feature gate

r? bjorn3

fixes rust-lang/rust#161820

I created the internal feature gate without a tracking issue. `autodiff` didn’t seem like it was the right one.
2026-09-10 14:06:09 +10:00
malezjaa
4a17c03d39 Put manual calls of Enzyme intrinsics behind a feature gate 2026-09-09 22:24:54 +02:00
Jonathan Brouwer
7a02fd9f27 Remove gate_check from AttributeStability::Unstable 2026-09-01 18:45:44 +02:00
Jonathan Brouwer
8536b9e91a Rollup merge of #162051 - nnethercote:rustc_feature-cleanups, r=JonathanBrouwer
`rustc_feature` cleanups

Various cleanups. Details in individual commits.

r? @JonathanBrouwer
2026-09-01 13:27:43 +02:00
Nicholas Nethercote
60be5628af Simplify find_gated_cfg
Every caller passes a predicate that just does a name comparison.
2026-08-31 19:59:03 +10:00
Nicholas Nethercote
ef2ae3a7e0 Streamline a check 2026-08-31 19:59:03 +10:00
Nicholas Nethercote
ca967fa4e7 Add a missing backtick 2026-08-31 19:59:03 +10:00
Nicholas Nethercote
6146d3aacc Use NonZero<u32> consistently
Avoid mixing it with `NonZeroU32`.
2026-08-31 19:59:03 +10:00
Nicholas Nethercote
799c6d0902 Various comment improvements
Fix typos, wrap overlong lines, add missing comments, etc.
2026-08-31 19:59:03 +10:00
Nicholas Nethercote
b18fed12d8 Return a slice instead of &Vec<T> in two methods
It's more idiomatic.
2026-08-31 19:59:03 +10:00
Nicholas Nethercote
cd09177a9a Derive StableHash for three feature structs 2026-08-31 19:59:03 +10:00
Nicholas Nethercote
9670dfaf15 Use GateFn in AttributeStability
Also fix a typo and wrap some overlong comment lines.
2026-08-31 19:59:03 +10:00
Nicholas Nethercote
2a534f5f34 BUILTIN_ATTRIBUTE_MAP improvements
Rename it `BUILTIN_ATTRIBUTE_SET` because it's a set, and use `contains`
instead of `get` where appropriate.
2026-08-31 19:59:01 +10:00
Jonathan Brouwer
e36bc49e98 Rollup merge of #161931 - JonathanBrouwer:revert-test-entry-point, r=mejrs
Revert "Add rustc_test_entrypoint_marker"

Reverts https://github.com/rust-lang/rust/pull/158854 because it caused two beta regressions
Revert required some minor solving of conflicts
We can think about re-landing it after

Fixes https://github.com/rust-lang/rust/issues/161920
Fixes https://github.com/rust-lang/rust/issues/161917

cc: @Nadrieril @N1ark @aDotInTheVoid @jdonszelmann
2026-08-30 21:48:06 +02:00
Jonathan Brouwer
9b70ab051c Revert "Add rustc_test_entrypoint_marker" 2026-08-30 19:18:27 +02:00
Matthias Krüger
28182a7e29 remove rustc_never_type_options attr remnants
While fuzzing I noticed we would now ICE in two places when encountering an empty or filled `#![rustc_never_type_options()]` attr:

compiler/rustc_passes/src/check_attr.rs:160:33: builtin attribute "rustc_never_type_options" not handled by `CheckAttrVisitor`
compiler/rustc_attr_parsing/src/validate_attr.rs:42:17: assertion failed: lint_attrs.contains(name)

So remove these two entries after which we will just error with `error: cannot find attribute`
2026-08-29 14:36:32 +02:00
Jonathan Brouwer
17366b1d1d Rollup merge of #161891 - mejrs:eii_incomplete, r=RalfJung
Mark `extern_item_impls` feature as incomplete

context: https://github.com/rust-lang/rust/pull/161873#discussion_r3873029239

> If they are so unstable, maybe they should have a separate feature gate that's marked as `incomplete`. Or the entire `extern_item_impls` should be marked "incomplete".

I think it's just best to mark the entire thing as incomplete for now. Later, when the implementation matures we can consider removing the incompleteness or splitting the feature in unstable and incomplete parts.

r? @bjorn3 @RalfJung
2026-08-28 10:15:56 +02:00
mejrs
e53f70e3c2 Mark extern_item_impls feature as incomplete 2026-08-27 23:30:47 +02:00
bjorn3
6c4af72a31 Rename extern "unadjusted" to extern "llvm-intrinsic"
This makes it clear that it is only meant for LLVM intrinsics and not
for defining or calling arbitrary user functions.
2026-08-27 12:26:05 +02:00
Jonathan Brouwer
844b744a99 Rollup merge of #160871 - WaffleLapkin:remove_rustc_reservation_impl, r=oli-obk,JonathanBrouwer
Remove `#[rustc_reservation_impl]`

Based on https://github.com/rust-lang/rust/pull/160705.

There was only ever one reservation impl and it got (/is being) removed in rust-lang/rust#160705. I don't think there is a reason to keep the machinery, given how specific and tricky the semantics of it are (see https://github.com/rust-lang/rust/issues/64631).

Closes https://github.com/rust-lang/rust/issues/64631.

cc @clarfonthey since you seem to have found another use for the attribute (https://github.com/rust-lang/rust/issues/64631#issuecomment-4633993125) (I haven't looked into it, so not sure if it might be worth keeping the attribute for that use case).

r? types
2026-08-25 18:00:06 +02:00
Jonathan Brouwer
dda473214e Rollup merge of #161443 - khyperia:abbys-tests, r=BoxyUwU
add internal DSL for testing binders

implements https://github.com/rust-lang/project-assumptions-on-binders/issues/8

apologies to the inevitable swarm of people who get pinged for this...

basically the only interesting diff is `compiler/rustc_hir_analysis/src/check/wfcheck.rs`, which actually implements the test. there's probably still features we want to add to this DSL (e.g. `RegionConstraint::AliasTyOutlivesViaEnv`), and there might be some bugs lurking, but this is at least a base to work off of. It's perma-unstable and for internal use only, so support and quality doesn't have to be incredibly high. For example, parser recovery and whatnot is just, bad, but whatever.

r? BoxyUwU
2026-08-25 18:00:01 +02:00
Waffle Lapkin
905772570b remove #[rustc_reservation_impl] 2026-08-25 14:26:49 +02:00
cyrgani
9caab2652e remove box_patterns feature 2026-08-25 07:50:03 +00:00
Waffle Lapkin
6ed4ce5c0c stabilize the never type (!) 2026-08-24 19:04:00 +02:00
khyperia
210fd61779 add internal DSL for testing binders 2026-08-24 08:54:48 +02:00
Josh Stone
3f38a78275 replace-version-placeholder
(cherry picked from commit 982c76891ff5e7e2fb61a5bd5f2727c2c5906f8e)
2026-08-19 09:20:34 -07:00
carbotaniuman
5898a3974a Initial implementation of FnPtr trait
This commit is an initial implementation of the `FnPtr` trait as
described in the `fn_static` tracking issue, which consists of moving
the internally unstable `core::marker::FnPtr` to `core::ops::FnPtr`, as
well as changing the API. Because `NonNull` is used in the new `as_ptr`
signature, it was also turned into a proper lang item.
2026-08-17 22:17:22 -05:00
Ada Alakbarova
b190091d40 rename #[rustc_dump_predicates] to #[rustc_dump_clauses] 2026-08-17 14:24:07 +02:00
Folkert de Vries
652ab85ead stabilize extern "custom" 2026-08-14 22:28:22 +02:00
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