Skip to content

Commit

Permalink
Fix line display
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Apr 22, 2017
1 parent 91fb6bc commit 9c97882
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
12 changes: 4 additions & 8 deletions src/librustdoc/html/markdown.rs
Expand Up @@ -719,7 +719,7 @@ pub fn old_find_testable_code(doc: &str, tests: &mut ::test::Collector, position
text: *const hoedown_buffer,
lang: *const hoedown_buffer,
data: *const hoedown_renderer_data,
_line: libc::size_t) {
line: libc::size_t) {
unsafe {
if text.is_null() { return }
let block_info = if lang.is_null() {
Expand All @@ -737,22 +737,18 @@ pub fn old_find_testable_code(doc: &str, tests: &mut ::test::Collector, position
let lines = text.lines().map(|l| {
stripped_filtered_line(l).unwrap_or(l)
});
let text = lines.collect::<Vec<&str>>().join("\n");
let filename = tests.get_filename();

if tests.render_type == RenderType::Hoedown {
let text = (*text).as_bytes();
let text = str::from_utf8(text).unwrap();
let lines = text.lines().map(|l| {
stripped_filtered_line(l).unwrap_or(l)
});
let text = lines.collect::<Vec<&str>>().join("\n");
let line = tests.get_line() + line;
tests.add_test(text.to_owned(),
block_info.should_panic, block_info.no_run,
block_info.ignore, block_info.test_harness,
block_info.compile_fail, block_info.error_codes,
line, filename);
} else {
tests.add_old_test(lines.collect::<Vec<&str>>().join("\n"), filename);
tests.add_old_test(text, filename);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/librustdoc/test.rs
Expand Up @@ -464,19 +464,19 @@ impl Collector {
as_test_harness: bool, compile_fail: bool, error_codes: Vec<String>,
line: usize, filename: String) {
let name = self.generate_name(line, &filename);
// to be removed when hoedown is removed
if self.render_type == RenderType::Pulldown {
let name_beg = self.generate_name_beginning(&filename);
let mut found = false;
// to be removed when hoedown is removed
let test = test.trim().to_owned();
if let Some(entry) = self.old_tests.get_mut(&name_beg) {
found = entry.remove_item(&test).is_some();
}
if !found {
let _ = writeln!(&mut io::stderr(),
"WARNING: {} Code block is not currently run as a test, but will in \
future versions of rustdoc. Please ensure this code block is a \
runnable test, or use the `ignore` directive.",
"WARNING: {} Code block is not currently run as a test, but will \
in future versions of rustdoc. Please ensure this code block is \
a runnable test, or use the `ignore` directive.",
name);
return
}
Expand Down

0 comments on commit 9c97882

Please sign in to comment.