rustfmt icon indicating copy to clipboard operation
rustfmt copied to clipboard

rustfmt eats comment after `->` in return type

Open Centri3 opened this issue 2 years ago • 3 comments

fn a() -> /* my super detailed comment on what this bool is */ bool {}

The comment is entirely eaten:

fn a() -> bool {}

Centri3 avatar Aug 02 '23 18:08 Centri3

Thank you for the report. Here's where this one is happening:

https://github.com/rust-lang/rustfmt/blob/a72613be50f8afa39c2d46f732252463dc9cc14f/src/items.rs#L2059-L2078

ytmimi avatar Aug 02 '23 18:08 ytmimi

It's also deleting it if the comment is inside the return type, as in

    fn foo() -> (/*TODO: This type needs to blahblahblah*/);

AloeareV avatar May 21 '25 18:05 AloeareV

It's also deleting it if the comment is inside the return type, as in

fn foo() -> (/*TODO: This type needs to blahblahblah*/);

@AloeareV This is off topic for this issue as the comment location you're pointing out is within a different part of the AST.

ytmimi avatar May 31 '25 15:05 ytmimi