Skip to content

Commit

Permalink
assert we get at least two rendered lines back
Browse files Browse the repository at this point in the history
  • Loading branch information
nikomatsakis committed May 2, 2016
1 parent db8a9a9 commit 9355a91
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/libsyntax/errors/snippet/mod.rs
Expand Up @@ -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
Expand Down Expand Up @@ -492,6 +492,9 @@ impl FileInfo {
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(""),
Expand Down

0 comments on commit 9355a91

Please sign in to comment.