Skip to content

Commit 14f1e34

Browse files
committed
fix a bug in compiletest JSON parsing for duplicate errors
In some cases, we give multiple primary spans, in which case we would report one `//~` annotation per primary span. That was very confusing because these things are reported to the user as a single error. UI tests would be better here.
1 parent 77d9e38 commit 14f1e34

File tree

7 files changed

+1
-7
lines changed

7 files changed

+1
-7
lines changed

src/test/compile-fail/binop-move-semantics.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ fn mut_plus_immut() {
6262
&mut f
6363
+
6464
&f; //~ ERROR: cannot borrow `f` as immutable because it is also borrowed as mutable
65-
//~^ cannot borrow `f` as immutable because it is also borrowed as mutable
6665
}
6766

6867
fn immut_plus_mut() {
@@ -71,7 +70,6 @@ fn immut_plus_mut() {
7170
&f
7271
+
7372
&mut f; //~ ERROR: cannot borrow `f` as mutable because it is also borrowed as immutable
74-
//~^ cannot borrow `f` as mutable because it is also borrowed as immutable
7573
}
7674

7775
fn main() {}

src/test/compile-fail/borrowck/borrowck-lend-flow-loop.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ fn while_aliased_mut_cond(cond: bool, cond2: bool) {
109109
borrow(&*v); //~ ERROR cannot borrow
110110
if cond2 {
111111
x = &mut v; //~ ERROR cannot borrow
112-
//~^ ERROR cannot borrow
113112
}
114113
}
115114
}

src/test/compile-fail/borrowck/borrowck-mut-borrow-linear-errors.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ fn main() {
1919
match 1 {
2020
1 => { addr = &mut x; }
2121
//~^ ERROR cannot borrow `x` as mutable more than once at a time
22-
//~| ERROR cannot borrow `x` as mutable more than once at a time
2322
2 => { addr = &mut x; }
2423
//~^ ERROR cannot borrow `x` as mutable more than once at a time
2524
_ => { addr = &mut x; }

src/test/compile-fail/issue-25579.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ fn causes_ice(mut l: &mut Sexpression) {
1717
loop { match l {
1818
&mut Sexpression::Num(ref mut n) => {},
1919
&mut Sexpression::Cons(ref mut expr) => { //~ ERROR cannot borrow `l.0`
20-
//~| ERROR cannot borrow `l.0`
2120
l = &mut **expr; //~ ERROR cannot assign to `l`
2221
}
2322
}}

src/test/compile-fail/issue-38412.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
fn main() {
1212
let Box(a) = loop { };
1313
//~^ ERROR expected tuple struct/variant, found struct `Box`
14-
//~| ERROR expected tuple struct/variant, found struct `Box`
1514

1615
// (The below is a trick to allow compiler to infer a type for
1716
// variable `a` without attempting to ascribe a type to the

src/test/compile-fail/lint-unused-imports.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ use std::fmt::{};
2121
// Should get errors for both 'Some' and 'None'
2222
use std::option::Option::{Some, None};
2323
//~^ ERROR unused imports: `None`, `Some`
24-
//~| ERROR unused imports: `None`, `Some`
2524

2625
use test::A; //~ ERROR unused import: `test::A`
2726
// Be sure that if we just bring some methods into scope that they're also

src/tools/compiletest/src/json.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ fn push_expected_errors(expected_errors: &mut Vec<Error>,
9797
let primary_spans: Vec<_> = spans_in_this_file.iter()
9898
.cloned()
9999
.filter(|span| span.is_primary)
100+
.take(1) // sometimes we have more than one showing up in the json; pick first
100101
.collect();
101102
let primary_spans = if primary_spans.is_empty() {
102103
// subdiagnostics often don't have a span of their own;

0 commit comments

Comments
 (0)