]> git.lizzy.rs Git - rust.git/commitdiff
fix a bug in compiletest JSON parsing for duplicate errors
authorNiko Matsakis <niko@alum.mit.edu>
Tue, 11 Apr 2017 20:58:04 +0000 (16:58 -0400)
committerNiko Matsakis <niko@alum.mit.edu>
Wed, 12 Apr 2017 00:32:47 +0000 (20:32 -0400)
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.

src/test/compile-fail/binop-move-semantics.rs
src/test/compile-fail/borrowck/borrowck-lend-flow-loop.rs
src/test/compile-fail/borrowck/borrowck-mut-borrow-linear-errors.rs
src/test/compile-fail/issue-25579.rs
src/test/compile-fail/issue-38412.rs
src/test/compile-fail/lint-unused-imports.rs
src/tools/compiletest/src/json.rs

index 0cc6ea3e984d95c9f2c4e365608b0917c9ad5755..cff0064497aff34ac814b8be55d4a1b9c4e64b9d 100644 (file)
@@ -62,7 +62,6 @@ fn mut_plus_immut() {
     &mut f
     +
     &f;  //~ ERROR: cannot borrow `f` as immutable because it is also borrowed as mutable
-    //~^ cannot borrow `f` as immutable because it is also borrowed as mutable
 }
 
 fn immut_plus_mut() {
@@ -71,7 +70,6 @@ fn immut_plus_mut() {
     &f
     +
     &mut f;  //~ ERROR: cannot borrow `f` as mutable because it is also borrowed as immutable
-    //~^ cannot borrow `f` as mutable because it is also borrowed as immutable
 }
 
 fn main() {}
index 56cbe0b1878675314087ea02137e368721b1448a..f09e7ffd7e4b791c4b51472ca9db8013b79e0659 100644 (file)
@@ -109,7 +109,6 @@ fn while_aliased_mut_cond(cond: bool, cond2: bool) {
         borrow(&*v); //~ ERROR cannot borrow
         if cond2 {
             x = &mut v; //~ ERROR cannot borrow
-            //~^ ERROR cannot borrow
         }
     }
 }
index f789d44016eb177850ec2dd3cf35b6ae421c3b11..38e0e27a7b98e792e828f44bb7ad64ec83f426a0 100644 (file)
@@ -19,7 +19,6 @@ fn main() {
         match 1 {
             1 => { addr = &mut x; }
             //~^ ERROR cannot borrow `x` as mutable more than once at a time
-            //~| ERROR cannot borrow `x` as mutable more than once at a time
             2 => { addr = &mut x; }
             //~^ ERROR cannot borrow `x` as mutable more than once at a time
             _ => { addr = &mut x; }
index 849c9aa18c905a2ca39d4f44c8aca1537943e894..323ce3b0adf33d89f9166ffd2c2b60182a2120cb 100644 (file)
@@ -17,7 +17,6 @@ fn causes_ice(mut l: &mut Sexpression) {
     loop { match l {
         &mut Sexpression::Num(ref mut n) => {},
         &mut Sexpression::Cons(ref mut expr) => { //~ ERROR cannot borrow `l.0`
-            //~| ERROR cannot borrow `l.0`
             l = &mut **expr; //~ ERROR cannot assign to `l`
         }
     }}
index 3b62aaf2ab8e9450789eca11ffa54610af1bc333..b4feadbacf7404cc61d1b9cc91f54224eaa19ffd 100644 (file)
@@ -11,7 +11,6 @@
 fn main() {
     let Box(a) = loop { };
     //~^ ERROR expected tuple struct/variant, found struct `Box`
-    //~| ERROR expected tuple struct/variant, found struct `Box`
 
     // (The below is a trick to allow compiler to infer a type for
     // variable `a` without attempting to ascribe a type to the
index f6f7c210f466a0712d6dca5d2269e4289ca8ec12..5bb2ab75c53fd42a8fadd9b43920b94e87e0d216 100644 (file)
@@ -21,7 +21,6 @@
 // Should get errors for both 'Some' and 'None'
 use std::option::Option::{Some, None};
 //~^ ERROR unused imports: `None`, `Some`
-//~| ERROR unused imports: `None`, `Some`
 
 use test::A;       //~ ERROR unused import: `test::A`
 // Be sure that if we just bring some methods into scope that they're also
index d9da1bdc3485837d8024036f23ff5be81f5e7c71..06cbd9a3df41686b464dee0f15dda74cb91ab8fc 100644 (file)
@@ -97,6 +97,7 @@ fn push_expected_errors(expected_errors: &mut Vec<Error>,
     let primary_spans: Vec<_> = spans_in_this_file.iter()
         .cloned()
         .filter(|span| span.is_primary)
+        .take(1) // sometimes we have more than one showing up in the json; pick first
         .collect();
     let primary_spans = if primary_spans.is_empty() {
         // subdiagnostics often don't have a span of their own;