do not use InterpError::description outside librustc::mir

This commit is contained in:
Ralf Jung 2019-07-24 09:12:21 +02:00
parent a7f28678bb
commit c0420b1a59
3 changed files with 6 additions and 5 deletions

View File

@ -330,7 +330,7 @@ pub enum InterpError<'tcx, O> {
pub type InterpResult<'tcx, T = ()> = Result<T, InterpErrorInfo<'tcx>>;
impl<'tcx, O> InterpError<'tcx, O> {
pub fn description(&self) -> &str {
pub(crate) fn description(&self) -> &str {
use self::InterpError::*;
match *self {
MachineError(ref inner) => inner,

View File

@ -418,8 +418,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
vec![file_line_col, index, len])
}
_ => {
let str = msg.description();
let msg_str = LocalInternedString::intern(str);
let str = format!("{:?}", msg);
let msg_str = LocalInternedString::intern(&str);
let msg_file_line_col = bx.static_panic_msg(
Some(msg_str),
filename,

View File

@ -809,7 +809,7 @@ impl<'mir, 'tcx> MutVisitor<'tcx> for ConstPropagator<'mir, 'tcx> {
self.super_terminator(terminator, location);
let source_info = terminator.source_info;
match &mut terminator.kind {
TerminatorKind::Assert { expected, msg, ref mut cond, .. } => {
TerminatorKind::Assert { expected, ref msg, ref mut cond, .. } => {
if let Some(value) = self.eval_operand(&cond, source_info) {
trace!("assertion on {:?} should be {:?}", value, expected);
let expected = ScalarMaybeUndef::from(Scalar::from_bool(*expected));
@ -836,7 +836,8 @@ impl<'mir, 'tcx> MutVisitor<'tcx> for ConstPropagator<'mir, 'tcx> {
Panic(PanicMessage::Overflow(_)) |
Panic(PanicMessage::OverflowNeg) |
Panic(PanicMessage::DivisionByZero) |
Panic(PanicMessage::RemainderByZero) => msg.description().to_owned(),
Panic(PanicMessage::RemainderByZero) =>
format!("{:?}", msg),
Panic(PanicMessage::BoundsCheck { ref len, ref index }) => {
let len = self
.eval_operand(len, source_info)