Open
Description
Edit (simplified):
Output of rustfmt on nightly-2024-03-08:
fn main() {
app.with_state()
.layer(xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(
|foo: &Xxxxxxxxx| macroxxxx!(??xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx),
));
}
Expected:
fn main() {
app.with_state()
.layer(xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(|foo: &Xxxxxxxxx| {
macroxxxx!(??xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)
}));
}
original report
This code:
fn main() {
let app = app
.with_state(build_schema().await)
.layer(TraceLayer::new_for_http().make_span_with(
|req: &Request<_>| info_span!("req", method=?req.method(), path=req.uri().to_string()),
));
}
formats to:
❮ rustfmt +nightly-2024-03-08 b.rs --emit stdout
/tmp/ktmp/SgB/b.rs:
fn main() {
let app =
app.with_state(build_schema().await)
.layer(TraceLayer::new_for_http().make_span_with(
|req: &Request<_>| info_span!("req", method=?req.method(), path=req.uri().to_string()),
));
}
I think leaving the original code is fine. Or maybe It's ideal to indent the argument one more block like this:
fn main() {
let app =
app.with_state(build_schema().await)
.layer(TraceLayer::new_for_http().make_span_with(
|req: &Request<_>| info_span!("req", method=?req.method(), path=req.uri().to_string()),
));
}
because rustfmt emits like so if the argument was normal function call. For example:
❯ rustfmt +nightly-2024-03-08 a.rs --emit stdout
/tmp/ktmp/SgB/a.rs:
fn main() {
let app =
app.with_state(build_schema().await)
.layer(TraceLayer::new_for_http().make_span_with(
sooooooooooooooooooooooooooooooooooooooo_long_function_call_here(foo, bar, baz),
));
}