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`
|
|
|
|
unsafe { asm!("", options(noreturn)); }
|
|
|
|
}
|
|
|
|
|
|
|
|
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`
|
|
|
|
unsafe { asm!("", options(noreturn)); }
|
|
|
|
}
|
|
|
|
|
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`
|
|
|
|
unsafe { asm!("", options(noreturn)); }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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`
|
|
|
|
unsafe { asm!("", options(noreturn)); }
|
|
|
|
}
|
|
|
|
|
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`
|
|
|
|
unsafe { asm!("", options(noreturn)); }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub mod naked {
|
2021-12-09 18:15:33 -06:00
|
|
|
use std::arch::asm;
|
|
|
|
|
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 {
|
2021-08-03 10:19:35 -05:00
|
|
|
unsafe { asm!("", options(noreturn)); }
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct Naked;
|
|
|
|
|
|
|
|
impl Naked {
|
|
|
|
#[naked]
|
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
|
|
|
unsafe { asm!("", options(noreturn)); }
|
|
|
|
}
|
|
|
|
|
|
|
|
#[naked]
|
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
|
|
|
unsafe { asm!("", options(noreturn)); }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl super::Trait for Naked {
|
|
|
|
#[naked]
|
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
|
|
|
unsafe { asm!("", options(noreturn)); }
|
|
|
|
}
|
|
|
|
|
|
|
|
#[naked]
|
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
|
|
|
unsafe { asm!("", options(noreturn)); }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|