Closed
Description
In 2024, rustdoc seems to fail to parse a rust code line that starts with ##
.
//! Test
//!
//! ```
//! ##[allow(dead_code)]
//! println!("hello world");
//! ```
In 2021, this renders in a weird way where it strips the first #
, but doesn't actually hide the line. I would expect the line to be hidden. I don't know if that is intentional.

In 2024, cargo doc
generates a warning:
arning: could not parse code block as Rust code
--> src/lib.rs:3:5
|
3 | //! ```
| _____^
4 | | //! ##[allow(dead_code)]
5 | | //! println!("hello world");
6 | | //! ```
| |_______^
|
= note: error from rustc: reserved multi-hash token is forbidden
= note: `#[warn(rustdoc::invalid_rust_codeblocks)]` on by default
help: mark blocks that do not contain Rust code as text
|
3 | //! ```text
| ++++
I'm not sure what I expect here. I assume it is conflicting with the reserved syntax of 2024.
Is the ##
form really intended to be supported as a way to hide a line? cc @GuillaumeGomez
Meta
rustc --version --verbose
:
rustc 1.86.0-nightly (92bedea1c 2025-02-11)
binary: rustc
commit-hash: 92bedea1c51e3a969d60972be854506ffd8c5cb6
commit-date: 2025-02-11
host: aarch64-apple-darwin
release: 1.86.0-nightly
LLVM version: 19.1.7