Skip to main content

2026-05-04

Discoveries

Rust Things

Cheap trace in no_std:

struct ErrorInfo {
message: &'static str,
file: &'static str,
line: u32,
}

macro_rules! error_info {
($msg:expr) => {
ErrorInfo {
message: $msg,
file: file!(), // built-in macro, returns &'static str
line: line!(), // built-in macro, returns u32
}
};
}

fn something() -> Result<(), ErrorInfo> {
Err(error_info!("something went wrong"))
}