Skip to content

Remove weird handling of ## in code examples #118825

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion library/std/src/keyword_docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1095,7 +1095,7 @@ mod move_keyword {}
/// ```rust,compile_fail,E0502
/// let mut v = vec![0, 1];
/// let mut_ref_v = &mut v;
/// ##[allow(unused)]
/// #[allow(unused)]
/// let ref_v = &v;
/// mut_ref_v.push(2);
/// ```
Expand Down
4 changes: 1 addition & 3 deletions src/librustdoc/html/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,7 @@ impl<'a> Line<'a> {
// then reallocate to remove it; which would make us return a String.
fn map_line(s: &str) -> Line<'_> {
let trimmed = s.trim();
if trimmed.starts_with("##") {
Line::Shown(Cow::Owned(s.replacen("##", "#", 1)))
} else if let Some(stripped) = trimmed.strip_prefix("# ") {
if let Some(stripped) = trimmed.strip_prefix("# ") {
// # text
Line::Hidden(stripped)
} else if trimmed == "#" {
Expand Down
10 changes: 5 additions & 5 deletions tests/rustdoc/issue-41783.codeblock.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<code># single
## double
### triple
<span class="attr">#[outer]
#![inner]</span></code>
<code>## single
### double
#### triple
#<span class="attr">#[outer]
</span>#<span class="attr">#![inner]</span></code>
2 changes: 1 addition & 1 deletion tests/rustdoc/issue-41783.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// @hasraw - '<span class="attr">#[outer]'
// @!hasraw - '<span class="attr">#[outer]</span>'
// @hasraw - '#![inner]</span>'
// @!hasraw - '<span class="attr">#![inner]</span>'
// @hasraw - '#<span class="attr">#![inner]</span>'
// @snapshot 'codeblock' - '//*[@class="toggle top-doc"]/*[@class="docblock"]//pre/code'

/// ```no_run
Expand Down