2021-09-06 10:44:19 -05:00
|
|
|
//@ revisions: x86_64 aarch64
|
2022-03-19 10:50:24 -05:00
|
|
|
//@ needs-asm-support
|
2021-09-06 10:44:19 -05:00
|
|
|
//@[x86_64] only-x86_64
|
|
|
|
//@[aarch64] only-aarch64
|
2021-08-03 10:19:35 -05:00
|
|
|
#![deny(unused)]
|
|
|
|
#![feature(naked_functions)]
|
|
|
|
#![crate_type = "lib"]
|
|
|
|
|
|
|
|
pub trait Trait {
|
2021-09-06 10:44:19 -05:00
|
|
|
extern "C" fn trait_associated(a: usize, b: usize) -> usize;
|
|
|
|
extern "C" fn trait_method(&self, a: usize, b: usize) -> usize;
|
2021-08-03 10:19:35 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
pub mod normal {
|
2021-12-09 18:15:33 -06:00
|
|
|
use std::arch::asm;
|
|
|
|
|
2021-09-06 10:44:19 -05:00
|
|
|
pub extern "C" fn function(a: usize, b: usize) -> usize {
|
2021-08-03 10:19:35 -05:00
|
|
|
//~^ ERROR unused variable: `a`
|
|
|
|
//~| ERROR unused variable: `b`
|
2024-08-04 09:45:48 -05:00
|
|
|
unsafe {
|
|
|
|
asm!("", options(noreturn));
|
|
|
|
}
|
2021-08-03 10:19:35 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
pub struct Normal;
|
|
|
|
|
|
|
|
impl Normal {
|
2021-09-06 10:44:19 -05:00
|
|
|
pub extern "C" fn associated(a: usize, b: usize) -> usize {
|
2021-08-03 10:19:35 -05:00
|
|
|
//~^ ERROR unused variable: `a`
|
|
|
|
//~| ERROR unused variable: `b`
|
2024-08-04 09:45:48 -05:00
|
|
|
unsafe {
|
|
|
|
asm!("", options(noreturn));
|
|
|
|
}
|
2021-08-03 10:19:35 -05:00
|
|
|
}
|
|
|
|
|
2021-09-06 10:44:19 -05:00
|
|
|
pub extern "C" fn method(&self, a: usize, b: usize) -> usize {
|
2021-08-03 10:19:35 -05:00
|
|
|
//~^ ERROR unused variable: `a`
|
|
|
|
//~| ERROR unused variable: `b`
|
2024-08-04 09:45:48 -05:00
|
|
|
unsafe {
|
|
|
|
asm!("", options(noreturn));
|
|
|
|
}
|
2021-08-03 10:19:35 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl super::Trait for Normal {
|
2021-09-06 10:44:19 -05:00
|
|
|
extern "C" fn trait_associated(a: usize, b: usize) -> usize {
|
2021-08-03 10:19:35 -05:00
|
|
|
//~^ ERROR unused variable: `a`
|
|
|
|
//~| ERROR unused variable: `b`
|
2024-08-04 09:45:48 -05:00
|
|
|
unsafe {
|
|
|
|
asm!("", options(noreturn));
|
|
|
|
}
|
2021-08-03 10:19:35 -05:00
|
|
|
}
|
|
|
|
|
2021-09-06 10:44:19 -05:00
|
|
|
extern "C" fn trait_method(&self, a: usize, b: usize) -> usize {
|
2021-08-03 10:19:35 -05:00
|
|
|
//~^ ERROR unused variable: `a`
|
|
|
|
//~| ERROR unused variable: `b`
|
2024-08-04 09:45:48 -05:00
|
|
|
unsafe {
|
|
|
|
asm!("", options(noreturn));
|
|
|
|
}
|
2021-08-03 10:19:35 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub mod naked {
|
2024-08-04 09:45:48 -05:00
|
|
|
use std::arch::naked_asm;
|
2021-12-09 18:15:33 -06:00
|
|
|
|
2021-08-03 10:19:35 -05:00
|
|
|
#[naked]
|
2021-09-06 10:44:19 -05:00
|
|
|
pub extern "C" fn function(a: usize, b: usize) -> usize {
|
2024-08-04 09:45:48 -05:00
|
|
|
unsafe {
|
2024-09-05 06:45:26 -05:00
|
|
|
naked_asm!("");
|
2024-08-04 09:45:48 -05:00
|
|
|
}
|
2021-08-03 10:19:35 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
pub struct Naked;
|
|
|
|
|
|
|
|
impl Naked {
|
|
|
|
#[naked]
|
2021-09-06 10:44:19 -05:00
|
|
|
pub extern "C" fn associated(a: usize, b: usize) -> usize {
|
2024-08-04 09:45:48 -05:00
|
|
|
unsafe {
|
2024-09-05 06:45:26 -05:00
|
|
|
naked_asm!("");
|
2024-08-04 09:45:48 -05:00
|
|
|
}
|
2021-08-03 10:19:35 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[naked]
|
2021-09-06 10:44:19 -05:00
|
|
|
pub extern "C" fn method(&self, a: usize, b: usize) -> usize {
|
2024-08-04 09:45:48 -05:00
|
|
|
unsafe {
|
2024-09-05 06:45:26 -05:00
|
|
|
naked_asm!("");
|
2024-08-04 09:45:48 -05:00
|
|
|
}
|
2021-08-03 10:19:35 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl super::Trait for Naked {
|
|
|
|
#[naked]
|
2021-09-06 10:44:19 -05:00
|
|
|
extern "C" fn trait_associated(a: usize, b: usize) -> usize {
|
2024-08-04 09:45:48 -05:00
|
|
|
unsafe {
|
2024-09-05 06:45:26 -05:00
|
|
|
naked_asm!("");
|
2024-08-04 09:45:48 -05:00
|
|
|
}
|
2021-08-03 10:19:35 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[naked]
|
2021-09-06 10:44:19 -05:00
|
|
|
extern "C" fn trait_method(&self, a: usize, b: usize) -> usize {
|
2024-08-04 09:45:48 -05:00
|
|
|
unsafe {
|
2024-09-05 06:45:26 -05:00
|
|
|
naked_asm!("");
|
2024-08-04 09:45:48 -05:00
|
|
|
}
|
2021-08-03 10:19:35 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|