Skip to content

Commit 9c97882

Browse files
Fix line display
1 parent 91fb6bc commit 9c97882

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

src/librustdoc/html/markdown.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ pub fn old_find_testable_code(doc: &str, tests: &mut ::test::Collector, position
719719
text: *const hoedown_buffer,
720720
lang: *const hoedown_buffer,
721721
data: *const hoedown_renderer_data,
722-
_line: libc::size_t) {
722+
line: libc::size_t) {
723723
unsafe {
724724
if text.is_null() { return }
725725
let block_info = if lang.is_null() {
@@ -737,22 +737,18 @@ pub fn old_find_testable_code(doc: &str, tests: &mut ::test::Collector, position
737737
let lines = text.lines().map(|l| {
738738
stripped_filtered_line(l).unwrap_or(l)
739739
});
740+
let text = lines.collect::<Vec<&str>>().join("\n");
740741
let filename = tests.get_filename();
741742

742743
if tests.render_type == RenderType::Hoedown {
743-
let text = (*text).as_bytes();
744-
let text = str::from_utf8(text).unwrap();
745-
let lines = text.lines().map(|l| {
746-
stripped_filtered_line(l).unwrap_or(l)
747-
});
748-
let text = lines.collect::<Vec<&str>>().join("\n");
744+
let line = tests.get_line() + line;
749745
tests.add_test(text.to_owned(),
750746
block_info.should_panic, block_info.no_run,
751747
block_info.ignore, block_info.test_harness,
752748
block_info.compile_fail, block_info.error_codes,
753749
line, filename);
754750
} else {
755-
tests.add_old_test(lines.collect::<Vec<&str>>().join("\n"), filename);
751+
tests.add_old_test(text, filename);
756752
}
757753
}
758754
}

src/librustdoc/test.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -464,19 +464,19 @@ impl Collector {
464464
as_test_harness: bool, compile_fail: bool, error_codes: Vec<String>,
465465
line: usize, filename: String) {
466466
let name = self.generate_name(line, &filename);
467+
// to be removed when hoedown is removed
467468
if self.render_type == RenderType::Pulldown {
468469
let name_beg = self.generate_name_beginning(&filename);
469470
let mut found = false;
470-
// to be removed when hoedown is removed
471471
let test = test.trim().to_owned();
472472
if let Some(entry) = self.old_tests.get_mut(&name_beg) {
473473
found = entry.remove_item(&test).is_some();
474474
}
475475
if !found {
476476
let _ = writeln!(&mut io::stderr(),
477-
"WARNING: {} Code block is not currently run as a test, but will in \
478-
future versions of rustdoc. Please ensure this code block is a \
479-
runnable test, or use the `ignore` directive.",
477+
"WARNING: {} Code block is not currently run as a test, but will \
478+
in future versions of rustdoc. Please ensure this code block is \
479+
a runnable test, or use the `ignore` directive.",
480480
name);
481481
return
482482
}

0 commit comments

Comments
 (0)