Skip to content

Commit df8a3d5

Browse files
committed
stabilize naked_functions
1 parent 49e5e4e commit df8a3d5

File tree

53 files changed

+165
-294
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+165
-294
lines changed

compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
1-
#![feature(
2-
no_core,
3-
lang_items,
4-
never_type,
5-
linkage,
6-
extern_types,
7-
naked_functions,
8-
thread_local,
9-
repr_simd
10-
)]
1+
#![feature(no_core, lang_items, never_type, linkage, extern_types, thread_local, repr_simd)]
112
#![no_core]
123
#![allow(dead_code, non_camel_case_types, internal_features)]
134

compiler/rustc_error_codes/src/error_codes/E0787.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ An unsupported naked function definition.
33
Erroneous code example:
44

55
```compile_fail,E0787
6-
#![feature(naked_functions)]
7-
86
#[unsafe(naked)]
97
pub extern "C" fn f() -> u32 {
108
42

compiler/rustc_feature/src/accepted.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,8 @@ declare_features! (
300300
/// Allows patterns with concurrent by-move and by-ref bindings.
301301
/// For example, you can write `Foo(a, ref b)` where `a` is by-move and `b` is by-ref.
302302
(accepted, move_ref_pattern, "1.49.0", Some(68354)),
303+
/// Allows using `#[naked]` on functions.
304+
(accepted, naked_functions, "CURRENT_RUSTC_VERSION", Some(90957)),
303305
/// Allows specifying modifiers in the link attribute: `#[link(modifiers = "...")]`
304306
(accepted, native_link_modifiers, "1.61.0", Some(81490)),
305307
/// Allows specifying the bundle link modifier

compiler/rustc_feature/src/builtin_attrs.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,7 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
443443
ungated!(unsafe(Edition2024) no_mangle, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::No),
444444
ungated!(used, Normal, template!(Word, List: "compiler|linker"), WarnFollowing, EncodeCrossCrate::No),
445445
ungated!(link_ordinal, Normal, template!(List: "ordinal"), ErrorPreceding, EncodeCrossCrate::Yes),
446+
ungated!(unsafe naked, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::No),
446447

447448
// Limits:
448449
ungated!(
@@ -515,12 +516,6 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
515516
// Unstable attributes:
516517
// ==========================================================================
517518

518-
// Linking:
519-
gated!(
520-
unsafe naked, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::No,
521-
naked_functions, experimental!(naked)
522-
),
523-
524519
// Testing:
525520
gated!(
526521
test_runner, CrateLevel, template!(List: "path"), ErrorFollowing,

compiler/rustc_feature/src/unstable.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,8 +563,6 @@ declare_features! (
563563
(unstable, must_not_suspend, "1.57.0", Some(83310)),
564564
/// Allows `mut ref` and `mut ref mut` identifier patterns.
565565
(incomplete, mut_ref, "1.79.0", Some(123076)),
566-
/// Allows using `#[naked]` on functions.
567-
(unstable, naked_functions, "1.9.0", Some(90957)),
568566
/// Allows using `#[naked]` on `extern "Rust"` functions.
569567
(unstable, naked_functions_rustic_abi, "CURRENT_RUSTC_VERSION", Some(138997)),
570568
/// Allows using `#[target_feature(enable = "...")]` on `#[naked]` on functions.

compiler/rustc_passes/src/check_attr.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -690,13 +690,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
690690
}
691691
}
692692
}
693-
// FIXME(#80564): We permit struct fields, match arms and macro defs to have an
694-
// `#[naked]` attribute with just a lint, because we previously
695-
// erroneously allowed it and some crates used it accidentally, to be compatible
696-
// with crates depending on them, we can't throw an error here.
697-
Target::Field | Target::Arm | Target::MacroDef => {
698-
self.inline_attr_str_error_with_macro_def(hir_id, attr, "naked")
699-
}
700693
_ => {
701694
self.dcx().emit_err(errors::AttrShouldBeAppliedToFn {
702695
attr_span: attr.span(),

library/core/src/arch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub macro asm("assembly template", $(operands,)* $(options($(option),*))?) {
3232
///
3333
/// [Rust By Example]: https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html
3434
/// [reference]: https://doc.rust-lang.org/nightly/reference/inline-assembly.html
35-
#[unstable(feature = "naked_functions", issue = "90957")]
35+
#[stable(feature = "naked_functions", since = "CURRENT_RUSTC_VERSION")]
3636
#[rustc_builtin_macro]
3737
pub macro naked_asm("assembly template", $(operands,)* $(options($(option),*))?) {
3838
/* compiler built-in */

src/doc/unstable-book/src/compiler-flags/sanitizer.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,6 @@ See the [Clang ControlFlowIntegrity documentation][clang-cfi] for more details.
245245
## Example 1: Redirecting control flow using an indirect branch/call to an invalid destination
246246
247247
```rust,ignore (making doc tests pass cross-platform is hard)
248-
#![feature(naked_functions)]
249-
250248
use std::arch::naked_asm;
251249
use std::mem;
252250

tests/assembly/naked-functions/aarch64-naked-fn-no-bti-prolog.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//@ only-aarch64
55

66
#![crate_type = "lib"]
7-
#![feature(naked_functions)]
7+
88
use std::arch::naked_asm;
99

1010
// The problem at hand: Rust has adopted a fairly strict meaning for "naked functions",

tests/assembly/naked-functions/aix.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//@[aix] needs-llvm-components: powerpc
1010

1111
#![crate_type = "lib"]
12-
#![feature(no_core, naked_functions, asm_experimental_arch, f128, linkage, fn_align)]
12+
#![feature(no_core, asm_experimental_arch, f128, linkage, fn_align)]
1313
#![no_core]
1414

1515
// tests that naked functions work for the `powerpc64-ibm-aix` target.

0 commit comments

Comments
 (0)