about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAlexis Beingessner <a.beingessner@gmail.com>2015-07-30 15:29:34 -0700
committerAlexis Beingessner <a.beingessner@gmail.com>2015-07-30 15:51:50 -0700
commit5b0721d0fe390ff3f6741cdf15bf93b8a1df2879 (patch)
tree47cc268a9c5fb8422c692fd9f700b960b4c6b6b0 /src
parent6edc994021a6bb1922ef77f62841f01a7bdf235d (diff)
downloadrust-5b0721d0fe390ff3f6741cdf15bf93b8a1df2879.tar.gz
rust-5b0721d0fe390ff3f6741cdf15bf93b8a1df2879.zip
fix rustdoc metadata parsing
Diffstat (limited to 'src')
-rw-r--r--src/librustdoc/markdown.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/librustdoc/markdown.rs b/src/librustdoc/markdown.rs
index bc6c797e5c5..a311b938e96 100644
--- a/src/librustdoc/markdown.rs
+++ b/src/librustdoc/markdown.rs
@@ -29,13 +29,14 @@ use test::{TestOptions, Collector};
 /// Separate any lines at the start of the file that begin with `%`.
 fn extract_leading_metadata<'a>(s: &'a str) -> (Vec<&'a str>, &'a str) {
     let mut metadata = Vec::new();
+    let mut count = 0;
     for line in s.lines() {
         if line.starts_with("%") {
             // remove %<whitespace>
-            metadata.push(line[1..].trim_left())
+            metadata.push(line[1..].trim_left());
+            count += line.len() + 1;
         } else {
-            let line_start_byte = s.find(line).unwrap();
-            return (metadata, &s[line_start_byte..]);
+            return (metadata, &s[count..]);
         }
     }
     // if we're here, then all lines were metadata % lines.