1
Fork 0

Reduce noise in error reporting

This commit is contained in:
Oliver Schneider 2018-01-26 15:19:01 +01:00 committed by Oliver Schneider
parent 8a93972ba9
commit b75a828e2b
No known key found for this signature in database
GPG key ID: A69F8D225B3AD7D9
7 changed files with 27 additions and 11 deletions

View file

@ -306,7 +306,7 @@ impl<'tcx> fmt::Display for EvalError<'tcx> {
PathNotFound(ref path) => PathNotFound(ref path) =>
write!(f, "Cannot find path {:?}", path), write!(f, "Cannot find path {:?}", path),
MachineError(ref inner) => MachineError(ref inner) =>
write!(f, "machine error: {}", inner), write!(f, "{}", inner),
IncorrectAllocationInformation(size, size2, align, align2) => IncorrectAllocationInformation(size, size2, align, align2) =>
write!(f, "incorrect alloc info: expected size {} and align {}, got size {} and align {}", size, align, size2, align2), write!(f, "incorrect alloc info: expected size {} and align {}, got size {} and align {}", size, align, size2, align2),
_ => write!(f, "{}", self.description()), _ => write!(f, "{}", self.description()),

View file

@ -76,7 +76,7 @@ impl<'tcx> Discr<'tcx> {
let n = n as i128; let n = n as i128;
let oflo = val > max - n; let oflo = val > max - n;
let val = if oflo { let val = if oflo {
min + (n - (max - val)) min + (n - (max - val) - 1)
} else { } else {
val + n val + n
}; };
@ -95,7 +95,7 @@ impl<'tcx> Discr<'tcx> {
let val = self.val; let val = self.val;
let oflo = val > max - n; let oflo = val > max - n;
let val = if oflo { let val = if oflo {
min + (n - (max - val)) min + (n - (max - val) - 1)
} else { } else {
val + n val + n
}; };

View file

@ -183,7 +183,7 @@ impl fmt::Display for ConstEvalError {
msg msg
) )
} }
NotConst(ref msg) => write!(f, "Cannot evaluate within constants: \"{}\"", msg), NotConst(ref msg) => write!(f, "{}", msg),
} }
} }
} }

View file

@ -26,5 +26,4 @@ fn main() {
write(|| format_args!("{}", String::from("Hello world"))); 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 //~| ERROR borrowed value does not live long enough
//~| ERROR borrowed value does not live long enough
} }

View file

@ -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"]);
}

View file

@ -56,7 +56,7 @@ fn f_u16() {
Ok = u16::MAX - 1, Ok = u16::MAX - 1,
Ok2, Ok2,
OhNo, //~ ERROR enum discriminant overflowed [E0370] OhNo, //~ ERROR enum discriminant overflowed [E0370]
//~| overflowed on value after 65535u16 //~| overflowed on value after 65535
} }
let x = A::Ok; let x = A::Ok;
@ -68,7 +68,7 @@ fn f_i32() {
Ok = i32::MAX - 1, Ok = i32::MAX - 1,
Ok2, Ok2,
OhNo, //~ ERROR enum discriminant overflowed [E0370] OhNo, //~ ERROR enum discriminant overflowed [E0370]
//~| overflowed on value after 2147483647i32 //~| overflowed on value after 2147483647
} }
let x = A::Ok; let x = A::Ok;
@ -80,7 +80,7 @@ fn f_u32() {
Ok = u32::MAX - 1, Ok = u32::MAX - 1,
Ok2, Ok2,
OhNo, //~ ERROR enum discriminant overflowed [E0370] OhNo, //~ ERROR enum discriminant overflowed [E0370]
//~| overflowed on value after 4294967295u32 //~| overflowed on value after 4294967295
} }
let x = A::Ok; let x = A::Ok;
@ -92,7 +92,7 @@ fn f_i64() {
Ok = i64::MAX - 1, Ok = i64::MAX - 1,
Ok2, Ok2,
OhNo, //~ ERROR enum discriminant overflowed [E0370] OhNo, //~ ERROR enum discriminant overflowed [E0370]
//~| overflowed on value after 9223372036854775807i64 //~| overflowed on value after 9223372036854775807
} }
let x = A::Ok; let x = A::Ok;
@ -104,7 +104,7 @@ fn f_u64() {
Ok = u64::MAX - 1, Ok = u64::MAX - 1,
Ok2, Ok2,
OhNo, //~ ERROR enum discriminant overflowed [E0370] OhNo, //~ ERROR enum discriminant overflowed [E0370]
//~| overflowed on value after 18446744073709551615u64 //~| overflowed on value after 18446744073709551615
} }
let x = A::Ok; let x = A::Ok;

View file

@ -11,7 +11,7 @@
enum Enum { enum Enum {
P = 3, P = 3,
X = 3, X = 3,
//~^ ERROR discriminant value `3isize` already exists //~^ ERROR discriminant value `3` already exists
Y = 5 Y = 5
} }