]> git.lizzy.rs Git - rust.git/commitdiff
assert we get at least two rendered lines back
authorNiko Matsakis <niko@alum.mit.edu>
Mon, 2 May 2016 17:05:14 +0000 (13:05 -0400)
committerNiko Matsakis <niko@alum.mit.edu>
Mon, 2 May 2016 17:05:14 +0000 (13:05 -0400)
src/libsyntax/errors/snippet/mod.rs

index 1ec4a0157426ae709a26f42098f665b697492165..e213f623ab85dac2e40fe4c49536fc0938f74b0e 100644 (file)
@@ -38,13 +38,13 @@ pub struct FileInfo {
     lines: Vec<Line>,
 }
 
-#[derive(Clone)]
+#[derive(Clone, Debug)]
 struct Line {
     line_index: usize,
     annotations: Vec<Annotation>,
 }
 
-#[derive(Clone, PartialOrd, Ord, PartialEq, Eq)]
+#[derive(Clone, Debug, PartialOrd, Ord, PartialEq, Eq)]
 struct Annotation {
     /// Start column, 0-based indexing -- counting *characters*, not
     /// utf-8 bytes. Note that it is important that this field goes
@@ -492,6 +492,9 @@ fn render_file_lines(&self, codemap: &Rc<CodeMap>) -> Vec<RenderedLine> {
                             let gap_amount =
                                 rendered_lines[0].text[0].text.len() +
                                 rendered_lines[0].text[1].text.len();
+                            assert!(rendered_lines.len() >= 2,
+                                    "no annotations resulted from: {:?}",
+                                    line);
                             for i in 1..rendered_lines.len() {
                                 rendered_lines[i].text.insert(0, StyledString {
                                     text: vec![" "; gap_amount].join(""),