Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stabilize naked_functions #134213

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
#![feature(
no_core,
lang_items,
never_type,
linkage,
extern_types,
naked_functions,
thread_local,
repr_simd
)]
#![feature(no_core, lang_items, never_type, linkage, extern_types, thread_local, repr_simd)]
#![no_core]
#![allow(dead_code, non_camel_case_types, internal_features)]

2 changes: 0 additions & 2 deletions compiler/rustc_error_codes/src/error_codes/E0787.md
Original file line number Diff line number Diff line change
@@ -3,8 +3,6 @@ An unsupported naked function definition.
Erroneous code example:

```compile_fail,E0787
#![feature(naked_functions)]

#[naked]
pub extern "C" fn f() -> u32 {
42
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/accepted.rs
Original file line number Diff line number Diff line change
@@ -298,6 +298,8 @@ declare_features! (
/// Allows patterns with concurrent by-move and by-ref bindings.
/// For example, you can write `Foo(a, ref b)` where `a` is by-move and `b` is by-ref.
(accepted, move_ref_pattern, "1.49.0", Some(68354)),
/// Allows using `#[naked]` on functions.
(accepted, naked_functions, "CURRENT_RUSTC_VERSION", Some(90957)),
/// Allows specifying modifiers in the link attribute: `#[link(modifiers = "...")]`
(accepted, native_link_modifiers, "1.61.0", Some(81490)),
/// Allows specifying the bundle link modifier
7 changes: 1 addition & 6 deletions compiler/rustc_feature/src/builtin_attrs.rs
Original file line number Diff line number Diff line change
@@ -428,6 +428,7 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
ungated!(unsafe no_mangle, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::No),
ungated!(used, Normal, template!(Word, List: "compiler|linker"), WarnFollowing, EncodeCrossCrate::No),
ungated!(link_ordinal, Normal, template!(List: "ordinal"), ErrorPreceding, EncodeCrossCrate::Yes),
ungated!(naked, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::No),

// Limits:
ungated!(
@@ -500,12 +501,6 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
// Unstable attributes:
// ==========================================================================

// Linking:
gated!(
naked, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::No,
naked_functions, experimental!(naked)
),

// Testing:
gated!(
test_runner, CrateLevel, template!(List: "path"), ErrorFollowing,
2 changes: 0 additions & 2 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
@@ -564,8 +564,6 @@ declare_features! (
(unstable, must_not_suspend, "1.57.0", Some(83310)),
/// Allows `mut ref` and `mut ref mut` identifier patterns.
(incomplete, mut_ref, "1.79.0", Some(123076)),
/// Allows using `#[naked]` on functions.
(unstable, naked_functions, "1.9.0", Some(90957)),
/// Allows using `#[target_feature(enable = "...")]` on `#[naked]` on functions.
(unstable, naked_functions_target_feature, "1.86.0", Some(138568)),
/// Allows specifying the as-needed link modifier
2 changes: 1 addition & 1 deletion compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
@@ -2836,7 +2836,7 @@ declare_lint! {
/// ### Example
///
/// ```rust
/// #![feature(asm_experimental_arch, naked_functions)]
/// #![feature(asm_experimental_arch)]
///
/// use std::arch::naked_asm;
///
2 changes: 1 addition & 1 deletion library/core/src/arch.rs
Original file line number Diff line number Diff line change
@@ -32,7 +32,7 @@ pub macro asm("assembly template", $(operands,)* $(options($(option),*))?) {
///
/// [Rust By Example]: https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html
/// [reference]: https://doc.rust-lang.org/nightly/reference/inline-assembly.html
#[unstable(feature = "naked_functions", issue = "90957")]
#[stable(feature = "naked_functions", since = "CURRENT_RUSTC_VERSION")]
#[rustc_builtin_macro]
pub macro naked_asm("assembly template", $(operands,)* $(options($(option),*))?) {
/* compiler built-in */
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
//@ only-aarch64

#![crate_type = "lib"]
#![feature(naked_functions)]

use std::arch::naked_asm;

// The problem at hand: Rust has adopted a fairly strict meaning for "naked functions",
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
//@ only-x86_64

#![crate_type = "lib"]
#![feature(naked_functions)]

use std::arch::naked_asm;

// The problem at hand: Rust has adopted a fairly strict meaning for "naked functions",
1 change: 0 additions & 1 deletion tests/codegen/cffi/c-variadic-naked.rs
Original file line number Diff line number Diff line change
@@ -5,7 +5,6 @@

#![crate_type = "lib"]
#![feature(c_variadic)]
#![feature(naked_functions)]
#![no_std]

#[naked]
2 changes: 1 addition & 1 deletion tests/codegen/naked-asan.rs
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@

#![crate_type = "lib"]
#![no_std]
#![feature(abi_x86_interrupt, naked_functions)]
#![feature(abi_x86_interrupt)]

pub fn caller() {
page_fault_handler(1, 2);
2 changes: 1 addition & 1 deletion tests/codegen/naked-fn/aligned.rs
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
//@ ignore-arm no "ret" mnemonic

#![crate_type = "lib"]
#![feature(naked_functions, fn_align)]
#![feature(fn_align)]
use std::arch::naked_asm;

// CHECK: .balign 16
1 change: 0 additions & 1 deletion tests/codegen/naked-fn/generics.rs
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@
//@ only-x86_64

#![crate_type = "lib"]
#![feature(naked_functions, asm_const)]

use std::arch::naked_asm;

2 changes: 1 addition & 1 deletion tests/codegen/naked-fn/instruction-set.rs
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
//@ [thumb-mode] needs-llvm-components: arm

#![crate_type = "lib"]
#![feature(no_core, lang_items, rustc_attrs, naked_functions)]
#![feature(no_core, lang_items, rustc_attrs)]
#![no_core]

extern crate minicore;
2 changes: 1 addition & 1 deletion tests/codegen/naked-fn/naked-functions.rs
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@
//@[thumb] needs-llvm-components: arm

#![crate_type = "lib"]
#![feature(no_core, lang_items, rustc_attrs, naked_functions)]
#![feature(no_core, lang_items, rustc_attrs)]
#![no_core]

extern crate minicore;
2 changes: 1 addition & 1 deletion tests/run-make/naked-symbol-visibility/a_rust_dylib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(naked_functions, linkage)]
#![feature(linkage)]
#![crate_type = "dylib"]

use std::arch::naked_asm;
1 change: 0 additions & 1 deletion tests/ui/asm/naked-asm-outside-naked-fn.rs
Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@
//@ ignore-nvptx64
//@ ignore-spirv

#![feature(naked_functions)]
#![crate_type = "lib"]

use std::arch::naked_asm;
6 changes: 3 additions & 3 deletions tests/ui/asm/naked-asm-outside-naked-fn.stderr
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
error: the `naked_asm!` macro can only be used in functions marked with `#[naked]`
--> $DIR/naked-asm-outside-naked-fn.rs:21:14
--> $DIR/naked-asm-outside-naked-fn.rs:20:14
|
LL | unsafe { naked_asm!("") }
| ^^^^^^^^^^^^^^

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

error: the `naked_asm!` macro can only be used in functions marked with `#[naked]`
--> $DIR/naked-asm-outside-naked-fn.rs:32:19
--> $DIR/naked-asm-outside-naked-fn.rs:31:19
|
LL | unsafe { naked_asm!("") } ;
| ^^^^^^^^^^^^^^
1 change: 0 additions & 1 deletion tests/ui/asm/naked-functions-ffi.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//@ check-pass
//@ needs-asm-support
#![feature(naked_functions)]
#![crate_type = "lib"]

use std::arch::naked_asm;
4 changes: 2 additions & 2 deletions tests/ui/asm/naked-functions-ffi.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
warning: `extern` fn uses type `char`, which is not FFI-safe
--> $DIR/naked-functions-ffi.rs:9:28
--> $DIR/naked-functions-ffi.rs:8:28
|
LL | pub extern "C" fn naked(p: char) -> u128 {
| ^^^^ not FFI-safe
@@ -9,7 +9,7 @@ LL | pub extern "C" fn naked(p: char) -> u128 {
= note: `#[warn(improper_ctypes_definitions)]` on by default

warning: `extern` fn uses type `u128`, which is not FFI-safe
--> $DIR/naked-functions-ffi.rs:9:37
--> $DIR/naked-functions-ffi.rs:8:37
|
LL | pub extern "C" fn naked(p: char) -> u128 {
| ^^^^ not FFI-safe
1 change: 0 additions & 1 deletion tests/ui/asm/naked-functions-inline.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//@ needs-asm-support
#![feature(naked_functions)]
#![crate_type = "lib"]

use std::arch::naked_asm;
8 changes: 4 additions & 4 deletions tests/ui/asm/naked-functions-inline.stderr
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
error[E0736]: attribute incompatible with `#[naked]`
--> $DIR/naked-functions-inline.rs:13:1
--> $DIR/naked-functions-inline.rs:12:1
|
LL | #[naked]
| -------- function marked with `#[naked]` here
LL | #[inline]
| ^^^^^^^^^ the `inline` attribute is incompatible with `#[naked]`

error[E0736]: attribute incompatible with `#[naked]`
--> $DIR/naked-functions-inline.rs:20:1
--> $DIR/naked-functions-inline.rs:19:1
|
LL | #[naked]
| -------- function marked with `#[naked]` here
LL | #[inline(always)]
| ^^^^^^^^^^^^^^^^^ the `inline` attribute is incompatible with `#[naked]`

error[E0736]: attribute incompatible with `#[naked]`
--> $DIR/naked-functions-inline.rs:27:1
--> $DIR/naked-functions-inline.rs:26:1
|
LL | #[naked]
| -------- function marked with `#[naked]` here
LL | #[inline(never)]
| ^^^^^^^^^^^^^^^^ the `inline` attribute is incompatible with `#[naked]`

error[E0736]: attribute incompatible with `#[naked]`
--> $DIR/naked-functions-inline.rs:34:19
--> $DIR/naked-functions-inline.rs:33:19
|
LL | #[naked]
| -------- function marked with `#[naked]` here
2 changes: 1 addition & 1 deletion tests/ui/asm/naked-functions-instruction-set.rs
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
//@ build-pass

#![crate_type = "lib"]
#![feature(no_core, naked_functions)]
#![feature(no_core)]
#![no_core]

extern crate minicore;
2 changes: 1 addition & 1 deletion tests/ui/asm/naked-functions-target-feature.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//@ build-pass
//@ needs-asm-support

#![feature(naked_functions, naked_functions_target_feature)]
#![feature(naked_functions_target_feature)]
#![crate_type = "lib"]

use std::arch::{asm, naked_asm};
1 change: 0 additions & 1 deletion tests/ui/asm/naked-functions-testattrs.rs
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@
//@ compile-flags: --test

#![allow(undefined_naked_function_abi)]
#![feature(naked_functions)]
#![feature(test)]
#![crate_type = "lib"]

8 changes: 4 additions & 4 deletions tests/ui/asm/naked-functions-testattrs.stderr
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
error[E0736]: cannot use `#[naked]` with testing attributes
--> $DIR/naked-functions-testattrs.rs:12:1
--> $DIR/naked-functions-testattrs.rs:11:1
|
LL | #[test]
| ------- function marked with testing attribute here
LL | #[naked]
| ^^^^^^^^ `#[naked]` is incompatible with testing attributes

error[E0736]: cannot use `#[naked]` with testing attributes
--> $DIR/naked-functions-testattrs.rs:20:1
--> $DIR/naked-functions-testattrs.rs:19:1
|
LL | #[test]
| ------- function marked with testing attribute here
LL | #[naked]
| ^^^^^^^^ `#[naked]` is incompatible with testing attributes

error[E0736]: cannot use `#[naked]` with testing attributes
--> $DIR/naked-functions-testattrs.rs:28:1
--> $DIR/naked-functions-testattrs.rs:27:1
|
LL | #[test]
| ------- function marked with testing attribute here
LL | #[naked]
| ^^^^^^^^ `#[naked]` is incompatible with testing attributes

error[E0736]: cannot use `#[naked]` with testing attributes
--> $DIR/naked-functions-testattrs.rs:35:1
--> $DIR/naked-functions-testattrs.rs:34:1
|
LL | #[bench]
| -------- function marked with testing attribute here
20 changes: 10 additions & 10 deletions tests/ui/asm/naked-functions-unused.aarch64.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: unused variable: `a`
--> $DIR/naked-functions-unused.rs:17:32
--> $DIR/naked-functions-unused.rs:16:32
|
LL | pub extern "C" fn function(a: usize, b: usize) -> usize {
| ^ help: if this is intentional, prefix it with an underscore: `_a`
@@ -12,55 +12,55 @@ LL | #![deny(unused)]
= note: `#[deny(unused_variables)]` implied by `#[deny(unused)]`

error: unused variable: `b`
--> $DIR/naked-functions-unused.rs:17:42
--> $DIR/naked-functions-unused.rs:16:42
|
LL | pub extern "C" fn function(a: usize, b: usize) -> usize {
| ^ help: if this is intentional, prefix it with an underscore: `_b`

error: unused variable: `a`
--> $DIR/naked-functions-unused.rs:28:38
--> $DIR/naked-functions-unused.rs:27:38
|
LL | pub extern "C" fn associated(a: usize, b: usize) -> usize {
| ^ help: if this is intentional, prefix it with an underscore: `_a`

error: unused variable: `b`
--> $DIR/naked-functions-unused.rs:28:48
--> $DIR/naked-functions-unused.rs:27:48
|
LL | pub extern "C" fn associated(a: usize, b: usize) -> usize {
| ^ help: if this is intentional, prefix it with an underscore: `_b`

error: unused variable: `a`
--> $DIR/naked-functions-unused.rs:36:41
--> $DIR/naked-functions-unused.rs:35:41
|
LL | pub extern "C" fn method(&self, a: usize, b: usize) -> usize {
| ^ help: if this is intentional, prefix it with an underscore: `_a`

error: unused variable: `b`
--> $DIR/naked-functions-unused.rs:36:51
--> $DIR/naked-functions-unused.rs:35:51
|
LL | pub extern "C" fn method(&self, a: usize, b: usize) -> usize {
| ^ help: if this is intentional, prefix it with an underscore: `_b`

error: unused variable: `a`
--> $DIR/naked-functions-unused.rs:46:40
--> $DIR/naked-functions-unused.rs:45:40
|
LL | extern "C" fn trait_associated(a: usize, b: usize) -> usize {
| ^ help: if this is intentional, prefix it with an underscore: `_a`

error: unused variable: `b`
--> $DIR/naked-functions-unused.rs:46:50
--> $DIR/naked-functions-unused.rs:45:50
|
LL | extern "C" fn trait_associated(a: usize, b: usize) -> usize {
| ^ help: if this is intentional, prefix it with an underscore: `_b`

error: unused variable: `a`
--> $DIR/naked-functions-unused.rs:54:43
--> $DIR/naked-functions-unused.rs:53:43
|
LL | extern "C" fn trait_method(&self, a: usize, b: usize) -> usize {
| ^ help: if this is intentional, prefix it with an underscore: `_a`

error: unused variable: `b`
--> $DIR/naked-functions-unused.rs:54:53
--> $DIR/naked-functions-unused.rs:53:53
|
LL | extern "C" fn trait_method(&self, a: usize, b: usize) -> usize {
| ^ help: if this is intentional, prefix it with an underscore: `_b`
1 change: 0 additions & 1 deletion tests/ui/asm/naked-functions-unused.rs
Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@
//@[x86_64] only-x86_64
//@[aarch64] only-aarch64
#![deny(unused)]
#![feature(naked_functions)]
#![crate_type = "lib"]

pub trait Trait {
Loading
Loading