Skip to content

Commit

Permalink
Back to single line between errors. Add header space to secondary files
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Turner committed May 24, 2016
1 parent 9cc8deb commit 00b78d0
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/libsyntax/errors/emitter.rs
Expand Up @@ -238,7 +238,7 @@ impl EmitterWriter {
self.first = false;
} else {
if !self.old_school {
write!(self.dst, "\n\n")?;
write!(self.dst, "\n")?;
}
}
}
Expand Down Expand Up @@ -682,6 +682,7 @@ mod test {
println!("r#\"\n{}\"#", str);
assert_eq!(str, &r#"
--> dummy.txt:11:1
|>
11 |> e-lä-vän
|> ^
"#[1..]);
Expand Down Expand Up @@ -746,6 +747,7 @@ mod test {

let expect_start = &r#"
--> dummy.txt:1:6
|>
1 |> _____aaaaaa____bbbbbb__cccccdd_
|> ^^^^^^ ^^^^^^ ^^^^^^^
"#[1..];
Expand Down Expand Up @@ -818,6 +820,7 @@ mod test {

let expect0 = &r#"
--> dummy.txt:5:1
|>
5 |> ccccc
|> ^
...
Expand All @@ -830,6 +833,7 @@ mod test {

let expect = &r#"
--> dummy.txt:1:1
|>
1 |> aaaaa
|> ^
...
Expand Down
7 changes: 7 additions & 0 deletions src/libsyntax/errors/snippet/mod.rs
Expand Up @@ -494,6 +494,13 @@ impl FileInfo {
}],
kind: RenderedLineKind::OtherFileName,
});
output.push(RenderedLine {
text: vec![StyledString {
text: "".to_string(),
style: Style::FileNameStyle,
}],
kind: RenderedLineKind::Annotations,
});
}
}
}
Expand Down
14 changes: 14 additions & 0 deletions src/libsyntax/errors/snippet/test.rs
Expand Up @@ -98,6 +98,7 @@ fn foo() {
let text = make_string(&lines);
assert_eq!(&text[..], &"
--> foo.rs:3:2
|>
3 |> \tbar;
|> \t^^^
"[1..]);
Expand Down Expand Up @@ -130,6 +131,7 @@ fn foo() {
println!("text=\n{}", text);
assert_eq!(&text[..], &r#"
::: foo.rs
|>
3 |> vec.push(vec.pop().unwrap());
|> --- --- - previous borrow ends here
|> | |
Expand Down Expand Up @@ -199,12 +201,14 @@ fn bar() {
// Note that the `|>` remain aligned across both files:
assert_eq!(&text[..], &r#"
--> foo.rs:3:14
|>
3 |> vec.push(vec.pop().unwrap());
|> --- ^^^ - c
|> | |
|> | b
|> a
::: bar.rs
|>
17 |> vec.push();
|> --- - f
|> |
Expand Down Expand Up @@ -249,6 +253,7 @@ fn foo() {
println!("text=\n{}", text);
assert_eq!(&text[..], &r#"
::: foo.rs
|>
3 |> let name = find_id(&data, 22).unwrap();
|> ---- immutable borrow begins here
...
Expand Down Expand Up @@ -288,6 +293,7 @@ fn foo() {
println!("text=r#\"\n{}\".trim_left()", text);
assert_eq!(&text[..], &r#"
::: foo.rs
|>
3 |> vec.push(vec.pop().unwrap());
|> -------- ------ D
|> ||
Expand Down Expand Up @@ -324,6 +330,7 @@ fn foo() {
println!("text=r#\"\n{}\".trim_left()", text);
assert_eq!(&text[..], &r#"
::: foo.rs
|>
3 |> vec.push(vec.pop().unwrap());
|> --- --- - previous borrow ends here
|> | |
Expand Down Expand Up @@ -362,6 +369,7 @@ fn foo() {
println!("text=r#\"\n{}\".trim_left()", text);
assert_eq!(&text[..], &r#"
::: foo.rs
|>
4 |> let mut vec2 = vec;
|> --- `vec` moved here because it has type `collections::vec::Vec<i32>`
...
Expand Down Expand Up @@ -398,6 +406,7 @@ fn foo() {
println!("text=&r#\"\n{}\n\"#[1..]", text);
assert_eq!(text, &r#"
::: foo.rs
|>
3 |> let mut vec = vec![0, 1, 2];
|> --- ---
4 |> let mut vec2 = vec;
Expand Down Expand Up @@ -429,6 +438,7 @@ impl SomeTrait for () {
println!("r#\"\n{}\"", text);
assert_eq!(text, &r#"
::: foo.rs
|>
3 |> fn foo(x: u32) {
|> -
"#[1..]);
Expand Down Expand Up @@ -458,6 +468,7 @@ fn span_overlap_label() {
println!("r#\"\n{}\"", text);
assert_eq!(text, &r#"
::: foo.rs
|>
2 |> fn foo(x: u32) {
|> --------------
|> | |
Expand Down Expand Up @@ -492,6 +503,7 @@ fn span_overlap_label2() {
println!("r#\"\n{}\"", text);
assert_eq!(text, &r#"
::: foo.rs
|>
2 |> fn foo(x: u32) {
|> --------------
|> | |
Expand Down Expand Up @@ -537,6 +549,7 @@ fn span_overlap_label3() {
println!("r#\"\n{}\"", text);
assert_eq!(text, &r#"
::: foo.rs
|>
3 |> let closure = || {
|> - foo
4 |> inner
Expand Down Expand Up @@ -577,6 +590,7 @@ fn main() {
println!("r#\"\n{}\"", text);
assert_eq!(text, &r#"
--> foo.rs:11:2
|>
11 |> }
|> -
"#[1..]);
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/mismatched_types/issue-26480.stderr
Expand Up @@ -5,13 +5,11 @@ error: mismatched types [--explain E0308]
|> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected u64, found usize
$DIR/issue-26480.rs:38:5: 38:19: note: in this expansion of write! (defined in $DIR/issue-26480.rs)


error: non-scalar cast: `_` as `()`
--> $DIR/issue-26480.rs:33:19
|>
33 |> ($x:expr) => ($x as ())
|> ^^^^^^^^
$DIR/issue-26480.rs:39:5: 39:14: note: in this expansion of cast! (defined in $DIR/issue-26480.rs)


error: aborting due to 2 previous errors
1 change: 0 additions & 1 deletion src/test/ui/mismatched_types/main.stderr
Expand Up @@ -6,5 +6,4 @@ error: mismatched types [--explain E0308]
note: expected type `u32`
note: found type `()`


error: aborting due to previous error

0 comments on commit 00b78d0

Please sign in to comment.