diff options
| author | bors <bors@rust-lang.org> | 2014-10-06 14:57:19 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-10-06 14:57:19 +0000 |
| commit | 3edcdbb0c01187a0cc6456ca29cd858579459b18 (patch) | |
| tree | 1caa839129f4003d2863242fb07e058299bef86b /src | |
| parent | 0d94fdaeb8b16b0f34c4bc03e7f95a18ffffba75 (diff) | |
| parent | 942bed7aa6225b63b9633b4540dd4498c0a44623 (diff) | |
| download | rust-3edcdbb0c01187a0cc6456ca29cd858579459b18.tar.gz rust-3edcdbb0c01187a0cc6456ca29cd858579459b18.zip | |
auto merge of #17796 : tomjakubowski/rust/rustdoc-ice-17736, r=alexcrichton
Previously, external code might call `markdown::render()` without having called `markdown::reset_headers()`, meaning the TLS key `used_header_map` was unset. Now `markdown::render()` ensures that `used_header_map` is set by calling `reset_headers` if necessary. Fix #17736
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustdoc/html/markdown.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index 86f56660d3a..faf361f0290 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -268,6 +268,10 @@ pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result { text.with_c_str(|p| unsafe { hoedown_buffer_puts(ob, p) }); } + if used_header_map.get().is_none() { + reset_headers(); + } + unsafe { let ob = hoedown_buffer_new(DEF_OUNIT); let renderer = hoedown_html_renderer_new(0, 0); @@ -446,7 +450,7 @@ impl<'a> fmt::Show for MarkdownWithToc<'a> { #[cfg(test)] mod tests { - use super::LangString; + use super::{LangString, Markdown}; #[test] fn test_lang_string_parse() { @@ -474,4 +478,10 @@ mod tests { t("{.example .rust}", false,false,false,false,false); t("{.test_harness .rust}", false,false,false,false,true); } + + #[test] + fn issue_17736() { + let markdown = "# title"; + format!("{}", Markdown(markdown.as_slice())); + } } |
