Skip to content

Commit 03bd1ac

Browse files
committed
stabilize optimize attribute (size, speed, and none)
This commit stabilizes the `#[optimize]` attribute, which allows for more fine-grained control of optimization levels.
1 parent dfbea5b commit 03bd1ac

24 files changed

Lines changed: 144 additions & 234 deletions

compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ impl SingleAttributeParser for OptimizeParser {
2626
Allow(Target::Method(MethodKind::Inherent)),
2727
]);
2828
const TEMPLATE: AttributeTemplate = template!(List: &["size", "speed", "none"]);
29-
const STABILITY: AttributeStability = unstable!(optimize_attribute);
29+
const STABILITY: AttributeStability = AttributeStability::Stable;
3030

3131
fn convert(cx: &mut AcceptContext<'_, '_>, args: &ArgParser) -> Option<AttributeKind> {
3232
let single = cx.expect_single_element_list(args, cx.attr_span)?;

compiler/rustc_feature/src/accepted.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,8 @@ declare_features! (
342342
(accepted, non_modrs_mods, "1.30.0", Some(44660)),
343343
/// Allows using multiple nested field accesses in offset_of!
344344
(accepted, offset_of_nested, "1.82.0", Some(120140)),
345+
/// Allows using `#[optimize(X)]`.
346+
(accepted, optimize_attribute, "CURRENT_RUSTC_VERSION", Some(54882)),
345347
/// Allows the use of or-patterns (e.g., `0 | 1`).
346348
(accepted, or_patterns, "1.53.0", Some(54883)),
347349
/// Allows using `+bundle,+whole-archive` link modifiers with native libs.

compiler/rustc_feature/src/builtin_attrs.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ pub static BUILTIN_ATTRIBUTES: &[Symbol] = &[
157157
sym::force_target_feature,
158158
sym::sanitize,
159159
sym::coverage,
160+
sym::optimize,
160161

161162
sym::doc,
162163

@@ -180,8 +181,6 @@ pub static BUILTIN_ATTRIBUTES: &[Symbol] = &[
180181
sym::marker,
181182
sym::thread_local,
182183
sym::no_core,
183-
// RFC 2412
184-
sym::optimize,
185184

186185
sym::ffi_pure,
187186
sym::ffi_const,

compiler/rustc_feature/src/unstable.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -690,8 +690,6 @@ declare_features! (
690690
(unstable, offset_of_enum, "1.75.0", Some(120141)),
691691
/// Allows using fields with slice type in offset_of!
692692
(unstable, offset_of_slice, "1.81.0", Some(126151)),
693-
/// Allows using `#[optimize(X)]`.
694-
(unstable, optimize_attribute, "1.34.0", Some(54882)),
695693
/// Allows specifying nop padding on functions for dynamic patching.
696694
(unstable, patchable_function_entry, "1.81.0", Some(123115)),
697695
/// Experimental features that make `Pin` more ergonomic.

library/alloc/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@
209209
#![feature(multiple_supertrait_upcastable)]
210210
#![feature(negative_impls)]
211211
#![feature(never_type)]
212-
#![feature(optimize_attribute)]
213212
#![feature(rustc_attrs)]
214213
#![feature(slice_internals)]
215214
#![feature(staged_api)]

library/alloctests/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
#![feature(dropck_eyepatch)]
6464
#![feature(min_specialization)]
6565
#![feature(never_type)]
66-
#![feature(optimize_attribute)]
6766
#![feature(prelude_import)]
6867
#![feature(rustc_attrs)]
6968
#![feature(staged_api)]

library/core/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@
147147
#![feature(negative_impls)]
148148
#![feature(never_type)]
149149
#![feature(no_core)]
150-
#![feature(optimize_attribute)]
151150
#![feature(pattern_types)]
152151
#![feature(pin_macro_internals)]
153152
#![feature(prelude_import)]

library/std/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,6 @@
303303
#![feature(needs_panic_runtime)]
304304
#![feature(negative_impls)]
305305
#![feature(never_type)]
306-
#![feature(optimize_attribute)]
307306
#![feature(prelude_import)]
308307
#![feature(rustc_attrs)]
309308
#![feature(rustdoc_internals)]

tests/codegen-llvm/issues/issue-136329-optnone-noinline.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
33
//@ compile-flags: -Copt-level=3
44

5-
#![feature(optimize_attribute)]
6-
75
#[optimize(none)]
86
pub fn foo() {
97
let _x = 123;

tests/codegen-llvm/optimize-attr-1.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
//@[SIZE-OPT] compile-flags: -Copt-level=s -Ccodegen-units=1
44
//@[SPEED-OPT] compile-flags: -Copt-level=3 -Ccodegen-units=1
55

6-
#![feature(optimize_attribute)]
76
#![crate_type = "rlib"]
87

98
// CHECK-LABEL: define{{.*}}i32 @nothing

0 commit comments

Comments
 (0)