about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Schneider <git-no-reply-9879165716479413131@oli-obk.de>2018-01-26 15:19:01 +0100
committerOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>2018-03-08 08:34:11 +0100
commitb75a828e2ba5a3fc7b433bc0898cba3596758fe6 (patch)
treed87ec1d9624ec5e698433bdad2538c69c830cc48
parent8a93972ba9c29bf5c735108a8f7c316aa60fa0da (diff)
downloadrust-b75a828e2ba5a3fc7b433bc0898cba3596758fe6.tar.gz
rust-b75a828e2ba5a3fc7b433bc0898cba3596758fe6.zip
Reduce noise in error reporting
-rw-r--r--src/librustc/mir/interpret/error.rs2
-rw-r--r--src/librustc/ty/util.rs4
-rw-r--r--src/librustc_mir/interpret/const_eval.rs2
-rw-r--r--src/test/compile-fail/issue-27592.rs1
-rw-r--r--src/test/run-pass/ctfe/promotion.rs17
-rw-r--r--src/test/ui/discrim-overflow.rs10
-rw-r--r--src/test/ui/error-codes/E0081.rs2
7 files changed, 27 insertions, 11 deletions
diff --git a/src/librustc/mir/interpret/error.rs b/src/librustc/mir/interpret/error.rs
index 702fd85794f..3e8aeaff57e 100644
--- a/src/librustc/mir/interpret/error.rs
+++ b/src/librustc/mir/interpret/error.rs
@@ -306,7 +306,7 @@ impl<'tcx> fmt::Display for EvalError<'tcx> {
             PathNotFound(ref path) =>
                 write!(f, "Cannot find path {:?}", path),
             MachineError(ref inner) =>
-                write!(f, "machine error: {}", inner),
+                write!(f, "{}", inner),
             IncorrectAllocationInformation(size, size2, align, align2) =>
                 write!(f, "incorrect alloc info: expected size {} and align {}, got size {} and align {}", size, align, size2, align2),
             _ => write!(f, "{}", self.description()),
diff --git a/src/librustc/ty/util.rs b/src/librustc/ty/util.rs
index dd33d68de2e..cbd9a1b8d4f 100644
--- a/src/librustc/ty/util.rs
+++ b/src/librustc/ty/util.rs
@@ -76,7 +76,7 @@ impl<'tcx> Discr<'tcx> {
             let n = n as i128;
             let oflo = val > max - n;
             let val = if oflo {
-                min + (n - (max - val))
+                min + (n - (max - val) - 1)
             } else {
                 val + n
             };
@@ -95,7 +95,7 @@ impl<'tcx> Discr<'tcx> {
             let val = self.val;
             let oflo = val > max - n;
             let val = if oflo {
-                min + (n - (max - val))
+                min + (n - (max - val) - 1)
             } else {
                 val + n
             };
diff --git a/src/librustc_mir/interpret/const_eval.rs b/src/librustc_mir/interpret/const_eval.rs
index 611633163fa..6c1d762c912 100644
--- a/src/librustc_mir/interpret/const_eval.rs
+++ b/src/librustc_mir/interpret/const_eval.rs
@@ -183,7 +183,7 @@ impl fmt::Display for ConstEvalError {
                     msg
                 )
             }
-            NotConst(ref msg) => write!(f, "Cannot evaluate within constants: \"{}\"", msg),
+            NotConst(ref msg) => write!(f, "{}", msg),
         }
     }
 }
diff --git a/src/test/compile-fail/issue-27592.rs b/src/test/compile-fail/issue-27592.rs
index bc295941147..731d4fb2bf6 100644
--- a/src/test/compile-fail/issue-27592.rs
+++ b/src/test/compile-fail/issue-27592.rs
@@ -26,5 +26,4 @@ fn main() {
     write(|| format_args!("{}", String::from("Hello world")));
     //~^ ERROR borrowed value does not live long enough
     //~| ERROR borrowed value does not live long enough
-    //~| ERROR borrowed value does not live long enough
 }
diff --git a/src/test/run-pass/ctfe/promotion.rs b/src/test/run-pass/ctfe/promotion.rs
new file mode 100644
index 00000000000..2d228408254
--- /dev/null
+++ b/src/test/run-pass/ctfe/promotion.rs
@@ -0,0 +1,17 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+fn foo(_: &'static [&'static str]) {}
+fn bar(_: &'static [&'static str; 3]) {}
+
+fn main() {
+    foo(&["a", "b", "c"]);
+    bar(&["d", "e", "f"]);
+}
diff --git a/src/test/ui/discrim-overflow.rs b/src/test/ui/discrim-overflow.rs
index 0b31d9f97f1..16b417c61a5 100644
--- a/src/test/ui/discrim-overflow.rs
+++ b/src/test/ui/discrim-overflow.rs
@@ -56,7 +56,7 @@ fn f_u16() {
         Ok = u16::MAX - 1,
         Ok2,
         OhNo, //~ ERROR enum discriminant overflowed [E0370]
-              //~| overflowed on value after 65535u16
+              //~| overflowed on value after 65535
     }
 
     let x = A::Ok;
@@ -68,7 +68,7 @@ fn f_i32() {
         Ok = i32::MAX - 1,
         Ok2,
         OhNo, //~ ERROR enum discriminant overflowed [E0370]
-              //~| overflowed on value after 2147483647i32
+              //~| overflowed on value after 2147483647
     }
 
     let x = A::Ok;
@@ -80,7 +80,7 @@ fn f_u32() {
         Ok = u32::MAX - 1,
         Ok2,
         OhNo, //~ ERROR enum discriminant overflowed [E0370]
-              //~| overflowed on value after 4294967295u32
+              //~| overflowed on value after 4294967295
     }
 
     let x = A::Ok;
@@ -92,7 +92,7 @@ fn f_i64() {
         Ok = i64::MAX - 1,
         Ok2,
         OhNo, //~ ERROR enum discriminant overflowed [E0370]
-              //~| overflowed on value after 9223372036854775807i64
+              //~| overflowed on value after 9223372036854775807
     }
 
     let x = A::Ok;
@@ -104,7 +104,7 @@ fn f_u64() {
         Ok = u64::MAX - 1,
         Ok2,
         OhNo, //~ ERROR enum discriminant overflowed [E0370]
-              //~| overflowed on value after 18446744073709551615u64
+              //~| overflowed on value after 18446744073709551615
     }
 
     let x = A::Ok;
diff --git a/src/test/ui/error-codes/E0081.rs b/src/test/ui/error-codes/E0081.rs
index 3b571667336..c0cdad25868 100644
--- a/src/test/ui/error-codes/E0081.rs
+++ b/src/test/ui/error-codes/E0081.rs
@@ -11,7 +11,7 @@
 enum Enum {
     P = 3,
     X = 3,
-    //~^ ERROR discriminant value `3isize` already exists
+    //~^ ERROR discriminant value `3` already exists
     Y = 5
 }