Skip to content

Commit 5e42734

Browse files
committed
Auto merge of rust-lang#118825 - GuillaumeGomez:double-hash-handling, r=<try>
Remove weird handling of ## in code examples As mentioned in rust-lang#118711, the handling of `##` in code blocks in code examples is very surprising. Let's see if crates are using it with a crater run. r? `@notriddle`
2 parents ff2c563 + 8b60110 commit 5e42734

File tree

4 files changed

+8
-10
lines changed

4 files changed

+8
-10
lines changed

library/std/src/keyword_docs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1095,7 +1095,7 @@ mod move_keyword {}
10951095
/// ```rust,compile_fail,E0502
10961096
/// let mut v = vec![0, 1];
10971097
/// let mut_ref_v = &mut v;
1098-
/// ##[allow(unused)]
1098+
/// #[allow(unused)]
10991099
/// let ref_v = &v;
11001100
/// mut_ref_v.push(2);
11011101
/// ```

src/librustdoc/html/markdown.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,7 @@ impl<'a> Line<'a> {
168168
// then reallocate to remove it; which would make us return a String.
169169
fn map_line(s: &str) -> Line<'_> {
170170
let trimmed = s.trim();
171-
if trimmed.starts_with("##") {
172-
Line::Shown(Cow::Owned(s.replacen("##", "#", 1)))
173-
} else if let Some(stripped) = trimmed.strip_prefix("# ") {
171+
if let Some(stripped) = trimmed.strip_prefix("# ") {
174172
// # text
175173
Line::Hidden(stripped)
176174
} else if trimmed == "#" {
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
<code># single
2-
## double
3-
### triple
4-
<span class="attr">#[outer]
5-
#![inner]</span></code>
1+
<code>## single
2+
### double
3+
#### triple
4+
#<span class="attr">#[outer]
5+
</span>#<span class="attr">#![inner]</span></code>

tests/rustdoc/issue-41783.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// @hasraw - '<span class="attr">#[outer]'
55
// @!hasraw - '<span class="attr">#[outer]</span>'
66
// @hasraw - '#![inner]</span>'
7-
// @!hasraw - '<span class="attr">#![inner]</span>'
7+
// @hasraw - '#<span class="attr">#![inner]</span>'
88
// @snapshot 'codeblock' - '//*[@class="toggle top-doc"]/*[@class="docblock"]//pre/code'
99

1010
/// ```no_run

0 commit comments

Comments
 (0)