Remove redundant warnings in rustc_trans
This commit is contained in:
parent
c568807989
commit
0f72f0009a
@ -351,26 +351,18 @@ impl<'a, 'tcx> FunctionCx<'a, 'tcx> {
|
|||||||
.max(tcx.data_layout.pointer_align);
|
.max(tcx.data_layout.pointer_align);
|
||||||
|
|
||||||
// Put together the arguments to the panic entry point.
|
// 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 } => {
|
mir::AssertMessage::BoundsCheck { ref len, ref index } => {
|
||||||
let len = self.trans_operand(&mut bx, len).immediate();
|
let len = self.trans_operand(&mut bx, len).immediate();
|
||||||
let index = self.trans_operand(&mut bx, index).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 = C_struct(bx.cx, &[filename, line, col], false);
|
||||||
let file_line_col = consts::addr_of(bx.cx,
|
let file_line_col = consts::addr_of(bx.cx,
|
||||||
file_line_col,
|
file_line_col,
|
||||||
align,
|
align,
|
||||||
"panic_bounds_check_loc");
|
"panic_bounds_check_loc");
|
||||||
(lang_items::PanicBoundsCheckFnLangItem,
|
(lang_items::PanicBoundsCheckFnLangItem,
|
||||||
vec![file_line_col, index, len],
|
vec![file_line_col, index, len])
|
||||||
const_err)
|
|
||||||
}
|
}
|
||||||
mir::AssertMessage::Math(ref err) => {
|
mir::AssertMessage::Math(ref err) => {
|
||||||
let msg_str = Symbol::intern(err.description()).as_str();
|
let msg_str = Symbol::intern(err.description()).as_str();
|
||||||
@ -383,8 +375,7 @@ impl<'a, 'tcx> FunctionCx<'a, 'tcx> {
|
|||||||
align,
|
align,
|
||||||
"panic_loc");
|
"panic_loc");
|
||||||
(lang_items::PanicFnLangItem,
|
(lang_items::PanicFnLangItem,
|
||||||
vec![msg_file_line_col],
|
vec![msg_file_line_col])
|
||||||
Some(err.description().to_owned()))
|
|
||||||
}
|
}
|
||||||
mir::AssertMessage::GeneratorResumedAfterReturn |
|
mir::AssertMessage::GeneratorResumedAfterReturn |
|
||||||
mir::AssertMessage::GeneratorResumedAfterPanic => {
|
mir::AssertMessage::GeneratorResumedAfterPanic => {
|
||||||
@ -403,24 +394,10 @@ impl<'a, 'tcx> FunctionCx<'a, 'tcx> {
|
|||||||
align,
|
align,
|
||||||
"panic_loc");
|
"panic_loc");
|
||||||
(lang_items::PanicFnLangItem,
|
(lang_items::PanicFnLangItem,
|
||||||
vec![msg_file_line_col],
|
vec![msg_file_line_col])
|
||||||
None)
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 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.
|
// Obtain the panic entry point.
|
||||||
let def_id = common::langcall(bx.tcx(), Some(span), "", lang_item);
|
let def_id = common::langcall(bx.tcx(), Some(span), "", lang_item);
|
||||||
let instance = ty::Instance::mono(bx.tcx(), def_id);
|
let instance = ty::Instance::mono(bx.tcx(), def_id);
|
||||||
|
Loading…
Reference in New Issue
Block a user