]> git.lizzy.rs Git - rust.git/commitdiff
Reduce noise in error reporting
authorOliver Schneider <git-no-reply-9879165716479413131@oli-obk.de>
Fri, 26 Jan 2018 14:19:01 +0000 (15:19 +0100)
committerOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Thu, 8 Mar 2018 07:34:11 +0000 (08:34 +0100)
src/librustc/mir/interpret/error.rs
src/librustc/ty/util.rs
src/librustc_mir/interpret/const_eval.rs
src/test/compile-fail/issue-27592.rs
src/test/run-pass/ctfe/promotion.rs [new file with mode: 0644]
src/test/ui/discrim-overflow.rs
src/test/ui/error-codes/E0081.rs

index 702fd85794fff7a784560b6e0171aef7028bbe80..3e8aeaff57e626efcd3a0aa86cc4bd2536506a2b 100644 (file)
@@ -306,7 +306,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
             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()),
index dd33d68de2e4a4e8d448c89fe4ac411053011060..cbd9a1b8d4f932de801e58e65ec3364310348a4b 100644 (file)
@@ -76,7 +76,7 @@ pub fn checked_add<'a, 'gcx>(self, tcx: TyCtxt<'a, 'gcx, 'tcx>, n: u128) -> (Sel
             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 @@ pub fn checked_add<'a, 'gcx>(self, tcx: TyCtxt<'a, 'gcx, 'tcx>, n: u128) -> (Sel
             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
             };
index 611633163fad5421198e1c95fe8870060eb48042..6c1d762c912cf7cdd797f9c254c96aabbbbca7f1 100644 (file)
@@ -183,7 +183,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
                     msg
                 )
             }
-            NotConst(ref msg) => write!(f, "Cannot evaluate within constants: \"{}\"", msg),
+            NotConst(ref msg) => write!(f, "{}", msg),
         }
     }
 }
index bc295941147467eabe3e199ed6ce55916abe517f..731d4fb2bf693ea2f1cccda229569f21aa19fc89 100644 (file)
@@ -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 (file)
index 0000000..2d22840
--- /dev/null
@@ -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"]);
+}
index 0b31d9f97f174274dc56dca788fa2028ed3f6b88..16b417c61a517d772cd7acb24f7406c764fef360 100644 (file)
@@ -56,7 +56,7 @@ enum A {
         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 @@ enum A {
         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 @@ enum A {
         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 @@ enum A {
         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 @@ enum A {
         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;
index 3b571667336ac9956baf27ed188d00a2e0355d63..c0cdad258687da8c7b9b3d5692063fb37e1e8ea9 100644 (file)
@@ -11,7 +11,7 @@
 enum Enum {
     P = 3,
     X = 3,
-    //~^ ERROR discriminant value `3isize` already exists
+    //~^ ERROR discriminant value `3` already exists
     Y = 5
 }