noir-lang / noir

Noir is a domain specific language for zero knowledge proofs
https://noir-lang.org
Apache License 2.0
890 stars 199 forks source link

Don't fmt `unsafe` blocks to span multiple lines. #6459

Open iAmMichaelConnor opened 1 week ago

iAmMichaelConnor commented 1 week ago

Problem

A subjective one for you.

Say you have this code:

let a = my_unconstrained_fn();

And then the compiler warns you to wrap it in an unsafe block:

let a = unsafe { my_unconstrained_fn() };

This is nice and still on one line.

But then the formatter spills it over 3 lines, and I can understand why, but I feel like it hurts readability when these unsafe blocks span lines when they don't need to.

let a = unsafe {
    my_unconstrained_fn()
};
asterite commented 1 day ago

I think this is already working as expected. At least this code:

fn main() {
    let a = unsafe { my_unconstrained_fn() };
}

remains formatted as is.