From 680ec3cc24c9e9a51fbbe1b6bf9bc4285f225d60 Mon Sep 17 00:00:00 2001 From: Luca Versari Date: Mon, 1 Jun 2026 21:34:00 +0200 Subject: [PATCH] stabilize optimize attribute (size, speed, and none) This commit stabilizes the `#[optimize]` attribute, which allows for more fine-grained control of optimization levels. --- compiler/rustc_feature/src/accepted.rs | 2 + compiler/rustc_feature/src/builtin_attrs.rs | 2 +- compiler/rustc_feature/src/unstable.rs | 2 - library/alloc/src/lib.rs | 1 - library/alloctests/lib.rs | 1 - library/core/src/lib.rs | 1 - library/std/src/lib.rs | 1 - .../issues/issue-136329-optnone-noinline.rs | 2 - tests/codegen-llvm/optimize-attr-1.rs | 1 - tests/mir-opt/optimize_none.rs | 2 - tests/rustdoc-json/attrs/optimize.rs | 2 - tests/ui/attributes/malformed-attrs.rs | 1 - tests/ui/attributes/malformed-attrs.stderr | 174 +++++++++--------- tests/ui/attributes/optimize.rs | 9 +- tests/ui/attributes/optimize.stderr | 8 +- tests/ui/coroutine/other-attribute-on-gen.rs | 1 - .../feature-gate-optimize_attribute.rs | 15 -- .../feature-gate-optimize_attribute.stderr | 64 ------- 18 files changed, 102 insertions(+), 187 deletions(-) delete mode 100644 tests/ui/feature-gates/feature-gate-optimize_attribute.rs delete mode 100644 tests/ui/feature-gates/feature-gate-optimize_attribute.stderr diff --git a/compiler/rustc_feature/src/accepted.rs b/compiler/rustc_feature/src/accepted.rs index 63c35ad4e122b..28b60888393d1 100644 --- a/compiler/rustc_feature/src/accepted.rs +++ b/compiler/rustc_feature/src/accepted.rs @@ -340,6 +340,8 @@ declare_features! ( (accepted, non_modrs_mods, "1.30.0", Some(44660)), /// Allows using multiple nested field accesses in offset_of! (accepted, offset_of_nested, "1.82.0", Some(120140)), + /// Allows using `#[optimize(X)]`. + (accepted, optimize_attribute, "CURRENT_RUSTC_VERSION", Some(54882)), /// Allows the use of or-patterns (e.g., `0 | 1`). (accepted, or_patterns, "1.53.0", Some(54883)), /// Allows using `+bundle,+whole-archive` link modifiers with native libs. diff --git a/compiler/rustc_feature/src/builtin_attrs.rs b/compiler/rustc_feature/src/builtin_attrs.rs index c61b8d66af426..9b7803797d74c 100644 --- a/compiler/rustc_feature/src/builtin_attrs.rs +++ b/compiler/rustc_feature/src/builtin_attrs.rs @@ -373,7 +373,7 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ gated!(thread_local, "`#[thread_local]` is an experimental feature, and does not currently handle destructors"), gated!(no_core, experimental!(no_core)), // RFC 2412 - gated!(optimize, optimize_attribute, experimental!(optimize)), + ungated!(optimize), gated!(ffi_pure, experimental!(ffi_pure)), gated!(ffi_const, experimental!(ffi_const)), diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index 388482209cf9e..548adf726623d 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -678,8 +678,6 @@ declare_features! ( (unstable, offset_of_enum, "1.75.0", Some(120141)), /// Allows using fields with slice type in offset_of! (unstable, offset_of_slice, "1.81.0", Some(126151)), - /// Allows using `#[optimize(X)]`. - (unstable, optimize_attribute, "1.34.0", Some(54882)), /// Allows specifying nop padding on functions for dynamic patching. (unstable, patchable_function_entry, "1.81.0", Some(123115)), /// Experimental features that make `Pin` more ergonomic. diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs index f66dc648f809b..b9bc22148cc84 100644 --- a/library/alloc/src/lib.rs +++ b/library/alloc/src/lib.rs @@ -190,7 +190,6 @@ #![feature(multiple_supertrait_upcastable)] #![feature(negative_impls)] #![feature(never_type)] -#![feature(optimize_attribute)] #![feature(rustc_attrs)] #![feature(slice_internals)] #![feature(staged_api)] diff --git a/library/alloctests/lib.rs b/library/alloctests/lib.rs index db643ccb7a4e6..acfa0dc259fa0 100644 --- a/library/alloctests/lib.rs +++ b/library/alloctests/lib.rs @@ -61,7 +61,6 @@ #![feature(dropck_eyepatch)] #![feature(min_specialization)] #![feature(never_type)] -#![feature(optimize_attribute)] #![feature(prelude_import)] #![feature(rustc_attrs)] #![feature(staged_api)] diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 1cdf52de8cad8..b6f405e2311d3 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -156,7 +156,6 @@ #![feature(negative_impls)] #![feature(never_type)] #![feature(no_core)] -#![feature(optimize_attribute)] #![feature(pattern_types)] #![feature(pin_macro_internals)] #![feature(prelude_import)] diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index addbb407083c7..0858224c9ef6c 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -301,7 +301,6 @@ #![feature(needs_panic_runtime)] #![feature(negative_impls)] #![feature(never_type)] -#![feature(optimize_attribute)] #![feature(prelude_import)] #![feature(rustc_attrs)] #![feature(rustdoc_internals)] diff --git a/tests/codegen-llvm/issues/issue-136329-optnone-noinline.rs b/tests/codegen-llvm/issues/issue-136329-optnone-noinline.rs index 57c9e47a4992a..1dd4ee585d6e1 100644 --- a/tests/codegen-llvm/issues/issue-136329-optnone-noinline.rs +++ b/tests/codegen-llvm/issues/issue-136329-optnone-noinline.rs @@ -2,8 +2,6 @@ //@ compile-flags: -Copt-level=3 -#![feature(optimize_attribute)] - #[optimize(none)] pub fn foo() { let _x = 123; diff --git a/tests/codegen-llvm/optimize-attr-1.rs b/tests/codegen-llvm/optimize-attr-1.rs index db6bdcf9a8b90..c4cb8e460476f 100644 --- a/tests/codegen-llvm/optimize-attr-1.rs +++ b/tests/codegen-llvm/optimize-attr-1.rs @@ -3,7 +3,6 @@ //@[SIZE-OPT] compile-flags: -Copt-level=s -Ccodegen-units=1 //@[SPEED-OPT] compile-flags: -Copt-level=3 -Ccodegen-units=1 -#![feature(optimize_attribute)] #![crate_type = "rlib"] // CHECK-LABEL: define{{.*}}i32 @nothing diff --git a/tests/mir-opt/optimize_none.rs b/tests/mir-opt/optimize_none.rs index 99efcc35e5955..912257a5273b1 100644 --- a/tests/mir-opt/optimize_none.rs +++ b/tests/mir-opt/optimize_none.rs @@ -2,8 +2,6 @@ //@[NO-OPT] compile-flags: -Copt-level=0 //@[SPEED-OPT] compile-flags: -Copt-level=3 -Coverflow-checks=y -#![feature(optimize_attribute)] - #[optimize(none)] pub fn add_noopt() -> i32 { // CHECK-LABEL: fn add_noopt( diff --git a/tests/rustdoc-json/attrs/optimize.rs b/tests/rustdoc-json/attrs/optimize.rs index 5988120ab2f75..eac9aef5912d9 100644 --- a/tests/rustdoc-json/attrs/optimize.rs +++ b/tests/rustdoc-json/attrs/optimize.rs @@ -1,5 +1,3 @@ -#![feature(optimize_attribute)] - //@ is "$.index[?(@.name=='speed')].attrs" '[{"other": "#[attr = Optimize(Speed)]"}]' #[optimize(speed)] pub fn speed() {} diff --git a/tests/ui/attributes/malformed-attrs.rs b/tests/ui/attributes/malformed-attrs.rs index c73feb9110f11..c31e5a43e2cbc 100644 --- a/tests/ui/attributes/malformed-attrs.rs +++ b/tests/ui/attributes/malformed-attrs.rs @@ -5,7 +5,6 @@ #![feature(allow_internal_unstable)] // FIXME(#82232, #143834): temporarily renamed to mitigate `#[align]` nameres ambiguity #![feature(fn_align)] -#![feature(optimize_attribute)] #![feature(dropck_eyepatch)] #![feature(export_stable)] #![allow(incomplete_features)] diff --git a/tests/ui/attributes/malformed-attrs.stderr b/tests/ui/attributes/malformed-attrs.stderr index 4c9673bf80562..7566c54c35e5d 100644 --- a/tests/ui/attributes/malformed-attrs.stderr +++ b/tests/ui/attributes/malformed-attrs.stderr @@ -1,5 +1,5 @@ error[E0539]: malformed `cfg` attribute input - --> $DIR/malformed-attrs.rs:106:1 + --> $DIR/malformed-attrs.rs:105:1 | LL | #[cfg] | ^^^^^^ expected this to be a list @@ -11,7 +11,7 @@ LL | #[cfg(predicate)] | +++++++++++ error[E0539]: malformed `cfg_attr` attribute input - --> $DIR/malformed-attrs.rs:108:1 + --> $DIR/malformed-attrs.rs:107:1 | LL | #[cfg_attr] | ^^^^^^^^^^^ expected this to be a list @@ -23,13 +23,13 @@ LL | #[cfg_attr(predicate, attr1, attr2, ...)] | ++++++++++++++++++++++++++++++ error[E0463]: can't find crate for `wloop` - --> $DIR/malformed-attrs.rs:210:1 + --> $DIR/malformed-attrs.rs:209:1 | LL | extern crate wloop; | ^^^^^^^^^^^^^^^^^^^ can't find crate error: malformed `allow` attribute input - --> $DIR/malformed-attrs.rs:176:1 + --> $DIR/malformed-attrs.rs:175:1 | LL | #[allow] | ^^^^^^^^ @@ -45,7 +45,7 @@ LL | #[allow(lint1, lint2, lint3, reason = "...")] | +++++++++++++++++++++++++++++++++++++ error: malformed `expect` attribute input - --> $DIR/malformed-attrs.rs:178:1 + --> $DIR/malformed-attrs.rs:177:1 | LL | #[expect] | ^^^^^^^^^ @@ -61,7 +61,7 @@ LL | #[expect(lint1, lint2, lint3, reason = "...")] | +++++++++++++++++++++++++++++++++++++ error: malformed `warn` attribute input - --> $DIR/malformed-attrs.rs:180:1 + --> $DIR/malformed-attrs.rs:179:1 | LL | #[warn] | ^^^^^^^ @@ -77,7 +77,7 @@ LL | #[warn(lint1, lint2, lint3, reason = "...")] | +++++++++++++++++++++++++++++++++++++ error: malformed `deny` attribute input - --> $DIR/malformed-attrs.rs:182:1 + --> $DIR/malformed-attrs.rs:181:1 | LL | #[deny] | ^^^^^^^ @@ -93,7 +93,7 @@ LL | #[deny(lint1, lint2, lint3, reason = "...")] | +++++++++++++++++++++++++++++++++++++ error: malformed `forbid` attribute input - --> $DIR/malformed-attrs.rs:184:1 + --> $DIR/malformed-attrs.rs:183:1 | LL | #[forbid] | ^^^^^^^^^ @@ -109,25 +109,25 @@ LL | #[forbid(lint1, lint2, lint3, reason = "...")] | +++++++++++++++++++++++++++++++++++++ error: the `#[proc_macro]` attribute is only usable with crates of the `proc-macro` crate type - --> $DIR/malformed-attrs.rs:103:1 + --> $DIR/malformed-attrs.rs:102:1 | LL | #[proc_macro = 18] | ^^^^^^^^^^^^^^^^^^ error: the `#[proc_macro_attribute]` attribute is only usable with crates of the `proc-macro` crate type - --> $DIR/malformed-attrs.rs:120:1 + --> $DIR/malformed-attrs.rs:119:1 | LL | #[proc_macro_attribute = 19] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the `#[proc_macro_derive]` attribute is only usable with crates of the `proc-macro` crate type - --> $DIR/malformed-attrs.rs:127:1 + --> $DIR/malformed-attrs.rs:126:1 | LL | #[proc_macro_derive] | ^^^^^^^^^^^^^^^^^^^^ error[E0658]: allow_internal_unsafe side-steps the unsafe_code lint - --> $DIR/malformed-attrs.rs:215:1 + --> $DIR/malformed-attrs.rs:214:1 | LL | #[allow_internal_unsafe = 1] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -136,7 +136,7 @@ LL | #[allow_internal_unsafe = 1] = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0539]: malformed `windows_subsystem` attribute input - --> $DIR/malformed-attrs.rs:26:1 + --> $DIR/malformed-attrs.rs:25:1 | LL | #![windows_subsystem] | ^^^-----------------^ @@ -152,7 +152,7 @@ LL | #![windows_subsystem = "windows"] | +++++++++++ error[E0539]: malformed `export_name` attribute input - --> $DIR/malformed-attrs.rs:29:1 + --> $DIR/malformed-attrs.rs:28:1 | LL | #[unsafe(export_name)] | ^^^^^^^^^^^^^^^^^^^^^^ @@ -163,19 +163,19 @@ LL | #[unsafe(export_name = "name")] | ++++++++ error: `rustc_allow_const_fn_unstable` expects a list of feature names - --> $DIR/malformed-attrs.rs:31:1 + --> $DIR/malformed-attrs.rs:30:1 | LL | #[rustc_allow_const_fn_unstable] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `allow_internal_unstable` expects a list of feature names - --> $DIR/malformed-attrs.rs:34:1 + --> $DIR/malformed-attrs.rs:33:1 | LL | #[allow_internal_unstable] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0539]: malformed `rustc_confusables` attribute input - --> $DIR/malformed-attrs.rs:36:1 + --> $DIR/malformed-attrs.rs:35:1 | LL | #[rustc_confusables] | ^^^^^^^^^^^^^^^^^^^^ expected this to be a list @@ -186,7 +186,7 @@ LL | #[rustc_confusables("name1", "name2", ...)] | +++++++++++++++++++++++ error: `#[rustc_confusables]` attribute cannot be used on functions - --> $DIR/malformed-attrs.rs:36:1 + --> $DIR/malformed-attrs.rs:35:1 | LL | #[rustc_confusables] | ^^^^^^^^^^^^^^^^^^^^ @@ -194,7 +194,7 @@ LL | #[rustc_confusables] = help: `#[rustc_confusables]` can only be applied to inherent methods error[E0539]: malformed `deprecated` attribute input - --> $DIR/malformed-attrs.rs:39:1 + --> $DIR/malformed-attrs.rs:38:1 | LL | #[deprecated = 5] | ^^^^^^^^^^^^^^^-^ @@ -202,7 +202,7 @@ LL | #[deprecated = 5] | expected a string literal here error[E0539]: malformed `rustc_macro_transparency` attribute input - --> $DIR/malformed-attrs.rs:43:1 + --> $DIR/malformed-attrs.rs:42:1 | LL | #[rustc_macro_transparency] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -217,7 +217,7 @@ LL | #[rustc_macro_transparency = "transparent"] | +++++++++++++++ error: `#[rustc_macro_transparency]` attribute cannot be used on functions - --> $DIR/malformed-attrs.rs:43:1 + --> $DIR/malformed-attrs.rs:42:1 | LL | #[rustc_macro_transparency] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -225,7 +225,7 @@ LL | #[rustc_macro_transparency] = help: `#[rustc_macro_transparency]` can only be applied to macro defs error[E0539]: malformed `repr` attribute input - --> $DIR/malformed-attrs.rs:46:1 + --> $DIR/malformed-attrs.rs:45:1 | LL | #[repr] | ^^^^^^^ expected this to be a list @@ -233,7 +233,7 @@ LL | #[repr] = note: for more information, visit error[E0565]: malformed `rustc_as_ptr` attribute input - --> $DIR/malformed-attrs.rs:49:1 + --> $DIR/malformed-attrs.rs:48:1 | LL | #[rustc_as_ptr = 5] | ^^^^^^^^^^^^^^^---^ @@ -247,7 +247,7 @@ LL + #[rustc_as_ptr] | error[E0539]: malformed `rustc_align` attribute input - --> $DIR/malformed-attrs.rs:54:1 + --> $DIR/malformed-attrs.rs:53:1 | LL | #[rustc_align] | ^^^^^^^^^^^^^^ expected this to be a list @@ -258,7 +258,7 @@ LL | #[rustc_align()] | ++++++++++++++++++++++ error[E0539]: malformed `optimize` attribute input - --> $DIR/malformed-attrs.rs:56:1 + --> $DIR/malformed-attrs.rs:55:1 | LL | #[optimize] | ^^^^^^^^^^^ expected this to be a list @@ -273,7 +273,7 @@ LL | #[optimize(speed)] | +++++++ error[E0565]: malformed `cold` attribute input - --> $DIR/malformed-attrs.rs:58:1 + --> $DIR/malformed-attrs.rs:57:1 | LL | #[cold = 1] | ^^^^^^^---^ @@ -287,7 +287,7 @@ LL + #[cold] | error[E0539]: malformed `must_use` attribute input - --> $DIR/malformed-attrs.rs:60:1 + --> $DIR/malformed-attrs.rs:59:1 | LL | #[must_use()] | ^^^^^^^^^^--^ @@ -305,7 +305,7 @@ LL + #[must_use] | error[E0565]: malformed `no_mangle` attribute input - --> $DIR/malformed-attrs.rs:62:1 + --> $DIR/malformed-attrs.rs:61:1 | LL | #[no_mangle = 1] | ^^^^^^^^^^^^---^ @@ -319,7 +319,7 @@ LL + #[no_mangle] | error[E0565]: malformed `naked` attribute input - --> $DIR/malformed-attrs.rs:64:1 + --> $DIR/malformed-attrs.rs:63:1 | LL | #[unsafe(naked())] | ^^^^^^^^^^^^^^--^^ @@ -333,7 +333,7 @@ LL + #[unsafe(naked)] | error[E0565]: malformed `track_caller` attribute input - --> $DIR/malformed-attrs.rs:66:1 + --> $DIR/malformed-attrs.rs:65:1 | LL | #[track_caller()] | ^^^^^^^^^^^^^^--^ @@ -347,7 +347,7 @@ LL + #[track_caller] | error[E0539]: malformed `export_name` attribute input - --> $DIR/malformed-attrs.rs:68:1 + --> $DIR/malformed-attrs.rs:67:1 | LL | #[export_name()] | ^^^^^^^^^^^^^^^^ @@ -359,7 +359,7 @@ LL + #[export_name = "name"] | error[E0805]: malformed `used` attribute input - --> $DIR/malformed-attrs.rs:70:1 + --> $DIR/malformed-attrs.rs:69:1 | LL | #[used()] | ^^^^^^--^ @@ -377,7 +377,7 @@ LL + #[used] | error: `#[used]` attribute cannot be used on functions - --> $DIR/malformed-attrs.rs:70:1 + --> $DIR/malformed-attrs.rs:69:1 | LL | #[used()] | ^^^^^^^^^ @@ -385,7 +385,7 @@ LL | #[used()] = help: `#[used]` can only be applied to statics error[E0539]: malformed `crate_name` attribute input - --> $DIR/malformed-attrs.rs:73:1 + --> $DIR/malformed-attrs.rs:72:1 | LL | #[crate_name] | ^^^^^^^^^^^^^ @@ -396,7 +396,7 @@ LL | #[crate_name = "name"] | ++++++++ error[E0539]: malformed `target_feature` attribute input - --> $DIR/malformed-attrs.rs:78:1 + --> $DIR/malformed-attrs.rs:77:1 | LL | #[target_feature] | ^^^^^^^^^^^^^^^^^ expected this to be a list @@ -407,7 +407,7 @@ LL | #[target_feature(enable = "feat1, feat2")] | +++++++++++++++++++++++++ error[E0565]: malformed `export_stable` attribute input - --> $DIR/malformed-attrs.rs:80:1 + --> $DIR/malformed-attrs.rs:79:1 | LL | #[export_stable = 1] | ^^^^^^^^^^^^^^^^---^ @@ -421,7 +421,7 @@ LL + #[export_stable] | error[E0539]: malformed `link` attribute input - --> $DIR/malformed-attrs.rs:82:1 + --> $DIR/malformed-attrs.rs:81:1 | LL | #[link] | ^^^^^^^ expected this to be a list @@ -429,7 +429,7 @@ LL | #[link] = note: for more information, visit error[E0539]: malformed `link_name` attribute input - --> $DIR/malformed-attrs.rs:86:1 + --> $DIR/malformed-attrs.rs:85:1 | LL | #[link_name] | ^^^^^^^^^^^^ @@ -441,7 +441,7 @@ LL | #[link_name = "name"] | ++++++++ error[E0539]: malformed `link_section` attribute input - --> $DIR/malformed-attrs.rs:90:1 + --> $DIR/malformed-attrs.rs:89:1 | LL | #[link_section] | ^^^^^^^^^^^^^^^ @@ -453,7 +453,7 @@ LL | #[link_section = "name"] | ++++++++ error[E0539]: malformed `coverage` attribute input - --> $DIR/malformed-attrs.rs:92:1 + --> $DIR/malformed-attrs.rs:91:1 | LL | #[coverage] | ^^^^^^^^^^^ expected this to be a list @@ -466,13 +466,13 @@ LL | #[coverage(on)] | ++++ error[E0539]: malformed `sanitize` attribute input - --> $DIR/malformed-attrs.rs:94:1 + --> $DIR/malformed-attrs.rs:93:1 | LL | #[sanitize] | ^^^^^^^^^^^ expected this to be a list error[E0565]: malformed `no_implicit_prelude` attribute input - --> $DIR/malformed-attrs.rs:99:1 + --> $DIR/malformed-attrs.rs:98:1 | LL | #[no_implicit_prelude = 23] | ^^^^^^^^^^^^^^^^^^^^^^----^ @@ -486,7 +486,7 @@ LL + #[no_implicit_prelude] | error[E0565]: malformed `proc_macro` attribute input - --> $DIR/malformed-attrs.rs:103:1 + --> $DIR/malformed-attrs.rs:102:1 | LL | #[proc_macro = 18] | ^^^^^^^^^^^^^----^ @@ -500,7 +500,7 @@ LL + #[proc_macro] | error[E0539]: malformed `instruction_set` attribute input - --> $DIR/malformed-attrs.rs:110:1 + --> $DIR/malformed-attrs.rs:109:1 | LL | #[instruction_set] | ^^^^^^^^^^^^^^^^^^ expected this to be a list @@ -512,7 +512,7 @@ LL | #[instruction_set(set)] | +++++ error[E0539]: malformed `patchable_function_entry` attribute input - --> $DIR/malformed-attrs.rs:112:1 + --> $DIR/malformed-attrs.rs:111:1 | LL | #[patchable_function_entry] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected this to be a list @@ -523,7 +523,7 @@ LL | #[patchable_function_entry(prefix_nops = m, entry_nops = n)] | +++++++++++++++++++++++++++++++++ error[E0565]: malformed `coroutine` attribute input - --> $DIR/malformed-attrs.rs:115:5 + --> $DIR/malformed-attrs.rs:114:5 | LL | #[coroutine = 63] || {} | ^^^^^^^^^^^^----^ @@ -537,7 +537,7 @@ LL + #[coroutine] || {} | error[E0565]: malformed `proc_macro_attribute` attribute input - --> $DIR/malformed-attrs.rs:120:1 + --> $DIR/malformed-attrs.rs:119:1 | LL | #[proc_macro_attribute = 19] | ^^^^^^^^^^^^^^^^^^^^^^^----^ @@ -551,7 +551,7 @@ LL + #[proc_macro_attribute] | error[E0539]: malformed `must_use` attribute input - --> $DIR/malformed-attrs.rs:123:1 + --> $DIR/malformed-attrs.rs:122:1 | LL | #[must_use = 1] | ^^^^^^^^^^^^^-^ @@ -569,7 +569,7 @@ LL + #[must_use] | error[E0539]: malformed `proc_macro_derive` attribute input - --> $DIR/malformed-attrs.rs:127:1 + --> $DIR/malformed-attrs.rs:126:1 | LL | #[proc_macro_derive] | ^^^^^^^^^^^^^^^^^^^^ expected this to be a list @@ -583,7 +583,7 @@ LL | #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] | ++++++++++++++++++++++++++++++++++++++++++ error[E0539]: malformed `must_not_suspend` attribute input - --> $DIR/malformed-attrs.rs:132:1 + --> $DIR/malformed-attrs.rs:131:1 | LL | #[must_not_suspend()] | ^^^^^^^^^^^^^^^^^^--^ @@ -599,7 +599,7 @@ LL + #[must_not_suspend] | error[E0539]: malformed `cfi_encoding` attribute input - --> $DIR/malformed-attrs.rs:134:1 + --> $DIR/malformed-attrs.rs:133:1 | LL | #[cfi_encoding = ""] | ^^^^^^^^^^^^^^^^^--^ @@ -612,7 +612,7 @@ LL | #[cfi_encoding = "encoding"] | ++++++++ error[E0565]: malformed `marker` attribute input - --> $DIR/malformed-attrs.rs:153:1 + --> $DIR/malformed-attrs.rs:152:1 | LL | #[marker = 3] | ^^^^^^^^^---^ @@ -626,7 +626,7 @@ LL + #[marker] | error[E0565]: malformed `fundamental` attribute input - --> $DIR/malformed-attrs.rs:155:1 + --> $DIR/malformed-attrs.rs:154:1 | LL | #[fundamental()] | ^^^^^^^^^^^^^--^ @@ -640,7 +640,7 @@ LL + #[fundamental] | error[E0565]: malformed `ffi_pure` attribute input - --> $DIR/malformed-attrs.rs:163:5 + --> $DIR/malformed-attrs.rs:162:5 | LL | #[unsafe(ffi_pure = 1)] | ^^^^^^^^^^^^^^^^^^---^^ @@ -654,7 +654,7 @@ LL + #[unsafe(ffi_pure)] | error[E0539]: malformed `link_ordinal` attribute input - --> $DIR/malformed-attrs.rs:165:5 + --> $DIR/malformed-attrs.rs:164:5 | LL | #[link_ordinal] | ^^^^^^^^^^^^^^^ expected this to be a list @@ -666,7 +666,7 @@ LL | #[link_ordinal(ordinal)] | +++++++++ error[E0565]: malformed `ffi_const` attribute input - --> $DIR/malformed-attrs.rs:169:5 + --> $DIR/malformed-attrs.rs:168:5 | LL | #[unsafe(ffi_const = 1)] | ^^^^^^^^^^^^^^^^^^^---^^ @@ -680,13 +680,13 @@ LL + #[unsafe(ffi_const)] | error[E0539]: malformed `linkage` attribute input - --> $DIR/malformed-attrs.rs:171:5 + --> $DIR/malformed-attrs.rs:170:5 | LL | #[linkage] | ^^^^^^^^^^ expected this to be of the form `linkage = "..."` error[E0539]: malformed `debugger_visualizer` attribute input - --> $DIR/malformed-attrs.rs:186:1 + --> $DIR/malformed-attrs.rs:185:1 | LL | #[debugger_visualizer] | ^^^^^^^^^^^^^^^^^^^^^^ expected this to be a list @@ -698,7 +698,7 @@ LL | #[debugger_visualizer(natvis_file = "...", gdb_script_file = "...")] | ++++++++++++++++++++++++++++++++++++++++++++++ error[E0565]: malformed `automatically_derived` attribute input - --> $DIR/malformed-attrs.rs:188:1 + --> $DIR/malformed-attrs.rs:187:1 | LL | #[automatically_derived = 18] | ^^^^^^^^^^^^^^^^^^^^^^^^----^ @@ -712,7 +712,7 @@ LL + #[automatically_derived] | error[E0565]: malformed `non_exhaustive` attribute input - --> $DIR/malformed-attrs.rs:196:1 + --> $DIR/malformed-attrs.rs:195:1 | LL | #[non_exhaustive = 1] | ^^^^^^^^^^^^^^^^^---^ @@ -726,7 +726,7 @@ LL + #[non_exhaustive] | error[E0565]: malformed `thread_local` attribute input - --> $DIR/malformed-attrs.rs:202:1 + --> $DIR/malformed-attrs.rs:201:1 | LL | #[thread_local()] | ^^^^^^^^^^^^^^--^ @@ -740,7 +740,7 @@ LL + #[thread_local] | error[E0565]: malformed `no_link` attribute input - --> $DIR/malformed-attrs.rs:206:1 + --> $DIR/malformed-attrs.rs:205:1 | LL | #[no_link()] | ^^^^^^^^^--^ @@ -754,7 +754,7 @@ LL + #[no_link] | error[E0539]: malformed `macro_use` attribute input - --> $DIR/malformed-attrs.rs:208:1 + --> $DIR/malformed-attrs.rs:207:1 | LL | #[macro_use = 1] | ^^^^^^^^^^^^---^ @@ -772,7 +772,7 @@ LL + #[macro_use] | error[E0539]: malformed `macro_export` attribute input - --> $DIR/malformed-attrs.rs:213:1 + --> $DIR/malformed-attrs.rs:212:1 | LL | #[macro_export = 18] | ^^^^^^^^^^^^^^^----^ @@ -789,7 +789,7 @@ LL + #[macro_export] | error[E0565]: malformed `allow_internal_unsafe` attribute input - --> $DIR/malformed-attrs.rs:215:1 + --> $DIR/malformed-attrs.rs:214:1 | LL | #[allow_internal_unsafe = 1] | ^^^^^^^^^^^^^^^^^^^^^^^^---^ @@ -803,7 +803,7 @@ LL + #[allow_internal_unsafe] | error: attribute should be applied to `const fn` - --> $DIR/malformed-attrs.rs:31:1 + --> $DIR/malformed-attrs.rs:30:1 | LL | #[rustc_allow_const_fn_unstable] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -815,7 +815,7 @@ LL | | } | |_- not a `const fn` warning: attribute should be applied to an `extern` block with non-Rust ABI - --> $DIR/malformed-attrs.rs:82:1 + --> $DIR/malformed-attrs.rs:81:1 | LL | #[link] | ^^^^^^^ @@ -830,19 +830,19 @@ LL | | } = note: requested on the command line with `-W unused-attributes` error: `#[repr(align(...))]` is not supported on functions - --> $DIR/malformed-attrs.rs:46:1 + --> $DIR/malformed-attrs.rs:45:1 | LL | #[repr] | ^^^^^^^ | help: use `#[rustc_align(...)]` instead - --> $DIR/malformed-attrs.rs:46:1 + --> $DIR/malformed-attrs.rs:45:1 | LL | #[repr] | ^^^^^^^ error: valid forms for the attribute are `#[doc = "string"]`, `#[doc(alias)]`, `#[doc(attribute)]`, `#[doc(auto_cfg)]`, `#[doc(cfg)]`, `#[doc(fake_variadic)]`, `#[doc(hidden)]`, `#[doc(html_favicon_url)]`, `#[doc(html_logo_url)]`, `#[doc(html_no_source)]`, `#[doc(html_playground_url)]`, `#[doc(html_root_url)]`, `#[doc(include)]`, `#[doc(inline)]`, `#[doc(issue_tracker_base_url)]`, `#[doc(keyword)]`, `#[doc(masked)]`, `#[doc(no_default_passes)]`, `#[doc(no_inline)]`, `#[doc(notable_trait)]`, `#[doc(passes)]`, `#[doc(plugins)]`, `#[doc(rust_logo)]`, `#[doc(search_unbox)]`, `#[doc(spotlight)]`, and `#[doc(test)]` - --> $DIR/malformed-attrs.rs:41:1 + --> $DIR/malformed-attrs.rs:40:1 | LL | #[doc] | ^^^^^^ @@ -854,7 +854,7 @@ LL | #![deny(invalid_doc_attributes)] | ^^^^^^^^^^^^^^^^^^^^^^ error: valid forms for the attribute are `#[inline(always)]`, `#[inline(never)]`, and `#[inline]` - --> $DIR/malformed-attrs.rs:51:1 + --> $DIR/malformed-attrs.rs:50:1 | LL | #[inline = 5] | ^^^^^^^^^^^^^ @@ -864,13 +864,13 @@ LL | #[inline = 5] = note: `#[deny(ill_formed_attribute_input)]` (part of `#[deny(future_incompatible)]`) on by default warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![crate_name]` - --> $DIR/malformed-attrs.rs:73:1 + --> $DIR/malformed-attrs.rs:72:1 | LL | #[crate_name] | ^^^^^^^^^^^^^ | note: this attribute does not have an `!`, which means it is applied to this function - --> $DIR/malformed-attrs.rs:114:1 + --> $DIR/malformed-attrs.rs:113:1 | LL | / fn test() { LL | | #[coroutine = 63] || {} @@ -879,13 +879,13 @@ LL | | } | |_^ error: valid forms for the attribute are `#[doc = "string"]`, `#[doc(alias)]`, `#[doc(attribute)]`, `#[doc(auto_cfg)]`, `#[doc(cfg)]`, `#[doc(fake_variadic)]`, `#[doc(hidden)]`, `#[doc(html_favicon_url)]`, `#[doc(html_logo_url)]`, `#[doc(html_no_source)]`, `#[doc(html_playground_url)]`, `#[doc(html_root_url)]`, `#[doc(include)]`, `#[doc(inline)]`, `#[doc(issue_tracker_base_url)]`, `#[doc(keyword)]`, `#[doc(masked)]`, `#[doc(no_default_passes)]`, `#[doc(no_inline)]`, `#[doc(notable_trait)]`, `#[doc(passes)]`, `#[doc(plugins)]`, `#[doc(rust_logo)]`, `#[doc(search_unbox)]`, `#[doc(spotlight)]`, and `#[doc(test)]` - --> $DIR/malformed-attrs.rs:76:1 + --> $DIR/malformed-attrs.rs:75:1 | LL | #[doc] | ^^^^^^ warning: `#[link_name]` attribute cannot be used on functions - --> $DIR/malformed-attrs.rs:86:1 + --> $DIR/malformed-attrs.rs:85:1 | LL | #[link_name] | ^^^^^^^^^^^^ @@ -894,7 +894,7 @@ LL | #[link_name] = help: `#[link_name]` can be applied to foreign functions and foreign statics error: valid forms for the attribute are `#[ignore = "reason"]` and `#[ignore]` - --> $DIR/malformed-attrs.rs:96:1 + --> $DIR/malformed-attrs.rs:95:1 | LL | #[ignore()] | ^^^^^^^^^^^ @@ -903,7 +903,7 @@ LL | #[ignore()] = note: for more information, see issue #57571 warning: `#[no_implicit_prelude]` attribute cannot be used on functions - --> $DIR/malformed-attrs.rs:99:1 + --> $DIR/malformed-attrs.rs:98:1 | LL | #[no_implicit_prelude = 23] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -912,7 +912,7 @@ LL | #[no_implicit_prelude = 23] = help: `#[no_implicit_prelude]` can be applied to crates and modules warning: missing options for `diagnostic::on_unimplemented` attribute - --> $DIR/malformed-attrs.rs:138:1 + --> $DIR/malformed-attrs.rs:137:1 | LL | #[diagnostic::on_unimplemented] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -921,7 +921,7 @@ LL | #[diagnostic::on_unimplemented] = note: `#[warn(malformed_diagnostic_attributes)]` (part of `#[warn(unknown_or_malformed_diagnostic_attributes)]`) on by default warning: malformed `diagnostic::on_unimplemented` attribute - --> $DIR/malformed-attrs.rs:140:1 + --> $DIR/malformed-attrs.rs:139:1 | LL | #[diagnostic::on_unimplemented = 1] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid option found here @@ -929,13 +929,13 @@ LL | #[diagnostic::on_unimplemented = 1] = help: only `message`, `note` and `label` are allowed as options warning: `#[diagnostic::do_not_recommend]` does not expect any arguments - --> $DIR/malformed-attrs.rs:147:1 + --> $DIR/malformed-attrs.rs:146:1 | LL | #[diagnostic::do_not_recommend()] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: `#[automatically_derived]` attribute cannot be used on modules - --> $DIR/malformed-attrs.rs:188:1 + --> $DIR/malformed-attrs.rs:187:1 | LL | #[automatically_derived = 18] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -944,7 +944,7 @@ LL | #[automatically_derived = 18] = help: `#[automatically_derived]` can only be applied to trait impl blocks error: valid forms for the attribute are `#[ignore = "reason"]` and `#[ignore]` - --> $DIR/malformed-attrs.rs:222:1 + --> $DIR/malformed-attrs.rs:221:1 | LL | #[ignore = 1] | ^^^^^^^^^^^^^ @@ -953,7 +953,7 @@ LL | #[ignore = 1] = note: for more information, see issue #57571 error[E0308]: mismatched types - --> $DIR/malformed-attrs.rs:115:23 + --> $DIR/malformed-attrs.rs:114:23 | LL | fn test() { | - help: a return type might be missing here: `-> _` @@ -961,7 +961,7 @@ LL | #[coroutine = 63] || {} | ^^^^^ expected `()`, found coroutine | = note: expected unit type `()` - found coroutine `{coroutine@$DIR/malformed-attrs.rs:115:23: 115:25}` + found coroutine `{coroutine@$DIR/malformed-attrs.rs:114:23: 114:25}` error: aborting due to 73 previous errors; 8 warnings emitted @@ -969,7 +969,7 @@ Some errors have detailed explanations: E0308, E0463, E0539, E0565, E0658, E0805 For more information about an error, try `rustc --explain E0308`. Future incompatibility report: Future breakage diagnostic: error: valid forms for the attribute are `#[inline(always)]`, `#[inline(never)]`, and `#[inline]` - --> $DIR/malformed-attrs.rs:51:1 + --> $DIR/malformed-attrs.rs:50:1 | LL | #[inline = 5] | ^^^^^^^^^^^^^ @@ -980,7 +980,7 @@ LL | #[inline = 5] Future breakage diagnostic: error: valid forms for the attribute are `#[ignore = "reason"]` and `#[ignore]` - --> $DIR/malformed-attrs.rs:96:1 + --> $DIR/malformed-attrs.rs:95:1 | LL | #[ignore()] | ^^^^^^^^^^^ @@ -991,7 +991,7 @@ LL | #[ignore()] Future breakage diagnostic: error: valid forms for the attribute are `#[ignore = "reason"]` and `#[ignore]` - --> $DIR/malformed-attrs.rs:222:1 + --> $DIR/malformed-attrs.rs:221:1 | LL | #[ignore = 1] | ^^^^^^^^^^^^^ diff --git a/tests/ui/attributes/optimize.rs b/tests/ui/attributes/optimize.rs index 78e05f111e7bf..39186dd1edd0f 100644 --- a/tests/ui/attributes/optimize.rs +++ b/tests/ui/attributes/optimize.rs @@ -1,4 +1,3 @@ -#![feature(optimize_attribute)] #![feature(stmt_expr_attributes)] #![deny(unused_attributes)] #![allow(dead_code)] @@ -40,3 +39,11 @@ fn async_block() -> impl Future { async fn async_fn() { () } + +#[optimize(none)] +fn valid_none() {} + +#[optimize(none)] +async fn async_fn_none() { + () +} diff --git a/tests/ui/attributes/optimize.stderr b/tests/ui/attributes/optimize.stderr index 2ded1a973f33d..4553543b80693 100644 --- a/tests/ui/attributes/optimize.stderr +++ b/tests/ui/attributes/optimize.stderr @@ -1,5 +1,5 @@ error: `#[optimize]` attribute cannot be used on structs - --> $DIR/optimize.rs:8:1 + --> $DIR/optimize.rs:7:1 | LL | #[optimize(speed)] | ^^^^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | #[optimize(speed)] = help: `#[optimize]` can only be applied to functions error: `#[optimize]` attribute cannot be used on expressions - --> $DIR/optimize.rs:12:5 + --> $DIR/optimize.rs:11:5 | LL | #[optimize(speed)] | ^^^^^^^^^^^^^^^^^^ @@ -15,7 +15,7 @@ LL | #[optimize(speed)] = help: `#[optimize]` can only be applied to functions error: `#[optimize]` attribute cannot be used on modules - --> $DIR/optimize.rs:21:1 + --> $DIR/optimize.rs:20:1 | LL | #[optimize(speed)] | ^^^^^^^^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | #[optimize(speed)] = help: `#[optimize]` can only be applied to functions error: `#[optimize]` attribute cannot be used on inherent impl blocks - --> $DIR/optimize.rs:24:1 + --> $DIR/optimize.rs:23:1 | LL | #[optimize(speed)] | ^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/coroutine/other-attribute-on-gen.rs b/tests/ui/coroutine/other-attribute-on-gen.rs index e13a0abcbfd63..8fb428fd81b25 100644 --- a/tests/ui/coroutine/other-attribute-on-gen.rs +++ b/tests/ui/coroutine/other-attribute-on-gen.rs @@ -1,7 +1,6 @@ //@ edition: 2024 //@ run-pass #![feature(gen_blocks)] -#![feature(optimize_attribute)] #![feature(async_iterator)] #![allow(dead_code)] diff --git a/tests/ui/feature-gates/feature-gate-optimize_attribute.rs b/tests/ui/feature-gates/feature-gate-optimize_attribute.rs deleted file mode 100644 index ed5a11270f83e..0000000000000 --- a/tests/ui/feature-gates/feature-gate-optimize_attribute.rs +++ /dev/null @@ -1,15 +0,0 @@ -#![crate_type="rlib"] - -#[optimize(size)] //~ ERROR the `#[optimize]` attribute is an experimental feature -fn size() {} - -#[optimize(speed)] //~ ERROR the `#[optimize]` attribute is an experimental feature -fn speed() {} - -#[optimize(none)] //~ ERROR the `#[optimize]` attribute is an experimental feature -fn none() {} - -#[optimize(banana)] -//~^ ERROR the `#[optimize]` attribute is an experimental feature -//~| ERROR malformed `optimize` attribute input [E0539] -fn not_known() {} diff --git a/tests/ui/feature-gates/feature-gate-optimize_attribute.stderr b/tests/ui/feature-gates/feature-gate-optimize_attribute.stderr deleted file mode 100644 index 646abf8e4a16e..0000000000000 --- a/tests/ui/feature-gates/feature-gate-optimize_attribute.stderr +++ /dev/null @@ -1,64 +0,0 @@ -error[E0658]: the `#[optimize]` attribute is an experimental feature - --> $DIR/feature-gate-optimize_attribute.rs:3:1 - | -LL | #[optimize(size)] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #54882 for more information - = help: add `#![feature(optimize_attribute)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: the `#[optimize]` attribute is an experimental feature - --> $DIR/feature-gate-optimize_attribute.rs:6:1 - | -LL | #[optimize(speed)] - | ^^^^^^^^^^^^^^^^^^ - | - = note: see issue #54882 for more information - = help: add `#![feature(optimize_attribute)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: the `#[optimize]` attribute is an experimental feature - --> $DIR/feature-gate-optimize_attribute.rs:9:1 - | -LL | #[optimize(none)] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #54882 for more information - = help: add `#![feature(optimize_attribute)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: the `#[optimize]` attribute is an experimental feature - --> $DIR/feature-gate-optimize_attribute.rs:12:1 - | -LL | #[optimize(banana)] - | ^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #54882 for more information - = help: add `#![feature(optimize_attribute)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0539]: malformed `optimize` attribute input - --> $DIR/feature-gate-optimize_attribute.rs:12:1 - | -LL | #[optimize(banana)] - | ^^^^^^^^^^^------^^ - | | - | valid arguments are `size`, `speed` or `none` - | -help: try changing it to one of the following valid forms of the attribute - | -LL - #[optimize(banana)] -LL + #[optimize(none)] - | -LL - #[optimize(banana)] -LL + #[optimize(size)] - | -LL - #[optimize(banana)] -LL + #[optimize(speed)] - | - -error: aborting due to 5 previous errors - -Some errors have detailed explanations: E0539, E0658. -For more information about an error, try `rustc --explain E0539`.