Skip to content

Commit ae2fa18

Browse files
committed
stabilize naked_functions
1 parent 6afee11 commit ae2fa18

Some content is hidden

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

43 files changed

+150
-279
lines changed

Diff for: compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs

+1-10
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

Diff for: compiler/rustc_error_codes/src/error_codes/E0787.md

-2
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
#[naked]
97
pub extern "C" fn f() -> u32 {
108
42

Diff for: compiler/rustc_feature/src/accepted.rs

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

Diff for: compiler/rustc_feature/src/builtin_attrs.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
432432
ungated!(unsafe no_mangle, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::No),
433433
ungated!(used, Normal, template!(Word, List: "compiler|linker"), WarnFollowing, EncodeCrossCrate::No),
434434
ungated!(link_ordinal, Normal, template!(List: "ordinal"), ErrorPreceding, EncodeCrossCrate::Yes),
435+
ungated!(naked, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::No),
435436

436437
// Limits:
437438
ungated!(
@@ -506,12 +507,6 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
506507
// Unstable attributes:
507508
// ==========================================================================
508509

509-
// Linking:
510-
gated!(
511-
naked, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::No,
512-
naked_functions, experimental!(naked)
513-
),
514-
515510
// Testing:
516511
gated!(
517512
test_runner, CrateLevel, template!(List: "path"), ErrorFollowing,

Diff for: compiler/rustc_feature/src/unstable.rs

-2
Original file line numberDiff line numberDiff line change
@@ -554,8 +554,6 @@ declare_features! (
554554
(unstable, must_not_suspend, "1.57.0", Some(83310)),
555555
/// Allows `mut ref` and `mut ref mut` identifier patterns.
556556
(incomplete, mut_ref, "1.79.0", Some(123076)),
557-
/// Allows using `#[naked]` on functions.
558-
(unstable, naked_functions, "1.9.0", Some(90957)),
559557
/// Allows specifying the as-needed link modifier
560558
(unstable, native_link_modifiers_as_needed, "1.53.0", Some(81490)),
561559
/// Allow negative trait implementations.

Diff for: compiler/rustc_lint_defs/src/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2923,7 +2923,7 @@ declare_lint! {
29232923
/// ### Example
29242924
///
29252925
/// ```rust
2926-
/// #![feature(asm_experimental_arch, naked_functions)]
2926+
/// #![feature(asm_experimental_arch)]
29272927
///
29282928
/// use std::arch::naked_asm;
29292929
///

Diff for: library/core/src/arch.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub macro asm("assembly template", $(operands,)* $(options($(option),*))?) {
2424
///
2525
/// [Rust By Example]: https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html
2626
/// [reference]: https://doc.rust-lang.org/nightly/reference/inline-assembly.html
27-
#[unstable(feature = "naked_functions", issue = "90957")]
27+
#[stable(feature = "naked_functions", since = "CURRENT_RUSTC_VERSION")]
2828
#[rustc_builtin_macro]
2929
pub macro naked_asm("assembly template", $(operands,)* $(options($(option),*))?) {
3030
/* compiler built-in */

Diff for: src/doc/unstable-book/src/compiler-flags/sanitizer.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,7 @@ 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-
250-
use std::arch::asm;
248+
use std::arch::naked_asm;
251249
use std::mem;
252250

253251
fn add_one(x: i32) -> i32 {
@@ -258,7 +256,7 @@ fn add_one(x: i32) -> i32 {
258256
pub extern "C" fn add_two(x: i32) {
259257
// x + 2 preceded by a landing pad/nop block
260258
unsafe {
261-
asm!(
259+
naked_asm!(
262260
"
263261
nop
264262
nop

Diff for: src/tools/rust-analyzer/crates/hir-expand/src/inert_attr_macro.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
195195
ungated!(no_mangle, Normal, template!(Word), WarnFollowing, @only_local: true),
196196
ungated!(used, Normal, template!(Word, List: "compiler|linker"), WarnFollowing, @only_local: true),
197197
ungated!(link_ordinal, Normal, template!(List: "ordinal"), ErrorPreceding),
198+
ungated!(naked, Normal, template!(Word), WarnFollowing, @only_local: true),
198199

199200
// Limits:
200201
ungated!(recursion_limit, CrateLevel, template!(NameValueStr: "N"), FutureWarnFollowing),
@@ -253,12 +254,6 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
253254
// Unstable attributes:
254255
// ==========================================================================
255256

256-
// Linking:
257-
gated!(
258-
naked, Normal, template!(Word), WarnFollowing, @only_local: true,
259-
naked_functions, experimental!(naked)
260-
),
261-
262257
// Testing:
263258
gated!(
264259
test_runner, CrateLevel, template!(List: "path"), ErrorFollowing, custom_test_frameworks,

Diff for: tests/assembly/aarch64-naked-fn-no-bti-prolog.rs

+1-1
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",

Diff for: tests/assembly/x86_64-naked-fn-no-cet-prolog.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//@ only-x86_64
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",

Diff for: tests/codegen/cffi/c-variadic-naked.rs

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
#![crate_type = "lib"]
77
#![feature(c_variadic)]
8-
#![feature(naked_functions)]
98
#![no_std]
109

1110
#[naked]

Diff for: tests/codegen/naked-asan.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#![crate_type = "lib"]
88
#![no_std]
9-
#![feature(abi_x86_interrupt, naked_functions)]
9+
#![feature(abi_x86_interrupt)]
1010

1111
pub fn caller() {
1212
page_fault_handler(1, 2);

Diff for: tests/codegen/naked-fn/aligned.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//@ ignore-arm no "ret" mnemonic
44

55
#![crate_type = "lib"]
6-
#![feature(naked_functions, fn_align)]
6+
#![feature(fn_align)]
77
use std::arch::naked_asm;
88

99
// CHECK: .balign 16

Diff for: tests/codegen/naked-fn/generics.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
//@ only-x86_64
33

44
#![crate_type = "lib"]
5-
#![feature(naked_functions, asm_const)]
65

76
use std::arch::naked_asm;
87

Diff for: tests/codegen/naked-fn/instruction-set.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//@ [thumb-mode] needs-llvm-components: arm
66

77
#![crate_type = "lib"]
8-
#![feature(no_core, lang_items, rustc_attrs, naked_functions)]
8+
#![feature(no_core, lang_items, rustc_attrs)]
99
#![no_core]
1010

1111
#[rustc_builtin_macro]

Diff for: tests/codegen/naked-fn/naked-functions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//@[thumb] needs-llvm-components: arm
1111

1212
#![crate_type = "lib"]
13-
#![feature(no_core, lang_items, rustc_attrs, naked_functions)]
13+
#![feature(no_core, lang_items, rustc_attrs)]
1414
#![no_core]
1515

1616
#[rustc_builtin_macro]

Diff for: tests/run-make/naked-symbol-visibility/a_rust_dylib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(naked_functions, linkage)]
1+
#![feature(linkage)]
22
#![crate_type = "dylib"]
33

44
use std::arch::naked_asm;

Diff for: tests/ui/asm/naked-asm-outside-naked-fn.rs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
//@ ignore-nvptx64
44
//@ ignore-spirv
55

6-
#![feature(naked_functions)]
76
#![crate_type = "lib"]
87

98
use std::arch::naked_asm;

Diff for: tests/ui/asm/naked-asm-outside-naked-fn.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
error: the `naked_asm!` macro can only be used in functions marked with `#[naked]`
2-
--> $DIR/naked-asm-outside-naked-fn.rs:21:14
2+
--> $DIR/naked-asm-outside-naked-fn.rs:20:14
33
|
44
LL | unsafe { naked_asm!("") }
55
| ^^^^^^^^^^^^^^
66

77
error: the `naked_asm!` macro can only be used in functions marked with `#[naked]`
8-
--> $DIR/naked-asm-outside-naked-fn.rs:26:18
8+
--> $DIR/naked-asm-outside-naked-fn.rs:25:18
99
|
1010
LL | unsafe { (|| naked_asm!(""))() }
1111
| ^^^^^^^^^^^^^^
1212

1313
error: the `naked_asm!` macro can only be used in functions marked with `#[naked]`
14-
--> $DIR/naked-asm-outside-naked-fn.rs:32:19
14+
--> $DIR/naked-asm-outside-naked-fn.rs:31:19
1515
|
1616
LL | unsafe { naked_asm!("") } ;
1717
| ^^^^^^^^^^^^^^

Diff for: tests/ui/asm/naked-functions-ffi.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//@ check-pass
22
//@ needs-asm-support
3-
#![feature(naked_functions)]
43
#![crate_type = "lib"]
54

65
use std::arch::naked_asm;

Diff for: tests/ui/asm/naked-functions-ffi.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: `extern` fn uses type `char`, which is not FFI-safe
2-
--> $DIR/naked-functions-ffi.rs:9:28
2+
--> $DIR/naked-functions-ffi.rs:8:28
33
|
44
LL | pub extern "C" fn naked(p: char) -> u128 {
55
| ^^^^ not FFI-safe
@@ -9,7 +9,7 @@ LL | pub extern "C" fn naked(p: char) -> u128 {
99
= note: `#[warn(improper_ctypes_definitions)]` on by default
1010

1111
warning: `extern` fn uses type `u128`, which is not FFI-safe
12-
--> $DIR/naked-functions-ffi.rs:9:37
12+
--> $DIR/naked-functions-ffi.rs:8:37
1313
|
1414
LL | pub extern "C" fn naked(p: char) -> u128 {
1515
| ^^^^ not FFI-safe

Diff for: tests/ui/asm/naked-functions-inline.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//@ needs-asm-support
2-
#![feature(naked_functions)]
32
#![crate_type = "lib"]
43

54
use std::arch::naked_asm;

Diff for: tests/ui/asm/naked-functions-inline.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
error[E0736]: attribute incompatible with `#[naked]`
2-
--> $DIR/naked-functions-inline.rs:13:1
2+
--> $DIR/naked-functions-inline.rs:12:1
33
|
44
LL | #[naked]
55
| -------- function marked with `#[naked]` here
66
LL | #[inline]
77
| ^^^^^^^^^ the `inline` attribute is incompatible with `#[naked]`
88

99
error[E0736]: attribute incompatible with `#[naked]`
10-
--> $DIR/naked-functions-inline.rs:20:1
10+
--> $DIR/naked-functions-inline.rs:19:1
1111
|
1212
LL | #[naked]
1313
| -------- function marked with `#[naked]` here
1414
LL | #[inline(always)]
1515
| ^^^^^^^^^^^^^^^^^ the `inline` attribute is incompatible with `#[naked]`
1616

1717
error[E0736]: attribute incompatible with `#[naked]`
18-
--> $DIR/naked-functions-inline.rs:27:1
18+
--> $DIR/naked-functions-inline.rs:26:1
1919
|
2020
LL | #[naked]
2121
| -------- function marked with `#[naked]` here
2222
LL | #[inline(never)]
2323
| ^^^^^^^^^^^^^^^^ the `inline` attribute is incompatible with `#[naked]`
2424

2525
error[E0736]: attribute incompatible with `#[naked]`
26-
--> $DIR/naked-functions-inline.rs:34:19
26+
--> $DIR/naked-functions-inline.rs:33:19
2727
|
2828
LL | #[naked]
2929
| -------- function marked with `#[naked]` here

Diff for: tests/ui/asm/naked-functions-instruction-set.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//@ build-pass
66

77
#![crate_type = "lib"]
8-
#![feature(no_core, naked_functions)]
8+
#![feature(no_core)]
99
#![no_core]
1010

1111
extern crate minicore;

Diff for: tests/ui/asm/naked-functions-testattrs.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
//@ compile-flags: --test
33

44
#![allow(undefined_naked_function_abi)]
5-
#![feature(naked_functions)]
65
#![feature(test)]
76
#![crate_type = "lib"]
87

Diff for: tests/ui/asm/naked-functions-testattrs.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
error[E0736]: cannot use `#[naked]` with testing attributes
2-
--> $DIR/naked-functions-testattrs.rs:12:1
2+
--> $DIR/naked-functions-testattrs.rs:11:1
33
|
44
LL | #[test]
55
| ------- function marked with testing attribute here
66
LL | #[naked]
77
| ^^^^^^^^ `#[naked]` is incompatible with testing attributes
88

99
error[E0736]: cannot use `#[naked]` with testing attributes
10-
--> $DIR/naked-functions-testattrs.rs:20:1
10+
--> $DIR/naked-functions-testattrs.rs:19:1
1111
|
1212
LL | #[test]
1313
| ------- function marked with testing attribute here
1414
LL | #[naked]
1515
| ^^^^^^^^ `#[naked]` is incompatible with testing attributes
1616

1717
error[E0736]: cannot use `#[naked]` with testing attributes
18-
--> $DIR/naked-functions-testattrs.rs:28:1
18+
--> $DIR/naked-functions-testattrs.rs:27:1
1919
|
2020
LL | #[test]
2121
| ------- function marked with testing attribute here
2222
LL | #[naked]
2323
| ^^^^^^^^ `#[naked]` is incompatible with testing attributes
2424

2525
error[E0736]: cannot use `#[naked]` with testing attributes
26-
--> $DIR/naked-functions-testattrs.rs:35:1
26+
--> $DIR/naked-functions-testattrs.rs:34:1
2727
|
2828
LL | #[bench]
2929
| -------- function marked with testing attribute here

0 commit comments

Comments
 (0)