the noreturn
option in asm!
is poorly named, making it very confusing that the correct way to write a #[naked]
function is:
#[naked]
pub unsafe extern "C" fn my_fn() {
asm!("ret", options(noreturn));
}
where the asm!
block has to be marked noreturn
because it returns from the function.
I suggest deprecating noreturn
and naming the new replacement option diverges
or diverging
:
#[naked]
pub unsafe extern "C" fn my_fn() {
asm!("ret", options(diverges));
}
This was originally suggested on Zulip by @digama0 afaict: rust-lang