about summary refs log tree commit diff
path: root/compiler/rustc_feature
AgeCommit message (Collapse)AuthorLines
2025-10-02Extract common logic for iterating over featuresDeadbeef-0/+10
Two places doing the same thing is enough to motivate me to extract this to a method :)
2025-09-29Fix removed version of `doc_auto_cfg`, `doc_cfg_hide`Daniel McNab-2/+2
2025-09-28Rollup merge of #147066 - SimonSapin:macro_attr-tracking, r=lqdMatthias Krüger-1/+1
Fix tracking issue number for feature(macro_attr) The ability to define an attribute macro with `macro_rules!` is tracked at https://github.com/rust-lang/rust/issues/143547, not https://github.com/rust-lang/rust/issues/83527
2025-09-27Remove `doc_auto_cfg` feature as wellGuillaume Gomez-2/+2
2025-09-27Apply first review round suggestionsGuillaume Gomez-0/+2
2025-09-27Remove `doc_cfg_hide` featureGuillaume Gomez-2/+0
2025-09-27Fix tracking issue number for feature(macro_attr)Simon Sapin-1/+1
The ability to define an attribute macro with `macro_rules!` is tracked at https://github.com/rust-lang/rust/issues/143547, not https://github.com/rust-lang/rust/issues/83527
2025-09-26Update CURRENT_RUSTC_VERSION post-bumpMark Rousskov-14/+14
2025-09-25Rollup merge of #146667 - calebzulawski:simd-mono-lane-limit, r=lcnr,RalfJungStuart Cook-0/+6
Add an attribute to check the number of lanes in a SIMD vector after monomorphization Allows std::simd to drop the `LaneCount<N>: SupportedLaneCount` trait and maintain good error messages. Also, extends rust-lang/rust#145967 by including spans in layout errors for all ADTs. r? ``@RalfJung`` cc ``@workingjubilee`` ``@programmerjake``
2025-09-23Add an attribute to check the number of lanes in a SIMD vector after ↵Caleb Zulawski-0/+6
monomorphization Unify zero-length and oversized SIMD errors
2025-09-13initial implementation of the darwin_objc unstable featureJo Bates-0/+8
2025-09-09allow `#[rustc_align_static(N)]` on `static`sFolkert de Vries-0/+3
We need a different attribute than `rustc_align` because unstable attributes are tied to their feature (we can't have two unstable features use the same unstable attribute). Otherwise this uses all of the same infrastructure as `#[rustc_align]`.
2025-09-04Rollup merge of #145932 - JamieCunliffe:target-feature-inlining, r=jackh726Stuart Cook-0/+2
Allow `inline(always)` with a target feature behind a unstable feature `target_feature_inline_always`. Rather than adding the inline always attribute to the function definition, we add it to the callsite. We can then check that the target features match and that the call would be safe to inline. If the function isn't inlined due to a mismatch, we emit a warning informing the user that the function can't be inlined due to the target feature mismatch. See tracking issue rust-lang/rust#145574
2025-09-02stabilize extended_varargs_abi_supportRalf Jung-3/+3
2025-08-27inline at the callsite & warn when target features mismatchJames Barford-Evans-0/+2
Co-authored-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com>
2025-08-22Rollup merge of #145726 - aapoalas:reborrow-lang-experiment, r=petrochenkovJacob Pratt-0/+1
Experiment: Reborrow trait Tracking issue: rust-lang/rust#145612 Starting off really small here: just introduce the unstable feature and the feature gate, and one of the two traits that the Reborrow experiment deals with. ### Cliff-notes explanation The `Reborrow` trait is conceptually a close cousin of `Copy` with the exception that it disables the source (`self`) for the lifetime of the target / result of the reborrow action. It can be viewed as a method of `fn reborrow(self: Self<'a>) -> Self<'a>` with the compiler adding tracking of the resulting `Self<'a>` (or any value derived from it that retains the `'a` lifetime) to keep the `self` disabled for reads and writes. No method is planned to be surfaced to the user, however, as reborrowing cannot be seen in code (except for method calls [`a.foo()` reborrows `a`] and explicit reborrows [`&*a`]) and thus triggering user-code in it could be viewed as "spooky action at a distance". Furthermore, the added compiler tracking cannot be seen on the method itself, violating the Golden Rule. Note that the userland "reborrow" method is not True Reborrowing, but rather a form of a "Fancy Deref": ```rust fn reborrow(&'short self: Self<'long>) -> Self<'short>; ``` The lifetime shortening is the issue here: a reborrowed `Self` or any value derived from it is bound to the method that called `reborrow`, since `&'short` is effectively a local variable. True Reborrowing does not shorten the lifetime of the result. To avoid having to introduce new kinds of references, new kinds of lifetime annotations, or a blessed trait method, no method will be introduced at all. Instead, the `Reborrow` trait is intended to be a derived trait that effectively reborrows each field individually; `Copy` fields end up just copying, while fields that themselves `Reborrow` get disabled in the source, usually leading to the source itself being disabled (some differences may appear with structs that contain multiple reborrowable fields). The goal of the experiment is to determine how the actual implementation here will shape out, and what the "bottom case" for the recursive / deriving `Reborrow` is. `Reborrow` has a friend trait, `CoerceShared`, which is equivalent to a `&'a mut T -> &'a T` conversion. This is needed as a different trait and different operation due to the different semantics it enforces on the source: a `CoerceShared` operation only disables the source for writes / exclusive access for the lifetime of the result. That trait is not yet introduced in this PR, though there is no particular reason why it could not be introduced.
2025-08-22Add an experimental unsafe(force_target_feature) attribute.Luca Versari-0/+6
This uses the feature gate for https://github.com/rust-lang/rust/issues/143352, but is described in https://github.com/rust-lang/rfcs/pull/3820 which is strongly tied to the experiment.
2025-08-21Introduce Reborrow lang item and traitAapo Alasuutari-1/+1
2025-08-21Introduce reborrow unstable featureAapo Alasuutari-0/+1
2025-08-20Auto merge of #144086 - clubby789:alloc-zeroed, r=nikicbors-0/+4
Pass `alloc-variant-zeroed` to LLVM Makes use of https://github.com/llvm/llvm-project/pull/138299 (once we pull in a version of LLVM with this attribute). ~~Unfortunately also requires https://github.com/llvm/llvm-project/pull/149336 to work.~~ Closes rust-lang/rust#104847
2025-08-20Pass `alloc-variant-zeroed` to LLVMclubby789-0/+4
2025-08-19Rollup merge of #145243 - jdonszelmann:inner-attr-errors, r=petrochenkovStuart Cook-2/+6
take attr style into account in diagnostics when the original attribute was specified as an inner attribute, the suggestion will now match that attribute style
2025-08-19Rollup merge of #142681 - 1c3t3a:sanitize-off-on, r=rcvalleStuart Cook-5/+7
Remove the `#[no_sanitize]` attribute in favor of `#[sanitize(xyz = "on|off")]` This came up during the sanitizer stabilization (rust-lang/rust#123617). Instead of a `#[no_sanitize(xyz)]` attribute, we would like to have a `#[sanitize(xyz = "on|off")]` attribute, which is more powerful and allows to be extended in the future (instead of just focusing on turning sanitizers off). The implementation is done according to what was [discussed on Zulip](https://rust-lang.zulipchat.com/#narrow/channel/343119-project-exploit-mitigations/topic/Stabilize.20the.20.60no_sanitize.60.20attribute/with/495377292)). The new attribute also works on modules, traits and impl items and thus enables usage as the following: ```rust #[sanitize(address = "off")] mod foo { fn unsanitized(..) {} #[sanitize(address = "on")] fn sanitized(..) {} } trait MyTrait { #[sanitize(address = "off")] fn unsanitized_default(..) {} } #[sanitize(thread = "off")] impl MyTrait for () { ... } ``` r? ```@rcvalle```
2025-08-18Remove the no_sanitize attribute in favor of sanitizeBastian Kersting-7/+3
This removes the #[no_sanitize] attribute, which was behind an unstable feature named no_sanitize. Instead, we introduce the sanitize attribute which is more powerful and allows to be extended in the future (instead of just focusing on turning sanitizers off). This also makes sanitize(kernel_address = ..) attribute work with -Zsanitize=address To do it the same as how clang disables address sanitizer, we now disable ASAN on sanitize(kernel_address = "off") and KASAN on sanitize(address = "off"). The same was added to clang in https://reviews.llvm.org/D44981.
2025-08-18Implement the #[sanitize(..)] attributeBastian Kersting-0/+6
This change implements the #[sanitize(..)] attribute, which opts to replace the currently unstable #[no_sanitize]. Essentially the new attribute works similar as #[no_sanitize], just with more flexible options regarding where it is applied. E.g. it is possible to turn a certain sanitizer either on or off: `#[sanitize(address = "on|off")]` This attribute now also applies to more places, e.g. it is possible to turn off a sanitizer for an entire module or impl block: ```rust \#[sanitize(address = "off")] mod foo { fn unsanitized(..) {} #[sanitize(address = "on")] fn sanitized(..) {} } \#[sanitize(thread = "off")] impl MyTrait for () { ... } ``` This attribute is enabled behind the unstable `sanitize` feature.
2025-08-18Rollup merge of #145208 - joshtriplett:mbe-derive, r=petrochenkovStuart Cook-0/+2
Implement declarative (`macro_rules!`) derive macros (RFC 3698) This is a draft for review, and should not be merged yet. This is layered atop https://github.com/rust-lang/rust/pull/145153 , and has only two additional commits atop that. The first handles parsing and provides a test for various parse errors. The second implements expansion and handles application. This implements RFC 3698, "Declarative (`macro_rules!`) derive macros". Tracking issue: https://github.com/rust-lang/rust/issues/143549 This has one remaining issue, which I could use some help debugging: in `tests/ui/macros/macro-rules-derive-error.rs`, the diagnostics for `derive(fn_only)` (for a `fn_only` with no `derive` rules) and `derive(ForwardReferencedDerive)` both get emitted twice, as a duplicate diagnostic. From what I can tell via adding some debugging code, `unresolved_macro_suggestions` is getting called twice from `finalize_macro_resolutions` for each of them, because `self.single_segment_macro_resolutions` has two entries for the macro, with two different `parent_scope` values. I'm not clear on why that happened; it doesn't happen with the equivalent code using attrs. I'd welcome any suggestions for fixing this.
2025-08-16Auto merge of #145304 - m-ou-se:simplify-panic, r=oli-obkbors-4/+0
Revert "Partially outline code inside the panic! macro". This reverts https://github.com/rust-lang/rust/pull/115670 Without any tests/benchmarks that show some improvement, it's hard to know whether the change had any positive effect. (And if it did, whether that effect is still achieved today.)
2025-08-16take attr style into account in attr diagnosticsJana Dönszelmann-2/+6
2025-08-15Add `derive_from` unstable featureJakub Beránek-0/+2
2025-08-14mbe: Parse macro `derive` rulesJosh Triplett-0/+2
This handles various kinds of errors, but does not allow applying the derive yet. This adds the feature gate `macro_derive`.
2025-08-14Stabilize `sse4a` and `tbm` target featuressayantn-2/+4
- remove some stabilized target features from `gate.rs`
2025-08-12Revert "Partially outline code inside the panic! macro".Mara Bos-4/+0
Without any tests/benchmarks that show some improvement, it's hard to know whether the change had any positive effect at all. (And if it did, whether that effect is still achieved today.)
2025-08-11Rework `NameValueStr`Esteban Küber-8/+8
2025-08-11Add more docs to templates for attrs with incorrect argumentsEsteban Küber-1/+4
2025-08-11Add link to docs on malformed attributesEsteban Küber-71/+270
2025-08-11Allow attr entries to declare list of alternatives for `List` and ↵Esteban Küber-72/+99
`NamedValueStr` Modify `AttributeTemplate` to support list of alternatives for list and name value attribute styles. Suggestions now provide more correct suggested code: ``` error[E0805]: malformed `used` attribute input --> $DIR/used_with_multi_args.rs:3:1 | LL | #[used(compiler, linker)] | ^^^^^^------------------^ | | | expected a single argument here | help: try changing it to one of the following valid forms of the attribute | LL - #[used(compiler, linker)] LL + #[used(compiler)] | LL - #[used(compiler, linker)] LL + #[used(linker)] | LL - #[used(compiler, linker)] LL + #[used] | ``` instead of the prior "masking" of the lack of this feature by suggesting pipe-separated lists: ``` error[E0805]: malformed `used` attribute input --> $DIR/used_with_multi_args.rs:3:1 | LL | #[used(compiler, linker)] | ^^^^^^------------------^ | | | expected a single argument here | help: try changing it to one of the following valid forms of the attribute | LL - #[used(compiler, linker)] LL + #[used(compiler|linker)] | LL - #[used(compiler, linker)] LL + #[used] | ```
2025-08-09Fix an unstable feature comment that wasn't a doc commentJosh Triplett-1/+1
Every other feature in the list uses a doc comment; fix one that used a regular comment to use a doc comment.
2025-08-08mbe: Parse macro attribute rulesJosh Triplett-0/+2
This handles various kinds of errors, but does not allow applying the attributes yet. This adds the feature gate `macro_attr`.
2025-08-07Auto merge of #145043 - Zalathar:rollup-3dbvdrm, r=Zalatharbors-0/+1
Rollup of 19 pull requests Successful merges: - rust-lang/rust#137831 (Tweak auto trait errors) - rust-lang/rust#138689 (add nvptx_target_feature) - rust-lang/rust#140267 (implement continue_ok and break_ok for ControlFlow) - rust-lang/rust#143028 (emit `StorageLive` and schedule `StorageDead` for `let`-`else`'s bindings after matching) - rust-lang/rust#143764 (lower pattern bindings in the order they're written and base drop order on primary bindings' order) - rust-lang/rust#143808 (Port `#[should_panic]` to the new attribute parsing infrastructure ) - rust-lang/rust#143906 (Miri: non-deterministic floating point operations in `foreign_items`) - rust-lang/rust#143929 (Mark all deprecation lints in name resolution as deny-by-default and report-in-deps) - rust-lang/rust#144133 (Stabilize const TypeId::of) - rust-lang/rust#144369 (Upgrade semicolon_in_expressions_from_macros from warn to deny) - rust-lang/rust#144439 (Introduce ModernIdent type to unify macro 2.0 hygiene handling) - rust-lang/rust#144473 (Address libunwind.a inconsistency issues in the bootstrap program) - rust-lang/rust#144601 (Allow `cargo fix` to partially apply `mismatched_lifetime_syntaxes`) - rust-lang/rust#144650 (Additional tce tests) - rust-lang/rust#144659 (bootstrap: refactor mingw dist and fix gnullvm) - rust-lang/rust#144682 (Stabilize `strict_overflow_ops`) - rust-lang/rust#145026 (Update books) - rust-lang/rust#145033 (Reimplement `print_region` in `type_name.rs`.) - rust-lang/rust#145040 (rustc-dev-guide subtree update) Failed merges: - rust-lang/rust#143857 (Port #[macro_export] to the new attribute parsing infrastructure) r? `@ghost` `@rustbot` modify labels: rollup
2025-08-07Rollup merge of #138689 - jedbrown:jed/nvptx-target-feature, r=ZuseZ4Stuart Cook-0/+1
add nvptx_target_feature Tracking issue: #141468 (nvptx), which is part of #44839 (catch-all arches) The feature gate is `#![feature(nvptx_target_feature)]` This exposes the target features `sm_20` through `sm_120a` [as defined](https://github.com/llvm/llvm-project/blob/llvmorg-20.1.1/llvm/lib/Target/NVPTX/NVPTX.td#L59-L85) by LLVM. Cc: ``````@gonzalobg`````` ``````@rustbot`````` label +O-NVPTX +A-target-feature
2025-08-06replace version placeholderBoxy-4/+4
2025-08-01Remove the omit_gdb_pretty_printer_section attributebjorn3-7/+2
Disabling loading of pretty printers in the debugger itself is more reliable. Before this commit the .gdb_debug_scripts section couldn't be included in dylibs or rlibs as otherwise there is no way to disable the section anymore without recompiling the entire standard library.
2025-07-31remove rustc_attr_data_structuresJana Dönszelmann-3/+3
2025-07-19Mitigate `#[align]` name resolution ambiguity regression with a renameJieyou Xu-1/+2
From `#[align]` -> `#[rustc_align]`. Attributes starting with `rustc` are always perma-unstable and feature-gated by `feature(rustc_attrs)`. See regression RUST-143834. For the underlying problem where even introducing new feature-gated unstable built-in attributes can break user code such as ```rs macro_rules! align { () => { /* .. */ }; } pub(crate) use align; // `use` here becomes ambiguous ``` refer to RUST-134963. Since the `#[align]` attribute is still feature-gated by `feature(fn_align)`, we can rename it as a mitigation. Note that `#[rustc_align]` will obviously mean that current unstable user code using `feature(fn_aling)` will need additionally `feature(rustc_attrs)`, but this is a short-term mitigation to buy time, and is expected to be changed to a better name with less collision potential. See <https://rust-lang.zulipchat.com/#narrow/channel/238009-t-compiler.2Fmeetings/topic/.5Bweekly.5D.202025-07-17/near/529290371> where mitigation options were considered.
2025-07-17parse `const trait Trait`Deadbeef-0/+1
2025-07-15Implement other logicstiif-0/+4
2025-07-13update issue number for `const_trait_impl`Deadbeef-1/+1
2025-07-02Auto merge of #143214 - camsteffen:remove-let-chains-feature, r=est31bors-2/+2
Remove let_chains unstable feature Per https://github.com/rust-lang/rust/issues/53667#issuecomment-3016742982 (but then I also noticed rust-lang/rust#140722) This replaces the feature gate with a parser error that says let chains require 2024. A lot of tests were using the unstable feature. I either added edition:2024 to the test or split out the parts that require 2024.
2025-07-02Auto merge of #142974 - cuviper:stage0-bump, r=Mark-Simulacrumbors-10/+10
Update stage0 to 1.89.0-beta.1 - Update version placeholders - Update stage0 to 1.89.0-beta.1 - Update `STAGE0_MISSING_TARGETS` - Update `cfg(bootstrap)` r? `@Mark-Simulacrum` try-job: dist-i586-gnu-i586-i686-musl
2025-07-01Remove support for dyn*Michael Goulet-2/+3