Skip to content

Commit c0420b1

Browse files
committed
do not use InterpError::description outside librustc::mir
1 parent a7f2867 commit c0420b1

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

src/librustc/mir/interpret/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ pub enum InterpError<'tcx, O> {
330330
pub type InterpResult<'tcx, T = ()> = Result<T, InterpErrorInfo<'tcx>>;
331331

332332
impl<'tcx, O> InterpError<'tcx, O> {
333-
pub fn description(&self) -> &str {
333+
pub(crate) fn description(&self) -> &str {
334334
use self::InterpError::*;
335335
match *self {
336336
MachineError(ref inner) => inner,

src/librustc_codegen_ssa/mir/block.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,8 +418,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
418418
vec![file_line_col, index, len])
419419
}
420420
_ => {
421-
let str = msg.description();
422-
let msg_str = LocalInternedString::intern(str);
421+
let str = format!("{:?}", msg);
422+
let msg_str = LocalInternedString::intern(&str);
423423
let msg_file_line_col = bx.static_panic_msg(
424424
Some(msg_str),
425425
filename,

src/librustc_mir/transform/const_prop.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ impl<'mir, 'tcx> MutVisitor<'tcx> for ConstPropagator<'mir, 'tcx> {
809809
self.super_terminator(terminator, location);
810810
let source_info = terminator.source_info;
811811
match &mut terminator.kind {
812-
TerminatorKind::Assert { expected, msg, ref mut cond, .. } => {
812+
TerminatorKind::Assert { expected, ref msg, ref mut cond, .. } => {
813813
if let Some(value) = self.eval_operand(&cond, source_info) {
814814
trace!("assertion on {:?} should be {:?}", value, expected);
815815
let expected = ScalarMaybeUndef::from(Scalar::from_bool(*expected));
@@ -836,7 +836,8 @@ impl<'mir, 'tcx> MutVisitor<'tcx> for ConstPropagator<'mir, 'tcx> {
836836
Panic(PanicMessage::Overflow(_)) |
837837
Panic(PanicMessage::OverflowNeg) |
838838
Panic(PanicMessage::DivisionByZero) |
839-
Panic(PanicMessage::RemainderByZero) => msg.description().to_owned(),
839+
Panic(PanicMessage::RemainderByZero) =>
840+
format!("{:?}", msg),
840841
Panic(PanicMessage::BoundsCheck { ref len, ref index }) => {
841842
let len = self
842843
.eval_operand(len, source_info)

0 commit comments

Comments
 (0)