From 4aede759146260cddd194de71375d3f1b8183135 Mon Sep 17 00:00:00 2001 From: Ariel Ben-Yehuda Date: Wed, 1 Mar 2017 02:44:01 +0200 Subject: [PATCH] transform broken MIR warnings to hard ICEs We ought to do that sometime, and this PR fixes all broken MIR errors I could find. --- src/librustc_mir/transform/type_check.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/librustc_mir/transform/type_check.rs b/src/librustc_mir/transform/type_check.rs index c2faf27412c69..fb7d708778ef6 100644 --- a/src/librustc_mir/transform/type_check.rs +++ b/src/librustc_mir/transform/type_check.rs @@ -25,22 +25,21 @@ use syntax_pos::{Span, DUMMY_SP}; use rustc_data_structures::indexed_vec::Idx; +fn mirbug(tcx: TyCtxt, span: Span, msg: &str) { + tcx.sess.diagnostic().span_bug(span, msg); +} + macro_rules! span_mirbug { ($context:expr, $elem:expr, $($message:tt)*) => ({ - $context.tcx().sess.span_warn( - $context.last_span, - &format!("broken MIR ({:?}): {}", $elem, format!($($message)*)) - ) + mirbug($context.tcx(), $context.last_span, + &format!("broken MIR ({:?}): {}", $elem, format!($($message)*))) }) } macro_rules! span_mirbug_and_err { ($context:expr, $elem:expr, $($message:tt)*) => ({ { - $context.tcx().sess.span_warn( - $context.last_span, - &format!("broken MIR ({:?}): {:?}", $elem, format!($($message)*)) - ); + span_mirbug!($context, $elem, $($message)*); $context.error() } })