diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:18:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:18:58 +0000 |
commit | a4b7ed7a42c716ab9f05e351f003d589124fd55d (patch) | |
tree | b620cd3f223850b28716e474e80c58059dca5dd4 /tests/ui/asm/naked-functions-unused.rs | |
parent | Adding upstream version 1.67.1+dfsg1. (diff) | |
download | rustc-a4b7ed7a42c716ab9f05e351f003d589124fd55d.tar.xz rustc-a4b7ed7a42c716ab9f05e351f003d589124fd55d.zip |
Adding upstream version 1.68.2+dfsg1.upstream/1.68.2+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/asm/naked-functions-unused.rs')
-rw-r--r-- | tests/ui/asm/naked-functions-unused.rs | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/tests/ui/asm/naked-functions-unused.rs b/tests/ui/asm/naked-functions-unused.rs new file mode 100644 index 000000000..044a0e5b9 --- /dev/null +++ b/tests/ui/asm/naked-functions-unused.rs @@ -0,0 +1,87 @@ +// revisions: x86_64 aarch64 +// needs-asm-support +//[x86_64] only-x86_64 +//[aarch64] only-aarch64 +#![deny(unused)] +#![feature(naked_functions)] +#![crate_type = "lib"] + +pub trait Trait { + extern "C" fn trait_associated(a: usize, b: usize) -> usize; + extern "C" fn trait_method(&self, a: usize, b: usize) -> usize; +} + +pub mod normal { + use std::arch::asm; + + pub extern "C" fn function(a: usize, b: usize) -> usize { + //~^ ERROR unused variable: `a` + //~| ERROR unused variable: `b` + unsafe { asm!("", options(noreturn)); } + } + + pub struct Normal; + + impl Normal { + pub extern "C" fn associated(a: usize, b: usize) -> usize { + //~^ ERROR unused variable: `a` + //~| ERROR unused variable: `b` + unsafe { asm!("", options(noreturn)); } + } + + pub extern "C" fn method(&self, a: usize, b: usize) -> usize { + //~^ ERROR unused variable: `a` + //~| ERROR unused variable: `b` + unsafe { asm!("", options(noreturn)); } + } + } + + impl super::Trait for Normal { + extern "C" fn trait_associated(a: usize, b: usize) -> usize { + //~^ ERROR unused variable: `a` + //~| ERROR unused variable: `b` + unsafe { asm!("", options(noreturn)); } + } + + extern "C" fn trait_method(&self, a: usize, b: usize) -> usize { + //~^ ERROR unused variable: `a` + //~| ERROR unused variable: `b` + unsafe { asm!("", options(noreturn)); } + } + } +} + +pub mod naked { + use std::arch::asm; + + #[naked] + pub extern "C" fn function(a: usize, b: usize) -> usize { + unsafe { asm!("", options(noreturn)); } + } + + pub struct Naked; + + impl Naked { + #[naked] + pub extern "C" fn associated(a: usize, b: usize) -> usize { + unsafe { asm!("", options(noreturn)); } + } + + #[naked] + pub extern "C" fn method(&self, a: usize, b: usize) -> usize { + unsafe { asm!("", options(noreturn)); } + } + } + + impl super::Trait for Naked { + #[naked] + extern "C" fn trait_associated(a: usize, b: usize) -> usize { + unsafe { asm!("", options(noreturn)); } + } + + #[naked] + extern "C" fn trait_method(&self, a: usize, b: usize) -> usize { + unsafe { asm!("", options(noreturn)); } + } + } +} |