Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/accepted.rs
Copy link
Copy Markdown
Member

@jieyouxu jieyouxu Jun 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussion: hm, I wonder if this attribute deserves an entry in the rustc book (a bit like lint levels), because while sure there's the Reference PR, but this is more like a compiler knob?

View changes since the review

Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_feature/src/builtin_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion library/alloc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
1 change: 0 additions & 1 deletion library/alloctests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
1 change: 0 additions & 1 deletion library/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
1 change: 0 additions & 1 deletion library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
2 changes: 0 additions & 2 deletions tests/codegen-llvm/issues/issue-136329-optnone-noinline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

//@ compile-flags: -Copt-level=3

#![feature(optimize_attribute)]

#[optimize(none)]
pub fn foo() {
let _x = 123;
Expand Down
1 change: 0 additions & 1 deletion tests/codegen-llvm/optimize-attr-1.rs
Copy link
Copy Markdown
Member

@jieyouxu jieyouxu Jun 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question (non-blocking): hm, do we know what happened to optimize-attr-2.rs 🙈

View changes since the review

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions tests/mir-opt/optimize_none.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 0 additions & 2 deletions tests/rustdoc-json/attrs/optimize.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![feature(optimize_attribute)]

//@ is "$.index[?(@.name=='speed')].attrs" '[{"other": "#[attr = Optimize(Speed)]"}]'
#[optimize(speed)]
pub fn speed() {}
Expand Down
1 change: 0 additions & 1 deletion tests/ui/attributes/malformed-attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
Loading
Loading