From 0f72f0009a309059952feb973a8e066845988f2a Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Mon, 29 Jan 2018 15:02:01 +0100 Subject: [PATCH] Remove redundant warnings in rustc_trans --- src/librustc_trans/mir/block.rs | 31 ++++--------------------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/src/librustc_trans/mir/block.rs b/src/librustc_trans/mir/block.rs index 9d70f8669b2..efb5338f680 100644 --- a/src/librustc_trans/mir/block.rs +++ b/src/librustc_trans/mir/block.rs @@ -351,26 +351,18 @@ impl<'a, 'tcx> FunctionCx<'a, 'tcx> { .max(tcx.data_layout.pointer_align); // Put together the arguments to the panic entry point. - let (lang_item, args, const_err) = match *msg { + let (lang_item, args) = match *msg { mir::AssertMessage::BoundsCheck { ref len, ref index } => { let len = self.trans_operand(&mut bx, len).immediate(); let index = self.trans_operand(&mut bx, index).immediate(); - let const_err = common::const_to_opt_u128(len, false) - .and_then(|len| common::const_to_opt_u128(index, false) - .map(|index| format!( - "index out of bounds: the len is {} but the index is {}", - len, index, - ))); - let file_line_col = C_struct(bx.cx, &[filename, line, col], false); let file_line_col = consts::addr_of(bx.cx, file_line_col, align, "panic_bounds_check_loc"); (lang_items::PanicBoundsCheckFnLangItem, - vec![file_line_col, index, len], - const_err) + vec![file_line_col, index, len]) } mir::AssertMessage::Math(ref err) => { let msg_str = Symbol::intern(err.description()).as_str(); @@ -383,8 +375,7 @@ impl<'a, 'tcx> FunctionCx<'a, 'tcx> { align, "panic_loc"); (lang_items::PanicFnLangItem, - vec![msg_file_line_col], - Some(err.description().to_owned())) + vec![msg_file_line_col]) } mir::AssertMessage::GeneratorResumedAfterReturn | mir::AssertMessage::GeneratorResumedAfterPanic => { @@ -403,24 +394,10 @@ impl<'a, 'tcx> FunctionCx<'a, 'tcx> { align, "panic_loc"); (lang_items::PanicFnLangItem, - vec![msg_file_line_col], - None) + vec![msg_file_line_col]) } }; - // If we know we always panic, and the error message - // is also constant, then we can produce a warning. - if const_cond == Some(!expected) { - if let Some(err) = const_err { - let mut diag = bx.tcx().sess.struct_span_warn( - span, &format!( - "this expression will panic at run-time with {:?}", - err, - )); - diag.emit(); - } - } - // Obtain the panic entry point. let def_id = common::langcall(bx.tcx(), Some(span), "", lang_item); let instance = ty::Instance::mono(bx.tcx(), def_id);