]> git.lizzy.rs Git - rust.git/commitdiff
Deduplicate error reports for statics
authorOliver Schneider <github35764891676564198441@oli-obk.de>
Tue, 3 Jul 2018 10:03:47 +0000 (12:03 +0200)
committerOliver Schneider <github35764891676564198441@oli-obk.de>
Tue, 3 Jul 2018 10:03:47 +0000 (12:03 +0200)
src/librustc_mir/monomorphize/collector.rs
src/test/compile-fail/issue-14227.rs
src/test/compile-fail/issue-28324.rs
src/test/ui/const-eval/index_out_of_bounds.rs
src/test/ui/const-eval/index_out_of_bounds.stderr

index 3a046cd800a3e1db0419999a10f86ed804c40d61..09c5df000526031de3d68087af39aaa5a887bce4 100644 (file)
@@ -395,15 +395,8 @@ fn collect_items_rec<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
             };
             let param_env = ty::ParamEnv::reveal_all();
 
-            match tcx.const_eval(param_env.and(cid)) {
-                Ok(val) => collect_const(tcx, val, instance.substs, &mut neighbors),
-                Err(err) => {
-                    let span = tcx.def_span(def_id);
-                    err.report_as_error(
-                        tcx.at(span),
-                        "could not evaluate static initializer",
-                    );
-                }
+            if let Ok(val) = tcx.const_eval(param_env.and(cid)) {
+                collect_const(tcx, val, instance.substs, &mut neighbors);
             }
         }
         MonoItem::Fn(instance) => {
index 95f017061a2576efb65e4baf94083394bbc48e18..250e78ce2464005d9837f07fe7d7e4178cb4d369 100644 (file)
@@ -16,7 +16,5 @@
 static CRASH: () = symbol;
 //~^ ERROR could not evaluate static initializer
 //~| tried to read from foreign (extern) static
-//~^^^ ERROR could not evaluate static initializer
-//~| tried to read from foreign (extern) static
 
 fn main() {}
index 8512238dd31ca668d1dfa0dd1fd1bf248a2113ad..af73db2b4d211aa154863b35f4fbada37b19b175 100644 (file)
@@ -17,7 +17,5 @@
 pub static BAZ: u32 = *&error_message_count;
 //~^ ERROR could not evaluate static initializer
 //~| tried to read from foreign (extern) static
-//~^^^ ERROR could not evaluate static initializer
-//~| tried to read from foreign (extern) static
 
 fn main() {}
index 55c64d2b04e45e7194280eb19e3b8508d7cd82ed..f3578bcef6e411b5018155264b7bbc6be5d28b18 100644 (file)
@@ -10,7 +10,6 @@
 
 static FOO: i32 = [][0];
 //~^ ERROR E0080
-//~| ERROR E0080
 
 fn main() {
     let array = [std::env::args().len()];
index 828fba55a3afebc8b432e9fa6c36d7b18f531ded..464ba8ff92723b622b8987c7a750f7a68c822a20 100644 (file)
@@ -4,22 +4,14 @@ error[E0080]: could not evaluate static initializer
 LL | static FOO: i32 = [][0];
    |                   ^^^^^ index out of bounds: the len is 0 but the index is 0
 
-error[E0080]: could not evaluate static initializer
-  --> $DIR/index_out_of_bounds.rs:11:1
-   |
-LL | static FOO: i32 = [][0];
-   | ^^^^^^^^^^^^^^^^^^-----^
-   |                   |
-   |                   index out of bounds: the len is 0 but the index is 0
-
 error: index out of bounds: the len is 1 but the index is 1
-  --> $DIR/index_out_of_bounds.rs:17:5
+  --> $DIR/index_out_of_bounds.rs:16:5
    |
 LL |     array[1]; //~ ERROR index out of bounds
    |     ^^^^^^^^
    |
    = note: #[deny(const_err)] on by default
 
-error: aborting due to 3 previous errors
+error: aborting due to 2 previous errors
 
 For more information about this error, try `rustc --explain E0080`.