Skip to content

format comments bug: comment merges with the next line even if it's a code block opener #6675

@msrd0

Description

@msrd0

I just ran rustfmt on bytemuck (da748163ea203f80098b6bdc754c54ebc535364c) and then this happened:

diff --git a/src/transparent.rs b/src/transparent.rs
index a588eea..de099db 100644
--- a/src/transparent.rs
+++ b/src/transparent.rs
@@ -103,9 +103,9 @@ use super::*;
 /// #[derive(TransparentWrapper)]
 /// #[repr(transparent)]
 /// #[transparent(usize)]
-/// struct Wrapper<T: ?Sized>(usize, PhantomData<T>); // PhantomData<T> implements Zeroable for all T
-/// ```
-///
+/// struct Wrapper<T: ?Sized>(usize, PhantomData<T>); // PhantomData<T>
+/// implements Zeroable for all T ```
+///
 /// Here, an error will occur, because `MyZst` does not implement `Zeroable`.
 #[cfg_attr(feature = "derive", doc = "```compile_fail")]
 #[cfg_attr(

This feels like #4158 except that issue was fixed in 2020 and my rustfmt is newer:

$ cargo +nightly fmt -- -V
rustfmt 1.8.0-nightly (54a8a1db60 2025-09-26)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-commentsArea: commentsC-bugCategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICES-fixed-needs-subtree-syncStatus: fixed, but needs a subtree sync

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions