dtolnay / no-panic

Attribute macro to require that the compiler prove a function can't ever panic
Apache License 2.0
1k stars 13 forks source link

Fail Non-Panicking Code with 'extern functions couldn't be found' #51

Closed netzdoktor closed 11 months ago

netzdoktor commented 11 months ago

Similar to #50, I get errors even when compiling non-panicking code. For example, this:

#[no_panic]
fn taut(s: &str) -> &str {
    "foo"
}

fn main() {
    println!("Hello, {}!", taut("world"));
}

This fails with 'extern functions couldn't be found'. Are there any third-party requirements before one can use no_panic?

dtolnay commented 11 months ago

You would need to use opt-level = 1 or greater for that code. Setting this up is covered in https://github.com/dtolnay/no-panic/tree/0.1.26#caveats.