]> git.lizzy.rs Git - rust.git/commitdiff
Fix line display
authorGuillaume Gomez <guillaume1.gomez@gmail.com>
Sat, 22 Apr 2017 12:56:36 +0000 (14:56 +0200)
committerGuillaume Gomez <guillaume1.gomez@gmail.com>
Sat, 22 Apr 2017 12:56:36 +0000 (14:56 +0200)
src/librustdoc/html/markdown.rs
src/librustdoc/test.rs

index 0dc7ae2873b71c59c327b36e67094d785eb7c188..85a28bbfbc6d0bb0e636356327fbde67030cb00c 100644 (file)
@@ -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() {
@@ -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);
             }
         }
     }
index a30ec25de60d755b96f08e4fdbe84e5a12c581df..5b9ab304db0a9667ff27843166d7baca1aabf8d0 100644 (file)
@@ -464,19 +464,19 @@ pub fn add_test(&mut self, test: String,
                     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 \
+                                  runnable test, or use the `ignore` directive.",
                                  name);
                 return
             }