`wrap_comments` sometimes breaks code blocks in lists
Open
Nobody has claimed this yet.
A-comments
A-markdown
only-with-option
P-low
UO-wrap_comments
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the supplied nested-list example with rustfmt 1.5.2-nightly and the wrap_comments option, then trace the formatting path that handles comments and code fences in lists. Done means the nested compile_fail code block remains preserved instead of being joined into the surrounding comment text.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100