rustfmt icon indicating copy to clipboard operation
rustfmt copied to clipboard

`wrap_comments` sometimes breaks code blocks in lists

Open wackbyte opened this issue 1 year ago • 2 comments

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.

wackbyte avatar Apr 11 '23 13:04 wackbyte