This site is being rebuilt and some pages are out of date. For current details, write to [email protected]. This notice goes away when the rebuild is done.

No analytics unless you allow it, no tracking. This site keeps in your browser the language you pick, the theme, its colour, which site you chose, the currency on the pricing page and that you closed this notice; signing in adds session cookies. The legal page has the details.

Sign in

Radar · Rust · Archive · Week 28 · Jul 7 – 13, 2025

Stabilizing naked functions

Worth knowinglanguage

What changed
The Rust team has stabilized the #[naked] attribute, allowing functions to be written without a prologue or epilogue.
Production impact
The source does not say.
Try it
Add #[naked] to a function and compile with rustc --edition=2021.
Source
blog.rust-lang.org/2025/07/03/stabilizing-naked-functions/

Understand it, then run it

Run it now

Todayrust
// This program demonstrates a stable naked function in Rust 1.98.1 (edition 2024).
// It prints the result of adding two numbers using hand‑written assembly.

#![allow(dead_code)]

#[unsafe(naked)]
pub extern "sysv64" fn add(a: u64, b: u64) -> u64 {
    // The assembly loads the arguments from the SysV registers rdi and rsi,
    // adds them, and returns the result in rax.
    core::arch::naked_asm!(
        "lea rax, [rdi + rsi]",
        "ret"
    );
}

fn main() {
    // Call the naked function like any other Rust function.
    let result = unsafe { add(10, 32) };
    println!("10 + 32 = {}", result);
}

What it printed when we ran it on Rust 1.98.1 (edition 2024)

10 + 32 = 42

Run sends this program (for Solidity, the contract and its tests) to our own sandbox, where it is compiled and run once, with no network, and what it printed or the test report comes back here. Nothing is kept. Runs are counted per visitor for the day so everyone gets a turn; the details are on the legal page.

Written by gpt-oss-20b from the linked source · claims checked against the sources · archive, not individually reviewed