Skip to content

Commit

Permalink
use naked_asm! in feature-gate-naked_functions test
Browse files Browse the repository at this point in the history
  • Loading branch information
folkertdev committed Aug 4, 2024
1 parent 89d804b commit bfa880f
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 12 deletions.
9 changes: 6 additions & 3 deletions tests/ui/feature-gates/feature-gate-naked_functions.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
//@ needs-asm-support

use std::arch::asm;
use std::arch::naked_asm;
//~^ ERROR use of unstable library feature 'naked_functions'

#[naked]
//~^ the `#[naked]` attribute is an experimental feature
extern "C" fn naked() {
naked_asm!("", options(noreturn))
//~^ ERROR: requires unsafe
//~^ ERROR use of unstable library feature 'naked_functions'
//~| ERROR: requires unsafe
}

#[naked]
//~^ the `#[naked]` attribute is an experimental feature
extern "C" fn naked_2() -> isize {
naked_asm!("", options(noreturn))
//~^ ERROR: requires unsafe
//~^ ERROR use of unstable library feature 'naked_functions'
//~| ERROR: requires unsafe
}

fn main() {}
48 changes: 39 additions & 9 deletions tests/ui/feature-gates/feature-gate-naked_functions.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
error[E0658]: use of unstable library feature 'naked_functions'
--> $DIR/feature-gate-naked_functions.rs:9:5
|
LL | naked_asm!("", options(noreturn))
| ^^^^^^^^^
|
= note: see issue #90957 <https://github.com/rust-lang/rust/issues/90957> for more information
= help: add `#![feature(naked_functions)]` 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[E0658]: use of unstable library feature 'naked_functions'
--> $DIR/feature-gate-naked_functions.rs:17:5
|
LL | naked_asm!("", options(noreturn))
| ^^^^^^^^^
|
= note: see issue #90957 <https://github.com/rust-lang/rust/issues/90957> for more information
= help: add `#![feature(naked_functions)]` 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[E0658]: the `#[naked]` attribute is an experimental feature
--> $DIR/feature-gate-naked_functions.rs:5:1
--> $DIR/feature-gate-naked_functions.rs:6:1
|
LL | #[naked]
| ^^^^^^^^
Expand All @@ -9,7 +29,7 @@ LL | #[naked]
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0658]: the `#[naked]` attribute is an experimental feature
--> $DIR/feature-gate-naked_functions.rs:12:1
--> $DIR/feature-gate-naked_functions.rs:14:1
|
LL | #[naked]
| ^^^^^^^^
Expand All @@ -18,23 +38,33 @@ LL | #[naked]
= help: add `#![feature(naked_functions)]` 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[E0658]: use of unstable library feature 'naked_functions'
--> $DIR/feature-gate-naked_functions.rs:3:5
|
LL | use std::arch::naked_asm;
| ^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #90957 <https://github.com/rust-lang/rust/issues/90957> for more information
= help: add `#![feature(naked_functions)]` 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[E0133]: use of inline assembly is unsafe and requires unsafe function or block
--> $DIR/feature-gate-naked_functions.rs:8:5
--> $DIR/feature-gate-naked_functions.rs:9:5
|
LL | asm!("", options(noreturn))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ use of inline assembly
LL | naked_asm!("", options(noreturn))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ use of inline assembly
|
= note: inline assembly is entirely unchecked and can cause undefined behavior

error[E0133]: use of inline assembly is unsafe and requires unsafe function or block
--> $DIR/feature-gate-naked_functions.rs:15:5
--> $DIR/feature-gate-naked_functions.rs:17:5
|
LL | asm!("", options(noreturn))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ use of inline assembly
LL | naked_asm!("", options(noreturn))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ use of inline assembly
|
= note: inline assembly is entirely unchecked and can cause undefined behavior

error: aborting due to 4 previous errors
error: aborting due to 7 previous errors

Some errors have detailed explanations: E0133, E0658.
For more information about an error, try `rustc --explain E0133`.

0 comments on commit bfa880f

Please sign in to comment.