librustc_trans: use bug!(), span_bug!()
This commit is contained in:
parent
35e160364d
commit
c59ea491ea
@ -242,7 +242,7 @@ impl<'a> ConstantExpr<'a> {
|
||||
fn eq(self, other: ConstantExpr<'a>, tcx: &TyCtxt) -> bool {
|
||||
match compare_lit_exprs(tcx, self.0, other.0) {
|
||||
Some(result) => result == Ordering::Equal,
|
||||
None => panic!("compare_list_exprs: type mismatch"),
|
||||
None => bug!("compare_list_exprs: type mismatch"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -828,7 +828,7 @@ impl FailureHandler {
|
||||
fn handle_fail(&self, bcx: Block) {
|
||||
match *self {
|
||||
Infallible =>
|
||||
panic!("attempted to panic in a non-panicking panic handler!"),
|
||||
bug!("attempted to panic in a non-panicking panic handler!"),
|
||||
JumpToBasicBlock(basic_block) =>
|
||||
Br(bcx, basic_block, DebugLoc::None),
|
||||
Unreachable =>
|
||||
@ -939,11 +939,11 @@ fn compare_values<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
|
||||
|
||||
compare_str(cx, lhs_data, lhs_len, rhs_data, rhs_len, rhs_t, debug_loc)
|
||||
},
|
||||
_ => cx.sess().bug("only byte strings supported in compare_values"),
|
||||
_ => bug!("only byte strings supported in compare_values"),
|
||||
},
|
||||
_ => cx.sess().bug("only string and byte strings supported in compare_values"),
|
||||
_ => bug!("only string and byte strings supported in compare_values"),
|
||||
},
|
||||
_ => cx.sess().bug("only scalars, byte strings, and strings supported in compare_values"),
|
||||
_ => bug!("only scalars, byte strings, and strings supported in compare_values"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -986,7 +986,7 @@ fn insert_lllocals<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
||||
Lvalue::new_with_hint("_match::insert_lllocals (match_input)",
|
||||
bcx, binding_info.id, hint_kind)
|
||||
}
|
||||
_ => unreachable!(),
|
||||
_ => bug!(),
|
||||
};
|
||||
let datum = Datum::new(llval, binding_info.ty, lvalue);
|
||||
call_lifetime_start(bcx, llbinding);
|
||||
@ -1317,7 +1317,7 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
||||
bcx = r.bcx;
|
||||
}
|
||||
_ => {
|
||||
bcx.sess().bug(
|
||||
bug!(
|
||||
"in compile_submatch, expected \
|
||||
opt.trans() to return a SingleResult")
|
||||
}
|
||||
|
@ -218,7 +218,7 @@ impl FnType {
|
||||
Rust | RustCall => llvm::CCallConv,
|
||||
|
||||
// It's the ABI's job to select this, not us.
|
||||
System => ccx.sess().bug("system abi should be selected elsewhere"),
|
||||
System => bug!("system abi should be selected elsewhere"),
|
||||
|
||||
Stdcall => llvm::X86StdcallCallConv,
|
||||
Fastcall => llvm::X86FastcallCallConv,
|
||||
@ -241,8 +241,8 @@ impl FnType {
|
||||
&tupled_arguments[..]
|
||||
}
|
||||
_ => {
|
||||
unreachable!("argument to function with \"rust-call\" ABI \
|
||||
is not a tuple");
|
||||
bug!("argument to function with \"rust-call\" ABI \
|
||||
is not a tuple");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -302,9 +302,8 @@ fn represent_type_uncached<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
// non-empty body, explicit discriminants should have
|
||||
// been rejected by a checker before this point.
|
||||
if !cases.iter().enumerate().all(|(i,c)| c.discr == Disr::from(i)) {
|
||||
cx.sess().bug(&format!("non-C-like enum {} with specified \
|
||||
discriminants",
|
||||
cx.tcx().item_path_str(def.did)));
|
||||
bug!("non-C-like enum {} with specified discriminants",
|
||||
cx.tcx().item_path_str(def.did));
|
||||
}
|
||||
|
||||
if cases.len() == 1 {
|
||||
@ -430,7 +429,7 @@ fn represent_type_uncached<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
|
||||
General(ity, fields, dtor_to_init_u8(dtor))
|
||||
}
|
||||
_ => cx.sess().bug(&format!("adt::represent_type called on non-ADT type: {}", t))
|
||||
_ => bug!("adt::represent_type called on non-ADT type: {}", t)
|
||||
}
|
||||
}
|
||||
|
||||
@ -615,7 +614,7 @@ fn range_to_inttype(cx: &CrateContext, hint: Hint, bounds: &IntBounds) -> IntTyp
|
||||
match hint {
|
||||
attr::ReprInt(span, ity) => {
|
||||
if !bounds_usable(cx, ity, bounds) {
|
||||
cx.sess().span_bug(span, "representation hint insufficient for discriminant range")
|
||||
span_bug!(span, "representation hint insufficient for discriminant range")
|
||||
}
|
||||
return ity;
|
||||
}
|
||||
@ -632,10 +631,10 @@ fn range_to_inttype(cx: &CrateContext, hint: Hint, bounds: &IntBounds) -> IntTyp
|
||||
attempts = choose_shortest;
|
||||
},
|
||||
attr::ReprPacked => {
|
||||
cx.tcx().sess.bug("range_to_inttype: found ReprPacked on an enum");
|
||||
bug!("range_to_inttype: found ReprPacked on an enum");
|
||||
}
|
||||
attr::ReprSimd => {
|
||||
cx.tcx().sess.bug("range_to_inttype: found ReprSimd on an enum");
|
||||
bug!("range_to_inttype: found ReprSimd on an enum");
|
||||
}
|
||||
}
|
||||
for &ity in attempts {
|
||||
@ -835,7 +834,7 @@ fn generic_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
Type::array(&Type::i64(cx), align_units),
|
||||
a if a.count_ones() == 1 => Type::array(&Type::vector(&Type::i32(cx), a / 4),
|
||||
align_units),
|
||||
_ => panic!("unsupported enum alignment: {}", align)
|
||||
_ => bug!("unsupported enum alignment: {}", align)
|
||||
};
|
||||
assert_eq!(machine::llalign_of_min(cx, fill_ty), align);
|
||||
assert_eq!(padded_discr_size % discr_size, 0); // Ensure discr_ty can fill pad evenly
|
||||
@ -984,7 +983,7 @@ pub fn trans_case<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, r: &Repr, discr: Disr)
|
||||
C_integral(ll_inttype(bcx.ccx(), ity), discr.0, true)
|
||||
}
|
||||
Univariant(..) => {
|
||||
bcx.ccx().sess().bug("no cases for univariants or structs")
|
||||
bug!("no cases for univariants or structs")
|
||||
}
|
||||
RawNullablePointer { .. } |
|
||||
StructWrappedNullablePointer { .. } => {
|
||||
@ -1088,7 +1087,7 @@ pub fn trans_field_ptr_builder<'blk, 'tcx>(bcx: &BlockAndBuilder<'blk, 'tcx>,
|
||||
// someday), it will need to return a possibly-new bcx as well.
|
||||
match *r {
|
||||
CEnum(..) => {
|
||||
bcx.ccx().sess().bug("element access in C-like enum")
|
||||
bug!("element access in C-like enum")
|
||||
}
|
||||
Univariant(ref st, _dtor) => {
|
||||
assert_eq!(discr, Disr(0));
|
||||
@ -1279,7 +1278,7 @@ pub fn fold_variants<'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
|
||||
|
||||
bcx_next
|
||||
}
|
||||
_ => unreachable!()
|
||||
_ => bug!()
|
||||
}
|
||||
}
|
||||
|
||||
@ -1319,7 +1318,7 @@ pub fn trans_drop_flag_ptr<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
||||
fcx.pop_custom_cleanup_scope(custom_cleanup_scope);
|
||||
datum::DatumBlock::new(bcx, expr_datum)
|
||||
}
|
||||
_ => bcx.ccx().sess().bug("tried to get drop flag of non-droppable type")
|
||||
_ => bug!("tried to get drop flag of non-droppable type")
|
||||
}
|
||||
}
|
||||
|
||||
@ -1478,7 +1477,7 @@ pub fn const_get_discrim(r: &Repr, val: ValueRef) -> Disr {
|
||||
}
|
||||
Univariant(..) => Disr(0),
|
||||
RawNullablePointer { .. } | StructWrappedNullablePointer { .. } => {
|
||||
unreachable!("const discrim access of non c-like enum")
|
||||
bug!("const discrim access of non c-like enum")
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1488,10 +1487,10 @@ pub fn const_get_discrim(r: &Repr, val: ValueRef) -> Disr {
|
||||
///
|
||||
/// (Not to be confused with `common::const_get_elt`, which operates on
|
||||
/// raw LLVM-level structs and arrays.)
|
||||
pub fn const_get_field(ccx: &CrateContext, r: &Repr, val: ValueRef,
|
||||
_discr: Disr, ix: usize) -> ValueRef {
|
||||
pub fn const_get_field(r: &Repr, val: ValueRef, _discr: Disr,
|
||||
ix: usize) -> ValueRef {
|
||||
match *r {
|
||||
CEnum(..) => ccx.sess().bug("element access in C-like enum const"),
|
||||
CEnum(..) => bug!("element access in C-like enum const"),
|
||||
Univariant(..) => const_struct_field(val, ix),
|
||||
General(..) => const_struct_field(val, ix + 1),
|
||||
RawNullablePointer { .. } => {
|
||||
|
@ -221,7 +221,7 @@ fn dump_graph(tcx: &TyCtxt) {
|
||||
// Expect one of: "-> target", "source -> target", or "source ->".
|
||||
let parts: Vec<_> = string.split("->").collect();
|
||||
if parts.len() > 2 {
|
||||
panic!("Invalid RUST_DEP_GRAPH_FILTER: expected '[source] -> [target]'");
|
||||
bug!("Invalid RUST_DEP_GRAPH_FILTER: expected '[source] -> [target]'");
|
||||
}
|
||||
let sources = node_set(&query, &parts[0]);
|
||||
let targets = node_set(&query, &parts[1]);
|
||||
|
@ -187,8 +187,8 @@ pub fn link_binary(sess: &Session,
|
||||
let mut out_filenames = Vec::new();
|
||||
for &crate_type in sess.crate_types.borrow().iter() {
|
||||
if invalid_output_for_target(sess, crate_type) {
|
||||
sess.bug(&format!("invalid output type `{:?}` for target os `{}`",
|
||||
crate_type, sess.opts.target_triple));
|
||||
bug!("invalid output type `{:?}` for target os `{}`",
|
||||
crate_type, sess.opts.target_triple);
|
||||
}
|
||||
let out_file = link_binary_output(sess, trans, crate_type, outputs,
|
||||
crate_name);
|
||||
@ -282,7 +282,7 @@ pub fn each_linked_rlib(sess: &Session,
|
||||
let fmts = fmts.get(&config::CrateTypeExecutable).or_else(|| {
|
||||
fmts.get(&config::CrateTypeStaticlib)
|
||||
}).unwrap_or_else(|| {
|
||||
sess.bug("could not find formats for rlibs")
|
||||
bug!("could not find formats for rlibs")
|
||||
});
|
||||
for (cnum, path) in crates {
|
||||
match fmts[cnum as usize - 1] {
|
||||
@ -895,7 +895,7 @@ fn add_local_native_libraries(cmd: &mut Linker, sess: &Session) {
|
||||
match kind {
|
||||
NativeLibraryKind::NativeUnknown => cmd.link_dylib(l),
|
||||
NativeLibraryKind::NativeFramework => cmd.link_framework(l),
|
||||
NativeLibraryKind::NativeStatic => unreachable!(),
|
||||
NativeLibraryKind::NativeStatic => bug!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1081,7 +1081,7 @@ fn add_upstream_native_libraries(cmd: &mut Linker, sess: &Session) {
|
||||
NativeLibraryKind::NativeUnknown => cmd.link_dylib(lib),
|
||||
NativeLibraryKind::NativeFramework => cmd.link_framework(lib),
|
||||
NativeLibraryKind::NativeStatic => {
|
||||
sess.bug("statics shouldn't be propagated");
|
||||
bug!("statics shouldn't be propagated");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -271,10 +271,10 @@ impl<'a> Linker for MsvcLinker<'a> {
|
||||
}
|
||||
|
||||
fn framework_path(&mut self, _path: &Path) {
|
||||
panic!("frameworks are not supported on windows")
|
||||
bug!("frameworks are not supported on windows")
|
||||
}
|
||||
fn link_framework(&mut self, _framework: &str) {
|
||||
panic!("frameworks are not supported on windows")
|
||||
bug!("frameworks are not supported on windows")
|
||||
}
|
||||
|
||||
fn link_whole_staticlib(&mut self, lib: &str, _search_path: &[PathBuf]) {
|
||||
|
@ -224,8 +224,8 @@ fn exported_name_with_opt_suffix<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
// to be a value or type-def or something in there
|
||||
// *somewhere*
|
||||
ty_def_id.index = key.parent.unwrap_or_else(|| {
|
||||
panic!("finding type for {:?}, encountered def-id {:?} with no \
|
||||
parent", def_id, ty_def_id);
|
||||
bug!("finding type for {:?}, encountered def-id {:?} with no \
|
||||
parent", def_id, ty_def_id);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ impl Emitter for SharedEmitter {
|
||||
}
|
||||
|
||||
fn custom_emit(&mut self, _sp: &errors::RenderSpan, _msg: &str, _lvl: Level) {
|
||||
panic!("SharedEmitter doesn't support custom_emit");
|
||||
bug!("SharedEmitter doesn't support custom_emit");
|
||||
}
|
||||
}
|
||||
|
||||
@ -159,7 +159,7 @@ pub fn create_target_machine(sess: &Session) -> TargetMachineRef {
|
||||
.cg
|
||||
.relocation_model));
|
||||
sess.abort_if_errors();
|
||||
unreachable!();
|
||||
bug!();
|
||||
}
|
||||
};
|
||||
|
||||
@ -190,7 +190,7 @@ pub fn create_target_machine(sess: &Session) -> TargetMachineRef {
|
||||
.cg
|
||||
.code_model));
|
||||
sess.abort_if_errors();
|
||||
unreachable!();
|
||||
bug!();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -227,8 +227,7 @@ pub fn malloc_raw_dyn<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
}
|
||||
|
||||
|
||||
pub fn bin_op_to_icmp_predicate(ccx: &CrateContext,
|
||||
op: hir::BinOp_,
|
||||
pub fn bin_op_to_icmp_predicate(op: hir::BinOp_,
|
||||
signed: bool)
|
||||
-> llvm::IntPredicate {
|
||||
match op {
|
||||
@ -239,15 +238,14 @@ pub fn bin_op_to_icmp_predicate(ccx: &CrateContext,
|
||||
hir::BiGt => if signed { llvm::IntSGT } else { llvm::IntUGT },
|
||||
hir::BiGe => if signed { llvm::IntSGE } else { llvm::IntUGE },
|
||||
op => {
|
||||
ccx.sess()
|
||||
.bug(&format!("comparison_op_to_icmp_predicate: expected comparison operator, \
|
||||
found {:?}",
|
||||
op));
|
||||
bug!("comparison_op_to_icmp_predicate: expected comparison operator, \
|
||||
found {:?}",
|
||||
op)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn bin_op_to_fcmp_predicate(ccx: &CrateContext, op: hir::BinOp_) -> llvm::RealPredicate {
|
||||
pub fn bin_op_to_fcmp_predicate(op: hir::BinOp_) -> llvm::RealPredicate {
|
||||
match op {
|
||||
hir::BiEq => llvm::RealOEQ,
|
||||
hir::BiNe => llvm::RealUNE,
|
||||
@ -256,10 +254,9 @@ pub fn bin_op_to_fcmp_predicate(ccx: &CrateContext, op: hir::BinOp_) -> llvm::Re
|
||||
hir::BiGt => llvm::RealOGT,
|
||||
hir::BiGe => llvm::RealOGE,
|
||||
op => {
|
||||
ccx.sess()
|
||||
.bug(&format!("comparison_op_to_fcmp_predicate: expected comparison operator, \
|
||||
found {:?}",
|
||||
op));
|
||||
bug!("comparison_op_to_fcmp_predicate: expected comparison operator, \
|
||||
found {:?}",
|
||||
op);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -291,7 +288,7 @@ pub fn compare_fat_ptrs<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
hir::BiLe => (llvm::IntULE, llvm::IntULT),
|
||||
hir::BiGt => (llvm::IntUGT, llvm::IntUGT),
|
||||
hir::BiGe => (llvm::IntUGE, llvm::IntUGT),
|
||||
_ => unreachable!(),
|
||||
_ => bug!(),
|
||||
};
|
||||
|
||||
let addr_eq = ICmp(bcx, llvm::IntEQ, lhs_addr, rhs_addr, debug_loc);
|
||||
@ -302,7 +299,7 @@ pub fn compare_fat_ptrs<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
Or(bcx, addr_strict, addr_eq_extra_op, debug_loc)
|
||||
}
|
||||
_ => {
|
||||
bcx.tcx().sess.bug("unexpected fat ptr binop");
|
||||
bug!("unexpected fat ptr binop");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -322,19 +319,19 @@ pub fn compare_scalar_types<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
hir::BiEq | hir::BiLe | hir::BiGe => return C_bool(bcx.ccx(), true),
|
||||
hir::BiNe | hir::BiLt | hir::BiGt => return C_bool(bcx.ccx(), false),
|
||||
// refinements would be nice
|
||||
_ => bcx.sess().bug("compare_scalar_types: must be a comparison operator"),
|
||||
_ => bug!("compare_scalar_types: must be a comparison operator"),
|
||||
}
|
||||
}
|
||||
ty::TyFnDef(..) | ty::TyFnPtr(_) | ty::TyBool | ty::TyUint(_) | ty::TyChar => {
|
||||
ICmp(bcx,
|
||||
bin_op_to_icmp_predicate(bcx.ccx(), op, false),
|
||||
bin_op_to_icmp_predicate(op, false),
|
||||
lhs,
|
||||
rhs,
|
||||
debug_loc)
|
||||
}
|
||||
ty::TyRawPtr(mt) if common::type_is_sized(bcx.tcx(), mt.ty) => {
|
||||
ICmp(bcx,
|
||||
bin_op_to_icmp_predicate(bcx.ccx(), op, false),
|
||||
bin_op_to_icmp_predicate(op, false),
|
||||
lhs,
|
||||
rhs,
|
||||
debug_loc)
|
||||
@ -356,20 +353,20 @@ pub fn compare_scalar_types<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
}
|
||||
ty::TyInt(_) => {
|
||||
ICmp(bcx,
|
||||
bin_op_to_icmp_predicate(bcx.ccx(), op, true),
|
||||
bin_op_to_icmp_predicate(op, true),
|
||||
lhs,
|
||||
rhs,
|
||||
debug_loc)
|
||||
}
|
||||
ty::TyFloat(_) => {
|
||||
FCmp(bcx,
|
||||
bin_op_to_fcmp_predicate(bcx.ccx(), op),
|
||||
bin_op_to_fcmp_predicate(op),
|
||||
lhs,
|
||||
rhs,
|
||||
debug_loc)
|
||||
}
|
||||
// Should never get here, because t is scalar.
|
||||
_ => bcx.sess().bug("non-scalar type passed to compare_scalar_types"),
|
||||
_ => bug!("non-scalar type passed to compare_scalar_types"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -383,15 +380,15 @@ pub fn compare_simd_types<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
-> ValueRef {
|
||||
let signed = match t.sty {
|
||||
ty::TyFloat(_) => {
|
||||
let cmp = bin_op_to_fcmp_predicate(bcx.ccx(), op);
|
||||
let cmp = bin_op_to_fcmp_predicate(op);
|
||||
return SExt(bcx, FCmp(bcx, cmp, lhs, rhs, debug_loc), ret_ty);
|
||||
},
|
||||
ty::TyUint(_) => false,
|
||||
ty::TyInt(_) => true,
|
||||
_ => bcx.sess().bug("compare_simd_types: invalid SIMD type"),
|
||||
_ => bug!("compare_simd_types: invalid SIMD type"),
|
||||
};
|
||||
|
||||
let cmp = bin_op_to_icmp_predicate(bcx.ccx(), op, signed);
|
||||
let cmp = bin_op_to_icmp_predicate(op, signed);
|
||||
// LLVM outputs an `< size x i1 >`, so we need to perform a sign extension
|
||||
// to get the correctly sized type. This will compile to a single instruction
|
||||
// once the IR is converted to assembly if the SIMD instruction is supported
|
||||
@ -578,9 +575,9 @@ pub fn unsized_info<'ccx, 'tcx>(ccx: &CrateContext<'ccx, 'tcx>,
|
||||
consts::ptrcast(meth::get_vtable(ccx, trait_ref),
|
||||
Type::vtable_ptr(ccx))
|
||||
}
|
||||
_ => ccx.sess().bug(&format!("unsized_info: invalid unsizing {:?} -> {:?}",
|
||||
_ => bug!("unsized_info: invalid unsizing {:?} -> {:?}",
|
||||
source,
|
||||
target)),
|
||||
target),
|
||||
}
|
||||
}
|
||||
|
||||
@ -604,7 +601,7 @@ pub fn unsize_thin_ptr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
(PointerCast(bcx, src, ptr_ty),
|
||||
unsized_info(bcx.ccx(), a, b, None))
|
||||
}
|
||||
_ => bcx.sess().bug("unsize_thin_ptr: called on bad types"),
|
||||
_ => bug!("unsize_thin_ptr: called on bad types"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -638,12 +635,12 @@ pub fn coerce_unsized_into<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
let src_repr = adt::represent_type(bcx.ccx(), src_ty);
|
||||
let src_fields = match &*src_repr {
|
||||
&adt::Repr::Univariant(ref s, _) => &s.fields,
|
||||
_ => bcx.sess().bug("struct has non-univariant repr"),
|
||||
_ => bug!("struct has non-univariant repr"),
|
||||
};
|
||||
let dst_repr = adt::represent_type(bcx.ccx(), dst_ty);
|
||||
let dst_fields = match &*dst_repr {
|
||||
&adt::Repr::Univariant(ref s, _) => &s.fields,
|
||||
_ => bcx.sess().bug("struct has non-univariant repr"),
|
||||
_ => bug!("struct has non-univariant repr"),
|
||||
};
|
||||
|
||||
let src = adt::MaybeSizedValue::sized(src);
|
||||
@ -664,9 +661,9 @@ pub fn coerce_unsized_into<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => bcx.sess().bug(&format!("coerce_unsized_into: invalid coercion {:?} -> {:?}",
|
||||
src_ty,
|
||||
dst_ty)),
|
||||
_ => bug!("coerce_unsized_into: invalid coercion {:?} -> {:?}",
|
||||
src_ty,
|
||||
dst_ty),
|
||||
}
|
||||
}
|
||||
|
||||
@ -689,8 +686,7 @@ pub fn custom_coerce_unsize_info<'ccx, 'tcx>(ccx: &CrateContext<'ccx, 'tcx>,
|
||||
ccx.tcx().custom_coerce_unsized_kind(impl_def_id)
|
||||
}
|
||||
vtable => {
|
||||
ccx.sess().bug(&format!("invalid CoerceUnsized vtable: {:?}",
|
||||
vtable));
|
||||
bug!("invalid CoerceUnsized vtable: {:?}", vtable);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -758,7 +754,7 @@ pub fn llty_and_min_for_signed_ty<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
|
||||
};
|
||||
(llty, min)
|
||||
}
|
||||
_ => unreachable!(),
|
||||
_ => bug!(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -798,7 +794,7 @@ pub fn fail_if_zero_or_overflows<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
|
||||
(res, false)
|
||||
}
|
||||
_ => {
|
||||
cx.sess().bug(&format!("fail-if-zero on unexpected type: {}", rhs_t));
|
||||
bug!("fail-if-zero on unexpected type: {}", rhs_t);
|
||||
}
|
||||
};
|
||||
let bcx = with_cond(cx, is_zero, |bcx| {
|
||||
@ -1323,15 +1319,15 @@ fn build_cfg(tcx: &TyCtxt, id: ast::NodeId) -> (ast::NodeId, Option<cfg::CFG>) {
|
||||
hir::ItemFn(_, _, _, _, _, ref blk) => {
|
||||
blk
|
||||
}
|
||||
_ => tcx.sess.bug("unexpected item variant in has_nested_returns"),
|
||||
_ => bug!("unexpected item variant in has_nested_returns"),
|
||||
}
|
||||
}
|
||||
Some(hir_map::NodeTraitItem(trait_item)) => {
|
||||
match trait_item.node {
|
||||
hir::MethodTraitItem(_, Some(ref body)) => body,
|
||||
_ => {
|
||||
tcx.sess.bug("unexpected variant: trait item other than a provided method in \
|
||||
has_nested_returns")
|
||||
bug!("unexpected variant: trait item other than a provided method in \
|
||||
has_nested_returns")
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1339,14 +1335,14 @@ fn build_cfg(tcx: &TyCtxt, id: ast::NodeId) -> (ast::NodeId, Option<cfg::CFG>) {
|
||||
match impl_item.node {
|
||||
hir::ImplItemKind::Method(_, ref body) => body,
|
||||
_ => {
|
||||
tcx.sess.bug("unexpected variant: non-method impl item in has_nested_returns")
|
||||
bug!("unexpected variant: non-method impl item in has_nested_returns")
|
||||
}
|
||||
}
|
||||
}
|
||||
Some(hir_map::NodeExpr(e)) => {
|
||||
match e.node {
|
||||
hir::ExprClosure(_, _, ref blk) => blk,
|
||||
_ => tcx.sess.bug("unexpected expr variant in has_nested_returns"),
|
||||
_ => bug!("unexpected expr variant in has_nested_returns"),
|
||||
}
|
||||
}
|
||||
Some(hir_map::NodeVariant(..)) |
|
||||
@ -1355,8 +1351,8 @@ fn build_cfg(tcx: &TyCtxt, id: ast::NodeId) -> (ast::NodeId, Option<cfg::CFG>) {
|
||||
// glue, shims, etc
|
||||
None if id == ast::DUMMY_NODE_ID => return (ast::DUMMY_NODE_ID, None),
|
||||
|
||||
_ => tcx.sess.bug(&format!("unexpected variant in has_nested_returns: {}",
|
||||
tcx.map.path_to_string(id))),
|
||||
_ => bug!("unexpected variant in has_nested_returns: {}",
|
||||
tcx.map.path_to_string(id)),
|
||||
};
|
||||
|
||||
(blk.id, Some(cfg::CFG::new(tcx, blk)))
|
||||
@ -1675,7 +1671,7 @@ impl<'blk, 'tcx> FunctionContext<'blk, 'tcx> {
|
||||
// FIXME(pcwalton): Reduce the amount of code bloat this is responsible for.
|
||||
let tupled_arg_tys = match arg_ty.sty {
|
||||
ty::TyTuple(ref tys) => tys,
|
||||
_ => unreachable!("last argument of `rust-call` fn isn't a tuple?!")
|
||||
_ => bug!("last argument of `rust-call` fn isn't a tuple?!")
|
||||
};
|
||||
|
||||
unpack_datum!(bcx, datum::lvalue_scratch_datum(bcx,
|
||||
@ -1978,7 +1974,7 @@ pub fn trans_named_tuple_constructor<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
||||
expr::SaveIn(llresult),
|
||||
debug_loc);
|
||||
}
|
||||
_ => ccx.sess().bug("expected expr as arguments for variant/struct tuple constructor"),
|
||||
_ => bug!("expected expr as arguments for variant/struct tuple constructor"),
|
||||
}
|
||||
} else {
|
||||
// Just eval all the expressions (if any). Since expressions in Rust can have arbitrary
|
||||
@ -2381,7 +2377,7 @@ pub fn create_entry_wrapper(ccx: &CrateContext, sp: Span, main_llfn: ValueRef) {
|
||||
.help("did you use #[no_mangle] on `fn main`? Use #[start] instead")
|
||||
.emit();
|
||||
ccx.sess().abort_if_errors();
|
||||
panic!();
|
||||
bug!();
|
||||
}
|
||||
let llfn = declare::declare_cfn(ccx, "main", llfty);
|
||||
|
||||
@ -2734,7 +2730,7 @@ pub fn trans_crate<'tcx>(tcx: &TyCtxt<'tcx>,
|
||||
});
|
||||
|
||||
if POISONED {
|
||||
tcx.sess.bug("couldn't enable multi-threaded LLVM");
|
||||
bug!("couldn't enable multi-threaded LLVM");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ pub fn terminate(cx: Block, _: &str) {
|
||||
|
||||
pub fn check_not_terminated(cx: Block) {
|
||||
if cx.terminated.get() {
|
||||
panic!("already terminated!");
|
||||
bug!("already terminated!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -871,12 +871,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
.zip(args.iter().map(|&v| val_ty(v)));
|
||||
for (i, (expected_ty, actual_ty)) in iter.enumerate() {
|
||||
if expected_ty != actual_ty {
|
||||
self.ccx.sess().bug(
|
||||
&format!(
|
||||
"Type mismatch in function call of {:?}. \
|
||||
Expected {:?} for param {}, got {:?}",
|
||||
Value(llfn),
|
||||
expected_ty, i, actual_ty));
|
||||
bug!("Type mismatch in function call of {:?}. \
|
||||
Expected {:?} for param {}, got {:?}",
|
||||
Value(llfn),
|
||||
expected_ty, i, actual_ty);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ fn ty_align(ty: Type) -> usize {
|
||||
let elt = ty.element_type();
|
||||
ty_align(elt) * len
|
||||
}
|
||||
_ => panic!("ty_align: unhandled type")
|
||||
_ => bug!("ty_align: unhandled type")
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ fn ty_size(ty: Type) -> usize {
|
||||
let eltsz = ty_size(elt);
|
||||
len * eltsz
|
||||
}
|
||||
_ => panic!("ty_size: unhandled type")
|
||||
_ => bug!("ty_size: unhandled type")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ fn general_ty_align(ty: Type) -> usize {
|
||||
let elt = ty.element_type();
|
||||
general_ty_align(elt) * len
|
||||
}
|
||||
_ => panic!("ty_align: unhandled type")
|
||||
_ => bug!("ty_align: unhandled type")
|
||||
}
|
||||
}
|
||||
|
||||
@ -90,7 +90,7 @@ fn ios_ty_align(ty: Type) -> usize {
|
||||
let elt = ty.element_type();
|
||||
ios_ty_align(elt) * len
|
||||
}
|
||||
_ => panic!("ty_align: unhandled type")
|
||||
_ => bug!("ty_align: unhandled type")
|
||||
}
|
||||
}
|
||||
|
||||
@ -125,7 +125,7 @@ fn ty_size(ty: Type, align_fn: TyAlignFn) -> usize {
|
||||
let eltsz = ty_size(elt, align_fn);
|
||||
len * eltsz
|
||||
}
|
||||
_ => panic!("ty_size: unhandled type")
|
||||
_ => bug!("ty_size: unhandled type")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ fn ty_align(ty: Type) -> usize {
|
||||
let elt = ty.element_type();
|
||||
ty_align(elt) * len
|
||||
}
|
||||
_ => panic!("ty_align: unhandled type")
|
||||
_ => bug!("ty_align: unhandled type")
|
||||
}
|
||||
}
|
||||
|
||||
@ -82,7 +82,7 @@ fn ty_size(ty: Type) -> usize {
|
||||
let eltsz = ty_size(elt);
|
||||
len * eltsz
|
||||
}
|
||||
_ => panic!("ty_size: unhandled type")
|
||||
_ => bug!("ty_size: unhandled type")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ fn ty_align(ty: Type) -> usize {
|
||||
let elt = ty.element_type();
|
||||
ty_align(elt)
|
||||
}
|
||||
_ => panic!("ty_size: unhandled type")
|
||||
_ => bug!("ty_size: unhandled type")
|
||||
}
|
||||
}
|
||||
|
||||
@ -78,7 +78,7 @@ fn ty_size(ty: Type) -> usize {
|
||||
let eltsz = ty_size(elt);
|
||||
len * eltsz
|
||||
}
|
||||
_ => panic!("ty_size: unhandled type")
|
||||
_ => bug!("ty_size: unhandled type")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ fn ty_align(ty: Type) -> usize {
|
||||
let elt = ty.element_type();
|
||||
ty_align(elt)
|
||||
}
|
||||
_ => panic!("ty_align: unhandled type")
|
||||
_ => bug!("ty_align: unhandled type")
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,7 +75,7 @@ fn ty_size(ty: Type) -> usize {
|
||||
let eltsz = ty_size(elt);
|
||||
len * eltsz
|
||||
}
|
||||
_ => panic!("ty_size: unhandled type")
|
||||
_ => bug!("ty_size: unhandled type")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,7 @@ fn classify_ty(ty: Type) -> Vec<RegClass> {
|
||||
let elt = ty.element_type();
|
||||
ty_align(elt) * len
|
||||
}
|
||||
_ => panic!("ty_align: unhandled type")
|
||||
_ => bug!("ty_align: unhandled type")
|
||||
}
|
||||
}
|
||||
|
||||
@ -144,7 +144,7 @@ fn classify_ty(ty: Type) -> Vec<RegClass> {
|
||||
len * eltsz
|
||||
}
|
||||
|
||||
_ => panic!("ty_size: unhandled type")
|
||||
_ => bug!("ty_size: unhandled type")
|
||||
}
|
||||
}
|
||||
|
||||
@ -255,7 +255,7 @@ fn classify_ty(ty: Type) -> Vec<RegClass> {
|
||||
Integer => SSEInt(elt.int_width()),
|
||||
Float => SSEFv,
|
||||
Double => SSEDv,
|
||||
_ => panic!("classify: unhandled vector element type")
|
||||
_ => bug!("classify: unhandled vector element type")
|
||||
};
|
||||
|
||||
let mut i = 0;
|
||||
@ -268,7 +268,7 @@ fn classify_ty(ty: Type) -> Vec<RegClass> {
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
_ => panic!("classify: unhandled type")
|
||||
_ => bug!("classify: unhandled type")
|
||||
}
|
||||
}
|
||||
|
||||
@ -357,7 +357,7 @@ fn llreg_ty(ccx: &CrateContext, cls: &[RegClass]) -> Type {
|
||||
"llreg_ty: unsupported SSEInt width {}", bits);
|
||||
(64 / bits, Type::ix(ccx, bits))
|
||||
}
|
||||
_ => unreachable!(),
|
||||
_ => bug!(),
|
||||
};
|
||||
let vec_len = llvec_len(&cls[i + 1..]);
|
||||
let vec_ty = Type::vector(&elt_ty, vec_len as u64 * elts_per_word);
|
||||
@ -371,7 +371,7 @@ fn llreg_ty(ccx: &CrateContext, cls: &[RegClass]) -> Type {
|
||||
SSEDs => {
|
||||
tys.push(Type::f64(ccx));
|
||||
}
|
||||
_ => panic!("llregtype: unhandled class")
|
||||
_ => bug!("llregtype: unhandled class")
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
|
@ -184,8 +184,8 @@ impl<'tcx> Callee<'tcx> {
|
||||
let method_ty = def_ty(tcx, def_id, substs);
|
||||
let fn_ptr_ty = match method_ty.sty {
|
||||
ty::TyFnDef(_, _, fty) => tcx.mk_ty(ty::TyFnPtr(fty)),
|
||||
_ => unreachable!("expected fn item type, found {}",
|
||||
method_ty)
|
||||
_ => bug!("expected fn item type, found {}",
|
||||
method_ty)
|
||||
};
|
||||
Callee::ptr(immediate_rvalue(llfn, fn_ptr_ty))
|
||||
}
|
||||
@ -196,8 +196,8 @@ impl<'tcx> Callee<'tcx> {
|
||||
let method_ty = def_ty(tcx, def_id, substs);
|
||||
let fn_ptr_ty = match method_ty.sty {
|
||||
ty::TyFnDef(_, _, fty) => tcx.mk_ty(ty::TyFnPtr(fty)),
|
||||
_ => unreachable!("expected fn item type, found {}",
|
||||
method_ty)
|
||||
_ => bug!("expected fn item type, found {}",
|
||||
method_ty)
|
||||
};
|
||||
Callee::ptr(immediate_rvalue(llfn, fn_ptr_ty))
|
||||
}
|
||||
@ -209,7 +209,7 @@ impl<'tcx> Callee<'tcx> {
|
||||
}
|
||||
}
|
||||
vtable => {
|
||||
unreachable!("resolved vtable bad vtable {:?} in trans", vtable);
|
||||
bug!("resolved vtable bad vtable {:?} in trans", vtable);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -269,9 +269,9 @@ impl<'tcx> Callee<'tcx> {
|
||||
ty::TyFnDef(def_id, substs, _) => {
|
||||
return get_fn(ccx, def_id, substs);
|
||||
}
|
||||
_ => unreachable!("expected fn item type, found {}", self.ty)
|
||||
_ => bug!("expected fn item type, found {}", self.ty)
|
||||
},
|
||||
Intrinsic => unreachable!("intrinsic {} getting reified", self.ty)
|
||||
Intrinsic => bug!("intrinsic {} getting reified", self.ty)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -356,8 +356,8 @@ pub fn trans_fn_pointer_shim<'a, 'tcx>(
|
||||
ref sig }) => sig,
|
||||
|
||||
_ => {
|
||||
tcx.sess.bug(&format!("trans_fn_pointer_shim invoked on invalid type: {}",
|
||||
bare_fn_ty));
|
||||
bug!("trans_fn_pointer_shim invoked on invalid type: {}",
|
||||
bare_fn_ty);
|
||||
}
|
||||
};
|
||||
let sig = tcx.erase_late_bound_regions(sig);
|
||||
@ -481,7 +481,7 @@ fn get_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
// Create a fn pointer with the substituted signature.
|
||||
tcx.mk_ty(ty::TyFnPtr(fty))
|
||||
}
|
||||
_ => unreachable!("expected fn item type, found {}", fn_ty)
|
||||
_ => bug!("expected fn item type, found {}", fn_ty)
|
||||
};
|
||||
assert_eq!(type_of::type_of(ccx, fn_ptr_ty), common::val_ty(val));
|
||||
return immediate_rvalue(val, fn_ptr_ty);
|
||||
@ -494,7 +494,7 @@ fn get_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
// Create a fn pointer with the normalized signature.
|
||||
tcx.mk_fn_ptr(infer::normalize_associated_type(tcx, fty))
|
||||
}
|
||||
_ => unreachable!("expected fn item type, found {}", ty)
|
||||
_ => bug!("expected fn item type, found {}", ty)
|
||||
};
|
||||
|
||||
let instance = Instance::mono(ccx.tcx(), def_id);
|
||||
@ -537,7 +537,7 @@ fn get_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
}
|
||||
|
||||
ref variant => {
|
||||
ccx.sess().bug(&format!("get_fn: unexpected variant: {:?}", variant))
|
||||
bug!("get_fn: unexpected variant: {:?}", variant)
|
||||
}
|
||||
};
|
||||
|
||||
@ -689,7 +689,7 @@ fn trans_call_inner<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
||||
|
||||
let llfn = match callee {
|
||||
Fn(f) => f,
|
||||
_ => unreachable!("expected fn pointer callee, found {:?}", callee)
|
||||
_ => bug!("expected fn pointer callee, found {:?}", callee)
|
||||
};
|
||||
|
||||
let (llret, mut bcx) = base::invoke(bcx, llfn, &llargs, debug_loc);
|
||||
@ -830,8 +830,8 @@ fn trans_args_under_call_abi<'blk, 'tcx>(
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
bcx.sess().span_bug(tuple_expr.span,
|
||||
"argument to `.call()` wasn't a tuple?!")
|
||||
span_bug!(tuple_expr.span,
|
||||
"argument to `.call()` wasn't a tuple?!")
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -378,7 +378,7 @@ impl<'blk, 'tcx> CleanupMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx> {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
self.ccx.sess().bug("no loop scope found");
|
||||
bug!("no loop scope found");
|
||||
}
|
||||
|
||||
/// Returns a block to branch to which will perform all pending cleanups and
|
||||
@ -568,9 +568,8 @@ impl<'blk, 'tcx> CleanupMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
self.ccx.sess().bug(
|
||||
&format!("no cleanup scope {} found",
|
||||
self.ccx.tcx().map.node_to_string(cleanup_scope)));
|
||||
bug!("no cleanup scope {} found",
|
||||
self.ccx.tcx().map.node_to_string(cleanup_scope));
|
||||
}
|
||||
|
||||
/// Schedules a cleanup to occur in the top-most scope, which must be a temporary scope.
|
||||
@ -763,9 +762,7 @@ impl<'blk, 'tcx> CleanupHelperMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx
|
||||
}
|
||||
|
||||
LoopExit(id, _) => {
|
||||
self.ccx.sess().bug(&format!(
|
||||
"cannot exit from scope {}, \
|
||||
not in scope", id));
|
||||
bug!("cannot exit from scope {}, not in scope", id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1189,8 +1186,7 @@ pub fn temporary_scope(tcx: &TyCtxt,
|
||||
r
|
||||
}
|
||||
None => {
|
||||
tcx.sess.bug(&format!("no temporary scope available for expr {}",
|
||||
id))
|
||||
bug!("no temporary scope available for expr {}", id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -297,7 +297,6 @@ pub fn trans_closure_method<'a, 'tcx>(ccx: &'a CrateContext<'a, 'tcx>,
|
||||
let llfn_closure_kind = ccx.tcx().closure_kind(closure_def_id);
|
||||
|
||||
let _icx = push_ctxt("trans_closure_adapter_shim");
|
||||
let tcx = ccx.tcx();
|
||||
|
||||
debug!("trans_closure_adapter_shim(llfn_closure_kind={:?}, \
|
||||
trait_closure_kind={:?}, llfn={:?})",
|
||||
@ -329,9 +328,9 @@ pub fn trans_closure_method<'a, 'tcx>(ccx: &'a CrateContext<'a, 'tcx>,
|
||||
trans_fn_once_adapter_shim(ccx, closure_def_id, substs, llfn)
|
||||
}
|
||||
_ => {
|
||||
tcx.sess.bug(&format!("trans_closure_adapter_shim: cannot convert {:?} to {:?}",
|
||||
llfn_closure_kind,
|
||||
trait_closure_kind));
|
||||
bug!("trans_closure_adapter_shim: cannot convert {:?} to {:?}",
|
||||
llfn_closure_kind,
|
||||
trait_closure_kind);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -597,7 +597,7 @@ fn find_drop_glue_neighbors<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
|
||||
let substs = match fulfill_obligation(ccx, DUMMY_SP, trait_ref) {
|
||||
traits::VtableImpl(data) => data.substs,
|
||||
_ => unreachable!()
|
||||
_ => bug!()
|
||||
};
|
||||
|
||||
if can_have_local_instance(ccx, destructor_did) {
|
||||
@ -665,7 +665,7 @@ fn find_drop_glue_neighbors<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
ty::TyParam(_) |
|
||||
ty::TyInfer(_) |
|
||||
ty::TyError => {
|
||||
ccx.sess().bug("encountered unexpected type");
|
||||
bug!("encountered unexpected type");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -701,7 +701,7 @@ fn do_static_dispatch<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => unreachable!()
|
||||
_ => bug!()
|
||||
}
|
||||
} else {
|
||||
debug!(" => regular function");
|
||||
@ -760,7 +760,7 @@ fn do_static_trait_method_dispatch<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
None
|
||||
}
|
||||
_ => {
|
||||
tcx.sess.bug(&format!("static call to invalid vtable: {:?}", vtbl))
|
||||
bug!("static call to invalid vtable: {:?}", vtbl)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -845,10 +845,9 @@ fn find_vtable_types_for_unsizing<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
target_fields[coerce_index].ty(ccx.tcx(),
|
||||
target_substs))
|
||||
}
|
||||
_ => ccx.sess()
|
||||
.bug(&format!("find_vtable_types_for_unsizing: invalid coercion {:?} -> {:?}",
|
||||
source_ty,
|
||||
target_ty))
|
||||
_ => bug!("find_vtable_types_for_unsizing: invalid coercion {:?} -> {:?}",
|
||||
source_ty,
|
||||
target_ty)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1019,7 +1018,7 @@ impl<'b, 'a, 'v> hir_visit::Visitor<'v> for RootCollector<'b, 'a, 'v> {
|
||||
generics.is_type_parameterized()
|
||||
}
|
||||
_ => {
|
||||
unreachable!()
|
||||
bug!()
|
||||
}
|
||||
};
|
||||
|
||||
@ -1101,7 +1100,7 @@ fn create_trans_items_for_default_impls<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
unreachable!()
|
||||
bug!()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1252,8 +1251,8 @@ pub fn push_unique_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
ty::TyInfer(_) |
|
||||
ty::TyProjection(..) |
|
||||
ty::TyParam(_) => {
|
||||
cx.sess().bug(&format!("debuginfo: Trying to create type name for \
|
||||
unexpected type: {:?}", t));
|
||||
bug!("debuginfo: Trying to create type name for \
|
||||
unexpected type: {:?}", t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -194,9 +194,7 @@ impl<'tcx> VariantInfo<'tcx> {
|
||||
}
|
||||
|
||||
_ => {
|
||||
tcx.sess.bug(&format!(
|
||||
"cannot get field types from the type {:?}",
|
||||
ty));
|
||||
bug!("cannot get field types from the type {:?}", ty);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -209,7 +207,7 @@ impl<'tcx> VariantInfo<'tcx> {
|
||||
|
||||
pub fn field_index(&self, name: ast::Name) -> usize {
|
||||
self.fields.iter().position(|&Field(n,_)| n == name).unwrap_or_else(|| {
|
||||
panic!("unknown field `{}`", name)
|
||||
bug!("unknown field `{}`", name)
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -596,8 +594,7 @@ impl<'blk, 'tcx> BlockS<'blk, 'tcx> {
|
||||
match self.tcx().def_map.borrow().get(&nid) {
|
||||
Some(v) => v.full_def(),
|
||||
None => {
|
||||
self.tcx().sess.bug(&format!(
|
||||
"no def associated with node id {}", nid));
|
||||
bug!("no def associated with node id {}", nid);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -910,7 +907,7 @@ pub fn C_cstr(cx: &CrateContext, s: InternedString, null_terminated: bool) -> Va
|
||||
let gsym = token::gensym("str");
|
||||
let sym = format!("str{}", gsym.0);
|
||||
let g = declare::define_global(cx, &sym[..], val_ty(sc)).unwrap_or_else(||{
|
||||
cx.sess().bug(&format!("symbol `{}` is already defined", sym));
|
||||
bug!("symbol `{}` is already defined", sym);
|
||||
});
|
||||
llvm::LLVMSetInitializer(g, sc);
|
||||
llvm::LLVMSetGlobalConstant(g, True);
|
||||
@ -1102,11 +1099,11 @@ pub fn fulfill_obligation<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
"reached the recursion limit during monomorphization (selection ambiguity)");
|
||||
}
|
||||
Err(e) => {
|
||||
tcx.sess.span_bug(
|
||||
span_bug!(
|
||||
span,
|
||||
&format!("Encountered error `{:?}` selecting `{:?}` during trans",
|
||||
e,
|
||||
trait_ref))
|
||||
"Encountered error `{:?}` selecting `{:?}` during trans",
|
||||
e,
|
||||
trait_ref)
|
||||
}
|
||||
};
|
||||
|
||||
@ -1194,7 +1191,7 @@ pub fn inlined_variant_def<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
inlined_vid_def_id == v.did ||
|
||||
ccx.external().borrow().get(&v.did) == Some(&Some(inlined_vid))
|
||||
}).unwrap_or_else(|| {
|
||||
ccx.sess().bug(&format!("no variant for {:?}::{}", adt_def, inlined_vid))
|
||||
bug!("no variant for {:?}::{}", adt_def, inlined_vid)
|
||||
})
|
||||
}
|
||||
|
||||
@ -1255,6 +1252,6 @@ pub fn shift_mask_val<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
let mask = shift_mask_val(bcx, llty.element_type(), mask_llty.element_type(), invert);
|
||||
build::VectorSplat(bcx, mask_llty.vector_length(), mask)
|
||||
},
|
||||
_ => panic!("shift_mask_val: expected Integer or Vector, found {:?}", kind),
|
||||
_ => bug!("shift_mask_val: expected Integer or Vector, found {:?}", kind),
|
||||
}
|
||||
}
|
||||
|
@ -75,10 +75,10 @@ pub fn const_lit(cx: &CrateContext, e: &hir::Expr, lit: &ast::Lit)
|
||||
ty::TyUint(t) => {
|
||||
C_integral(Type::uint_from_ty(cx, t), i as u64, false)
|
||||
}
|
||||
_ => cx.sess().span_bug(lit.span,
|
||||
&format!("integer literal has type {:?} (expected int \
|
||||
or usize)",
|
||||
lit_int_ty))
|
||||
_ => span_bug!(lit.span,
|
||||
"integer literal has type {:?} (expected int \
|
||||
or usize)",
|
||||
lit_int_ty)
|
||||
}
|
||||
}
|
||||
LitKind::Float(ref fs, t) => {
|
||||
@ -91,7 +91,7 @@ pub fn const_lit(cx: &CrateContext, e: &hir::Expr, lit: &ast::Lit)
|
||||
C_floating(&fs, Type::float_from_ty(cx, t))
|
||||
}
|
||||
_ => {
|
||||
cx.sess().span_bug(lit.span,
|
||||
span_bug!(lit.span,
|
||||
"floating point literal doesn't have the right type");
|
||||
}
|
||||
}
|
||||
@ -121,7 +121,7 @@ fn addr_of_mut(ccx: &CrateContext,
|
||||
let gsym = token::gensym("_");
|
||||
let name = format!("{}{}", kind, gsym.0);
|
||||
let gv = declare::define_global(ccx, &name[..], val_ty(cv)).unwrap_or_else(||{
|
||||
ccx.sess().bug(&format!("symbol `{}` is already defined", name));
|
||||
bug!("symbol `{}` is already defined", name);
|
||||
});
|
||||
llvm::LLVMSetInitializer(gv, cv);
|
||||
llvm::LLVMSetAlignment(gv, align);
|
||||
@ -186,8 +186,7 @@ fn const_deref<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
}
|
||||
}
|
||||
None => {
|
||||
cx.sess().bug(&format!("unexpected dereferenceable type {:?}",
|
||||
ty))
|
||||
bug!("unexpected dereferenceable type {:?}", ty)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -232,7 +231,7 @@ pub fn get_const_expr<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
match lookup_const_by_id(ccx.tcx(), def_id, Some(substs)) {
|
||||
Some((ref expr, _ty)) => expr,
|
||||
None => {
|
||||
ccx.sess().span_bug(ref_expr.span, "constant item not found")
|
||||
span_bug!(ref_expr.span, "constant item not found")
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -357,7 +356,7 @@ pub fn const_expr<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
llconst = Callee::def(cx, def_id, substs).reify(cx).val;
|
||||
}
|
||||
_ => {
|
||||
unreachable!("{} cannot be reified to a fn ptr", ety)
|
||||
bug!("{} cannot be reified to a fn ptr", ety)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -441,9 +440,9 @@ pub fn const_expr<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
llvm::LLVMDumpValue(llconst);
|
||||
llvm::LLVMDumpValue(C_undef(llty));
|
||||
}
|
||||
cx.sess().bug(&format!("const {:?} of type {:?} has size {} instead of {}",
|
||||
e, ety_adjusted,
|
||||
csize, tsize));
|
||||
bug!("const {:?} of type {:?} has size {} instead of {}",
|
||||
e, ety_adjusted,
|
||||
csize, tsize);
|
||||
}
|
||||
Ok((llconst, ety_adjusted))
|
||||
}
|
||||
@ -550,7 +549,7 @@ fn const_err(cx: &CrateContext,
|
||||
fn check_binary_expr_validity(cx: &CrateContext, e: &hir::Expr, t: Ty,
|
||||
te1: ValueRef, te2: ValueRef,
|
||||
trueconst: TrueConst) -> Result<(), ConstEvalFailure> {
|
||||
let b = if let hir::ExprBinary(b, _, _) = e.node { b } else { unreachable!() };
|
||||
let b = if let hir::ExprBinary(b, _, _) = e.node { b } else { bug!() };
|
||||
let (lhs, rhs) = match (to_const_int(te1, t, cx.tcx()), to_const_int(te2, t, cx.tcx())) {
|
||||
(Some(v1), Some(v2)) => (v1, v2),
|
||||
_ => return Ok(()),
|
||||
@ -642,10 +641,10 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
},
|
||||
hir::BiEq | hir::BiNe | hir::BiLt | hir::BiLe | hir::BiGt | hir::BiGe => {
|
||||
if is_float {
|
||||
let cmp = base::bin_op_to_fcmp_predicate(cx, b.node);
|
||||
let cmp = base::bin_op_to_fcmp_predicate(b.node);
|
||||
ConstFCmp(cmp, te1, te2)
|
||||
} else {
|
||||
let cmp = base::bin_op_to_icmp_predicate(cx, b.node, signed);
|
||||
let cmp = base::bin_op_to_icmp_predicate(b.node, signed);
|
||||
ConstICmp(cmp, te1, te2)
|
||||
}
|
||||
},
|
||||
@ -669,13 +668,13 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
let brepr = adt::represent_type(cx, bt);
|
||||
let vinfo = VariantInfo::from_ty(cx.tcx(), bt, None);
|
||||
let ix = vinfo.field_index(field.node);
|
||||
adt::const_get_field(cx, &brepr, bv, vinfo.discr, ix)
|
||||
adt::const_get_field(&brepr, bv, vinfo.discr, ix)
|
||||
},
|
||||
hir::ExprTupField(ref base, idx) => {
|
||||
let (bv, bt) = const_expr(cx, &base, param_substs, fn_args, trueconst)?;
|
||||
let brepr = adt::represent_type(cx, bt);
|
||||
let vinfo = VariantInfo::from_ty(cx.tcx(), bt, None);
|
||||
adt::const_get_field(cx, &brepr, bv, vinfo.discr, idx.node)
|
||||
adt::const_get_field(&brepr, bv, vinfo.discr, idx.node)
|
||||
},
|
||||
hir::ExprIndex(ref base, ref index) => {
|
||||
let (bv, bt) = const_expr(cx, &base, param_substs, fn_args, trueconst)?;
|
||||
@ -683,7 +682,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
let iv = if let Some(iv) = const_to_opt_uint(iv) {
|
||||
iv
|
||||
} else {
|
||||
cx.sess().span_bug(index.span, "index is not an integer-constant expression");
|
||||
span_bug!(index.span, "index is not an integer-constant expression");
|
||||
};
|
||||
let (arr, len) = match bt.sty {
|
||||
ty::TyArray(_, u) => (bv, C_uint(cx, u)),
|
||||
@ -695,15 +694,15 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
ty::TyArray(_, u) => {
|
||||
(load_const(cx, bv, mt.ty), C_uint(cx, u))
|
||||
},
|
||||
_ => cx.sess().span_bug(base.span,
|
||||
&format!("index-expr base must be a vector \
|
||||
or string type, found {:?}",
|
||||
bt)),
|
||||
_ => span_bug!(base.span,
|
||||
"index-expr base must be a vector \
|
||||
or string type, found {:?}",
|
||||
bt),
|
||||
},
|
||||
_ => cx.sess().span_bug(base.span,
|
||||
&format!("index-expr base must be a vector \
|
||||
or string type, found {:?}",
|
||||
bt)),
|
||||
_ => span_bug!(base.span,
|
||||
"index-expr base must be a vector \
|
||||
or string type, found {:?}",
|
||||
bt),
|
||||
};
|
||||
|
||||
let len = unsafe { llvm::LLVMConstIntGetZExtValue(len) as u64 };
|
||||
@ -784,8 +783,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
llvm::LLVMConstPtrToInt(v, llty.to_ref())
|
||||
},
|
||||
_ => {
|
||||
cx.sess().impossible_case(e.span,
|
||||
"bad combination of types for cast")
|
||||
span_bug!(e.span, "bad combination of types for cast")
|
||||
},
|
||||
} } // unsafe { match ( ... ) {
|
||||
},
|
||||
@ -845,8 +843,8 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
(Some(ref f), _) => {
|
||||
const_expr(cx, &f.expr, param_substs, fn_args, trueconst).map(|(l, _)| l)
|
||||
},
|
||||
(_, Some((bv, _))) => Ok(adt::const_get_field(cx, &repr, bv, discr, ix)),
|
||||
(_, None) => cx.sess().span_bug(e.span, "missing struct field"),
|
||||
(_, Some((bv, _))) => Ok(adt::const_get_field(&repr, bv, discr, ix)),
|
||||
(_, None) => span_bug!(e.span, "missing struct field"),
|
||||
}
|
||||
})
|
||||
.collect::<Vec<Result<_, ConstEvalFailure>>>()
|
||||
@ -900,7 +898,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
if let Some(val) = fn_args.and_then(|args| args.get(&id).cloned()) {
|
||||
val
|
||||
} else {
|
||||
cx.sess().span_bug(e.span, "const fn argument not found")
|
||||
span_bug!(e.span, "const fn argument not found")
|
||||
}
|
||||
}
|
||||
Def::Fn(..) | Def::Method(..) => C_nil(cx),
|
||||
@ -917,15 +915,15 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
}
|
||||
ty::VariantKind::Tuple => C_nil(cx),
|
||||
ty::VariantKind::Struct => {
|
||||
cx.sess().span_bug(e.span, "path-expr refers to a dict variant!")
|
||||
span_bug!(e.span, "path-expr refers to a dict variant!")
|
||||
}
|
||||
}
|
||||
}
|
||||
// Unit struct or ctor.
|
||||
Def::Struct(..) => C_null(type_of::type_of(cx, ety)),
|
||||
_ => {
|
||||
cx.sess().span_bug(e.span, "expected a const, fn, struct, \
|
||||
or variant def")
|
||||
span_bug!(e.span, "expected a const, fn, struct, \
|
||||
or variant def")
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -969,7 +967,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
Disr::from(vinfo.disr_val),
|
||||
&arg_vals[..])
|
||||
}
|
||||
_ => cx.sess().span_bug(e.span, "expected a struct, variant, or const fn def"),
|
||||
_ => span_bug!(e.span, "expected a struct, variant, or const fn def"),
|
||||
}
|
||||
},
|
||||
hir::ExprMethodCall(_, _, ref args) => {
|
||||
@ -1003,14 +1001,14 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
substs);
|
||||
}
|
||||
_ =>
|
||||
cx.sess().span_bug(
|
||||
span_bug!(
|
||||
e.span,
|
||||
&format!("bad type for closure expr: {:?}", ety))
|
||||
"bad type for closure expr: {:?}", ety)
|
||||
}
|
||||
C_null(type_of::type_of(cx, ety))
|
||||
},
|
||||
_ => cx.sess().span_bug(e.span,
|
||||
"bad constant expression type in consts::const_expr"),
|
||||
_ => span_bug!(e.span,
|
||||
"bad constant expression type in consts::const_expr"),
|
||||
})
|
||||
}
|
||||
|
||||
@ -1105,7 +1103,7 @@ pub fn get_static<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, def_id: DefId)
|
||||
g
|
||||
}
|
||||
|
||||
item => unreachable!("get_static: expected static, found {:?}", item)
|
||||
item => bug!("get_static: expected static, found {:?}", item)
|
||||
}
|
||||
} else {
|
||||
// FIXME(nagisa): perhaps the map of externs could be offloaded to llvm somehow?
|
||||
|
@ -596,7 +596,7 @@ impl<'b, 'tcx> CrateContext<'b, 'tcx> {
|
||||
}
|
||||
match declare_intrinsic(self, key) {
|
||||
Some(v) => return v,
|
||||
None => panic!("unknown intrinsic '{}'", key)
|
||||
None => bug!("unknown intrinsic '{}'", key)
|
||||
}
|
||||
}
|
||||
|
||||
@ -785,7 +785,7 @@ impl<'b, 'tcx> CrateContext<'b, 'tcx> {
|
||||
match &self.sess().target.target.target_pointer_width[..] {
|
||||
"32" => 1 << 31,
|
||||
"64" => 1 << 47,
|
||||
_ => unreachable!() // error handled by config::build_target_config
|
||||
_ => bug!() // error handled by config::build_target_config
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -322,7 +322,7 @@ pub fn trans_break_cont<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
match bcx.tcx().def_map.borrow().get(&expr.id).map(|d| d.full_def()) {
|
||||
Some(Def::Label(loop_id)) => loop_id,
|
||||
r => {
|
||||
bcx.tcx().sess.bug(&format!("{:?} in def-map for label", r))
|
||||
bug!("{:?} in def-map for label", r)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -584,10 +584,10 @@ impl<'tcx> Datum<'tcx, Expr> {
|
||||
|
||||
/// Asserts that this datum *is* an lvalue and returns it.
|
||||
#[allow(dead_code)] // potentially useful
|
||||
pub fn assert_lvalue(self, bcx: Block) -> Datum<'tcx, Lvalue> {
|
||||
pub fn assert_lvalue(self) -> Datum<'tcx, Lvalue> {
|
||||
self.match_kind(
|
||||
|d| d,
|
||||
|_| bcx.sess().bug("assert_lvalue given rvalue"))
|
||||
|_| bug!("assert_lvalue given rvalue"))
|
||||
}
|
||||
|
||||
pub fn store_to_dest<'blk>(self,
|
||||
|
@ -98,7 +98,7 @@ fn with_new_scope<F>(cx: &CrateContext,
|
||||
}
|
||||
|
||||
if scope_stack.last().unwrap().scope_metadata != scope_metadata {
|
||||
cx.sess().span_bug(scope_span, "debuginfo: Inconsistency in scope management.");
|
||||
span_bug!(scope_span, "debuginfo: Inconsistency in scope management.");
|
||||
}
|
||||
|
||||
scope_stack.pop();
|
||||
|
@ -71,7 +71,7 @@ pub fn get_or_insert_gdb_debug_scripts_section_global(ccx: &CrateContext)
|
||||
|
||||
let section_var = declare::define_global(ccx, section_var_name,
|
||||
llvm_type).unwrap_or_else(||{
|
||||
ccx.sess().bug(&format!("symbol `{}` is already defined", section_var_name))
|
||||
bug!("symbol `{}` is already defined", section_var_name)
|
||||
});
|
||||
llvm::LLVMSetSection(section_var, section_name.as_ptr() as *const _);
|
||||
llvm::LLVMSetInitializer(section_var, C_bytes(ccx, section_contents));
|
||||
|
@ -102,25 +102,22 @@ impl<'tcx> TypeMap<'tcx> {
|
||||
// Adds a Ty to metadata mapping to the TypeMap. The method will fail if
|
||||
// the mapping already exists.
|
||||
fn register_type_with_metadata<'a>(&mut self,
|
||||
cx: &CrateContext<'a, 'tcx>,
|
||||
type_: Ty<'tcx>,
|
||||
metadata: DIType) {
|
||||
if self.type_to_metadata.insert(type_, metadata).is_some() {
|
||||
cx.sess().bug(&format!("Type metadata for Ty '{}' is already in the TypeMap!",
|
||||
type_));
|
||||
bug!("Type metadata for Ty '{}' is already in the TypeMap!", type_);
|
||||
}
|
||||
}
|
||||
|
||||
// Adds a UniqueTypeId to metadata mapping to the TypeMap. The method will
|
||||
// fail if the mapping already exists.
|
||||
fn register_unique_id_with_metadata(&mut self,
|
||||
cx: &CrateContext,
|
||||
unique_type_id: UniqueTypeId,
|
||||
metadata: DIType) {
|
||||
if self.unique_id_to_metadata.insert(unique_type_id, metadata).is_some() {
|
||||
let unique_type_id_str = self.get_unique_type_id_as_string(unique_type_id);
|
||||
cx.sess().bug(&format!("Type metadata for unique id '{}' is already in the TypeMap!",
|
||||
&unique_type_id_str[..]));
|
||||
bug!("Type metadata for unique id '{}' is already in the TypeMap!",
|
||||
&unique_type_id_str[..]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -305,8 +302,8 @@ impl<'tcx> TypeMap<'tcx> {
|
||||
}
|
||||
},
|
||||
_ => {
|
||||
cx.sess().bug(&format!("get_unique_type_id_of_type() - unexpected type: {:?}",
|
||||
type_))
|
||||
bug!("get_unique_type_id_of_type() - unexpected type: {:?}",
|
||||
type_)
|
||||
}
|
||||
};
|
||||
|
||||
@ -415,8 +412,8 @@ fn create_and_register_recursive_type_forward_declaration<'a, 'tcx>(
|
||||
|
||||
// Insert the stub into the TypeMap in order to allow for recursive references
|
||||
let mut type_map = debug_context(cx).type_map.borrow_mut();
|
||||
type_map.register_unique_id_with_metadata(cx, unique_type_id, metadata_stub);
|
||||
type_map.register_type_with_metadata(cx, unfinished_type, metadata_stub);
|
||||
type_map.register_unique_id_with_metadata(unique_type_id, metadata_stub);
|
||||
type_map.register_type_with_metadata(unfinished_type, metadata_stub);
|
||||
|
||||
UnfinishedMetadata {
|
||||
unfinished_type: unfinished_type,
|
||||
@ -452,10 +449,9 @@ impl<'tcx> RecursiveTypeDescription<'tcx> {
|
||||
let type_map = debug_context(cx).type_map.borrow();
|
||||
if type_map.find_metadata_for_unique_id(unique_type_id).is_none() ||
|
||||
type_map.find_metadata_for_type(unfinished_type).is_none() {
|
||||
cx.sess().bug(&format!("Forward declaration of potentially recursive type \
|
||||
'{:?}' was not found in TypeMap!",
|
||||
unfinished_type)
|
||||
);
|
||||
bug!("Forward declaration of potentially recursive type \
|
||||
'{:?}' was not found in TypeMap!",
|
||||
unfinished_type);
|
||||
}
|
||||
}
|
||||
|
||||
@ -640,9 +636,9 @@ fn trait_pointer_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
let def_id = match trait_type.sty {
|
||||
ty::TyTrait(ref data) => data.principal_def_id(),
|
||||
_ => {
|
||||
cx.sess().bug(&format!("debuginfo: Unexpected trait-object type in \
|
||||
trait_pointer_metadata(): {:?}",
|
||||
trait_type));
|
||||
bug!("debuginfo: Unexpected trait-object type in \
|
||||
trait_pointer_metadata(): {:?}",
|
||||
trait_type);
|
||||
}
|
||||
};
|
||||
|
||||
@ -688,7 +684,7 @@ pub fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
// There is already an equivalent type in the TypeMap.
|
||||
// Register this Ty as an alias in the cache and
|
||||
// return the cached metadata.
|
||||
type_map.register_type_with_metadata(cx, t, metadata);
|
||||
type_map.register_type_with_metadata(t, metadata);
|
||||
return metadata;
|
||||
},
|
||||
None => {
|
||||
@ -803,8 +799,7 @@ pub fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
usage_site_span).finalize(cx)
|
||||
}
|
||||
_ => {
|
||||
cx.sess().bug(&format!("debuginfo: unexpected type in type_metadata: {:?}",
|
||||
sty))
|
||||
bug!("debuginfo: unexpected type in type_metadata: {:?}", sty)
|
||||
}
|
||||
};
|
||||
|
||||
@ -818,13 +813,13 @@ pub fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
None => {
|
||||
let unique_type_id_str =
|
||||
type_map.get_unique_type_id_as_string(unique_type_id);
|
||||
let error_message = format!("Expected type metadata for unique \
|
||||
type id '{}' to already be in \
|
||||
the debuginfo::TypeMap but it \
|
||||
was not. (Ty = {})",
|
||||
&unique_type_id_str[..],
|
||||
t);
|
||||
cx.sess().span_bug(usage_site_span, &error_message[..]);
|
||||
span_bug!(usage_site_span,
|
||||
"Expected type metadata for unique \
|
||||
type id '{}' to already be in \
|
||||
the debuginfo::TypeMap but it \
|
||||
was not. (Ty = {})",
|
||||
&unique_type_id_str[..],
|
||||
t);
|
||||
}
|
||||
};
|
||||
|
||||
@ -833,22 +828,22 @@ pub fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
if metadata != metadata_for_uid {
|
||||
let unique_type_id_str =
|
||||
type_map.get_unique_type_id_as_string(unique_type_id);
|
||||
let error_message = format!("Mismatch between Ty and \
|
||||
UniqueTypeId maps in \
|
||||
debuginfo::TypeMap. \
|
||||
UniqueTypeId={}, Ty={}",
|
||||
&unique_type_id_str[..],
|
||||
t);
|
||||
cx.sess().span_bug(usage_site_span, &error_message[..]);
|
||||
span_bug!(usage_site_span,
|
||||
"Mismatch between Ty and \
|
||||
UniqueTypeId maps in \
|
||||
debuginfo::TypeMap. \
|
||||
UniqueTypeId={}, Ty={}",
|
||||
&unique_type_id_str[..],
|
||||
t);
|
||||
}
|
||||
}
|
||||
None => {
|
||||
type_map.register_type_with_metadata(cx, t, metadata);
|
||||
type_map.register_type_with_metadata(t, metadata);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
type_map.register_type_with_metadata(cx, t, metadata);
|
||||
type_map.register_unique_id_with_metadata(cx, unique_type_id, metadata);
|
||||
type_map.register_type_with_metadata(t, metadata);
|
||||
type_map.register_unique_id_with_metadata(unique_type_id, metadata);
|
||||
}
|
||||
}
|
||||
|
||||
@ -901,16 +896,16 @@ pub fn scope_metadata(fcx: &FunctionContext,
|
||||
error_reporting_span: Span)
|
||||
-> DIScope {
|
||||
let scope_map = &fcx.debug_context
|
||||
.get_ref(fcx.ccx, error_reporting_span)
|
||||
.get_ref(error_reporting_span)
|
||||
.scope_map;
|
||||
match scope_map.borrow().get(&node_id).cloned() {
|
||||
Some(scope_metadata) => scope_metadata,
|
||||
None => {
|
||||
let node = fcx.ccx.tcx().map.get(node_id);
|
||||
|
||||
fcx.ccx.sess().span_bug(error_reporting_span,
|
||||
&format!("debuginfo: Could not find scope info for node {:?}",
|
||||
node));
|
||||
span_bug!(error_reporting_span,
|
||||
"debuginfo: Could not find scope info for node {:?}",
|
||||
node);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -945,7 +940,7 @@ fn basic_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
ty::TyFloat(float_ty) => {
|
||||
(float_ty.ty_to_string(), DW_ATE_float)
|
||||
},
|
||||
_ => cx.sess().bug("debuginfo::basic_type_metadata - t is invalid type")
|
||||
_ => bug!("debuginfo::basic_type_metadata - t is invalid type")
|
||||
};
|
||||
|
||||
let llvm_type = type_of::type_of(cx, t);
|
||||
@ -1162,7 +1157,7 @@ fn prepare_struct_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
|
||||
let (variant, substs) = match struct_type.sty {
|
||||
ty::TyStruct(def, substs) => (def.struct_variant(), substs),
|
||||
_ => cx.tcx().sess.bug("prepare_struct_metadata on a non-struct")
|
||||
_ => bug!("prepare_struct_metadata on a non-struct")
|
||||
};
|
||||
|
||||
let (containing_scope, _) = get_namespace_and_span_for_item(cx, variant.did);
|
||||
@ -1362,7 +1357,7 @@ impl<'tcx> EnumMemberDescriptionFactory<'tcx> {
|
||||
ty::VariantKind::Struct => {
|
||||
non_null_variant.fields[0].name.to_string()
|
||||
}
|
||||
ty::VariantKind::Unit => unreachable!()
|
||||
ty::VariantKind::Unit => bug!()
|
||||
},
|
||||
llvm_type: non_null_llvm_type,
|
||||
type_metadata: non_null_type_metadata,
|
||||
@ -1452,7 +1447,7 @@ impl<'tcx> EnumMemberDescriptionFactory<'tcx> {
|
||||
}
|
||||
]
|
||||
},
|
||||
adt::CEnum(..) => cx.sess().span_bug(self.span, "This should be unreachable.")
|
||||
adt::CEnum(..) => span_bug!(self.span, "This should be unreachable.")
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1747,8 +1742,8 @@ fn set_members_of_composite_type(cx: &CrateContext,
|
||||
let mut composite_types_completed =
|
||||
debug_context(cx).composite_types_completed.borrow_mut();
|
||||
if composite_types_completed.contains(&composite_type_metadata) {
|
||||
cx.sess().bug("debuginfo::set_members_of_composite_type() - \
|
||||
Already completed forward declaration re-encountered.");
|
||||
bug!("debuginfo::set_members_of_composite_type() - \
|
||||
Already completed forward declaration re-encountered.");
|
||||
} else {
|
||||
composite_types_completed.insert(composite_type_metadata);
|
||||
}
|
||||
@ -1855,20 +1850,19 @@ pub fn create_global_var_metadata(cx: &CrateContext,
|
||||
hir::ItemStatic(..) => (item.name, item.span),
|
||||
hir::ItemConst(..) => (item.name, item.span),
|
||||
_ => {
|
||||
cx.sess()
|
||||
.span_bug(item.span,
|
||||
&format!("debuginfo::\
|
||||
create_global_var_metadata() -
|
||||
Captured var-id refers to \
|
||||
unexpected ast_item variant: {:?}",
|
||||
var_item))
|
||||
span_bug!(item.span,
|
||||
"debuginfo::\
|
||||
create_global_var_metadata() -
|
||||
Captured var-id refers to \
|
||||
unexpected ast_item variant: {:?}",
|
||||
var_item)
|
||||
}
|
||||
}
|
||||
},
|
||||
_ => cx.sess().bug(&format!("debuginfo::create_global_var_metadata() \
|
||||
- Captured var-id refers to unexpected \
|
||||
hir_map variant: {:?}",
|
||||
var_item))
|
||||
_ => bug!("debuginfo::create_global_var_metadata() \
|
||||
- Captured var-id refers to unexpected \
|
||||
hir_map variant: {:?}",
|
||||
var_item)
|
||||
};
|
||||
|
||||
let (file_metadata, line_number) = if span != codemap::DUMMY_SP {
|
||||
@ -1924,15 +1918,15 @@ pub fn create_local_var_metadata(bcx: Block, local: &hir::Local) {
|
||||
let datum = match locals.get(&node_id) {
|
||||
Some(datum) => datum,
|
||||
None => {
|
||||
bcx.sess().span_bug(span,
|
||||
&format!("no entry in lllocals table for {}",
|
||||
node_id));
|
||||
span_bug!(span,
|
||||
"no entry in lllocals table for {}",
|
||||
node_id);
|
||||
}
|
||||
};
|
||||
|
||||
if unsafe { llvm::LLVMIsAAllocaInst(datum.val) } == ptr::null_mut() {
|
||||
cx.sess().span_bug(span, "debuginfo::create_local_var_metadata() - \
|
||||
Referenced variable location is not an alloca!");
|
||||
span_bug!(span, "debuginfo::create_local_var_metadata() - \
|
||||
Referenced variable location is not an alloca!");
|
||||
}
|
||||
|
||||
let scope_metadata = scope_metadata(bcx.fcx, node_id, span);
|
||||
@ -1968,7 +1962,7 @@ pub fn create_captured_var_metadata<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
|
||||
let variable_name = match ast_item {
|
||||
None => {
|
||||
cx.sess().span_bug(span, "debuginfo::create_captured_var_metadata: node not found");
|
||||
span_bug!(span, "debuginfo::create_captured_var_metadata: node not found");
|
||||
}
|
||||
Some(hir_map::NodeLocal(pat)) => {
|
||||
match pat.node {
|
||||
@ -1976,28 +1970,25 @@ pub fn create_captured_var_metadata<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
path1.node.name
|
||||
}
|
||||
_ => {
|
||||
cx.sess()
|
||||
.span_bug(span,
|
||||
&format!(
|
||||
"debuginfo::create_captured_var_metadata() - \
|
||||
Captured var-id refers to unexpected \
|
||||
hir_map variant: {:?}",
|
||||
ast_item));
|
||||
span_bug!(span,
|
||||
"debuginfo::create_captured_var_metadata() - \
|
||||
Captured var-id refers to unexpected \
|
||||
hir_map variant: {:?}",
|
||||
ast_item);
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
cx.sess()
|
||||
.span_bug(span,
|
||||
&format!("debuginfo::create_captured_var_metadata() - \
|
||||
Captured var-id refers to unexpected \
|
||||
hir_map variant: {:?}",
|
||||
ast_item));
|
||||
span_bug!(span,
|
||||
"debuginfo::create_captured_var_metadata() - \
|
||||
Captured var-id refers to unexpected \
|
||||
hir_map variant: {:?}",
|
||||
ast_item);
|
||||
}
|
||||
};
|
||||
|
||||
let variable_type = common::node_id_type(bcx, node_id);
|
||||
let scope_metadata = bcx.fcx.debug_context.get_ref(cx, span).fn_metadata;
|
||||
let scope_metadata = bcx.fcx.debug_context.get_ref(span).fn_metadata;
|
||||
|
||||
// env_pointer is the alloca containing the pointer to the environment,
|
||||
// so it's type is **EnvironmentType. In order to find out the type of
|
||||
@ -2096,7 +2087,7 @@ pub fn create_argument_metadata(bcx: Block, arg: &hir::Arg) {
|
||||
let scope_metadata = bcx
|
||||
.fcx
|
||||
.debug_context
|
||||
.get_ref(bcx.ccx(), arg.pat.span)
|
||||
.get_ref(arg.pat.span)
|
||||
.fn_metadata;
|
||||
let locals = bcx.fcx.lllocals.borrow();
|
||||
|
||||
@ -2104,22 +2095,20 @@ pub fn create_argument_metadata(bcx: Block, arg: &hir::Arg) {
|
||||
let datum = match locals.get(&node_id) {
|
||||
Some(v) => v,
|
||||
None => {
|
||||
bcx.sess().span_bug(span,
|
||||
&format!("no entry in lllocals table for {}",
|
||||
node_id));
|
||||
span_bug!(span, "no entry in lllocals table for {}", node_id);
|
||||
}
|
||||
};
|
||||
|
||||
if unsafe { llvm::LLVMIsAAllocaInst(datum.val) } == ptr::null_mut() {
|
||||
bcx.sess().span_bug(span, "debuginfo::create_argument_metadata() - \
|
||||
Referenced variable location is not an alloca!");
|
||||
span_bug!(span, "debuginfo::create_argument_metadata() - \
|
||||
Referenced variable location is not an alloca!");
|
||||
}
|
||||
|
||||
let argument_index = {
|
||||
let counter = &bcx
|
||||
.fcx
|
||||
.debug_context
|
||||
.get_ref(bcx.ccx(), span)
|
||||
.get_ref(span)
|
||||
.argument_counter;
|
||||
let argument_index = counter.get();
|
||||
counter.set(argument_index + 1);
|
||||
|
@ -119,18 +119,19 @@ pub enum FunctionDebugContext {
|
||||
|
||||
impl FunctionDebugContext {
|
||||
fn get_ref<'a>(&'a self,
|
||||
cx: &CrateContext,
|
||||
span: Span)
|
||||
-> &'a FunctionDebugContextData {
|
||||
match *self {
|
||||
FunctionDebugContext::RegularContext(box ref data) => data,
|
||||
FunctionDebugContext::DebugInfoDisabled => {
|
||||
cx.sess().span_bug(span,
|
||||
FunctionDebugContext::debuginfo_disabled_message());
|
||||
span_bug!(span,
|
||||
"{}",
|
||||
FunctionDebugContext::debuginfo_disabled_message());
|
||||
}
|
||||
FunctionDebugContext::FunctionWithoutDebugInfo => {
|
||||
cx.sess().span_bug(span,
|
||||
FunctionDebugContext::should_be_ignored_message());
|
||||
span_bug!(span,
|
||||
"{}",
|
||||
FunctionDebugContext::should_be_ignored_message());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -253,7 +254,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
(item.name, fn_decl, generics, top_level_block, item.span, true)
|
||||
}
|
||||
_ => {
|
||||
cx.sess().span_bug(item.span,
|
||||
span_bug!(item.span,
|
||||
"create_function_debug_context: item bound to non-function");
|
||||
}
|
||||
}
|
||||
@ -273,9 +274,9 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
true)
|
||||
}
|
||||
_ => {
|
||||
cx.sess().span_bug(impl_item.span,
|
||||
"create_function_debug_context() \
|
||||
called on non-method impl item?!")
|
||||
span_bug!(impl_item.span,
|
||||
"create_function_debug_context() \
|
||||
called on non-method impl item?!")
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -293,7 +294,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
// Don't try to lookup the item path:
|
||||
false)
|
||||
}
|
||||
_ => cx.sess().span_bug(expr.span,
|
||||
_ => span_bug!(expr.span,
|
||||
"create_function_debug_context: expected an expr_fn_block here")
|
||||
}
|
||||
}
|
||||
@ -312,10 +313,9 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
true)
|
||||
}
|
||||
_ => {
|
||||
cx.sess()
|
||||
.bug(&format!("create_function_debug_context: \
|
||||
unexpected sort of node: {:?}",
|
||||
fnitem))
|
||||
bug!("create_function_debug_context: \
|
||||
unexpected sort of node: {:?}",
|
||||
fnitem)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -324,9 +324,9 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
hir_map::NodeStructCtor(..) => {
|
||||
return FunctionDebugContext::FunctionWithoutDebugInfo;
|
||||
}
|
||||
_ => cx.sess().bug(&format!("create_function_debug_context: \
|
||||
unexpected sort of node: {:?}",
|
||||
fnitem))
|
||||
_ => bug!("create_function_debug_context: \
|
||||
unexpected sort of node: {:?}",
|
||||
fnitem)
|
||||
};
|
||||
|
||||
// This can be the case for functions inlined from another crate
|
||||
@ -441,7 +441,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
(sig, closure_type.abi)
|
||||
}
|
||||
|
||||
_ => cx.sess().bug("get_function_metdata: Expected a function type!")
|
||||
_ => bug!("get_function_metdata: Expected a function type!")
|
||||
};
|
||||
|
||||
let mut signature = Vec::with_capacity(sig.inputs.len() + 1);
|
||||
@ -640,7 +640,7 @@ fn declare_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
ArgumentVariable(_) | CapturedVariable => {
|
||||
assert!(!bcx.fcx
|
||||
.debug_context
|
||||
.get_ref(cx, span)
|
||||
.get_ref(span)
|
||||
.source_locations_enabled
|
||||
.get());
|
||||
source_loc::set_debug_location(cx, InternalDebugLocation::UnknownLocation);
|
||||
|
@ -126,9 +126,9 @@ pub fn namespace_for_item(cx: &CrateContext, def_id: DefId) -> Rc<NamespaceTreeN
|
||||
match parent_node {
|
||||
Some(node) => node,
|
||||
None => {
|
||||
cx.sess().bug(&format!("debuginfo::namespace_for_item(): \
|
||||
path too short for {:?}",
|
||||
def_id));
|
||||
bug!("debuginfo::namespace_for_item(): \
|
||||
path too short for {:?}",
|
||||
def_id);
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -154,8 +154,8 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
ty::TyInfer(_) |
|
||||
ty::TyProjection(..) |
|
||||
ty::TyParam(_) => {
|
||||
cx.sess().bug(&format!("debuginfo: Trying to create type name for \
|
||||
unexpected type: {:?}", t));
|
||||
bug!("debuginfo: Trying to create type name for \
|
||||
unexpected type: {:?}", t);
|
||||
}
|
||||
}
|
||||
|
||||
@ -178,7 +178,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
}
|
||||
|
||||
if path_element_count == 0 {
|
||||
cx.sess().bug("debuginfo: Encountered empty item path!");
|
||||
bug!("debuginfo: Encountered empty item path!");
|
||||
}
|
||||
|
||||
output.pop();
|
||||
|
@ -91,8 +91,8 @@ pub fn assert_type_for_node_id(cx: &CrateContext,
|
||||
node_id: ast::NodeId,
|
||||
error_reporting_span: Span) {
|
||||
if !cx.tcx().node_types().contains_key(&node_id) {
|
||||
cx.sess().span_bug(error_reporting_span,
|
||||
"debuginfo: Could not find type for node id!");
|
||||
span_bug!(error_reporting_span,
|
||||
"debuginfo: Could not find type for node id!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ use libc::c_uint;
|
||||
pub fn declare_global(ccx: &CrateContext, name: &str, ty: Type) -> llvm::ValueRef {
|
||||
debug!("declare_global(name={:?})", name);
|
||||
let namebuf = CString::new(name).unwrap_or_else(|_|{
|
||||
ccx.sess().bug(&format!("name {:?} contains an interior null byte", name))
|
||||
bug!("name {:?} contains an interior null byte", name)
|
||||
});
|
||||
unsafe {
|
||||
llvm::LLVMGetOrInsertGlobal(ccx.llmod(), namebuf.as_ptr(), ty.to_ref())
|
||||
@ -53,7 +53,7 @@ pub fn declare_global(ccx: &CrateContext, name: &str, ty: Type) -> llvm::ValueRe
|
||||
fn declare_raw_fn(ccx: &CrateContext, name: &str, callconv: llvm::CallConv, ty: Type) -> ValueRef {
|
||||
debug!("declare_raw_fn(name={:?}, ty={:?})", name, ty);
|
||||
let namebuf = CString::new(name).unwrap_or_else(|_|{
|
||||
ccx.sess().bug(&format!("name {:?} contains an interior null byte", name))
|
||||
bug!("name {:?} contains an interior null byte", name)
|
||||
});
|
||||
let llfn = unsafe {
|
||||
llvm::LLVMGetOrInsertFunction(ccx.llmod(), namebuf.as_ptr(), ty.to_ref())
|
||||
@ -152,7 +152,7 @@ pub fn define_internal_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
pub fn get_defined_value(ccx: &CrateContext, name: &str) -> Option<ValueRef> {
|
||||
debug!("get_defined_value(name={:?})", name);
|
||||
let namebuf = CString::new(name).unwrap_or_else(|_|{
|
||||
ccx.sess().bug(&format!("name {:?} contains an interior null byte", name))
|
||||
bug!("name {:?} contains an interior null byte", name)
|
||||
});
|
||||
let val = unsafe { llvm::LLVMGetNamedValue(ccx.llmod(), namebuf.as_ptr()) };
|
||||
if val.is_null() {
|
||||
|
@ -388,7 +388,7 @@ fn apply_adjustments<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
.reify(bcx.ccx()).to_expr_datum();
|
||||
}
|
||||
_ => {
|
||||
unreachable!("{} cannot be reified to a fn ptr", datum.ty)
|
||||
bug!("{} cannot be reified to a fn ptr", datum.ty)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -516,16 +516,16 @@ fn coerce_unsized<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
let repr_source = adt::represent_type(bcx.ccx(), source.ty);
|
||||
let src_fields = match &*repr_source {
|
||||
&adt::Repr::Univariant(ref s, _) => &s.fields,
|
||||
_ => bcx.sess().span_bug(span,
|
||||
&format!("Non univariant struct? (repr_source: {:?})",
|
||||
repr_source)),
|
||||
_ => span_bug!(span,
|
||||
"Non univariant struct? (repr_source: {:?})",
|
||||
repr_source),
|
||||
};
|
||||
let repr_target = adt::represent_type(bcx.ccx(), target.ty);
|
||||
let target_fields = match &*repr_target {
|
||||
&adt::Repr::Univariant(ref s, _) => &s.fields,
|
||||
_ => bcx.sess().span_bug(span,
|
||||
&format!("Non univariant struct? (repr_target: {:?})",
|
||||
repr_target)),
|
||||
_ => span_bug!(span,
|
||||
"Non univariant struct? (repr_target: {:?})",
|
||||
repr_target),
|
||||
};
|
||||
|
||||
let coerce_index = match kind {
|
||||
@ -555,9 +555,9 @@ fn coerce_unsized<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => bcx.sess().bug(&format!("coerce_unsized: invalid coercion {:?} -> {:?}",
|
||||
source.ty,
|
||||
target.ty))
|
||||
_ => bug!("coerce_unsized: invalid coercion {:?} -> {:?}",
|
||||
source.ty,
|
||||
target.ty)
|
||||
}
|
||||
bcx
|
||||
}
|
||||
@ -671,8 +671,8 @@ fn trans_datum_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
ty::TyBox(..) => {
|
||||
trans_uniq_expr(bcx, expr, box_ty, &contents, contents_ty)
|
||||
}
|
||||
_ => bcx.sess().span_bug(expr.span,
|
||||
"expected unique box")
|
||||
_ => span_bug!(expr.span,
|
||||
"expected unique box")
|
||||
}
|
||||
|
||||
}
|
||||
@ -708,11 +708,11 @@ fn trans_datum_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
trans_imm_cast(bcx, &val, expr.id)
|
||||
}
|
||||
_ => {
|
||||
bcx.tcx().sess.span_bug(
|
||||
span_bug!(
|
||||
expr.span,
|
||||
&format!("trans_rvalue_datum_unadjusted reached \
|
||||
fall-through case: {:?}",
|
||||
expr.node));
|
||||
"trans_rvalue_datum_unadjusted reached \
|
||||
fall-through case: {:?}",
|
||||
expr.node);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -798,9 +798,9 @@ fn trans_index<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
bcx.tcx().no_late_bound_regions(&method_ty.fn_ret()).unwrap().unwrap();
|
||||
let elt_ty = match ref_ty.builtin_deref(true, ty::NoPreference) {
|
||||
None => {
|
||||
bcx.tcx().sess.span_bug(index_expr.span,
|
||||
"index method didn't return a \
|
||||
dereferenceable type?!")
|
||||
span_bug!(index_expr.span,
|
||||
"index method didn't return a \
|
||||
dereferenceable type?!")
|
||||
}
|
||||
Some(elt_tm) => elt_tm.ty,
|
||||
};
|
||||
@ -895,9 +895,7 @@ pub fn trans_var<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, def: Def)
|
||||
match bcx.fcx.llupvars.borrow().get(&nid) {
|
||||
Some(&val) => Datum::new(val, local_ty, lval),
|
||||
None => {
|
||||
bcx.sess().bug(&format!(
|
||||
"trans_var: no llval for upvar {} found",
|
||||
nid));
|
||||
bug!("trans_var: no llval for upvar {} found", nid);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -905,16 +903,14 @@ pub fn trans_var<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, def: Def)
|
||||
let datum = match bcx.fcx.lllocals.borrow().get(&nid) {
|
||||
Some(&v) => v,
|
||||
None => {
|
||||
bcx.sess().bug(&format!(
|
||||
"trans_var: no datum for local/arg {} found",
|
||||
nid));
|
||||
bug!("trans_var: no datum for local/arg {} found", nid);
|
||||
}
|
||||
};
|
||||
debug!("take_local(nid={}, v={:?}, ty={})",
|
||||
nid, Value(datum.val), datum.ty);
|
||||
datum
|
||||
}
|
||||
_ => unreachable!("{:?} should not reach expr::trans_var", def)
|
||||
_ => bug!("{:?} should not reach expr::trans_var", def)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1051,11 +1047,11 @@ fn trans_rvalue_stmt_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
bcx
|
||||
}
|
||||
_ => {
|
||||
bcx.tcx().sess.span_bug(
|
||||
span_bug!(
|
||||
expr.span,
|
||||
&format!("trans_rvalue_stmt_unadjusted reached \
|
||||
fall-through case: {:?}",
|
||||
expr.node));
|
||||
"trans_rvalue_stmt_unadjusted reached \
|
||||
fall-through case: {:?}",
|
||||
expr.node);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1114,11 +1110,9 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
tvec::trans_lit_str(bcx, expr, (*s).clone(), dest)
|
||||
}
|
||||
_ => {
|
||||
bcx.tcx()
|
||||
.sess
|
||||
.span_bug(expr.span,
|
||||
"trans_rvalue_dps_unadjusted shouldn't be \
|
||||
translating this type of literal")
|
||||
span_bug!(expr.span,
|
||||
"trans_rvalue_dps_unadjusted shouldn't be \
|
||||
translating this type of literal")
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1141,9 +1135,9 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
let (def_id, substs) = match expr_ty(bcx, expr).sty {
|
||||
ty::TyClosure(def_id, ref substs) => (def_id, substs),
|
||||
ref t =>
|
||||
bcx.tcx().sess.span_bug(
|
||||
span_bug!(
|
||||
expr.span,
|
||||
&format!("closure expr without closure type: {:?}", t)),
|
||||
"closure expr without closure type: {:?}", t),
|
||||
};
|
||||
|
||||
closure::trans_closure_expr(dest,
|
||||
@ -1172,8 +1166,8 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
Callee::ptr(f)
|
||||
}
|
||||
_ => {
|
||||
bcx.tcx().sess.span_bug(expr.span,
|
||||
&format!("type of callee is not a fn: {}", f.ty));
|
||||
span_bug!(expr.span,
|
||||
"type of callee is not a fn: {}", f.ty);
|
||||
}
|
||||
}, ArgExprs(&args))
|
||||
};
|
||||
@ -1205,20 +1199,20 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
}
|
||||
hir::ExprCast(..) => {
|
||||
// Trait casts used to come this way, now they should be coercions.
|
||||
bcx.tcx().sess.span_bug(expr.span, "DPS expr_cast (residual trait cast?)")
|
||||
span_bug!(expr.span, "DPS expr_cast (residual trait cast?)")
|
||||
}
|
||||
hir::ExprAssignOp(op, _, _) => {
|
||||
bcx.tcx().sess.span_bug(
|
||||
span_bug!(
|
||||
expr.span,
|
||||
&format!("augmented assignment `{}=` should always be a rvalue_stmt",
|
||||
rustc_front::util::binop_to_string(op.node)))
|
||||
"augmented assignment `{}=` should always be a rvalue_stmt",
|
||||
rustc_front::util::binop_to_string(op.node))
|
||||
}
|
||||
_ => {
|
||||
bcx.tcx().sess.span_bug(
|
||||
span_bug!(
|
||||
expr.span,
|
||||
&format!("trans_rvalue_dps_unadjusted reached fall-through \
|
||||
case: {:?}",
|
||||
expr.node));
|
||||
"trans_rvalue_dps_unadjusted reached fall-through \
|
||||
case: {:?}",
|
||||
expr.node);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1261,9 +1255,9 @@ fn trans_def_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
bcx
|
||||
}
|
||||
_ => {
|
||||
bcx.tcx().sess.span_bug(ref_expr.span, &format!(
|
||||
"Non-DPS def {:?} referened by {}",
|
||||
def, bcx.node_id_to_string(ref_expr.id)));
|
||||
span_bug!(ref_expr.span,
|
||||
"Non-DPS def {:?} referened by {}",
|
||||
def, bcx.node_id_to_string(ref_expr.id));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1301,7 +1295,7 @@ fn trans_struct<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
}
|
||||
None => {
|
||||
if need_base.iter().any(|b| *b) {
|
||||
tcx.sess.span_bug(expr_span, "missing fields and no base expr")
|
||||
span_bug!(expr_span, "missing fields and no base expr")
|
||||
}
|
||||
None
|
||||
}
|
||||
@ -1415,7 +1409,7 @@ pub fn trans_adt<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
||||
bcx = trans_into(bcx, &base.expr, SaveIn(addr.value));
|
||||
},
|
||||
ExprKind::RvalueStmt => {
|
||||
bcx.tcx().sess.bug("unexpected expr kind for struct base expr")
|
||||
bug!("unexpected expr kind for struct base expr")
|
||||
}
|
||||
_ => {
|
||||
let base_datum = unpack_datum!(bcx, trans_to_lvalue(bcx, &base.expr, "base"));
|
||||
@ -1728,7 +1722,7 @@ fn trans_scalar_binop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
base::compare_scalar_types(bcx, lhs, rhs, lhs_t, op.node, binop_debug_loc)
|
||||
}
|
||||
_ => {
|
||||
bcx.tcx().sess.span_bug(binop_expr.span, "unexpected binop");
|
||||
span_bug!(binop_expr.span, "unexpected binop");
|
||||
}
|
||||
};
|
||||
|
||||
@ -1968,12 +1962,11 @@ fn trans_imm_cast<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
(Float, Int(I)) => FPToSI(bcx, llexpr, ll_t_out),
|
||||
(Float, Int(_)) => FPToUI(bcx, llexpr, ll_t_out),
|
||||
|
||||
_ => ccx.sess().span_bug(expr.span,
|
||||
&format!("translating unsupported cast: \
|
||||
{:?} -> {:?}",
|
||||
t_in,
|
||||
t_out)
|
||||
)
|
||||
_ => span_bug!(expr.span,
|
||||
"translating unsupported cast: \
|
||||
{:?} -> {:?}",
|
||||
t_in,
|
||||
t_out)
|
||||
};
|
||||
return immediate_rvalue_bcx(bcx, newval, t_out).to_expr_datumblock();
|
||||
}
|
||||
@ -2140,10 +2133,10 @@ fn deref_once<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
}
|
||||
|
||||
_ => {
|
||||
bcx.tcx().sess.span_bug(
|
||||
span_bug!(
|
||||
expr.span,
|
||||
&format!("deref invoked on expr of invalid type {:?}",
|
||||
datum.ty));
|
||||
"deref invoked on expr of invalid type {:?}",
|
||||
datum.ty);
|
||||
}
|
||||
};
|
||||
|
||||
@ -2200,16 +2193,16 @@ impl OverflowOpViaIntrinsic {
|
||||
TyInt(Is) => match &tcx.sess.target.target.target_pointer_width[..] {
|
||||
"32" => TyInt(I32),
|
||||
"64" => TyInt(I64),
|
||||
_ => panic!("unsupported target word size")
|
||||
_ => bug!("unsupported target word size")
|
||||
},
|
||||
TyUint(Us) => match &tcx.sess.target.target.target_pointer_width[..] {
|
||||
"32" => TyUint(U32),
|
||||
"64" => TyUint(U64),
|
||||
_ => panic!("unsupported target word size")
|
||||
_ => bug!("unsupported target word size")
|
||||
},
|
||||
ref t @ TyUint(_) | ref t @ TyInt(_) => t.clone(),
|
||||
_ => panic!("tried to get overflow intrinsic for {:?} applied to non-int type",
|
||||
*self)
|
||||
_ => bug!("tried to get overflow intrinsic for {:?} applied to non-int type",
|
||||
*self)
|
||||
};
|
||||
|
||||
match *self {
|
||||
@ -2224,7 +2217,7 @@ impl OverflowOpViaIntrinsic {
|
||||
TyUint(U32) => "llvm.uadd.with.overflow.i32",
|
||||
TyUint(U64) => "llvm.uadd.with.overflow.i64",
|
||||
|
||||
_ => unreachable!(),
|
||||
_ => bug!(),
|
||||
},
|
||||
OverflowOpViaIntrinsic::Sub => match new_sty {
|
||||
TyInt(I8) => "llvm.ssub.with.overflow.i8",
|
||||
@ -2237,7 +2230,7 @@ impl OverflowOpViaIntrinsic {
|
||||
TyUint(U32) => "llvm.usub.with.overflow.i32",
|
||||
TyUint(U64) => "llvm.usub.with.overflow.i64",
|
||||
|
||||
_ => unreachable!(),
|
||||
_ => bug!(),
|
||||
},
|
||||
OverflowOpViaIntrinsic::Mul => match new_sty {
|
||||
TyInt(I8) => "llvm.smul.with.overflow.i8",
|
||||
@ -2250,7 +2243,7 @@ impl OverflowOpViaIntrinsic {
|
||||
TyUint(U32) => "llvm.umul.with.overflow.i32",
|
||||
TyUint(U64) => "llvm.umul.with.overflow.i64",
|
||||
|
||||
_ => unreachable!(),
|
||||
_ => bug!(),
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -2337,7 +2330,7 @@ fn build_nonzero_check<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
let int_value = BitCast(bcx, value, Type::ix(bcx.ccx(), width));
|
||||
build_nonzero_check(bcx, int_value, binop_debug_loc)
|
||||
},
|
||||
_ => panic!("build_nonzero_check: expected Integer or Vector, found {:?}", kind),
|
||||
_ => bug!("build_nonzero_check: expected Integer or Vector, found {:?}", kind),
|
||||
}
|
||||
}
|
||||
|
||||
@ -2423,11 +2416,11 @@ fn expr_kind(tcx: &TyCtxt, expr: &hir::Expr) -> ExprKind {
|
||||
Def::AssociatedConst(..) => ExprKind::RvalueDatum,
|
||||
|
||||
def => {
|
||||
tcx.sess.span_bug(
|
||||
span_bug!(
|
||||
expr.span,
|
||||
&format!("uncategorized def for expr {}: {:?}",
|
||||
expr.id,
|
||||
def));
|
||||
"uncategorized def for expr {}: {:?}",
|
||||
expr.id,
|
||||
def);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -367,7 +367,7 @@ fn trans_struct_drop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
});
|
||||
let vtbl = match fulfill_obligation(bcx.ccx(), DUMMY_SP, trait_ref) {
|
||||
traits::VtableImpl(data) => data,
|
||||
_ => tcx.sess.bug(&format!("dtor for {:?} is not an impl???", t))
|
||||
_ => bug!("dtor for {:?} is not an impl???", t)
|
||||
};
|
||||
let dtor_did = def.destructor().unwrap();
|
||||
bcx = Callee::def(bcx.ccx(), dtor_did, vtbl.substs)
|
||||
@ -482,7 +482,7 @@ pub fn size_and_align_of_dst<'blk, 'tcx>(bcx: &BlockAndBuilder<'blk, 'tcx>,
|
||||
(bcx.mul(info, C_uint(bcx.ccx(), unit_size)),
|
||||
C_uint(bcx.ccx(), unit_align))
|
||||
}
|
||||
_ => bcx.sess().bug(&format!("Unexpected unsized type, found {}", t))
|
||||
_ => bug!("Unexpected unsized type, found {}", t)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,16 +102,16 @@ fn instantiate_inline(ccx: &CrateContext, fn_id: DefId) -> Option<DefId> {
|
||||
}
|
||||
hir::ItemStruct(ref struct_def, _) => {
|
||||
if struct_def.is_struct() {
|
||||
ccx.sess().bug("instantiate_inline: called on a \
|
||||
non-tuple struct")
|
||||
bug!("instantiate_inline: called on a \
|
||||
non-tuple struct")
|
||||
} else {
|
||||
ccx.external().borrow_mut().insert(fn_id, Some(struct_def.id()));
|
||||
ccx.external_srcs().borrow_mut().insert(struct_def.id(), fn_id);
|
||||
my_id = struct_def.id();
|
||||
}
|
||||
}
|
||||
_ => ccx.sess().bug("instantiate_inline: item has a \
|
||||
non-enum, non-struct parent")
|
||||
_ => bug!("instantiate_inline: item has a \
|
||||
non-enum, non-struct parent")
|
||||
}
|
||||
my_id
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
||||
let sig = tcx.erase_late_bound_regions(&fty.sig);
|
||||
(def_id, substs, infer::normalize_associated_type(tcx, &sig))
|
||||
}
|
||||
_ => unreachable!("expected fn item type, found {}", callee_ty)
|
||||
_ => bug!("expected fn item type, found {}", callee_ty)
|
||||
};
|
||||
let arg_tys = sig.inputs;
|
||||
let ret_ty = sig.output;
|
||||
@ -311,7 +311,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
||||
}
|
||||
|
||||
_ => {
|
||||
ccx.sess().bug("expected expr as argument for transmute");
|
||||
bug!("expected expr as argument for transmute");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -323,7 +323,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
||||
if name == "move_val_init" {
|
||||
if let callee::ArgExprs(ref exprs) = args {
|
||||
let (dest_expr, source_expr) = if exprs.len() != 2 {
|
||||
ccx.sess().bug("expected two exprs as arguments for `move_val_init` intrinsic");
|
||||
bug!("expected two exprs as arguments for `move_val_init` intrinsic");
|
||||
} else {
|
||||
(&exprs[0], &exprs[1])
|
||||
};
|
||||
@ -350,7 +350,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
||||
|
||||
return Result::new(bcx, llresult);
|
||||
} else {
|
||||
ccx.sess().bug("expected two exprs as arguments for `move_val_init` intrinsic");
|
||||
bug!("expected two exprs as arguments for `move_val_init` intrinsic");
|
||||
}
|
||||
}
|
||||
|
||||
@ -388,7 +388,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
||||
|
||||
let ret_ty = match ret_ty {
|
||||
ty::FnConverging(ret_ty) => ret_ty,
|
||||
ty::FnDiverging => unreachable!()
|
||||
ty::FnDiverging => bug!()
|
||||
};
|
||||
|
||||
let llret_ty = type_of::type_of(ccx, ret_ty);
|
||||
@ -651,7 +651,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
||||
} else {
|
||||
URem(bcx, llargs[0], llargs[1], call_debug_location)
|
||||
},
|
||||
_ => unreachable!(),
|
||||
_ => bug!(),
|
||||
},
|
||||
None => {
|
||||
span_invalid_monomorphization_error(
|
||||
@ -674,7 +674,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
||||
"fmul_fast" => FMulFast(bcx, llargs[0], llargs[1], call_debug_location),
|
||||
"fdiv_fast" => FDivFast(bcx, llargs[0], llargs[1], call_debug_location),
|
||||
"frem_fast" => FRemFast(bcx, llargs[0], llargs[1], call_debug_location),
|
||||
_ => unreachable!(),
|
||||
_ => bug!(),
|
||||
},
|
||||
None => {
|
||||
span_invalid_monomorphization_error(
|
||||
@ -820,7 +820,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
||||
(_, _) => {
|
||||
let intr = match Intrinsic::find(&name) {
|
||||
Some(intr) => intr,
|
||||
None => unreachable!("unknown intrinsic '{}'", name),
|
||||
None => bug!("unknown intrinsic '{}'", name),
|
||||
};
|
||||
fn one<T>(x: Vec<T>) -> T {
|
||||
assert_eq!(x.len(), 1);
|
||||
@ -839,7 +839,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
||||
match x {
|
||||
32 => vec![Type::f32(ccx)],
|
||||
64 => vec![Type::f64(ccx)],
|
||||
_ => unreachable!()
|
||||
_ => bug!()
|
||||
}
|
||||
}
|
||||
Pointer(ref t, ref llvm_elem, _const) => {
|
||||
@ -1242,7 +1242,7 @@ fn trans_gnu_try<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
Some(did) => {
|
||||
Callee::def(ccx, did, tcx.mk_substs(Substs::empty())).reify(ccx).val
|
||||
}
|
||||
None => ccx.sess().bug("eh_personality_catch not defined"),
|
||||
None => bug!("eh_personality_catch not defined"),
|
||||
};
|
||||
|
||||
let then = bcx.fcx.new_temp_block("then");
|
||||
@ -1357,7 +1357,7 @@ fn generate_filter_fn<'a, 'tcx>(fcx: &FunctionContext<'a, 'tcx>,
|
||||
Some(did) => {
|
||||
Callee::def(ccx, did, tcx.mk_substs(Substs::empty())).reify(ccx).val
|
||||
}
|
||||
None => ccx.sess().bug("msvc_try_filter not defined"),
|
||||
None => bug!("msvc_try_filter not defined"),
|
||||
};
|
||||
|
||||
let output = ty::FnOutput::FnConverging(tcx.types.i32);
|
||||
@ -1417,7 +1417,7 @@ fn generate_filter_fn<'a, 'tcx>(fcx: &FunctionContext<'a, 'tcx>,
|
||||
do_trans(bcx, exn, rbp);
|
||||
})
|
||||
} else {
|
||||
panic!("unknown target to generate a filter function")
|
||||
bug!("unknown target to generate a filter function")
|
||||
}
|
||||
}
|
||||
|
||||
@ -1513,8 +1513,8 @@ fn generic_simd_intrinsic<'blk, 'tcx, 'a>
|
||||
if name.starts_with("simd_shuffle") {
|
||||
let n: usize = match name["simd_shuffle".len()..].parse() {
|
||||
Ok(n) => n,
|
||||
Err(_) => tcx.sess.span_bug(span,
|
||||
"bad `simd_shuffle` instruction only caught in trans?")
|
||||
Err(_) => span_bug!(span,
|
||||
"bad `simd_shuffle` instruction only caught in trans?")
|
||||
};
|
||||
|
||||
require_simd!(ret_ty, "return");
|
||||
@ -1687,7 +1687,7 @@ fn generic_simd_intrinsic<'blk, 'tcx, 'a>
|
||||
simd_or: TyUint, TyInt => Or;
|
||||
simd_xor: TyUint, TyInt => Xor;
|
||||
}
|
||||
bcx.sess().span_bug(span, "unknown SIMD intrinsic");
|
||||
span_bug!(span, "unknown SIMD intrinsic");
|
||||
}
|
||||
|
||||
// Returns the width of an int TypeVariant, and if it's signed or not
|
||||
@ -1701,7 +1701,7 @@ fn int_type_width_signed<'tcx>(sty: &ty::TypeVariants<'tcx>, ccx: &CrateContext)
|
||||
match &ccx.tcx().sess.target.target.target_pointer_width[..] {
|
||||
"32" => 32,
|
||||
"64" => 64,
|
||||
tws => panic!("Unsupported target word size for isize: {}", tws),
|
||||
tws => bug!("Unsupported target word size for isize: {}", tws),
|
||||
}
|
||||
},
|
||||
ast::IntTy::I8 => 8,
|
||||
@ -1714,7 +1714,7 @@ fn int_type_width_signed<'tcx>(sty: &ty::TypeVariants<'tcx>, ccx: &CrateContext)
|
||||
match &ccx.tcx().sess.target.target.target_pointer_width[..] {
|
||||
"32" => 32,
|
||||
"64" => 64,
|
||||
tws => panic!("Unsupported target word size for usize: {}", tws),
|
||||
tws => bug!("Unsupported target word size for usize: {}", tws),
|
||||
}
|
||||
},
|
||||
ast::UintTy::U8 => 8,
|
||||
|
@ -43,7 +43,7 @@ extern crate flate;
|
||||
extern crate getopts;
|
||||
extern crate graphviz;
|
||||
extern crate libc;
|
||||
extern crate rustc;
|
||||
#[macro_use] extern crate rustc;
|
||||
extern crate rustc_back;
|
||||
extern crate rustc_data_structures;
|
||||
extern crate rustc_front;
|
||||
|
@ -186,15 +186,13 @@ pub fn get_vtable<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
// this would imply that the Self type being erased is
|
||||
// an object type; this cannot happen because we
|
||||
// cannot cast an unsized type into a trait object
|
||||
tcx.sess.bug(
|
||||
&format!("cannot get vtable for an object type: {:?}",
|
||||
data));
|
||||
bug!("cannot get vtable for an object type: {:?}",
|
||||
data);
|
||||
}
|
||||
traits::VtableParam(..) => {
|
||||
tcx.sess.bug(
|
||||
&format!("resolved vtable for {:?} to bad vtable {:?} in trans",
|
||||
trait_ref,
|
||||
vtable));
|
||||
bug!("resolved vtable for {:?} to bad vtable {:?} in trans",
|
||||
trait_ref,
|
||||
vtable);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -229,8 +227,8 @@ pub fn get_vtable_methods<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
|
||||
let trt_id = match tcx.impl_trait_ref(impl_id) {
|
||||
Some(t_id) => t_id.def_id,
|
||||
None => ccx.sess().bug("make_impl_vtable: don't know how to \
|
||||
make a vtable for a type impl!")
|
||||
None => bug!("make_impl_vtable: don't know how to \
|
||||
make a vtable for a type impl!")
|
||||
};
|
||||
|
||||
tcx.populate_implementations_for_trait_if_necessary(trt_id);
|
||||
@ -256,7 +254,7 @@ pub fn get_vtable_methods<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
|
||||
let trait_method_type = match tcx.impl_or_trait_item(trait_method_def_id) {
|
||||
ty::MethodTraitItem(m) => m,
|
||||
_ => ccx.sess().bug("should be a method, not other assoc item"),
|
||||
_ => bug!("should be a method, not other assoc item"),
|
||||
};
|
||||
let name = trait_method_type.name;
|
||||
|
||||
@ -330,7 +328,7 @@ pub fn get_impl_method<'tcx>(tcx: &TyCtxt<'tcx>,
|
||||
}
|
||||
}
|
||||
None => {
|
||||
tcx.sess.bug(&format!("method {:?} not found in {:?}", name, impl_def_id))
|
||||
bug!("method {:?} not found in {:?}", name, impl_def_id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||
ty: callee.ty
|
||||
}, f.abi, &f.sig)
|
||||
}
|
||||
_ => unreachable!("{} is not callable", callee.ty)
|
||||
_ => bug!("{} is not callable", callee.ty)
|
||||
};
|
||||
|
||||
// Handle intrinsics old trans wants Expr's for, ourselves.
|
||||
@ -295,7 +295,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||
return;
|
||||
}
|
||||
Fn(f) => f,
|
||||
Virtual(_) => unreachable!("Virtual fn ptr not extracted")
|
||||
Virtual(_) => bug!("Virtual fn ptr not extracted")
|
||||
};
|
||||
|
||||
// Many different ways to call a function handled here
|
||||
@ -417,7 +417,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||
}
|
||||
Immediate(llval) => (llval, false),
|
||||
Ref(llval) => (llval, true),
|
||||
FatPtr(_, _) => unreachable!("fat pointers handled above")
|
||||
FatPtr(_, _) => bug!("fat pointers handled above")
|
||||
};
|
||||
|
||||
if by_ref && !arg.is_indirect() {
|
||||
@ -470,9 +470,9 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||
let lv_ty = lv.ty.to_ty(bcx.tcx());
|
||||
let result_types = match lv_ty.sty {
|
||||
ty::TyTuple(ref tys) => tys,
|
||||
_ => bcx.tcx().sess.span_bug(
|
||||
_ => span_bug!(
|
||||
self.mir.span,
|
||||
&format!("bad final argument to \"rust-call\" fn {:?}", lv_ty))
|
||||
"bad final argument to \"rust-call\" fn {:?}", lv_ty)
|
||||
};
|
||||
|
||||
let base_repr = adt::represent_type(bcx.ccx(), lv_ty);
|
||||
|
@ -89,10 +89,10 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||
ConstVal::Struct(_) | ConstVal::Tuple(_) |
|
||||
ConstVal::Array(..) | ConstVal::Repeat(..) |
|
||||
ConstVal::Function(_) => {
|
||||
unreachable!("MIR must not use {:?} (which refers to a local ID)", cv)
|
||||
bug!("MIR must not use {:?} (which refers to a local ID)", cv)
|
||||
}
|
||||
ConstVal::Char(c) => C_integral(Type::char(ccx), c as u64, false),
|
||||
ConstVal::Dummy => unreachable!(),
|
||||
ConstVal::Dummy => bug!(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||
assert!(lvalue.llextra != ptr::null_mut());
|
||||
lvalue.llextra
|
||||
}
|
||||
_ => bcx.sess().bug("unexpected type in lvalue_len"),
|
||||
_ => bug!("unexpected type in lvalue_len"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -100,7 +100,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||
TempRef::Lvalue(lvalue) =>
|
||||
lvalue,
|
||||
TempRef::Operand(..) =>
|
||||
tcx.sess.bug(&format!("using operand temp {:?} as lvalue", lvalue)),
|
||||
bug!("using operand temp {:?} as lvalue", lvalue),
|
||||
},
|
||||
mir::Lvalue::Arg(index) => self.args[index as usize],
|
||||
mir::Lvalue::Static(def_id) => {
|
||||
|
@ -180,7 +180,7 @@ fn arg_value_refs<'bcx, 'tcx>(bcx: &BlockAndBuilder<'bcx, 'tcx>,
|
||||
|
||||
let tupled_arg_tys = match arg_ty.sty {
|
||||
ty::TyTuple(ref tys) => tys,
|
||||
_ => unreachable!("spread argument isn't a tuple?!")
|
||||
_ => bug!("spread argument isn't a tuple?!")
|
||||
};
|
||||
|
||||
let lltemp = bcx.with_block(|bcx| {
|
||||
|
@ -79,7 +79,7 @@ impl<'tcx> OperandRef<'tcx> {
|
||||
pub fn immediate(self) -> ValueRef {
|
||||
match self.val {
|
||||
OperandValue::Immediate(s) => s,
|
||||
_ => unreachable!()
|
||||
_ => bug!()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -124,8 +124,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||
return o;
|
||||
}
|
||||
TempRef::Operand(None) => {
|
||||
bcx.tcx().sess.bug(
|
||||
&format!("use of {:?} before def", lvalue));
|
||||
bug!("use of {:?} before def", lvalue);
|
||||
}
|
||||
TempRef::Lvalue(..) => {
|
||||
// use path below
|
||||
|
@ -70,7 +70,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||
let operand = self.trans_operand(&bcx, source);
|
||||
bcx.with_block(|bcx| {
|
||||
match operand.val {
|
||||
OperandValue::FatPtr(..) => unreachable!(),
|
||||
OperandValue::FatPtr(..) => bug!(),
|
||||
OperandValue::Immediate(llval) => {
|
||||
// unsize from an immediate structure. We don't
|
||||
// really need a temporary alloca here, but
|
||||
@ -185,7 +185,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||
ty::TySlice(_) | ty::TyStr => {
|
||||
(bcx.gepi(input.llval, &[from_start]), input.llextra)
|
||||
}
|
||||
_ => unreachable!("cannot slice {}", ty)
|
||||
_ => bug!("cannot slice {}", ty)
|
||||
};
|
||||
let adj = C_uint(ccx, from_start + from_end);
|
||||
let lllen1 = bcx.sub(lllen, adj);
|
||||
@ -246,7 +246,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||
.reify(bcx.ccx()).val)
|
||||
}
|
||||
_ => {
|
||||
unreachable!("{} cannot be reified to a fn ptr", operand.ty)
|
||||
bug!("{} cannot be reified to a fn ptr", operand.ty)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -279,9 +279,8 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||
OperandValue::FatPtr(lldata, llextra)
|
||||
}
|
||||
OperandValue::Ref(_) => {
|
||||
bcx.sess().bug(
|
||||
&format!("by-ref operand {:?} in trans_rvalue_operand",
|
||||
operand));
|
||||
bug!("by-ref operand {:?} in trans_rvalue_operand",
|
||||
operand);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -341,9 +340,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||
bcx.fptosi(llval, ll_t_out),
|
||||
(CastTy::Float, CastTy::Int(_)) =>
|
||||
bcx.fptoui(llval, ll_t_out),
|
||||
_ => bcx.ccx().sess().bug(
|
||||
&format!("unsupported cast: {:?} to {:?}", operand.ty, cast_ty)
|
||||
)
|
||||
_ => bug!("unsupported cast: {:?} to {:?}", operand.ty, cast_ty)
|
||||
};
|
||||
OperandValue::Immediate(newval)
|
||||
}
|
||||
@ -364,7 +361,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||
OperandValue::Immediate(llval)
|
||||
}
|
||||
} else {
|
||||
panic!("Unexpected non-FatPtr operand")
|
||||
bug!("Unexpected non-FatPtr operand")
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -425,7 +422,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||
DebugLoc::None)
|
||||
})
|
||||
}
|
||||
_ => unreachable!()
|
||||
_ => bug!()
|
||||
}
|
||||
|
||||
} else {
|
||||
@ -489,7 +486,8 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||
mir::Rvalue::Aggregate(..) |
|
||||
mir::Rvalue::Slice { .. } |
|
||||
mir::Rvalue::InlineAsm { .. } => {
|
||||
bcx.tcx().sess.bug(&format!("cannot generate operand from rvalue {:?}", rvalue));
|
||||
bug!("cannot generate operand from rvalue {:?}", rvalue);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,9 +36,9 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||
bcx
|
||||
}
|
||||
TempRef::Operand(Some(_)) => {
|
||||
bcx.tcx().sess.span_bug(
|
||||
statement.span,
|
||||
&format!("operand {:?} already assigned", rvalue));
|
||||
span_bug!(statement.span,
|
||||
"operand {:?} already assigned",
|
||||
rvalue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -149,13 +149,13 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
Disr::from(inlined_variant_def(ccx, fn_node_id).disr_val)
|
||||
}
|
||||
hir_map::NodeStructCtor(_) => Disr(0),
|
||||
_ => unreachable!()
|
||||
_ => bug!()
|
||||
};
|
||||
attributes::inline(lldecl, attributes::InlineAttr::Hint);
|
||||
base::trans_ctor_shim(ccx, fn_node_id, disr, psubsts, lldecl);
|
||||
}
|
||||
|
||||
_ => unreachable!("can't monomorphize a {:?}", map_node)
|
||||
_ => bug!("can't monomorphize a {:?}", map_node)
|
||||
};
|
||||
|
||||
ccx.monomorphizing().borrow_mut().insert(fn_id, depth);
|
||||
|
@ -183,8 +183,7 @@ fn write_content<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
bcx.tcx().sess.span_bug(content_expr.span,
|
||||
"unexpected evec content");
|
||||
span_bug!(content_expr.span, "unexpected evec content");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -236,8 +235,7 @@ fn write_content<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
bcx.tcx().sess.span_bug(content_expr.span,
|
||||
"unexpected vec content");
|
||||
span_bug!(content_expr.span, "unexpected vec content");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -264,8 +262,7 @@ fn elements_required(bcx: Block, content_expr: &hir::Expr) -> usize {
|
||||
match lit.node {
|
||||
ast::LitKind::Str(ref s, _) => s.len(),
|
||||
_ => {
|
||||
bcx.tcx().sess.span_bug(content_expr.span,
|
||||
"unexpected evec content")
|
||||
span_bug!(content_expr.span, "unexpected evec content")
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -273,8 +270,7 @@ fn elements_required(bcx: Block, content_expr: &hir::Expr) -> usize {
|
||||
hir::ExprRepeat(_, ref count_expr) => {
|
||||
eval_repeat_count(bcx.tcx(), &count_expr)
|
||||
}
|
||||
_ => bcx.tcx().sess.span_bug(content_expr.span,
|
||||
"unexpected vec content")
|
||||
_ => span_bug!(content_expr.span, "unexpected vec content")
|
||||
}
|
||||
}
|
||||
|
||||
@ -298,8 +294,6 @@ pub fn get_base_and_len<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
llval: ValueRef,
|
||||
vec_ty: Ty<'tcx>)
|
||||
-> (ValueRef, ValueRef) {
|
||||
let ccx = bcx.ccx();
|
||||
|
||||
match vec_ty.sty {
|
||||
ty::TyArray(_, n) => get_fixed_base_and_len(bcx, llval, n),
|
||||
ty::TySlice(_) | ty::TyStr => {
|
||||
@ -317,7 +311,7 @@ pub fn get_base_and_len<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
};
|
||||
get_base_and_len(bcx, inner, ty)
|
||||
},
|
||||
_ => ccx.sess().bug("unexpected type in get_base_and_len"),
|
||||
_ => bug!("unexpected type in get_base_and_len"),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -124,7 +124,7 @@ impl Type {
|
||||
match &ccx.tcx().sess.target.target.target_pointer_width[..] {
|
||||
"32" => Type::i32(ccx),
|
||||
"64" => Type::i64(ccx),
|
||||
tws => panic!("Unsupported target word size for int: {}", tws),
|
||||
tws => bug!("Unsupported target word size for int: {}", tws),
|
||||
}
|
||||
}
|
||||
|
||||
@ -288,7 +288,7 @@ impl Type {
|
||||
Double => 64,
|
||||
X86_FP80 => 80,
|
||||
FP128 | PPC_FP128 => 128,
|
||||
_ => panic!("llvm_float_width called on a non-float type")
|
||||
_ => bug!("llvm_float_width called on a non-float type")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,10 +113,9 @@ pub fn sizing_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Typ
|
||||
}
|
||||
|
||||
ty::TyProjection(..) | ty::TyInfer(..) | ty::TyParam(..) | ty::TyError => {
|
||||
cx.sess().bug(&format!("fictitious type {:?} in sizing_type_of()",
|
||||
t))
|
||||
bug!("fictitious type {:?} in sizing_type_of()", t)
|
||||
}
|
||||
ty::TySlice(_) | ty::TyTrait(..) | ty::TyStr => unreachable!()
|
||||
ty::TySlice(_) | ty::TyTrait(..) | ty::TyStr => bug!()
|
||||
};
|
||||
|
||||
debug!("--> mapped t={:?} to llsizingty={:?}", t, llsizingty);
|
||||
@ -132,7 +131,7 @@ fn unsized_info_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ty: Ty<'tcx>) -> Type
|
||||
Type::uint_from_ty(ccx, ast::UintTy::Us)
|
||||
}
|
||||
ty::TyTrait(_) => Type::vtable_ptr(ccx),
|
||||
_ => unreachable!("Unexpected tail in unsized_info_ty: {:?} for ty={:?}",
|
||||
_ => bug!("Unexpected tail in unsized_info_ty: {:?} for ty={:?}",
|
||||
unsized_part, ty)
|
||||
}
|
||||
}
|
||||
@ -296,10 +295,10 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) ->
|
||||
}
|
||||
}
|
||||
|
||||
ty::TyInfer(..) => cx.sess().bug("type_of with TyInfer"),
|
||||
ty::TyProjection(..) => cx.sess().bug("type_of with TyProjection"),
|
||||
ty::TyParam(..) => cx.sess().bug("type_of with ty_param"),
|
||||
ty::TyError => cx.sess().bug("type_of with TyError"),
|
||||
ty::TyInfer(..) => bug!("type_of with TyInfer"),
|
||||
ty::TyProjection(..) => bug!("type_of with TyProjection"),
|
||||
ty::TyParam(..) => bug!("type_of with ty_param"),
|
||||
ty::TyError => bug!("type_of with TyError"),
|
||||
};
|
||||
|
||||
debug!("--> mapped t={:?} to llty={:?}", t, llty);
|
||||
|
Loading…
Reference in New Issue
Block a user