rustfmt icon indicating copy to clipboard operation
rustfmt copied to clipboard

rustfmt deletes comment after arrow in Fn type

Open findepi opened this issue 1 year ago • 2 comments

Input:

fn foo(f: &dyn Fn(i32) -> /*result*/ i32)  {
}

after rustfmt becomes

fn foo(f: &dyn Fn(i32) -> i32) {}

Expected

Preserve /*result*/ comment

Observed

Comment deleted.

findepi avatar Feb 12 '25 14:02 findepi

Thanks for the report. This feels related to https://github.com/rust-lang/rustfmt/issues/5874

ytmimi avatar Feb 12 '25 15:02 ytmimi

Thanks for the link! I didn't find that issue because I was searching with Fn. Feel free to close as duplicate.

findepi avatar Feb 12 '25 17:02 findepi

Triage: it does feel related to #5874, though worth keeping separate since this is removing a comment in a param type decl position.

jieyouxu avatar Nov 05 '25 04:11 jieyouxu