diff --git a/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs index e88b1751e4b6c..96db6b0f13b7b 100644 --- a/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs @@ -36,7 +36,18 @@ impl SingleAttributeParser for OptimizeParser { let res = match single.meta_item_no_args().and_then(|i| i.path().word().map(|i| i.name)) { Some(sym::size) => OptimizeAttr::Size, - Some(sym::speed) => OptimizeAttr::Speed, + Some(sym::speed) => { + if !cx.features().optimize_speed() { + feature_err( + cx.sess(), + sym::optimize_speed, + cx.attr_span, + "`#[optimize(speed)]` is currently unstable", + ) + .emit(); + } + OptimizeAttr::Speed + } Some(sym::none) => OptimizeAttr::DoNotOptimize, _ => { cx.adcx() diff --git a/compiler/rustc_codegen_llvm/src/attributes.rs b/compiler/rustc_codegen_llvm/src/attributes.rs index bdbd43de07a53..0b6b07a1ed75e 100644 --- a/compiler/rustc_codegen_llvm/src/attributes.rs +++ b/compiler/rustc_codegen_llvm/src/attributes.rs @@ -520,7 +520,10 @@ pub(crate) fn llfn_attrs_from_instance<'ll, 'tcx>( to_add.push(llvm::AttributeKind::MinSize.create_attr(cx.llcx)); to_add.push(llvm::AttributeKind::OptimizeForSize.create_attr(cx.llcx)); } - OptimizeAttr::Speed => {} + OptimizeAttr::Speed => { + // Suppress default attrs (such as a global opt-for-size). + // We cannot actually tell LLVM to optimize *more* per-function. + } } if let Some(instance) = instance { diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index ed2bf64263c67..0e517558fa8c4 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -690,6 +690,8 @@ 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(speed)]`. + (unstable, optimize_speed, "CURRENT_RUSTC_VERSION", Some(165590)), /// 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/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index a7f8e37687b18..fd9aa2172fdca 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -1534,6 +1534,7 @@ symbols! { opt_out_copy, optimize, optimize_attribute, + optimize_speed, optimized, optin_builtin_traits, option, diff --git a/tests/codegen-llvm/optimize-attr-1.rs b/tests/codegen-llvm/optimize-attr-1.rs index c4cb8e460476f..195ab026e6dcd 100644 --- a/tests/codegen-llvm/optimize-attr-1.rs +++ b/tests/codegen-llvm/optimize-attr-1.rs @@ -4,6 +4,7 @@ //@[SPEED-OPT] compile-flags: -Copt-level=3 -Ccodegen-units=1 #![crate_type = "rlib"] +#![feature(optimize_speed)] // CHECK-LABEL: define{{.*}}i32 @nothing // CHECK-SAME: [[NOTHING_ATTRS:#[0-9]+]] diff --git a/tests/ui/attributes/malformed-attrs.rs b/tests/ui/attributes/malformed-attrs.rs index 6b66f05c03888..5ea415dbfa880 100644 --- a/tests/ui/attributes/malformed-attrs.rs +++ b/tests/ui/attributes/malformed-attrs.rs @@ -60,6 +60,8 @@ //~^ ERROR malformed #[optimize(none, speed)] //~^ ERROR malformed +#[optimize(banana)] +//~^ ERROR malformed #[cold = 1] //~^ ERROR malformed #[must_use()] diff --git a/tests/ui/attributes/malformed-attrs.stderr b/tests/ui/attributes/malformed-attrs.stderr index b982facaf2abb..7c96464cf47f4 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:109:3 + --> $DIR/malformed-attrs.rs:111:3 | 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:111:3 + --> $DIR/malformed-attrs.rs:113:3 | LL | #[cfg_attr] | ^^^^^^^^ expected this to be a list @@ -23,25 +23,25 @@ LL | #[cfg_attr(predicate, attr1, attr2, ...)] | ++++++++++++++++++++++++++++++ error[E0463]: can't find crate for `wloop` - --> $DIR/malformed-attrs.rs:215:1 + --> $DIR/malformed-attrs.rs:217:1 | LL | extern crate wloop; | ^^^^^^^^^^^^^^^^^^^ can't find crate error: the `proc_macro` attribute is only usable with crates of the `proc-macro` crate type - --> $DIR/malformed-attrs.rs:106:3 + --> $DIR/malformed-attrs.rs:108:3 | 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:123:3 + --> $DIR/malformed-attrs.rs:125:3 | 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:130:3 + --> $DIR/malformed-attrs.rs:132:3 | LL | #[proc_macro_derive] | ^^^^^^^^^^^^^^^^^ @@ -231,9 +231,29 @@ LL - #[optimize(none, speed)] LL + #[optimize(speed)] | -error[E0565]: malformed `cold` attribute input +error[E0539]: malformed `optimize` attribute input --> $DIR/malformed-attrs.rs:63:3 | +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[E0565]: malformed `cold` attribute input + --> $DIR/malformed-attrs.rs:65:3 + | LL | #[cold = 1] | ^^^^^--- | | @@ -246,7 +266,7 @@ LL + #[cold] | error[E0539]: malformed `must_use` attribute input - --> $DIR/malformed-attrs.rs:65:3 + --> $DIR/malformed-attrs.rs:67:3 | LL | #[must_use()] | ^^^^^^^^-- @@ -264,7 +284,7 @@ LL + #[must_use = "reason"] | error[E0565]: malformed `no_mangle` attribute input - --> $DIR/malformed-attrs.rs:67:3 + --> $DIR/malformed-attrs.rs:69:3 | LL | #[no_mangle = 1] | ^^^^^^^^^^--- @@ -278,7 +298,7 @@ LL + #[no_mangle] | error[E0565]: malformed `naked` attribute input - --> $DIR/malformed-attrs.rs:69:3 + --> $DIR/malformed-attrs.rs:71:3 | LL | #[unsafe(naked())] | ^^^^^^^^^^^^--^ @@ -292,7 +312,7 @@ LL + #[unsafe(naked)] | error[E0565]: malformed `track_caller` attribute input - --> $DIR/malformed-attrs.rs:71:3 + --> $DIR/malformed-attrs.rs:73:3 | LL | #[track_caller()] | ^^^^^^^^^^^^-- @@ -306,7 +326,7 @@ LL + #[track_caller] | error[E0539]: malformed `export_name` attribute input - --> $DIR/malformed-attrs.rs:73:3 + --> $DIR/malformed-attrs.rs:75:3 | LL | #[export_name()] | ^^^^^^^^^^^^^ @@ -318,7 +338,7 @@ LL + #[export_name = "name"] | error[E0805]: malformed `used` attribute input - --> $DIR/malformed-attrs.rs:75:3 + --> $DIR/malformed-attrs.rs:77:3 | LL | #[used()] | ^^^^-- @@ -336,7 +356,7 @@ LL | #[used(linker)] | ++++++ error: the `used` attribute cannot be used on functions - --> $DIR/malformed-attrs.rs:75:3 + --> $DIR/malformed-attrs.rs:77:3 | LL | #[used()] | ^^^^ @@ -346,7 +366,7 @@ LL | fn test() { = help: the `used` attribute can only be applied to statics error[E0539]: malformed `crate_name` attribute input - --> $DIR/malformed-attrs.rs:78:3 + --> $DIR/malformed-attrs.rs:80:3 | LL | #[crate_name] | ^^^^^^^^^^ @@ -357,7 +377,7 @@ LL | #[crate_name = "name"] | ++++++++ error[E0539]: malformed `target_feature` attribute input - --> $DIR/malformed-attrs.rs:81:3 + --> $DIR/malformed-attrs.rs:83:3 | LL | #[target_feature] | ^^^^^^^^^^^^^^ expected this to be a list @@ -368,7 +388,7 @@ LL | #[target_feature(enable = "feat1, feat2")] | +++++++++++++++++++++++++ error[E0565]: malformed `export_stable` attribute input - --> $DIR/malformed-attrs.rs:83:3 + --> $DIR/malformed-attrs.rs:85:3 | LL | #[export_stable = 1] | ^^^^^^^^^^^^^^--- @@ -382,7 +402,7 @@ LL + #[export_stable] | error[E0539]: malformed `link` attribute input - --> $DIR/malformed-attrs.rs:85:3 + --> $DIR/malformed-attrs.rs:87:3 | LL | #[link] | ^^^^ expected this to be a list @@ -390,7 +410,7 @@ LL | #[link] = note: for more information, visit error[E0539]: malformed `link_name` attribute input - --> $DIR/malformed-attrs.rs:89:3 + --> $DIR/malformed-attrs.rs:91:3 | LL | #[link_name] | ^^^^^^^^^ @@ -402,7 +422,7 @@ LL | #[link_name = "name"] | ++++++++ error[E0539]: malformed `link_section` attribute input - --> $DIR/malformed-attrs.rs:93:3 + --> $DIR/malformed-attrs.rs:95:3 | LL | #[link_section] | ^^^^^^^^^^^^ @@ -414,7 +434,7 @@ LL | #[link_section = "name"] | ++++++++ error[E0539]: malformed `coverage` attribute input - --> $DIR/malformed-attrs.rs:95:3 + --> $DIR/malformed-attrs.rs:97:3 | LL | #[coverage] | ^^^^^^^^ expected this to be a list @@ -427,13 +447,13 @@ LL | #[coverage(on)] | ++++ error[E0539]: malformed `sanitize` attribute input - --> $DIR/malformed-attrs.rs:97:3 + --> $DIR/malformed-attrs.rs:99:3 | LL | #[sanitize] | ^^^^^^^^ expected this to be a list error[E0565]: malformed `no_implicit_prelude` attribute input - --> $DIR/malformed-attrs.rs:102:3 + --> $DIR/malformed-attrs.rs:104:3 | LL | #[no_implicit_prelude = 23] | ^^^^^^^^^^^^^^^^^^^^---- @@ -447,7 +467,7 @@ LL + #[no_implicit_prelude] | error[E0565]: malformed `proc_macro` attribute input - --> $DIR/malformed-attrs.rs:106:3 + --> $DIR/malformed-attrs.rs:108:3 | LL | #[proc_macro = 18] | ^^^^^^^^^^^---- @@ -461,7 +481,7 @@ LL + #[proc_macro] | error[E0539]: malformed `instruction_set` attribute input - --> $DIR/malformed-attrs.rs:113:3 + --> $DIR/malformed-attrs.rs:115:3 | LL | #[instruction_set] | ^^^^^^^^^^^^^^^ expected this to be a list @@ -473,7 +493,7 @@ LL | #[instruction_set(set)] | +++++ error[E0539]: malformed `patchable_function_entry` attribute input - --> $DIR/malformed-attrs.rs:115:3 + --> $DIR/malformed-attrs.rs:117:3 | LL | #[patchable_function_entry] | ^^^^^^^^^^^^^^^^^^^^^^^^ expected this to be a list @@ -496,7 +516,7 @@ LL | | } | |_- not a `const fn` error[E0565]: malformed `coroutine` attribute input - --> $DIR/malformed-attrs.rs:118:7 + --> $DIR/malformed-attrs.rs:120:7 | LL | #[coroutine = 63] || {} | ^^^^^^^^^^---- @@ -510,7 +530,7 @@ LL + #[coroutine] || {} | error[E0565]: malformed `proc_macro_attribute` attribute input - --> $DIR/malformed-attrs.rs:123:3 + --> $DIR/malformed-attrs.rs:125:3 | LL | #[proc_macro_attribute = 19] | ^^^^^^^^^^^^^^^^^^^^^---- @@ -524,7 +544,7 @@ LL + #[proc_macro_attribute] | error[E0539]: malformed `must_use` attribute input - --> $DIR/malformed-attrs.rs:126:3 + --> $DIR/malformed-attrs.rs:128:3 | LL | #[must_use = 1] | ^^^^^^^^^^^- @@ -542,7 +562,7 @@ LL + #[must_use = "reason"] | error[E0539]: malformed `proc_macro_derive` attribute input - --> $DIR/malformed-attrs.rs:130:3 + --> $DIR/malformed-attrs.rs:132:3 | LL | #[proc_macro_derive] | ^^^^^^^^^^^^^^^^^ expected this to be a list @@ -556,7 +576,7 @@ LL | #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] | ++++++++++++++++++++++++++++++++++++++++++ error[E0539]: malformed `must_not_suspend` attribute input - --> $DIR/malformed-attrs.rs:135:3 + --> $DIR/malformed-attrs.rs:137:3 | LL | #[must_not_suspend()] | ^^^^^^^^^^^^^^^^-- @@ -572,7 +592,7 @@ LL | #[must_not_suspend(count)] | +++++ error[E0539]: malformed `cfi_encoding` attribute input - --> $DIR/malformed-attrs.rs:137:3 + --> $DIR/malformed-attrs.rs:139:3 | LL | #[cfi_encoding = ""] | ^^^^^^^^^^^^^^^-- @@ -585,7 +605,7 @@ LL | #[cfi_encoding = "encoding"] | ++++++++ error[E0565]: malformed `marker` attribute input - --> $DIR/malformed-attrs.rs:156:3 + --> $DIR/malformed-attrs.rs:158:3 | LL | #[marker = 3] | ^^^^^^^--- @@ -599,7 +619,7 @@ LL + #[marker] | error[E0565]: malformed `fundamental` attribute input - --> $DIR/malformed-attrs.rs:158:3 + --> $DIR/malformed-attrs.rs:160:3 | LL | #[fundamental()] | ^^^^^^^^^^^-- @@ -613,7 +633,7 @@ LL + #[fundamental] | error[E0565]: malformed `ffi_pure` attribute input - --> $DIR/malformed-attrs.rs:166:7 + --> $DIR/malformed-attrs.rs:168:7 | LL | #[unsafe(ffi_pure = 1)] | ^^^^^^^^^^^^^^^^---^ @@ -627,7 +647,7 @@ LL + #[unsafe(ffi_pure)] | error[E0539]: malformed `link_ordinal` attribute input - --> $DIR/malformed-attrs.rs:168:7 + --> $DIR/malformed-attrs.rs:170:7 | LL | #[link_ordinal] | ^^^^^^^^^^^^ expected this to be a list @@ -639,7 +659,7 @@ LL | #[link_ordinal(ordinal)] | +++++++++ error[E0565]: malformed `ffi_const` attribute input - --> $DIR/malformed-attrs.rs:172:7 + --> $DIR/malformed-attrs.rs:174:7 | LL | #[unsafe(ffi_const = 1)] | ^^^^^^^^^^^^^^^^^---^ @@ -653,13 +673,13 @@ LL + #[unsafe(ffi_const)] | error[E0539]: malformed `linkage` attribute input - --> $DIR/malformed-attrs.rs:174:7 + --> $DIR/malformed-attrs.rs:176:7 | LL | #[linkage] | ^^^^^^^ expected this to be of the form `linkage = "..."` error[E0539]: malformed `allow` attribute input - --> $DIR/malformed-attrs.rs:179:3 + --> $DIR/malformed-attrs.rs:181:3 | LL | #[allow] | ^^^^^ expected this to be a list @@ -675,7 +695,7 @@ LL | #[allow(lint1, lint2, lint3, reason = "...")] | +++++++++++++++++++++++++++++++++++++ error[E0539]: malformed `expect` attribute input - --> $DIR/malformed-attrs.rs:181:3 + --> $DIR/malformed-attrs.rs:183:3 | LL | #[expect] | ^^^^^^ expected this to be a list @@ -691,7 +711,7 @@ LL | #[expect(lint1, lint2, lint3, reason = "...")] | +++++++++++++++++++++++++++++++++++++ error[E0539]: malformed `warn` attribute input - --> $DIR/malformed-attrs.rs:183:3 + --> $DIR/malformed-attrs.rs:185:3 | LL | #[warn] | ^^^^ expected this to be a list @@ -707,7 +727,7 @@ LL | #[warn(lint1, lint2, lint3, reason = "...")] | +++++++++++++++++++++++++++++++++++++ error[E0539]: malformed `deny` attribute input - --> $DIR/malformed-attrs.rs:185:3 + --> $DIR/malformed-attrs.rs:187:3 | LL | #[deny] | ^^^^ expected this to be a list @@ -723,7 +743,7 @@ LL | #[deny(lint1, lint2, lint3, reason = "...")] | +++++++++++++++++++++++++++++++++++++ error[E0539]: malformed `forbid` attribute input - --> $DIR/malformed-attrs.rs:187:3 + --> $DIR/malformed-attrs.rs:189:3 | LL | #[forbid] | ^^^^^^ expected this to be a list @@ -739,7 +759,7 @@ LL | #[forbid(lint1, lint2, lint3, reason = "...")] | +++++++++++++++++++++++++++++++++++++ error[E0539]: malformed `debugger_visualizer` attribute input - --> $DIR/malformed-attrs.rs:189:3 + --> $DIR/malformed-attrs.rs:191:3 | LL | #[debugger_visualizer] | ^^^^^^^^^^^^^^^^^^^ expected this to be a list @@ -751,7 +771,7 @@ LL | #[debugger_visualizer(natvis_file = "...", gdb_script_file = "...")] | ++++++++++++++++++++++++++++++++++++++++++++++ error[E0565]: malformed `automatically_derived` attribute input - --> $DIR/malformed-attrs.rs:191:3 + --> $DIR/malformed-attrs.rs:193:3 | LL | #[automatically_derived = 18] | ^^^^^^^^^^^^^^^^^^^^^^---- @@ -765,7 +785,7 @@ LL + #[automatically_derived] | error[E0565]: malformed `non_exhaustive` attribute input - --> $DIR/malformed-attrs.rs:199:3 + --> $DIR/malformed-attrs.rs:201:3 | LL | #[non_exhaustive = 1] | ^^^^^^^^^^^^^^^--- @@ -779,7 +799,7 @@ LL + #[non_exhaustive] | error[E0565]: malformed `thread_local` attribute input - --> $DIR/malformed-attrs.rs:205:3 + --> $DIR/malformed-attrs.rs:207:3 | LL | #[thread_local()] | ^^^^^^^^^^^^-- @@ -793,7 +813,7 @@ LL + #[thread_local] | error[E0565]: malformed `no_link` attribute input - --> $DIR/malformed-attrs.rs:209:3 + --> $DIR/malformed-attrs.rs:211:3 | LL | #[no_link()] | ^^^^^^^-- @@ -807,7 +827,7 @@ LL + #[no_link] | error[E0539]: malformed `macro_use` attribute input - --> $DIR/malformed-attrs.rs:213:3 + --> $DIR/malformed-attrs.rs:215:3 | LL | #[macro_use = 1] | ^^^^^^^^^^--- @@ -825,7 +845,7 @@ LL + #[macro_use(name1, name2, ...)] | error[E0539]: malformed `macro_export` attribute input - --> $DIR/malformed-attrs.rs:218:3 + --> $DIR/malformed-attrs.rs:220:3 | LL | #[macro_export = 18] | ^^^^^^^^^^^^^---- @@ -842,7 +862,7 @@ LL + #[macro_export(local_inner_macros)] | error[E0658]: the `allow_internal_unsafe` attribute side-steps the `unsafe_code` lint - --> $DIR/malformed-attrs.rs:220:3 + --> $DIR/malformed-attrs.rs:222:3 | LL | #[allow_internal_unsafe = 1] | ^^^^^^^^^^^^^^^^^^^^^ @@ -851,7 +871,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[E0565]: malformed `allow_internal_unsafe` attribute input - --> $DIR/malformed-attrs.rs:220:3 + --> $DIR/malformed-attrs.rs:222:3 | LL | #[allow_internal_unsafe = 1] | ^^^^^^^^^^^^^^^^^^^^^^--- @@ -893,13 +913,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:78:1 + --> $DIR/malformed-attrs.rs:80:1 | LL | #[crate_name] | ^^^^^^^^^^^^^ | note: this attribute does not have an `!`, which means it is applied to this function - --> $DIR/malformed-attrs.rs:117:1 + --> $DIR/malformed-attrs.rs:119:1 | LL | / fn test() { LL | | #[coroutine = 63] || {} @@ -909,7 +929,7 @@ LL | | } = note: requested on the command line with `-W unused-attributes` warning: the `link` attribute cannot be used on functions - --> $DIR/malformed-attrs.rs:85:3 + --> $DIR/malformed-attrs.rs:87:3 | LL | #[link] | ^^^^ @@ -920,7 +940,7 @@ LL | fn test() { = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! warning: the `link_name` attribute cannot be used on functions - --> $DIR/malformed-attrs.rs:89:3 + --> $DIR/malformed-attrs.rs:91:3 | LL | #[link_name] | ^^^^^^^^^ @@ -931,7 +951,7 @@ LL | fn test() { = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! error: valid forms for the attribute are `ignore` and `ignore = "reason"` - --> $DIR/malformed-attrs.rs:99:3 + --> $DIR/malformed-attrs.rs:101:3 | LL | #[ignore()] | ^^^^^^^^ @@ -940,7 +960,7 @@ LL | #[ignore()] = note: for more information, see issue #57571 warning: the `no_implicit_prelude` attribute cannot be used on functions - --> $DIR/malformed-attrs.rs:102:3 + --> $DIR/malformed-attrs.rs:104:3 | LL | #[no_implicit_prelude = 23] | ^^^^^^^^^^^^^^^^^^^ @@ -951,7 +971,7 @@ LL | fn test() { = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! warning: missing options for `diagnostic::on_unimplemented` attribute - --> $DIR/malformed-attrs.rs:141:1 + --> $DIR/malformed-attrs.rs:143:1 | LL | #[diagnostic::on_unimplemented] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -960,7 +980,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:143:1 + --> $DIR/malformed-attrs.rs:145:1 | LL | #[diagnostic::on_unimplemented = 1] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid option found here @@ -968,13 +988,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:150:1 + --> $DIR/malformed-attrs.rs:152:1 | LL | #[diagnostic::do_not_recommend()] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: the `automatically_derived` attribute cannot be used on modules - --> $DIR/malformed-attrs.rs:191:3 + --> $DIR/malformed-attrs.rs:193:3 | LL | #[automatically_derived = 18] | ^^^^^^^^^^^^^^^^^^^^^ @@ -985,7 +1005,7 @@ LL | mod yooo { = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! error: use of deprecated `no_link` attribute - --> $DIR/malformed-attrs.rs:209:1 + --> $DIR/malformed-attrs.rs:211:1 | LL | #[no_link()] | ^^^^^^^^^^^^ @@ -995,7 +1015,7 @@ LL | #[no_link()] = note: `#[deny(no_link_attributes)]` (part of `#[deny(future_incompatible)]`) on by default error: valid forms for the attribute are `ignore` and `ignore = "reason"` - --> $DIR/malformed-attrs.rs:227:3 + --> $DIR/malformed-attrs.rs:229:3 | LL | #[ignore = 1] | ^^^^^^^^^^ @@ -1004,7 +1024,7 @@ LL | #[ignore = 1] = note: for more information, see issue #57571 error[E0308]: mismatched types - --> $DIR/malformed-attrs.rs:118:23 + --> $DIR/malformed-attrs.rs:120:23 | LL | fn test() { | - help: a return type might be missing here: `-> _` @@ -1012,9 +1032,9 @@ LL | #[coroutine = 63] || {} | ^^^^^ expected `()`, found coroutine | = note: expected unit type `()` - found coroutine `{coroutine@$DIR/malformed-attrs.rs:118:23: 118:25}` + found coroutine `{coroutine@$DIR/malformed-attrs.rs:120:23: 120:25}` -error: aborting due to 76 previous errors; 8 warnings emitted +error: aborting due to 77 previous errors; 8 warnings emitted Some errors have detailed explanations: E0308, E0433, E0463, E0539, E0565, E0658, E0805. For more information about an error, try `rustc --explain E0308`. @@ -1031,7 +1051,7 @@ LL | #[inline = 5] Future breakage diagnostic: error: valid forms for the attribute are `ignore` and `ignore = "reason"` - --> $DIR/malformed-attrs.rs:99:3 + --> $DIR/malformed-attrs.rs:101:3 | LL | #[ignore()] | ^^^^^^^^ @@ -1042,7 +1062,7 @@ LL | #[ignore()] Future breakage diagnostic: error: use of deprecated `no_link` attribute - --> $DIR/malformed-attrs.rs:209:1 + --> $DIR/malformed-attrs.rs:211:1 | LL | #[no_link()] | ^^^^^^^^^^^^ @@ -1053,7 +1073,7 @@ LL | #[no_link()] Future breakage diagnostic: error: valid forms for the attribute are `ignore` and `ignore = "reason"` - --> $DIR/malformed-attrs.rs:227:3 + --> $DIR/malformed-attrs.rs:229:3 | LL | #[ignore = 1] | ^^^^^^^^^^ diff --git a/tests/ui/attributes/optimize-smoke-test.rs b/tests/ui/attributes/optimize-smoke-test.rs index d379450fcaad9..6e3549a68fba7 100644 --- a/tests/ui/attributes/optimize-smoke-test.rs +++ b/tests/ui/attributes/optimize-smoke-test.rs @@ -1,3 +1,4 @@ +#![feature(optimize_speed)] //! Basic smoke test for `#[optimize(..)]` attributes. //@ run-pass diff --git a/tests/ui/attributes/optimize.rs b/tests/ui/attributes/optimize.rs index 41c716e0e9854..a5463f9a7f57a 100644 --- a/tests/ui/attributes/optimize.rs +++ b/tests/ui/attributes/optimize.rs @@ -1,3 +1,4 @@ +#![feature(optimize_speed)] #![feature(stmt_expr_attributes)] #![deny(unused_attributes)] #![allow(dead_code)] diff --git a/tests/ui/attributes/optimize.stderr b/tests/ui/attributes/optimize.stderr index d35b43b86c1bb..b852231e77f6b 100644 --- a/tests/ui/attributes/optimize.stderr +++ b/tests/ui/attributes/optimize.stderr @@ -1,5 +1,5 @@ error: the `optimize` attribute cannot be used on structs - --> $DIR/optimize.rs:7:3 + --> $DIR/optimize.rs:8:3 | LL | #[optimize(speed)] | ^^^^^^^^ @@ -8,7 +8,7 @@ LL | struct F; = help: the `optimize` attribute can only be applied to functions error: the `optimize` attribute cannot be used on expressions - --> $DIR/optimize.rs:11:7 + --> $DIR/optimize.rs:12:7 | LL | #[optimize(speed)] | ^^^^^^^^ @@ -17,7 +17,7 @@ LL | { = help: the `optimize` attribute can only be applied to functions error: the `optimize` attribute cannot be used on modules - --> $DIR/optimize.rs:20:3 + --> $DIR/optimize.rs:21:3 | LL | #[optimize(speed)] | ^^^^^^^^ @@ -26,7 +26,7 @@ LL | mod valid_module {} = help: the `optimize` attribute can only be applied to functions error: the `optimize` attribute cannot be used on inherent impl blocks - --> $DIR/optimize.rs:23:3 + --> $DIR/optimize.rs:24:3 | LL | #[optimize(speed)] | ^^^^^^^^ @@ -35,7 +35,7 @@ LL | impl F {} = help: the `optimize` attribute can only be applied to functions error: the `optimize` attribute cannot be used on required trait methods - --> $DIR/optimize.rs:44:7 + --> $DIR/optimize.rs:45:7 | LL | #[optimize(speed)] | ^^^^^^^^ @@ -44,31 +44,31 @@ LL | fn invalid(); = help: the `optimize` attribute can only be applied to functions with a body error: multiple `optimize` attributes - --> $DIR/optimize.rs:58:1 + --> $DIR/optimize.rs:59:1 | LL | #[optimize(speed)] | ^^^^^^^^^^^^^^^^^^ help: remove this attribute | note: attribute also specified here - --> $DIR/optimize.rs:57:1 + --> $DIR/optimize.rs:58:1 | LL | #[optimize(speed)] | ^^^^^^^^^^^^^^^^^^ error: multiple `optimize` attributes - --> $DIR/optimize.rs:62:1 + --> $DIR/optimize.rs:63:1 | LL | #[optimize(size)] | ^^^^^^^^^^^^^^^^^ help: remove this attribute | note: attribute also specified here - --> $DIR/optimize.rs:61:1 + --> $DIR/optimize.rs:62:1 | LL | #[optimize(speed)] | ^^^^^^^^^^^^^^^^^^ error: `#[optimize(none)]` cannot be used with `#[inline]` attributes - --> $DIR/optimize.rs:65:1 + --> $DIR/optimize.rs:66:1 | LL | #[optimize(none)] | ^^^^^^^^^^^^^^^^^ `#[optimize(none)]` here @@ -76,7 +76,7 @@ LL | #[inline] | --------- `#[inline]` here error: `#[optimize(none)]` cannot be used with `#[inline]` attributes - --> $DIR/optimize.rs:70:1 + --> $DIR/optimize.rs:71:1 | LL | #[inline(always)] | ----------------- `#[inline]` here diff --git a/tests/ui/coroutine/other-attribute-on-gen.rs b/tests/ui/coroutine/other-attribute-on-gen.rs index 8fb428fd81b25..4d0b5e528233c 100644 --- a/tests/ui/coroutine/other-attribute-on-gen.rs +++ b/tests/ui/coroutine/other-attribute-on-gen.rs @@ -1,5 +1,6 @@ //@ edition: 2024 //@ run-pass +#![feature(optimize_speed)] #![feature(gen_blocks)] #![feature(async_iterator)] #![allow(dead_code)] diff --git a/tests/ui/feature-gates/feature-gate-optimize_speed.rs b/tests/ui/feature-gates/feature-gate-optimize_speed.rs new file mode 100644 index 0000000000000..1516920720edd --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-optimize_speed.rs @@ -0,0 +1,4 @@ +#![crate_type="rlib"] + +#[optimize(speed)] //~ ERROR `#[optimize(speed)]` is currently unstable +fn speed() {} diff --git a/tests/ui/feature-gates/feature-gate-optimize_speed.stderr b/tests/ui/feature-gates/feature-gate-optimize_speed.stderr new file mode 100644 index 0000000000000..ab429325e061e --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-optimize_speed.stderr @@ -0,0 +1,13 @@ +error[E0658]: `#[optimize(speed)]` is currently unstable + --> $DIR/feature-gate-optimize_speed.rs:3:1 + | +LL | #[optimize(speed)] + | ^^^^^^^^^^^^^^^^^^ + | + = note: see issue #165590 for more information + = help: add `#![feature(optimize_speed)]` 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: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0658`.