Open
Description
Describe the bug
Using #[rustfmt::skip]
to prevent damage to comments doesn’t work if the comment is
inside a struct impl.
To Reproduce
#[rustfmt::skip]
/** Comment.
Rustfmt skips this as expected. */
fn main() {
for _ in 1..Foo::getRandomNumber() {
println!("Hello, world!");
}
}
struct Foo;
impl Foo {
#[rustfmt::skip]
/** Comment.
Rustfmt unindents this despite the ::skip above. */
#[allow(non_snake_case)]
pub fn getRandomNumber() -> i32 { 4 }
}
Expected behavior
The comment on getRandomNumber()
should be left alone.
Meta
- rustfmt version: 1.4.20-stable
- From where did you install rustfmt?: from the Fedora 32 repos.
- How do you run rustfmt: doesn’t matter, both
cargo fmt
andrustfmt
show the same defect.