Skip to content

wrap_comments sometimes breaks code blocks in lists #5746

Open
@wackbyte

Description

@wackbyte

With rustfmt 1.5.2-nightly (88fb1b92 2023-04-10):

Input code

Snippet from some internal documentation I'm writing:

//! - References?
//!   - Unsound. See this example:
//!     ```compile_fail
//!     # use core::mem::MaybeUninit;
//!     let mut a = 0;
//!     let b = maybe_uninit_ext::new::<&mut MaybeUninit<u8>>(&mut a);
//!     *b = maybe_uninit_ext::uninit();
//!     assert_eq!(a, 0); // undefined behavior! a is uninitialized.
//!     ```
//!     Due to interior mutability, this is an issue for immutable references
//!     as well.

Actual result

//! - References?
//!   - Unsound. See this example: ```compile_fail # use core::mem::MaybeUninit;
//!     let mut a = 0; let b = maybe_uninit_ext::new::<&mut
//!     MaybeUninit<u8>>(&mut a); *b = maybe_uninit_ext::uninit(); assert_eq!(a,
//!     0); // undefined behavior! a is uninitialized. ``` Due to interior
//!     mutability, this is an issue for immutable references as well.

Expected result

The code block should be preserved.

Metadata

Metadata

Assignees

No one assigned

    Labels

    a-commentsa-markdownmarkdown formatting in doc commentsonly-with-optionrequires a non-default option value to reproducep-low

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions