librustc_trans: use bug!(), span_bug!()
This commit is contained in:
parent
35e160364d
commit
c59ea491ea
51 changed files with 436 additions and 484 deletions
|
@ -242,7 +242,7 @@ impl<'a> ConstantExpr<'a> {
|
||||||
fn eq(self, other: ConstantExpr<'a>, tcx: &TyCtxt) -> bool {
|
fn eq(self, other: ConstantExpr<'a>, tcx: &TyCtxt) -> bool {
|
||||||
match compare_lit_exprs(tcx, self.0, other.0) {
|
match compare_lit_exprs(tcx, self.0, other.0) {
|
||||||
Some(result) => result == Ordering::Equal,
|
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) {
|
fn handle_fail(&self, bcx: Block) {
|
||||||
match *self {
|
match *self {
|
||||||
Infallible =>
|
Infallible =>
|
||||||
panic!("attempted to panic in a non-panicking panic handler!"),
|
bug!("attempted to panic in a non-panicking panic handler!"),
|
||||||
JumpToBasicBlock(basic_block) =>
|
JumpToBasicBlock(basic_block) =>
|
||||||
Br(bcx, basic_block, DebugLoc::None),
|
Br(bcx, basic_block, DebugLoc::None),
|
||||||
Unreachable =>
|
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)
|
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)",
|
Lvalue::new_with_hint("_match::insert_lllocals (match_input)",
|
||||||
bcx, binding_info.id, hint_kind)
|
bcx, binding_info.id, hint_kind)
|
||||||
}
|
}
|
||||||
_ => unreachable!(),
|
_ => bug!(),
|
||||||
};
|
};
|
||||||
let datum = Datum::new(llval, binding_info.ty, lvalue);
|
let datum = Datum::new(llval, binding_info.ty, lvalue);
|
||||||
call_lifetime_start(bcx, llbinding);
|
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 = r.bcx;
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
bcx.sess().bug(
|
bug!(
|
||||||
"in compile_submatch, expected \
|
"in compile_submatch, expected \
|
||||||
opt.trans() to return a SingleResult")
|
opt.trans() to return a SingleResult")
|
||||||
}
|
}
|
||||||
|
|
|
@ -218,7 +218,7 @@ impl FnType {
|
||||||
Rust | RustCall => llvm::CCallConv,
|
Rust | RustCall => llvm::CCallConv,
|
||||||
|
|
||||||
// It's the ABI's job to select this, not us.
|
// 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,
|
Stdcall => llvm::X86StdcallCallConv,
|
||||||
Fastcall => llvm::X86FastcallCallConv,
|
Fastcall => llvm::X86FastcallCallConv,
|
||||||
|
@ -241,8 +241,8 @@ impl FnType {
|
||||||
&tupled_arguments[..]
|
&tupled_arguments[..]
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
unreachable!("argument to function with \"rust-call\" ABI \
|
bug!("argument to function with \"rust-call\" ABI \
|
||||||
is not a tuple");
|
is not a tuple");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -302,9 +302,8 @@ fn represent_type_uncached<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||||
// non-empty body, explicit discriminants should have
|
// non-empty body, explicit discriminants should have
|
||||||
// been rejected by a checker before this point.
|
// been rejected by a checker before this point.
|
||||||
if !cases.iter().enumerate().all(|(i,c)| c.discr == Disr::from(i)) {
|
if !cases.iter().enumerate().all(|(i,c)| c.discr == Disr::from(i)) {
|
||||||
cx.sess().bug(&format!("non-C-like enum {} with specified \
|
bug!("non-C-like enum {} with specified discriminants",
|
||||||
discriminants",
|
cx.tcx().item_path_str(def.did));
|
||||||
cx.tcx().item_path_str(def.did)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if cases.len() == 1 {
|
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))
|
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 {
|
match hint {
|
||||||
attr::ReprInt(span, ity) => {
|
attr::ReprInt(span, ity) => {
|
||||||
if !bounds_usable(cx, ity, bounds) {
|
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;
|
return ity;
|
||||||
}
|
}
|
||||||
|
@ -632,10 +631,10 @@ fn range_to_inttype(cx: &CrateContext, hint: Hint, bounds: &IntBounds) -> IntTyp
|
||||||
attempts = choose_shortest;
|
attempts = choose_shortest;
|
||||||
},
|
},
|
||||||
attr::ReprPacked => {
|
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 => {
|
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 {
|
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),
|
Type::array(&Type::i64(cx), align_units),
|
||||||
a if a.count_ones() == 1 => Type::array(&Type::vector(&Type::i32(cx), a / 4),
|
a if a.count_ones() == 1 => Type::array(&Type::vector(&Type::i32(cx), a / 4),
|
||||||
align_units),
|
align_units),
|
||||||
_ => panic!("unsupported enum alignment: {}", align)
|
_ => bug!("unsupported enum alignment: {}", align)
|
||||||
};
|
};
|
||||||
assert_eq!(machine::llalign_of_min(cx, fill_ty), 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
|
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)
|
C_integral(ll_inttype(bcx.ccx(), ity), discr.0, true)
|
||||||
}
|
}
|
||||||
Univariant(..) => {
|
Univariant(..) => {
|
||||||
bcx.ccx().sess().bug("no cases for univariants or structs")
|
bug!("no cases for univariants or structs")
|
||||||
}
|
}
|
||||||
RawNullablePointer { .. } |
|
RawNullablePointer { .. } |
|
||||||
StructWrappedNullablePointer { .. } => {
|
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.
|
// someday), it will need to return a possibly-new bcx as well.
|
||||||
match *r {
|
match *r {
|
||||||
CEnum(..) => {
|
CEnum(..) => {
|
||||||
bcx.ccx().sess().bug("element access in C-like enum")
|
bug!("element access in C-like enum")
|
||||||
}
|
}
|
||||||
Univariant(ref st, _dtor) => {
|
Univariant(ref st, _dtor) => {
|
||||||
assert_eq!(discr, Disr(0));
|
assert_eq!(discr, Disr(0));
|
||||||
|
@ -1279,7 +1278,7 @@ pub fn fold_variants<'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
|
||||||
|
|
||||||
bcx_next
|
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);
|
fcx.pop_custom_cleanup_scope(custom_cleanup_scope);
|
||||||
datum::DatumBlock::new(bcx, expr_datum)
|
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),
|
Univariant(..) => Disr(0),
|
||||||
RawNullablePointer { .. } | StructWrappedNullablePointer { .. } => {
|
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
|
/// (Not to be confused with `common::const_get_elt`, which operates on
|
||||||
/// raw LLVM-level structs and arrays.)
|
/// raw LLVM-level structs and arrays.)
|
||||||
pub fn const_get_field(ccx: &CrateContext, r: &Repr, val: ValueRef,
|
pub fn const_get_field(r: &Repr, val: ValueRef, _discr: Disr,
|
||||||
_discr: Disr, ix: usize) -> ValueRef {
|
ix: usize) -> ValueRef {
|
||||||
match *r {
|
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),
|
Univariant(..) => const_struct_field(val, ix),
|
||||||
General(..) => const_struct_field(val, ix + 1),
|
General(..) => const_struct_field(val, ix + 1),
|
||||||
RawNullablePointer { .. } => {
|
RawNullablePointer { .. } => {
|
||||||
|
|
|
@ -221,7 +221,7 @@ fn dump_graph(tcx: &TyCtxt) {
|
||||||
// Expect one of: "-> target", "source -> target", or "source ->".
|
// Expect one of: "-> target", "source -> target", or "source ->".
|
||||||
let parts: Vec<_> = string.split("->").collect();
|
let parts: Vec<_> = string.split("->").collect();
|
||||||
if parts.len() > 2 {
|
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 sources = node_set(&query, &parts[0]);
|
||||||
let targets = node_set(&query, &parts[1]);
|
let targets = node_set(&query, &parts[1]);
|
||||||
|
|
|
@ -187,8 +187,8 @@ pub fn link_binary(sess: &Session,
|
||||||
let mut out_filenames = Vec::new();
|
let mut out_filenames = Vec::new();
|
||||||
for &crate_type in sess.crate_types.borrow().iter() {
|
for &crate_type in sess.crate_types.borrow().iter() {
|
||||||
if invalid_output_for_target(sess, crate_type) {
|
if invalid_output_for_target(sess, crate_type) {
|
||||||
sess.bug(&format!("invalid output type `{:?}` for target os `{}`",
|
bug!("invalid output type `{:?}` for target os `{}`",
|
||||||
crate_type, sess.opts.target_triple));
|
crate_type, sess.opts.target_triple);
|
||||||
}
|
}
|
||||||
let out_file = link_binary_output(sess, trans, crate_type, outputs,
|
let out_file = link_binary_output(sess, trans, crate_type, outputs,
|
||||||
crate_name);
|
crate_name);
|
||||||
|
@ -282,7 +282,7 @@ pub fn each_linked_rlib(sess: &Session,
|
||||||
let fmts = fmts.get(&config::CrateTypeExecutable).or_else(|| {
|
let fmts = fmts.get(&config::CrateTypeExecutable).or_else(|| {
|
||||||
fmts.get(&config::CrateTypeStaticlib)
|
fmts.get(&config::CrateTypeStaticlib)
|
||||||
}).unwrap_or_else(|| {
|
}).unwrap_or_else(|| {
|
||||||
sess.bug("could not find formats for rlibs")
|
bug!("could not find formats for rlibs")
|
||||||
});
|
});
|
||||||
for (cnum, path) in crates {
|
for (cnum, path) in crates {
|
||||||
match fmts[cnum as usize - 1] {
|
match fmts[cnum as usize - 1] {
|
||||||
|
@ -895,7 +895,7 @@ fn add_local_native_libraries(cmd: &mut Linker, sess: &Session) {
|
||||||
match kind {
|
match kind {
|
||||||
NativeLibraryKind::NativeUnknown => cmd.link_dylib(l),
|
NativeLibraryKind::NativeUnknown => cmd.link_dylib(l),
|
||||||
NativeLibraryKind::NativeFramework => cmd.link_framework(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::NativeUnknown => cmd.link_dylib(lib),
|
||||||
NativeLibraryKind::NativeFramework => cmd.link_framework(lib),
|
NativeLibraryKind::NativeFramework => cmd.link_framework(lib),
|
||||||
NativeLibraryKind::NativeStatic => {
|
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) {
|
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) {
|
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]) {
|
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
|
// to be a value or type-def or something in there
|
||||||
// *somewhere*
|
// *somewhere*
|
||||||
ty_def_id.index = key.parent.unwrap_or_else(|| {
|
ty_def_id.index = key.parent.unwrap_or_else(|| {
|
||||||
panic!("finding type for {:?}, encountered def-id {:?} with no \
|
bug!("finding type for {:?}, encountered def-id {:?} with no \
|
||||||
parent", def_id, ty_def_id);
|
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) {
|
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
|
.cg
|
||||||
.relocation_model));
|
.relocation_model));
|
||||||
sess.abort_if_errors();
|
sess.abort_if_errors();
|
||||||
unreachable!();
|
bug!();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@ pub fn create_target_machine(sess: &Session) -> TargetMachineRef {
|
||||||
.cg
|
.cg
|
||||||
.code_model));
|
.code_model));
|
||||||
sess.abort_if_errors();
|
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,
|
pub fn bin_op_to_icmp_predicate(op: hir::BinOp_,
|
||||||
op: hir::BinOp_,
|
|
||||||
signed: bool)
|
signed: bool)
|
||||||
-> llvm::IntPredicate {
|
-> llvm::IntPredicate {
|
||||||
match op {
|
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::BiGt => if signed { llvm::IntSGT } else { llvm::IntUGT },
|
||||||
hir::BiGe => if signed { llvm::IntSGE } else { llvm::IntUGE },
|
hir::BiGe => if signed { llvm::IntSGE } else { llvm::IntUGE },
|
||||||
op => {
|
op => {
|
||||||
ccx.sess()
|
bug!("comparison_op_to_icmp_predicate: expected comparison operator, \
|
||||||
.bug(&format!("comparison_op_to_icmp_predicate: expected comparison operator, \
|
found {:?}",
|
||||||
found {:?}",
|
op)
|
||||||
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 {
|
match op {
|
||||||
hir::BiEq => llvm::RealOEQ,
|
hir::BiEq => llvm::RealOEQ,
|
||||||
hir::BiNe => llvm::RealUNE,
|
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::BiGt => llvm::RealOGT,
|
||||||
hir::BiGe => llvm::RealOGE,
|
hir::BiGe => llvm::RealOGE,
|
||||||
op => {
|
op => {
|
||||||
ccx.sess()
|
bug!("comparison_op_to_fcmp_predicate: expected comparison operator, \
|
||||||
.bug(&format!("comparison_op_to_fcmp_predicate: expected comparison operator, \
|
found {:?}",
|
||||||
found {:?}",
|
op);
|
||||||
op));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -291,7 +288,7 @@ pub fn compare_fat_ptrs<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||||
hir::BiLe => (llvm::IntULE, llvm::IntULT),
|
hir::BiLe => (llvm::IntULE, llvm::IntULT),
|
||||||
hir::BiGt => (llvm::IntUGT, llvm::IntUGT),
|
hir::BiGt => (llvm::IntUGT, llvm::IntUGT),
|
||||||
hir::BiGe => (llvm::IntUGE, llvm::IntUGT),
|
hir::BiGe => (llvm::IntUGE, llvm::IntUGT),
|
||||||
_ => unreachable!(),
|
_ => bug!(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let addr_eq = ICmp(bcx, llvm::IntEQ, lhs_addr, rhs_addr, debug_loc);
|
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)
|
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::BiEq | hir::BiLe | hir::BiGe => return C_bool(bcx.ccx(), true),
|
||||||
hir::BiNe | hir::BiLt | hir::BiGt => return C_bool(bcx.ccx(), false),
|
hir::BiNe | hir::BiLt | hir::BiGt => return C_bool(bcx.ccx(), false),
|
||||||
// refinements would be nice
|
// 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 => {
|
ty::TyFnDef(..) | ty::TyFnPtr(_) | ty::TyBool | ty::TyUint(_) | ty::TyChar => {
|
||||||
ICmp(bcx,
|
ICmp(bcx,
|
||||||
bin_op_to_icmp_predicate(bcx.ccx(), op, false),
|
bin_op_to_icmp_predicate(op, false),
|
||||||
lhs,
|
lhs,
|
||||||
rhs,
|
rhs,
|
||||||
debug_loc)
|
debug_loc)
|
||||||
}
|
}
|
||||||
ty::TyRawPtr(mt) if common::type_is_sized(bcx.tcx(), mt.ty) => {
|
ty::TyRawPtr(mt) if common::type_is_sized(bcx.tcx(), mt.ty) => {
|
||||||
ICmp(bcx,
|
ICmp(bcx,
|
||||||
bin_op_to_icmp_predicate(bcx.ccx(), op, false),
|
bin_op_to_icmp_predicate(op, false),
|
||||||
lhs,
|
lhs,
|
||||||
rhs,
|
rhs,
|
||||||
debug_loc)
|
debug_loc)
|
||||||
|
@ -356,20 +353,20 @@ pub fn compare_scalar_types<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||||
}
|
}
|
||||||
ty::TyInt(_) => {
|
ty::TyInt(_) => {
|
||||||
ICmp(bcx,
|
ICmp(bcx,
|
||||||
bin_op_to_icmp_predicate(bcx.ccx(), op, true),
|
bin_op_to_icmp_predicate(op, true),
|
||||||
lhs,
|
lhs,
|
||||||
rhs,
|
rhs,
|
||||||
debug_loc)
|
debug_loc)
|
||||||
}
|
}
|
||||||
ty::TyFloat(_) => {
|
ty::TyFloat(_) => {
|
||||||
FCmp(bcx,
|
FCmp(bcx,
|
||||||
bin_op_to_fcmp_predicate(bcx.ccx(), op),
|
bin_op_to_fcmp_predicate(op),
|
||||||
lhs,
|
lhs,
|
||||||
rhs,
|
rhs,
|
||||||
debug_loc)
|
debug_loc)
|
||||||
}
|
}
|
||||||
// Should never get here, because t is scalar.
|
// 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 {
|
-> ValueRef {
|
||||||
let signed = match t.sty {
|
let signed = match t.sty {
|
||||||
ty::TyFloat(_) => {
|
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);
|
return SExt(bcx, FCmp(bcx, cmp, lhs, rhs, debug_loc), ret_ty);
|
||||||
},
|
},
|
||||||
ty::TyUint(_) => false,
|
ty::TyUint(_) => false,
|
||||||
ty::TyInt(_) => true,
|
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
|
// 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
|
// 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
|
// 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),
|
consts::ptrcast(meth::get_vtable(ccx, trait_ref),
|
||||||
Type::vtable_ptr(ccx))
|
Type::vtable_ptr(ccx))
|
||||||
}
|
}
|
||||||
_ => ccx.sess().bug(&format!("unsized_info: invalid unsizing {:?} -> {:?}",
|
_ => bug!("unsized_info: invalid unsizing {:?} -> {:?}",
|
||||||
source,
|
source,
|
||||||
target)),
|
target),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -604,7 +601,7 @@ pub fn unsize_thin_ptr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||||
(PointerCast(bcx, src, ptr_ty),
|
(PointerCast(bcx, src, ptr_ty),
|
||||||
unsized_info(bcx.ccx(), a, b, None))
|
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_repr = adt::represent_type(bcx.ccx(), src_ty);
|
||||||
let src_fields = match &*src_repr {
|
let src_fields = match &*src_repr {
|
||||||
&adt::Repr::Univariant(ref s, _) => &s.fields,
|
&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_repr = adt::represent_type(bcx.ccx(), dst_ty);
|
||||||
let dst_fields = match &*dst_repr {
|
let dst_fields = match &*dst_repr {
|
||||||
&adt::Repr::Univariant(ref s, _) => &s.fields,
|
&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);
|
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 {:?} -> {:?}",
|
_ => bug!("coerce_unsized_into: invalid coercion {:?} -> {:?}",
|
||||||
src_ty,
|
src_ty,
|
||||||
dst_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)
|
ccx.tcx().custom_coerce_unsized_kind(impl_def_id)
|
||||||
}
|
}
|
||||||
vtable => {
|
vtable => {
|
||||||
ccx.sess().bug(&format!("invalid CoerceUnsized vtable: {:?}",
|
bug!("invalid CoerceUnsized vtable: {:?}", vtable);
|
||||||
vtable));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -758,7 +754,7 @@ pub fn llty_and_min_for_signed_ty<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
|
||||||
};
|
};
|
||||||
(llty, min)
|
(llty, min)
|
||||||
}
|
}
|
||||||
_ => unreachable!(),
|
_ => bug!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -798,7 +794,7 @@ pub fn fail_if_zero_or_overflows<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
|
||||||
(res, false)
|
(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| {
|
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) => {
|
hir::ItemFn(_, _, _, _, _, ref blk) => {
|
||||||
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)) => {
|
Some(hir_map::NodeTraitItem(trait_item)) => {
|
||||||
match trait_item.node {
|
match trait_item.node {
|
||||||
hir::MethodTraitItem(_, Some(ref body)) => body,
|
hir::MethodTraitItem(_, Some(ref body)) => body,
|
||||||
_ => {
|
_ => {
|
||||||
tcx.sess.bug("unexpected variant: trait item other than a provided method in \
|
bug!("unexpected variant: trait item other than a provided method in \
|
||||||
has_nested_returns")
|
has_nested_returns")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1339,14 +1335,14 @@ fn build_cfg(tcx: &TyCtxt, id: ast::NodeId) -> (ast::NodeId, Option<cfg::CFG>) {
|
||||||
match impl_item.node {
|
match impl_item.node {
|
||||||
hir::ImplItemKind::Method(_, ref body) => body,
|
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)) => {
|
Some(hir_map::NodeExpr(e)) => {
|
||||||
match e.node {
|
match e.node {
|
||||||
hir::ExprClosure(_, _, ref blk) => blk,
|
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(..)) |
|
Some(hir_map::NodeVariant(..)) |
|
||||||
|
@ -1355,8 +1351,8 @@ fn build_cfg(tcx: &TyCtxt, id: ast::NodeId) -> (ast::NodeId, Option<cfg::CFG>) {
|
||||||
// glue, shims, etc
|
// glue, shims, etc
|
||||||
None if id == ast::DUMMY_NODE_ID => return (ast::DUMMY_NODE_ID, None),
|
None if id == ast::DUMMY_NODE_ID => return (ast::DUMMY_NODE_ID, None),
|
||||||
|
|
||||||
_ => tcx.sess.bug(&format!("unexpected variant in has_nested_returns: {}",
|
_ => bug!("unexpected variant in has_nested_returns: {}",
|
||||||
tcx.map.path_to_string(id))),
|
tcx.map.path_to_string(id)),
|
||||||
};
|
};
|
||||||
|
|
||||||
(blk.id, Some(cfg::CFG::new(tcx, blk)))
|
(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.
|
// FIXME(pcwalton): Reduce the amount of code bloat this is responsible for.
|
||||||
let tupled_arg_tys = match arg_ty.sty {
|
let tupled_arg_tys = match arg_ty.sty {
|
||||||
ty::TyTuple(ref tys) => tys,
|
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,
|
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),
|
expr::SaveIn(llresult),
|
||||||
debug_loc);
|
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 {
|
} else {
|
||||||
// Just eval all the expressions (if any). Since expressions in Rust can have arbitrary
|
// 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")
|
.help("did you use #[no_mangle] on `fn main`? Use #[start] instead")
|
||||||
.emit();
|
.emit();
|
||||||
ccx.sess().abort_if_errors();
|
ccx.sess().abort_if_errors();
|
||||||
panic!();
|
bug!();
|
||||||
}
|
}
|
||||||
let llfn = declare::declare_cfn(ccx, "main", llfty);
|
let llfn = declare::declare_cfn(ccx, "main", llfty);
|
||||||
|
|
||||||
|
@ -2734,7 +2730,7 @@ pub fn trans_crate<'tcx>(tcx: &TyCtxt<'tcx>,
|
||||||
});
|
});
|
||||||
|
|
||||||
if POISONED {
|
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) {
|
pub fn check_not_terminated(cx: Block) {
|
||||||
if cx.terminated.get() {
|
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)));
|
.zip(args.iter().map(|&v| val_ty(v)));
|
||||||
for (i, (expected_ty, actual_ty)) in iter.enumerate() {
|
for (i, (expected_ty, actual_ty)) in iter.enumerate() {
|
||||||
if expected_ty != actual_ty {
|
if expected_ty != actual_ty {
|
||||||
self.ccx.sess().bug(
|
bug!("Type mismatch in function call of {:?}. \
|
||||||
&format!(
|
Expected {:?} for param {}, got {:?}",
|
||||||
"Type mismatch in function call of {:?}. \
|
Value(llfn),
|
||||||
Expected {:?} for param {}, got {:?}",
|
expected_ty, i, actual_ty);
|
||||||
Value(llfn),
|
|
||||||
expected_ty, i, actual_ty));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ fn ty_align(ty: Type) -> usize {
|
||||||
let elt = ty.element_type();
|
let elt = ty.element_type();
|
||||||
ty_align(elt) * len
|
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);
|
let eltsz = ty_size(elt);
|
||||||
len * eltsz
|
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();
|
let elt = ty.element_type();
|
||||||
general_ty_align(elt) * len
|
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();
|
let elt = ty.element_type();
|
||||||
ios_ty_align(elt) * len
|
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);
|
let eltsz = ty_size(elt, align_fn);
|
||||||
len * eltsz
|
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();
|
let elt = ty.element_type();
|
||||||
ty_align(elt) * len
|
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);
|
let eltsz = ty_size(elt);
|
||||||
len * eltsz
|
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();
|
let elt = ty.element_type();
|
||||||
ty_align(elt)
|
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);
|
let eltsz = ty_size(elt);
|
||||||
len * eltsz
|
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();
|
let elt = ty.element_type();
|
||||||
ty_align(elt)
|
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);
|
let eltsz = ty_size(elt);
|
||||||
len * eltsz
|
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();
|
let elt = ty.element_type();
|
||||||
ty_align(elt) * len
|
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
|
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()),
|
Integer => SSEInt(elt.int_width()),
|
||||||
Float => SSEFv,
|
Float => SSEFv,
|
||||||
Double => SSEDv,
|
Double => SSEDv,
|
||||||
_ => panic!("classify: unhandled vector element type")
|
_ => bug!("classify: unhandled vector element type")
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut i = 0;
|
let mut i = 0;
|
||||||
|
@ -268,7 +268,7 @@ fn classify_ty(ty: Type) -> Vec<RegClass> {
|
||||||
i += 1;
|
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);
|
"llreg_ty: unsupported SSEInt width {}", bits);
|
||||||
(64 / bits, Type::ix(ccx, bits))
|
(64 / bits, Type::ix(ccx, bits))
|
||||||
}
|
}
|
||||||
_ => unreachable!(),
|
_ => bug!(),
|
||||||
};
|
};
|
||||||
let vec_len = llvec_len(&cls[i + 1..]);
|
let vec_len = llvec_len(&cls[i + 1..]);
|
||||||
let vec_ty = Type::vector(&elt_ty, vec_len as u64 * elts_per_word);
|
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 => {
|
SSEDs => {
|
||||||
tys.push(Type::f64(ccx));
|
tys.push(Type::f64(ccx));
|
||||||
}
|
}
|
||||||
_ => panic!("llregtype: unhandled class")
|
_ => bug!("llregtype: unhandled class")
|
||||||
}
|
}
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -184,8 +184,8 @@ impl<'tcx> Callee<'tcx> {
|
||||||
let method_ty = def_ty(tcx, def_id, substs);
|
let method_ty = def_ty(tcx, def_id, substs);
|
||||||
let fn_ptr_ty = match method_ty.sty {
|
let fn_ptr_ty = match method_ty.sty {
|
||||||
ty::TyFnDef(_, _, fty) => tcx.mk_ty(ty::TyFnPtr(fty)),
|
ty::TyFnDef(_, _, fty) => tcx.mk_ty(ty::TyFnPtr(fty)),
|
||||||
_ => unreachable!("expected fn item type, found {}",
|
_ => bug!("expected fn item type, found {}",
|
||||||
method_ty)
|
method_ty)
|
||||||
};
|
};
|
||||||
Callee::ptr(immediate_rvalue(llfn, fn_ptr_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 method_ty = def_ty(tcx, def_id, substs);
|
||||||
let fn_ptr_ty = match method_ty.sty {
|
let fn_ptr_ty = match method_ty.sty {
|
||||||
ty::TyFnDef(_, _, fty) => tcx.mk_ty(ty::TyFnPtr(fty)),
|
ty::TyFnDef(_, _, fty) => tcx.mk_ty(ty::TyFnPtr(fty)),
|
||||||
_ => unreachable!("expected fn item type, found {}",
|
_ => bug!("expected fn item type, found {}",
|
||||||
method_ty)
|
method_ty)
|
||||||
};
|
};
|
||||||
Callee::ptr(immediate_rvalue(llfn, fn_ptr_ty))
|
Callee::ptr(immediate_rvalue(llfn, fn_ptr_ty))
|
||||||
}
|
}
|
||||||
|
@ -209,7 +209,7 @@ impl<'tcx> Callee<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
vtable => {
|
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, _) => {
|
ty::TyFnDef(def_id, substs, _) => {
|
||||||
return get_fn(ccx, 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,
|
ref sig }) => sig,
|
||||||
|
|
||||||
_ => {
|
_ => {
|
||||||
tcx.sess.bug(&format!("trans_fn_pointer_shim invoked on invalid type: {}",
|
bug!("trans_fn_pointer_shim invoked on invalid type: {}",
|
||||||
bare_fn_ty));
|
bare_fn_ty);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let sig = tcx.erase_late_bound_regions(sig);
|
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.
|
// Create a fn pointer with the substituted signature.
|
||||||
tcx.mk_ty(ty::TyFnPtr(fty))
|
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));
|
assert_eq!(type_of::type_of(ccx, fn_ptr_ty), common::val_ty(val));
|
||||||
return immediate_rvalue(val, fn_ptr_ty);
|
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.
|
// Create a fn pointer with the normalized signature.
|
||||||
tcx.mk_fn_ptr(infer::normalize_associated_type(tcx, fty))
|
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);
|
let instance = Instance::mono(ccx.tcx(), def_id);
|
||||||
|
@ -537,7 +537,7 @@ fn get_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
ref variant => {
|
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 {
|
let llfn = match callee {
|
||||||
Fn(f) => f,
|
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);
|
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,
|
span_bug!(tuple_expr.span,
|
||||||
"argument to `.call()` wasn't a tuple?!")
|
"argument to `.call()` wasn't a tuple?!")
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -378,7 +378,7 @@ impl<'blk, 'tcx> CleanupMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx> {
|
||||||
return id;
|
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
|
/// 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(
|
bug!("no cleanup scope {} found",
|
||||||
&format!("no cleanup scope {} found",
|
self.ccx.tcx().map.node_to_string(cleanup_scope));
|
||||||
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.
|
/// 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, _) => {
|
LoopExit(id, _) => {
|
||||||
self.ccx.sess().bug(&format!(
|
bug!("cannot exit from scope {}, not in scope", id);
|
||||||
"cannot exit from scope {}, \
|
|
||||||
not in scope", id));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1189,8 +1186,7 @@ pub fn temporary_scope(tcx: &TyCtxt,
|
||||||
r
|
r
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
tcx.sess.bug(&format!("no temporary scope available for expr {}",
|
bug!("no temporary scope available for expr {}", id)
|
||||||
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 llfn_closure_kind = ccx.tcx().closure_kind(closure_def_id);
|
||||||
|
|
||||||
let _icx = push_ctxt("trans_closure_adapter_shim");
|
let _icx = push_ctxt("trans_closure_adapter_shim");
|
||||||
let tcx = ccx.tcx();
|
|
||||||
|
|
||||||
debug!("trans_closure_adapter_shim(llfn_closure_kind={:?}, \
|
debug!("trans_closure_adapter_shim(llfn_closure_kind={:?}, \
|
||||||
trait_closure_kind={:?}, llfn={:?})",
|
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)
|
trans_fn_once_adapter_shim(ccx, closure_def_id, substs, llfn)
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
tcx.sess.bug(&format!("trans_closure_adapter_shim: cannot convert {:?} to {:?}",
|
bug!("trans_closure_adapter_shim: cannot convert {:?} to {:?}",
|
||||||
llfn_closure_kind,
|
llfn_closure_kind,
|
||||||
trait_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) {
|
let substs = match fulfill_obligation(ccx, DUMMY_SP, trait_ref) {
|
||||||
traits::VtableImpl(data) => data.substs,
|
traits::VtableImpl(data) => data.substs,
|
||||||
_ => unreachable!()
|
_ => bug!()
|
||||||
};
|
};
|
||||||
|
|
||||||
if can_have_local_instance(ccx, destructor_did) {
|
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::TyParam(_) |
|
||||||
ty::TyInfer(_) |
|
ty::TyInfer(_) |
|
||||||
ty::TyError => {
|
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 {
|
} else {
|
||||||
debug!(" => regular function");
|
debug!(" => regular function");
|
||||||
|
@ -760,7 +760,7 @@ fn do_static_trait_method_dispatch<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||||
None
|
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_fields[coerce_index].ty(ccx.tcx(),
|
||||||
target_substs))
|
target_substs))
|
||||||
}
|
}
|
||||||
_ => ccx.sess()
|
_ => bug!("find_vtable_types_for_unsizing: invalid coercion {:?} -> {:?}",
|
||||||
.bug(&format!("find_vtable_types_for_unsizing: invalid coercion {:?} -> {:?}",
|
source_ty,
|
||||||
source_ty,
|
target_ty)
|
||||||
target_ty))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1019,7 +1018,7 @@ impl<'b, 'a, 'v> hir_visit::Visitor<'v> for RootCollector<'b, 'a, 'v> {
|
||||||
generics.is_type_parameterized()
|
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::TyInfer(_) |
|
||||||
ty::TyProjection(..) |
|
ty::TyProjection(..) |
|
||||||
ty::TyParam(_) => {
|
ty::TyParam(_) => {
|
||||||
cx.sess().bug(&format!("debuginfo: Trying to create type name for \
|
bug!("debuginfo: Trying to create type name for \
|
||||||
unexpected type: {:?}", t));
|
unexpected type: {:?}", t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -194,9 +194,7 @@ impl<'tcx> VariantInfo<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
_ => {
|
_ => {
|
||||||
tcx.sess.bug(&format!(
|
bug!("cannot get field types from the type {:?}", ty);
|
||||||
"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 {
|
pub fn field_index(&self, name: ast::Name) -> usize {
|
||||||
self.fields.iter().position(|&Field(n,_)| n == name).unwrap_or_else(|| {
|
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) {
|
match self.tcx().def_map.borrow().get(&nid) {
|
||||||
Some(v) => v.full_def(),
|
Some(v) => v.full_def(),
|
||||||
None => {
|
None => {
|
||||||
self.tcx().sess.bug(&format!(
|
bug!("no def associated with node id {}", nid);
|
||||||
"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 gsym = token::gensym("str");
|
||||||
let sym = format!("str{}", gsym.0);
|
let sym = format!("str{}", gsym.0);
|
||||||
let g = declare::define_global(cx, &sym[..], val_ty(sc)).unwrap_or_else(||{
|
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::LLVMSetInitializer(g, sc);
|
||||||
llvm::LLVMSetGlobalConstant(g, True);
|
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)");
|
"reached the recursion limit during monomorphization (selection ambiguity)");
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
tcx.sess.span_bug(
|
span_bug!(
|
||||||
span,
|
span,
|
||||||
&format!("Encountered error `{:?}` selecting `{:?}` during trans",
|
"Encountered error `{:?}` selecting `{:?}` during trans",
|
||||||
e,
|
e,
|
||||||
trait_ref))
|
trait_ref)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1194,7 +1191,7 @@ pub fn inlined_variant_def<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||||
inlined_vid_def_id == v.did ||
|
inlined_vid_def_id == v.did ||
|
||||||
ccx.external().borrow().get(&v.did) == Some(&Some(inlined_vid))
|
ccx.external().borrow().get(&v.did) == Some(&Some(inlined_vid))
|
||||||
}).unwrap_or_else(|| {
|
}).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);
|
let mask = shift_mask_val(bcx, llty.element_type(), mask_llty.element_type(), invert);
|
||||||
build::VectorSplat(bcx, mask_llty.vector_length(), mask)
|
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) => {
|
ty::TyUint(t) => {
|
||||||
C_integral(Type::uint_from_ty(cx, t), i as u64, false)
|
C_integral(Type::uint_from_ty(cx, t), i as u64, false)
|
||||||
}
|
}
|
||||||
_ => cx.sess().span_bug(lit.span,
|
_ => span_bug!(lit.span,
|
||||||
&format!("integer literal has type {:?} (expected int \
|
"integer literal has type {:?} (expected int \
|
||||||
or usize)",
|
or usize)",
|
||||||
lit_int_ty))
|
lit_int_ty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LitKind::Float(ref fs, t) => {
|
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))
|
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");
|
"floating point literal doesn't have the right type");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,7 @@ fn addr_of_mut(ccx: &CrateContext,
|
||||||
let gsym = token::gensym("_");
|
let gsym = token::gensym("_");
|
||||||
let name = format!("{}{}", kind, gsym.0);
|
let name = format!("{}{}", kind, gsym.0);
|
||||||
let gv = declare::define_global(ccx, &name[..], val_ty(cv)).unwrap_or_else(||{
|
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::LLVMSetInitializer(gv, cv);
|
||||||
llvm::LLVMSetAlignment(gv, align);
|
llvm::LLVMSetAlignment(gv, align);
|
||||||
|
@ -186,8 +186,7 @@ fn const_deref<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
cx.sess().bug(&format!("unexpected dereferenceable type {:?}",
|
bug!("unexpected dereferenceable type {:?}", ty)
|
||||||
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)) {
|
match lookup_const_by_id(ccx.tcx(), def_id, Some(substs)) {
|
||||||
Some((ref expr, _ty)) => expr,
|
Some((ref expr, _ty)) => expr,
|
||||||
None => {
|
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;
|
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(llconst);
|
||||||
llvm::LLVMDumpValue(C_undef(llty));
|
llvm::LLVMDumpValue(C_undef(llty));
|
||||||
}
|
}
|
||||||
cx.sess().bug(&format!("const {:?} of type {:?} has size {} instead of {}",
|
bug!("const {:?} of type {:?} has size {} instead of {}",
|
||||||
e, ety_adjusted,
|
e, ety_adjusted,
|
||||||
csize, tsize));
|
csize, tsize);
|
||||||
}
|
}
|
||||||
Ok((llconst, ety_adjusted))
|
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,
|
fn check_binary_expr_validity(cx: &CrateContext, e: &hir::Expr, t: Ty,
|
||||||
te1: ValueRef, te2: ValueRef,
|
te1: ValueRef, te2: ValueRef,
|
||||||
trueconst: TrueConst) -> Result<(), ConstEvalFailure> {
|
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())) {
|
let (lhs, rhs) = match (to_const_int(te1, t, cx.tcx()), to_const_int(te2, t, cx.tcx())) {
|
||||||
(Some(v1), Some(v2)) => (v1, v2),
|
(Some(v1), Some(v2)) => (v1, v2),
|
||||||
_ => return Ok(()),
|
_ => 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 => {
|
hir::BiEq | hir::BiNe | hir::BiLt | hir::BiLe | hir::BiGt | hir::BiGe => {
|
||||||
if is_float {
|
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)
|
ConstFCmp(cmp, te1, te2)
|
||||||
} else {
|
} 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)
|
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 brepr = adt::represent_type(cx, bt);
|
||||||
let vinfo = VariantInfo::from_ty(cx.tcx(), bt, None);
|
let vinfo = VariantInfo::from_ty(cx.tcx(), bt, None);
|
||||||
let ix = vinfo.field_index(field.node);
|
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) => {
|
hir::ExprTupField(ref base, idx) => {
|
||||||
let (bv, bt) = const_expr(cx, &base, param_substs, fn_args, trueconst)?;
|
let (bv, bt) = const_expr(cx, &base, param_substs, fn_args, trueconst)?;
|
||||||
let brepr = adt::represent_type(cx, bt);
|
let brepr = adt::represent_type(cx, bt);
|
||||||
let vinfo = VariantInfo::from_ty(cx.tcx(), bt, None);
|
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) => {
|
hir::ExprIndex(ref base, ref index) => {
|
||||||
let (bv, bt) = const_expr(cx, &base, param_substs, fn_args, trueconst)?;
|
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) {
|
let iv = if let Some(iv) = const_to_opt_uint(iv) {
|
||||||
iv
|
iv
|
||||||
} else {
|
} 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 {
|
let (arr, len) = match bt.sty {
|
||||||
ty::TyArray(_, u) => (bv, C_uint(cx, u)),
|
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) => {
|
ty::TyArray(_, u) => {
|
||||||
(load_const(cx, bv, mt.ty), C_uint(cx, u))
|
(load_const(cx, bv, mt.ty), C_uint(cx, u))
|
||||||
},
|
},
|
||||||
_ => cx.sess().span_bug(base.span,
|
_ => span_bug!(base.span,
|
||||||
&format!("index-expr base must be a vector \
|
"index-expr base must be a vector \
|
||||||
or string type, found {:?}",
|
or string type, found {:?}",
|
||||||
bt)),
|
bt),
|
||||||
},
|
},
|
||||||
_ => cx.sess().span_bug(base.span,
|
_ => span_bug!(base.span,
|
||||||
&format!("index-expr base must be a vector \
|
"index-expr base must be a vector \
|
||||||
or string type, found {:?}",
|
or string type, found {:?}",
|
||||||
bt)),
|
bt),
|
||||||
};
|
};
|
||||||
|
|
||||||
let len = unsafe { llvm::LLVMConstIntGetZExtValue(len) as u64 };
|
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())
|
llvm::LLVMConstPtrToInt(v, llty.to_ref())
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
cx.sess().impossible_case(e.span,
|
span_bug!(e.span, "bad combination of types for cast")
|
||||||
"bad combination of types for cast")
|
|
||||||
},
|
},
|
||||||
} } // unsafe { match ( ... ) {
|
} } // unsafe { match ( ... ) {
|
||||||
},
|
},
|
||||||
|
@ -845,8 +843,8 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||||
(Some(ref f), _) => {
|
(Some(ref f), _) => {
|
||||||
const_expr(cx, &f.expr, param_substs, fn_args, trueconst).map(|(l, _)| l)
|
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)),
|
(_, Some((bv, _))) => Ok(adt::const_get_field(&repr, bv, discr, ix)),
|
||||||
(_, None) => cx.sess().span_bug(e.span, "missing struct field"),
|
(_, None) => span_bug!(e.span, "missing struct field"),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect::<Vec<Result<_, ConstEvalFailure>>>()
|
.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()) {
|
if let Some(val) = fn_args.and_then(|args| args.get(&id).cloned()) {
|
||||||
val
|
val
|
||||||
} else {
|
} 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),
|
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::Tuple => C_nil(cx),
|
||||||
ty::VariantKind::Struct => {
|
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.
|
// Unit struct or ctor.
|
||||||
Def::Struct(..) => C_null(type_of::type_of(cx, ety)),
|
Def::Struct(..) => C_null(type_of::type_of(cx, ety)),
|
||||||
_ => {
|
_ => {
|
||||||
cx.sess().span_bug(e.span, "expected a const, fn, struct, \
|
span_bug!(e.span, "expected a const, fn, struct, \
|
||||||
or variant def")
|
or variant def")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -969,7 +967,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||||
Disr::from(vinfo.disr_val),
|
Disr::from(vinfo.disr_val),
|
||||||
&arg_vals[..])
|
&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) => {
|
hir::ExprMethodCall(_, _, ref args) => {
|
||||||
|
@ -1003,14 +1001,14 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||||
substs);
|
substs);
|
||||||
}
|
}
|
||||||
_ =>
|
_ =>
|
||||||
cx.sess().span_bug(
|
span_bug!(
|
||||||
e.span,
|
e.span,
|
||||||
&format!("bad type for closure expr: {:?}", ety))
|
"bad type for closure expr: {:?}", ety)
|
||||||
}
|
}
|
||||||
C_null(type_of::type_of(cx, ety))
|
C_null(type_of::type_of(cx, ety))
|
||||||
},
|
},
|
||||||
_ => cx.sess().span_bug(e.span,
|
_ => span_bug!(e.span,
|
||||||
"bad constant expression type in consts::const_expr"),
|
"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
|
g
|
||||||
}
|
}
|
||||||
|
|
||||||
item => unreachable!("get_static: expected static, found {:?}", item)
|
item => bug!("get_static: expected static, found {:?}", item)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// FIXME(nagisa): perhaps the map of externs could be offloaded to llvm somehow?
|
// 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) {
|
match declare_intrinsic(self, key) {
|
||||||
Some(v) => return v,
|
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[..] {
|
match &self.sess().target.target.target_pointer_width[..] {
|
||||||
"32" => 1 << 31,
|
"32" => 1 << 31,
|
||||||
"64" => 1 << 47,
|
"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()) {
|
match bcx.tcx().def_map.borrow().get(&expr.id).map(|d| d.full_def()) {
|
||||||
Some(Def::Label(loop_id)) => loop_id,
|
Some(Def::Label(loop_id)) => loop_id,
|
||||||
r => {
|
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.
|
/// Asserts that this datum *is* an lvalue and returns it.
|
||||||
#[allow(dead_code)] // potentially useful
|
#[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(
|
self.match_kind(
|
||||||
|d| d,
|
|d| d,
|
||||||
|_| bcx.sess().bug("assert_lvalue given rvalue"))
|
|_| bug!("assert_lvalue given rvalue"))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn store_to_dest<'blk>(self,
|
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 {
|
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();
|
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,
|
let section_var = declare::define_global(ccx, section_var_name,
|
||||||
llvm_type).unwrap_or_else(||{
|
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::LLVMSetSection(section_var, section_name.as_ptr() as *const _);
|
||||||
llvm::LLVMSetInitializer(section_var, C_bytes(ccx, section_contents));
|
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
|
// Adds a Ty to metadata mapping to the TypeMap. The method will fail if
|
||||||
// the mapping already exists.
|
// the mapping already exists.
|
||||||
fn register_type_with_metadata<'a>(&mut self,
|
fn register_type_with_metadata<'a>(&mut self,
|
||||||
cx: &CrateContext<'a, 'tcx>,
|
|
||||||
type_: Ty<'tcx>,
|
type_: Ty<'tcx>,
|
||||||
metadata: DIType) {
|
metadata: DIType) {
|
||||||
if self.type_to_metadata.insert(type_, metadata).is_some() {
|
if self.type_to_metadata.insert(type_, metadata).is_some() {
|
||||||
cx.sess().bug(&format!("Type metadata for Ty '{}' is already in the TypeMap!",
|
bug!("Type metadata for Ty '{}' is already in the TypeMap!", type_);
|
||||||
type_));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adds a UniqueTypeId to metadata mapping to the TypeMap. The method will
|
// Adds a UniqueTypeId to metadata mapping to the TypeMap. The method will
|
||||||
// fail if the mapping already exists.
|
// fail if the mapping already exists.
|
||||||
fn register_unique_id_with_metadata(&mut self,
|
fn register_unique_id_with_metadata(&mut self,
|
||||||
cx: &CrateContext,
|
|
||||||
unique_type_id: UniqueTypeId,
|
unique_type_id: UniqueTypeId,
|
||||||
metadata: DIType) {
|
metadata: DIType) {
|
||||||
if self.unique_id_to_metadata.insert(unique_type_id, metadata).is_some() {
|
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);
|
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!",
|
bug!("Type metadata for unique id '{}' is already in the TypeMap!",
|
||||||
&unique_type_id_str[..]));
|
&unique_type_id_str[..]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -305,8 +302,8 @@ impl<'tcx> TypeMap<'tcx> {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
cx.sess().bug(&format!("get_unique_type_id_of_type() - unexpected type: {:?}",
|
bug!("get_unique_type_id_of_type() - unexpected type: {:?}",
|
||||||
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
|
// Insert the stub into the TypeMap in order to allow for recursive references
|
||||||
let mut type_map = debug_context(cx).type_map.borrow_mut();
|
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_unique_id_with_metadata(unique_type_id, metadata_stub);
|
||||||
type_map.register_type_with_metadata(cx, unfinished_type, metadata_stub);
|
type_map.register_type_with_metadata(unfinished_type, metadata_stub);
|
||||||
|
|
||||||
UnfinishedMetadata {
|
UnfinishedMetadata {
|
||||||
unfinished_type: unfinished_type,
|
unfinished_type: unfinished_type,
|
||||||
|
@ -452,10 +449,9 @@ impl<'tcx> RecursiveTypeDescription<'tcx> {
|
||||||
let type_map = debug_context(cx).type_map.borrow();
|
let type_map = debug_context(cx).type_map.borrow();
|
||||||
if type_map.find_metadata_for_unique_id(unique_type_id).is_none() ||
|
if type_map.find_metadata_for_unique_id(unique_type_id).is_none() ||
|
||||||
type_map.find_metadata_for_type(unfinished_type).is_none() {
|
type_map.find_metadata_for_type(unfinished_type).is_none() {
|
||||||
cx.sess().bug(&format!("Forward declaration of potentially recursive type \
|
bug!("Forward declaration of potentially recursive type \
|
||||||
'{:?}' was not found in TypeMap!",
|
'{:?}' was not found in TypeMap!",
|
||||||
unfinished_type)
|
unfinished_type);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -640,9 +636,9 @@ fn trait_pointer_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||||
let def_id = match trait_type.sty {
|
let def_id = match trait_type.sty {
|
||||||
ty::TyTrait(ref data) => data.principal_def_id(),
|
ty::TyTrait(ref data) => data.principal_def_id(),
|
||||||
_ => {
|
_ => {
|
||||||
cx.sess().bug(&format!("debuginfo: Unexpected trait-object type in \
|
bug!("debuginfo: Unexpected trait-object type in \
|
||||||
trait_pointer_metadata(): {:?}",
|
trait_pointer_metadata(): {:?}",
|
||||||
trait_type));
|
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.
|
// There is already an equivalent type in the TypeMap.
|
||||||
// Register this Ty as an alias in the cache and
|
// Register this Ty as an alias in the cache and
|
||||||
// return the cached metadata.
|
// return the cached metadata.
|
||||||
type_map.register_type_with_metadata(cx, t, metadata);
|
type_map.register_type_with_metadata(t, metadata);
|
||||||
return metadata;
|
return metadata;
|
||||||
},
|
},
|
||||||
None => {
|
None => {
|
||||||
|
@ -803,8 +799,7 @@ pub fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||||
usage_site_span).finalize(cx)
|
usage_site_span).finalize(cx)
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
cx.sess().bug(&format!("debuginfo: unexpected type in type_metadata: {:?}",
|
bug!("debuginfo: unexpected type in type_metadata: {:?}", sty)
|
||||||
sty))
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -818,13 +813,13 @@ pub fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||||
None => {
|
None => {
|
||||||
let unique_type_id_str =
|
let unique_type_id_str =
|
||||||
type_map.get_unique_type_id_as_string(unique_type_id);
|
type_map.get_unique_type_id_as_string(unique_type_id);
|
||||||
let error_message = format!("Expected type metadata for unique \
|
span_bug!(usage_site_span,
|
||||||
type id '{}' to already be in \
|
"Expected type metadata for unique \
|
||||||
the debuginfo::TypeMap but it \
|
type id '{}' to already be in \
|
||||||
was not. (Ty = {})",
|
the debuginfo::TypeMap but it \
|
||||||
&unique_type_id_str[..],
|
was not. (Ty = {})",
|
||||||
t);
|
&unique_type_id_str[..],
|
||||||
cx.sess().span_bug(usage_site_span, &error_message[..]);
|
t);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -833,22 +828,22 @@ pub fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||||
if metadata != metadata_for_uid {
|
if metadata != metadata_for_uid {
|
||||||
let unique_type_id_str =
|
let unique_type_id_str =
|
||||||
type_map.get_unique_type_id_as_string(unique_type_id);
|
type_map.get_unique_type_id_as_string(unique_type_id);
|
||||||
let error_message = format!("Mismatch between Ty and \
|
span_bug!(usage_site_span,
|
||||||
UniqueTypeId maps in \
|
"Mismatch between Ty and \
|
||||||
debuginfo::TypeMap. \
|
UniqueTypeId maps in \
|
||||||
UniqueTypeId={}, Ty={}",
|
debuginfo::TypeMap. \
|
||||||
&unique_type_id_str[..],
|
UniqueTypeId={}, Ty={}",
|
||||||
t);
|
&unique_type_id_str[..],
|
||||||
cx.sess().span_bug(usage_site_span, &error_message[..]);
|
t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
type_map.register_type_with_metadata(cx, t, metadata);
|
type_map.register_type_with_metadata(t, metadata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
type_map.register_type_with_metadata(cx, t, metadata);
|
type_map.register_type_with_metadata(t, metadata);
|
||||||
type_map.register_unique_id_with_metadata(cx, unique_type_id, 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)
|
error_reporting_span: Span)
|
||||||
-> DIScope {
|
-> DIScope {
|
||||||
let scope_map = &fcx.debug_context
|
let scope_map = &fcx.debug_context
|
||||||
.get_ref(fcx.ccx, error_reporting_span)
|
.get_ref(error_reporting_span)
|
||||||
.scope_map;
|
.scope_map;
|
||||||
match scope_map.borrow().get(&node_id).cloned() {
|
match scope_map.borrow().get(&node_id).cloned() {
|
||||||
Some(scope_metadata) => scope_metadata,
|
Some(scope_metadata) => scope_metadata,
|
||||||
None => {
|
None => {
|
||||||
let node = fcx.ccx.tcx().map.get(node_id);
|
let node = fcx.ccx.tcx().map.get(node_id);
|
||||||
|
|
||||||
fcx.ccx.sess().span_bug(error_reporting_span,
|
span_bug!(error_reporting_span,
|
||||||
&format!("debuginfo: Could not find scope info for node {:?}",
|
"debuginfo: Could not find scope info for node {:?}",
|
||||||
node));
|
node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -945,7 +940,7 @@ fn basic_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||||
ty::TyFloat(float_ty) => {
|
ty::TyFloat(float_ty) => {
|
||||||
(float_ty.ty_to_string(), DW_ATE_float)
|
(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);
|
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 {
|
let (variant, substs) = match struct_type.sty {
|
||||||
ty::TyStruct(def, substs) => (def.struct_variant(), substs),
|
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);
|
let (containing_scope, _) = get_namespace_and_span_for_item(cx, variant.did);
|
||||||
|
@ -1362,7 +1357,7 @@ impl<'tcx> EnumMemberDescriptionFactory<'tcx> {
|
||||||
ty::VariantKind::Struct => {
|
ty::VariantKind::Struct => {
|
||||||
non_null_variant.fields[0].name.to_string()
|
non_null_variant.fields[0].name.to_string()
|
||||||
}
|
}
|
||||||
ty::VariantKind::Unit => unreachable!()
|
ty::VariantKind::Unit => bug!()
|
||||||
},
|
},
|
||||||
llvm_type: non_null_llvm_type,
|
llvm_type: non_null_llvm_type,
|
||||||
type_metadata: non_null_type_metadata,
|
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 =
|
let mut composite_types_completed =
|
||||||
debug_context(cx).composite_types_completed.borrow_mut();
|
debug_context(cx).composite_types_completed.borrow_mut();
|
||||||
if composite_types_completed.contains(&composite_type_metadata) {
|
if composite_types_completed.contains(&composite_type_metadata) {
|
||||||
cx.sess().bug("debuginfo::set_members_of_composite_type() - \
|
bug!("debuginfo::set_members_of_composite_type() - \
|
||||||
Already completed forward declaration re-encountered.");
|
Already completed forward declaration re-encountered.");
|
||||||
} else {
|
} else {
|
||||||
composite_types_completed.insert(composite_type_metadata);
|
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::ItemStatic(..) => (item.name, item.span),
|
||||||
hir::ItemConst(..) => (item.name, item.span),
|
hir::ItemConst(..) => (item.name, item.span),
|
||||||
_ => {
|
_ => {
|
||||||
cx.sess()
|
span_bug!(item.span,
|
||||||
.span_bug(item.span,
|
"debuginfo::\
|
||||||
&format!("debuginfo::\
|
create_global_var_metadata() -
|
||||||
create_global_var_metadata() -
|
Captured var-id refers to \
|
||||||
Captured var-id refers to \
|
unexpected ast_item variant: {:?}",
|
||||||
unexpected ast_item variant: {:?}",
|
var_item)
|
||||||
var_item))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_ => cx.sess().bug(&format!("debuginfo::create_global_var_metadata() \
|
_ => bug!("debuginfo::create_global_var_metadata() \
|
||||||
- Captured var-id refers to unexpected \
|
- Captured var-id refers to unexpected \
|
||||||
hir_map variant: {:?}",
|
hir_map variant: {:?}",
|
||||||
var_item))
|
var_item)
|
||||||
};
|
};
|
||||||
|
|
||||||
let (file_metadata, line_number) = if span != codemap::DUMMY_SP {
|
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) {
|
let datum = match locals.get(&node_id) {
|
||||||
Some(datum) => datum,
|
Some(datum) => datum,
|
||||||
None => {
|
None => {
|
||||||
bcx.sess().span_bug(span,
|
span_bug!(span,
|
||||||
&format!("no entry in lllocals table for {}",
|
"no entry in lllocals table for {}",
|
||||||
node_id));
|
node_id);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if unsafe { llvm::LLVMIsAAllocaInst(datum.val) } == ptr::null_mut() {
|
if unsafe { llvm::LLVMIsAAllocaInst(datum.val) } == ptr::null_mut() {
|
||||||
cx.sess().span_bug(span, "debuginfo::create_local_var_metadata() - \
|
span_bug!(span, "debuginfo::create_local_var_metadata() - \
|
||||||
Referenced variable location is not an alloca!");
|
Referenced variable location is not an alloca!");
|
||||||
}
|
}
|
||||||
|
|
||||||
let scope_metadata = scope_metadata(bcx.fcx, node_id, span);
|
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 {
|
let variable_name = match ast_item {
|
||||||
None => {
|
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)) => {
|
Some(hir_map::NodeLocal(pat)) => {
|
||||||
match pat.node {
|
match pat.node {
|
||||||
|
@ -1976,28 +1970,25 @@ pub fn create_captured_var_metadata<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||||
path1.node.name
|
path1.node.name
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
cx.sess()
|
span_bug!(span,
|
||||||
.span_bug(span,
|
"debuginfo::create_captured_var_metadata() - \
|
||||||
&format!(
|
Captured var-id refers to unexpected \
|
||||||
"debuginfo::create_captured_var_metadata() - \
|
hir_map variant: {:?}",
|
||||||
Captured var-id refers to unexpected \
|
ast_item);
|
||||||
hir_map variant: {:?}",
|
|
||||||
ast_item));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
cx.sess()
|
span_bug!(span,
|
||||||
.span_bug(span,
|
"debuginfo::create_captured_var_metadata() - \
|
||||||
&format!("debuginfo::create_captured_var_metadata() - \
|
Captured var-id refers to unexpected \
|
||||||
Captured var-id refers to unexpected \
|
hir_map variant: {:?}",
|
||||||
hir_map variant: {:?}",
|
ast_item);
|
||||||
ast_item));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let variable_type = common::node_id_type(bcx, node_id);
|
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,
|
// 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
|
// 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
|
let scope_metadata = bcx
|
||||||
.fcx
|
.fcx
|
||||||
.debug_context
|
.debug_context
|
||||||
.get_ref(bcx.ccx(), arg.pat.span)
|
.get_ref(arg.pat.span)
|
||||||
.fn_metadata;
|
.fn_metadata;
|
||||||
let locals = bcx.fcx.lllocals.borrow();
|
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) {
|
let datum = match locals.get(&node_id) {
|
||||||
Some(v) => v,
|
Some(v) => v,
|
||||||
None => {
|
None => {
|
||||||
bcx.sess().span_bug(span,
|
span_bug!(span, "no entry in lllocals table for {}", node_id);
|
||||||
&format!("no entry in lllocals table for {}",
|
|
||||||
node_id));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if unsafe { llvm::LLVMIsAAllocaInst(datum.val) } == ptr::null_mut() {
|
if unsafe { llvm::LLVMIsAAllocaInst(datum.val) } == ptr::null_mut() {
|
||||||
bcx.sess().span_bug(span, "debuginfo::create_argument_metadata() - \
|
span_bug!(span, "debuginfo::create_argument_metadata() - \
|
||||||
Referenced variable location is not an alloca!");
|
Referenced variable location is not an alloca!");
|
||||||
}
|
}
|
||||||
|
|
||||||
let argument_index = {
|
let argument_index = {
|
||||||
let counter = &bcx
|
let counter = &bcx
|
||||||
.fcx
|
.fcx
|
||||||
.debug_context
|
.debug_context
|
||||||
.get_ref(bcx.ccx(), span)
|
.get_ref(span)
|
||||||
.argument_counter;
|
.argument_counter;
|
||||||
let argument_index = counter.get();
|
let argument_index = counter.get();
|
||||||
counter.set(argument_index + 1);
|
counter.set(argument_index + 1);
|
||||||
|
|
|
@ -119,18 +119,19 @@ pub enum FunctionDebugContext {
|
||||||
|
|
||||||
impl FunctionDebugContext {
|
impl FunctionDebugContext {
|
||||||
fn get_ref<'a>(&'a self,
|
fn get_ref<'a>(&'a self,
|
||||||
cx: &CrateContext,
|
|
||||||
span: Span)
|
span: Span)
|
||||||
-> &'a FunctionDebugContextData {
|
-> &'a FunctionDebugContextData {
|
||||||
match *self {
|
match *self {
|
||||||
FunctionDebugContext::RegularContext(box ref data) => data,
|
FunctionDebugContext::RegularContext(box ref data) => data,
|
||||||
FunctionDebugContext::DebugInfoDisabled => {
|
FunctionDebugContext::DebugInfoDisabled => {
|
||||||
cx.sess().span_bug(span,
|
span_bug!(span,
|
||||||
FunctionDebugContext::debuginfo_disabled_message());
|
"{}",
|
||||||
|
FunctionDebugContext::debuginfo_disabled_message());
|
||||||
}
|
}
|
||||||
FunctionDebugContext::FunctionWithoutDebugInfo => {
|
FunctionDebugContext::FunctionWithoutDebugInfo => {
|
||||||
cx.sess().span_bug(span,
|
span_bug!(span,
|
||||||
FunctionDebugContext::should_be_ignored_message());
|
"{}",
|
||||||
|
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)
|
(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");
|
"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)
|
true)
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
cx.sess().span_bug(impl_item.span,
|
span_bug!(impl_item.span,
|
||||||
"create_function_debug_context() \
|
"create_function_debug_context() \
|
||||||
called on non-method impl item?!")
|
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:
|
// Don't try to lookup the item path:
|
||||||
false)
|
false)
|
||||||
}
|
}
|
||||||
_ => cx.sess().span_bug(expr.span,
|
_ => span_bug!(expr.span,
|
||||||
"create_function_debug_context: expected an expr_fn_block here")
|
"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)
|
true)
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
cx.sess()
|
bug!("create_function_debug_context: \
|
||||||
.bug(&format!("create_function_debug_context: \
|
unexpected sort of node: {:?}",
|
||||||
unexpected sort of node: {:?}",
|
fnitem)
|
||||||
fnitem))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -324,9 +324,9 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||||
hir_map::NodeStructCtor(..) => {
|
hir_map::NodeStructCtor(..) => {
|
||||||
return FunctionDebugContext::FunctionWithoutDebugInfo;
|
return FunctionDebugContext::FunctionWithoutDebugInfo;
|
||||||
}
|
}
|
||||||
_ => cx.sess().bug(&format!("create_function_debug_context: \
|
_ => bug!("create_function_debug_context: \
|
||||||
unexpected sort of node: {:?}",
|
unexpected sort of node: {:?}",
|
||||||
fnitem))
|
fnitem)
|
||||||
};
|
};
|
||||||
|
|
||||||
// This can be the case for functions inlined from another crate
|
// 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)
|
(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);
|
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 => {
|
ArgumentVariable(_) | CapturedVariable => {
|
||||||
assert!(!bcx.fcx
|
assert!(!bcx.fcx
|
||||||
.debug_context
|
.debug_context
|
||||||
.get_ref(cx, span)
|
.get_ref(span)
|
||||||
.source_locations_enabled
|
.source_locations_enabled
|
||||||
.get());
|
.get());
|
||||||
source_loc::set_debug_location(cx, InternalDebugLocation::UnknownLocation);
|
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 {
|
match parent_node {
|
||||||
Some(node) => node,
|
Some(node) => node,
|
||||||
None => {
|
None => {
|
||||||
cx.sess().bug(&format!("debuginfo::namespace_for_item(): \
|
bug!("debuginfo::namespace_for_item(): \
|
||||||
path too short for {:?}",
|
path too short for {:?}",
|
||||||
def_id));
|
def_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -154,8 +154,8 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||||
ty::TyInfer(_) |
|
ty::TyInfer(_) |
|
||||||
ty::TyProjection(..) |
|
ty::TyProjection(..) |
|
||||||
ty::TyParam(_) => {
|
ty::TyParam(_) => {
|
||||||
cx.sess().bug(&format!("debuginfo: Trying to create type name for \
|
bug!("debuginfo: Trying to create type name for \
|
||||||
unexpected type: {:?}", t));
|
unexpected type: {:?}", t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
if path_element_count == 0 {
|
if path_element_count == 0 {
|
||||||
cx.sess().bug("debuginfo: Encountered empty item path!");
|
bug!("debuginfo: Encountered empty item path!");
|
||||||
}
|
}
|
||||||
|
|
||||||
output.pop();
|
output.pop();
|
||||||
|
|
|
@ -91,8 +91,8 @@ pub fn assert_type_for_node_id(cx: &CrateContext,
|
||||||
node_id: ast::NodeId,
|
node_id: ast::NodeId,
|
||||||
error_reporting_span: Span) {
|
error_reporting_span: Span) {
|
||||||
if !cx.tcx().node_types().contains_key(&node_id) {
|
if !cx.tcx().node_types().contains_key(&node_id) {
|
||||||
cx.sess().span_bug(error_reporting_span,
|
span_bug!(error_reporting_span,
|
||||||
"debuginfo: Could not find type for node id!");
|
"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 {
|
pub fn declare_global(ccx: &CrateContext, name: &str, ty: Type) -> llvm::ValueRef {
|
||||||
debug!("declare_global(name={:?})", name);
|
debug!("declare_global(name={:?})", name);
|
||||||
let namebuf = CString::new(name).unwrap_or_else(|_|{
|
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 {
|
unsafe {
|
||||||
llvm::LLVMGetOrInsertGlobal(ccx.llmod(), namebuf.as_ptr(), ty.to_ref())
|
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 {
|
fn declare_raw_fn(ccx: &CrateContext, name: &str, callconv: llvm::CallConv, ty: Type) -> ValueRef {
|
||||||
debug!("declare_raw_fn(name={:?}, ty={:?})", name, ty);
|
debug!("declare_raw_fn(name={:?}, ty={:?})", name, ty);
|
||||||
let namebuf = CString::new(name).unwrap_or_else(|_|{
|
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 {
|
let llfn = unsafe {
|
||||||
llvm::LLVMGetOrInsertFunction(ccx.llmod(), namebuf.as_ptr(), ty.to_ref())
|
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> {
|
pub fn get_defined_value(ccx: &CrateContext, name: &str) -> Option<ValueRef> {
|
||||||
debug!("get_defined_value(name={:?})", name);
|
debug!("get_defined_value(name={:?})", name);
|
||||||
let namebuf = CString::new(name).unwrap_or_else(|_|{
|
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()) };
|
let val = unsafe { llvm::LLVMGetNamedValue(ccx.llmod(), namebuf.as_ptr()) };
|
||||||
if val.is_null() {
|
if val.is_null() {
|
||||||
|
|
|
@ -388,7 +388,7 @@ fn apply_adjustments<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||||
.reify(bcx.ccx()).to_expr_datum();
|
.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 repr_source = adt::represent_type(bcx.ccx(), source.ty);
|
||||||
let src_fields = match &*repr_source {
|
let src_fields = match &*repr_source {
|
||||||
&adt::Repr::Univariant(ref s, _) => &s.fields,
|
&adt::Repr::Univariant(ref s, _) => &s.fields,
|
||||||
_ => bcx.sess().span_bug(span,
|
_ => span_bug!(span,
|
||||||
&format!("Non univariant struct? (repr_source: {:?})",
|
"Non univariant struct? (repr_source: {:?})",
|
||||||
repr_source)),
|
repr_source),
|
||||||
};
|
};
|
||||||
let repr_target = adt::represent_type(bcx.ccx(), target.ty);
|
let repr_target = adt::represent_type(bcx.ccx(), target.ty);
|
||||||
let target_fields = match &*repr_target {
|
let target_fields = match &*repr_target {
|
||||||
&adt::Repr::Univariant(ref s, _) => &s.fields,
|
&adt::Repr::Univariant(ref s, _) => &s.fields,
|
||||||
_ => bcx.sess().span_bug(span,
|
_ => span_bug!(span,
|
||||||
&format!("Non univariant struct? (repr_target: {:?})",
|
"Non univariant struct? (repr_target: {:?})",
|
||||||
repr_target)),
|
repr_target),
|
||||||
};
|
};
|
||||||
|
|
||||||
let coerce_index = match kind {
|
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 {:?} -> {:?}",
|
_ => bug!("coerce_unsized: invalid coercion {:?} -> {:?}",
|
||||||
source.ty,
|
source.ty,
|
||||||
target.ty))
|
target.ty)
|
||||||
}
|
}
|
||||||
bcx
|
bcx
|
||||||
}
|
}
|
||||||
|
@ -671,8 +671,8 @@ fn trans_datum_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||||
ty::TyBox(..) => {
|
ty::TyBox(..) => {
|
||||||
trans_uniq_expr(bcx, expr, box_ty, &contents, contents_ty)
|
trans_uniq_expr(bcx, expr, box_ty, &contents, contents_ty)
|
||||||
}
|
}
|
||||||
_ => bcx.sess().span_bug(expr.span,
|
_ => span_bug!(expr.span,
|
||||||
"expected unique box")
|
"expected unique box")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -708,11 +708,11 @@ fn trans_datum_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||||
trans_imm_cast(bcx, &val, expr.id)
|
trans_imm_cast(bcx, &val, expr.id)
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
bcx.tcx().sess.span_bug(
|
span_bug!(
|
||||||
expr.span,
|
expr.span,
|
||||||
&format!("trans_rvalue_datum_unadjusted reached \
|
"trans_rvalue_datum_unadjusted reached \
|
||||||
fall-through case: {:?}",
|
fall-through case: {:?}",
|
||||||
expr.node));
|
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();
|
bcx.tcx().no_late_bound_regions(&method_ty.fn_ret()).unwrap().unwrap();
|
||||||
let elt_ty = match ref_ty.builtin_deref(true, ty::NoPreference) {
|
let elt_ty = match ref_ty.builtin_deref(true, ty::NoPreference) {
|
||||||
None => {
|
None => {
|
||||||
bcx.tcx().sess.span_bug(index_expr.span,
|
span_bug!(index_expr.span,
|
||||||
"index method didn't return a \
|
"index method didn't return a \
|
||||||
dereferenceable type?!")
|
dereferenceable type?!")
|
||||||
}
|
}
|
||||||
Some(elt_tm) => elt_tm.ty,
|
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) {
|
match bcx.fcx.llupvars.borrow().get(&nid) {
|
||||||
Some(&val) => Datum::new(val, local_ty, lval),
|
Some(&val) => Datum::new(val, local_ty, lval),
|
||||||
None => {
|
None => {
|
||||||
bcx.sess().bug(&format!(
|
bug!("trans_var: no llval for upvar {} found", nid);
|
||||||
"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) {
|
let datum = match bcx.fcx.lllocals.borrow().get(&nid) {
|
||||||
Some(&v) => v,
|
Some(&v) => v,
|
||||||
None => {
|
None => {
|
||||||
bcx.sess().bug(&format!(
|
bug!("trans_var: no datum for local/arg {} found", nid);
|
||||||
"trans_var: no datum for local/arg {} found",
|
|
||||||
nid));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
debug!("take_local(nid={}, v={:?}, ty={})",
|
debug!("take_local(nid={}, v={:?}, ty={})",
|
||||||
nid, Value(datum.val), datum.ty);
|
nid, Value(datum.val), datum.ty);
|
||||||
datum
|
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
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
bcx.tcx().sess.span_bug(
|
span_bug!(
|
||||||
expr.span,
|
expr.span,
|
||||||
&format!("trans_rvalue_stmt_unadjusted reached \
|
"trans_rvalue_stmt_unadjusted reached \
|
||||||
fall-through case: {:?}",
|
fall-through case: {:?}",
|
||||||
expr.node));
|
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)
|
tvec::trans_lit_str(bcx, expr, (*s).clone(), dest)
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
bcx.tcx()
|
span_bug!(expr.span,
|
||||||
.sess
|
"trans_rvalue_dps_unadjusted shouldn't be \
|
||||||
.span_bug(expr.span,
|
translating this type of literal")
|
||||||
"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 {
|
let (def_id, substs) = match expr_ty(bcx, expr).sty {
|
||||||
ty::TyClosure(def_id, ref substs) => (def_id, substs),
|
ty::TyClosure(def_id, ref substs) => (def_id, substs),
|
||||||
ref t =>
|
ref t =>
|
||||||
bcx.tcx().sess.span_bug(
|
span_bug!(
|
||||||
expr.span,
|
expr.span,
|
||||||
&format!("closure expr without closure type: {:?}", t)),
|
"closure expr without closure type: {:?}", t),
|
||||||
};
|
};
|
||||||
|
|
||||||
closure::trans_closure_expr(dest,
|
closure::trans_closure_expr(dest,
|
||||||
|
@ -1172,8 +1166,8 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||||
Callee::ptr(f)
|
Callee::ptr(f)
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
bcx.tcx().sess.span_bug(expr.span,
|
span_bug!(expr.span,
|
||||||
&format!("type of callee is not a fn: {}", f.ty));
|
"type of callee is not a fn: {}", f.ty);
|
||||||
}
|
}
|
||||||
}, ArgExprs(&args))
|
}, ArgExprs(&args))
|
||||||
};
|
};
|
||||||
|
@ -1205,20 +1199,20 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||||
}
|
}
|
||||||
hir::ExprCast(..) => {
|
hir::ExprCast(..) => {
|
||||||
// Trait casts used to come this way, now they should be coercions.
|
// 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, _, _) => {
|
hir::ExprAssignOp(op, _, _) => {
|
||||||
bcx.tcx().sess.span_bug(
|
span_bug!(
|
||||||
expr.span,
|
expr.span,
|
||||||
&format!("augmented assignment `{}=` should always be a rvalue_stmt",
|
"augmented assignment `{}=` should always be a rvalue_stmt",
|
||||||
rustc_front::util::binop_to_string(op.node)))
|
rustc_front::util::binop_to_string(op.node))
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
bcx.tcx().sess.span_bug(
|
span_bug!(
|
||||||
expr.span,
|
expr.span,
|
||||||
&format!("trans_rvalue_dps_unadjusted reached fall-through \
|
"trans_rvalue_dps_unadjusted reached fall-through \
|
||||||
case: {:?}",
|
case: {:?}",
|
||||||
expr.node));
|
expr.node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1261,9 +1255,9 @@ fn trans_def_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||||
bcx
|
bcx
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
bcx.tcx().sess.span_bug(ref_expr.span, &format!(
|
span_bug!(ref_expr.span,
|
||||||
"Non-DPS def {:?} referened by {}",
|
"Non-DPS def {:?} referened by {}",
|
||||||
def, bcx.node_id_to_string(ref_expr.id)));
|
def, bcx.node_id_to_string(ref_expr.id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1301,7 +1295,7 @@ fn trans_struct<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
if need_base.iter().any(|b| *b) {
|
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
|
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));
|
bcx = trans_into(bcx, &base.expr, SaveIn(addr.value));
|
||||||
},
|
},
|
||||||
ExprKind::RvalueStmt => {
|
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"));
|
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)
|
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(I)) => FPToSI(bcx, llexpr, ll_t_out),
|
||||||
(Float, Int(_)) => FPToUI(bcx, llexpr, ll_t_out),
|
(Float, Int(_)) => FPToUI(bcx, llexpr, ll_t_out),
|
||||||
|
|
||||||
_ => ccx.sess().span_bug(expr.span,
|
_ => span_bug!(expr.span,
|
||||||
&format!("translating unsupported cast: \
|
"translating unsupported cast: \
|
||||||
{:?} -> {:?}",
|
{:?} -> {:?}",
|
||||||
t_in,
|
t_in,
|
||||||
t_out)
|
t_out)
|
||||||
)
|
|
||||||
};
|
};
|
||||||
return immediate_rvalue_bcx(bcx, newval, t_out).to_expr_datumblock();
|
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,
|
expr.span,
|
||||||
&format!("deref invoked on expr of invalid type {:?}",
|
"deref invoked on expr of invalid type {:?}",
|
||||||
datum.ty));
|
datum.ty);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2200,16 +2193,16 @@ impl OverflowOpViaIntrinsic {
|
||||||
TyInt(Is) => match &tcx.sess.target.target.target_pointer_width[..] {
|
TyInt(Is) => match &tcx.sess.target.target.target_pointer_width[..] {
|
||||||
"32" => TyInt(I32),
|
"32" => TyInt(I32),
|
||||||
"64" => TyInt(I64),
|
"64" => TyInt(I64),
|
||||||
_ => panic!("unsupported target word size")
|
_ => bug!("unsupported target word size")
|
||||||
},
|
},
|
||||||
TyUint(Us) => match &tcx.sess.target.target.target_pointer_width[..] {
|
TyUint(Us) => match &tcx.sess.target.target.target_pointer_width[..] {
|
||||||
"32" => TyUint(U32),
|
"32" => TyUint(U32),
|
||||||
"64" => TyUint(U64),
|
"64" => TyUint(U64),
|
||||||
_ => panic!("unsupported target word size")
|
_ => bug!("unsupported target word size")
|
||||||
},
|
},
|
||||||
ref t @ TyUint(_) | ref t @ TyInt(_) => t.clone(),
|
ref t @ TyUint(_) | ref t @ TyInt(_) => t.clone(),
|
||||||
_ => panic!("tried to get overflow intrinsic for {:?} applied to non-int type",
|
_ => bug!("tried to get overflow intrinsic for {:?} applied to non-int type",
|
||||||
*self)
|
*self)
|
||||||
};
|
};
|
||||||
|
|
||||||
match *self {
|
match *self {
|
||||||
|
@ -2224,7 +2217,7 @@ impl OverflowOpViaIntrinsic {
|
||||||
TyUint(U32) => "llvm.uadd.with.overflow.i32",
|
TyUint(U32) => "llvm.uadd.with.overflow.i32",
|
||||||
TyUint(U64) => "llvm.uadd.with.overflow.i64",
|
TyUint(U64) => "llvm.uadd.with.overflow.i64",
|
||||||
|
|
||||||
_ => unreachable!(),
|
_ => bug!(),
|
||||||
},
|
},
|
||||||
OverflowOpViaIntrinsic::Sub => match new_sty {
|
OverflowOpViaIntrinsic::Sub => match new_sty {
|
||||||
TyInt(I8) => "llvm.ssub.with.overflow.i8",
|
TyInt(I8) => "llvm.ssub.with.overflow.i8",
|
||||||
|
@ -2237,7 +2230,7 @@ impl OverflowOpViaIntrinsic {
|
||||||
TyUint(U32) => "llvm.usub.with.overflow.i32",
|
TyUint(U32) => "llvm.usub.with.overflow.i32",
|
||||||
TyUint(U64) => "llvm.usub.with.overflow.i64",
|
TyUint(U64) => "llvm.usub.with.overflow.i64",
|
||||||
|
|
||||||
_ => unreachable!(),
|
_ => bug!(),
|
||||||
},
|
},
|
||||||
OverflowOpViaIntrinsic::Mul => match new_sty {
|
OverflowOpViaIntrinsic::Mul => match new_sty {
|
||||||
TyInt(I8) => "llvm.smul.with.overflow.i8",
|
TyInt(I8) => "llvm.smul.with.overflow.i8",
|
||||||
|
@ -2250,7 +2243,7 @@ impl OverflowOpViaIntrinsic {
|
||||||
TyUint(U32) => "llvm.umul.with.overflow.i32",
|
TyUint(U32) => "llvm.umul.with.overflow.i32",
|
||||||
TyUint(U64) => "llvm.umul.with.overflow.i64",
|
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));
|
let int_value = BitCast(bcx, value, Type::ix(bcx.ccx(), width));
|
||||||
build_nonzero_check(bcx, int_value, binop_debug_loc)
|
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::AssociatedConst(..) => ExprKind::RvalueDatum,
|
||||||
|
|
||||||
def => {
|
def => {
|
||||||
tcx.sess.span_bug(
|
span_bug!(
|
||||||
expr.span,
|
expr.span,
|
||||||
&format!("uncategorized def for expr {}: {:?}",
|
"uncategorized def for expr {}: {:?}",
|
||||||
expr.id,
|
expr.id,
|
||||||
def));
|
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) {
|
let vtbl = match fulfill_obligation(bcx.ccx(), DUMMY_SP, trait_ref) {
|
||||||
traits::VtableImpl(data) => data,
|
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();
|
let dtor_did = def.destructor().unwrap();
|
||||||
bcx = Callee::def(bcx.ccx(), dtor_did, vtbl.substs)
|
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)),
|
(bcx.mul(info, C_uint(bcx.ccx(), unit_size)),
|
||||||
C_uint(bcx.ccx(), unit_align))
|
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, _) => {
|
hir::ItemStruct(ref struct_def, _) => {
|
||||||
if struct_def.is_struct() {
|
if struct_def.is_struct() {
|
||||||
ccx.sess().bug("instantiate_inline: called on a \
|
bug!("instantiate_inline: called on a \
|
||||||
non-tuple struct")
|
non-tuple struct")
|
||||||
} else {
|
} else {
|
||||||
ccx.external().borrow_mut().insert(fn_id, Some(struct_def.id()));
|
ccx.external().borrow_mut().insert(fn_id, Some(struct_def.id()));
|
||||||
ccx.external_srcs().borrow_mut().insert(struct_def.id(), fn_id);
|
ccx.external_srcs().borrow_mut().insert(struct_def.id(), fn_id);
|
||||||
my_id = struct_def.id();
|
my_id = struct_def.id();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => ccx.sess().bug("instantiate_inline: item has a \
|
_ => bug!("instantiate_inline: item has a \
|
||||||
non-enum, non-struct parent")
|
non-enum, non-struct parent")
|
||||||
}
|
}
|
||||||
my_id
|
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);
|
let sig = tcx.erase_late_bound_regions(&fty.sig);
|
||||||
(def_id, substs, infer::normalize_associated_type(tcx, &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 arg_tys = sig.inputs;
|
||||||
let ret_ty = sig.output;
|
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 name == "move_val_init" {
|
||||||
if let callee::ArgExprs(ref exprs) = args {
|
if let callee::ArgExprs(ref exprs) = args {
|
||||||
let (dest_expr, source_expr) = if exprs.len() != 2 {
|
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 {
|
} else {
|
||||||
(&exprs[0], &exprs[1])
|
(&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);
|
return Result::new(bcx, llresult);
|
||||||
} else {
|
} 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 {
|
let ret_ty = match ret_ty {
|
||||||
ty::FnConverging(ret_ty) => ret_ty,
|
ty::FnConverging(ret_ty) => ret_ty,
|
||||||
ty::FnDiverging => unreachable!()
|
ty::FnDiverging => bug!()
|
||||||
};
|
};
|
||||||
|
|
||||||
let llret_ty = type_of::type_of(ccx, ret_ty);
|
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 {
|
} else {
|
||||||
URem(bcx, llargs[0], llargs[1], call_debug_location)
|
URem(bcx, llargs[0], llargs[1], call_debug_location)
|
||||||
},
|
},
|
||||||
_ => unreachable!(),
|
_ => bug!(),
|
||||||
},
|
},
|
||||||
None => {
|
None => {
|
||||||
span_invalid_monomorphization_error(
|
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),
|
"fmul_fast" => FMulFast(bcx, llargs[0], llargs[1], call_debug_location),
|
||||||
"fdiv_fast" => FDivFast(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),
|
"frem_fast" => FRemFast(bcx, llargs[0], llargs[1], call_debug_location),
|
||||||
_ => unreachable!(),
|
_ => bug!(),
|
||||||
},
|
},
|
||||||
None => {
|
None => {
|
||||||
span_invalid_monomorphization_error(
|
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) {
|
let intr = match Intrinsic::find(&name) {
|
||||||
Some(intr) => intr,
|
Some(intr) => intr,
|
||||||
None => unreachable!("unknown intrinsic '{}'", name),
|
None => bug!("unknown intrinsic '{}'", name),
|
||||||
};
|
};
|
||||||
fn one<T>(x: Vec<T>) -> T {
|
fn one<T>(x: Vec<T>) -> T {
|
||||||
assert_eq!(x.len(), 1);
|
assert_eq!(x.len(), 1);
|
||||||
|
@ -839,7 +839,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
||||||
match x {
|
match x {
|
||||||
32 => vec![Type::f32(ccx)],
|
32 => vec![Type::f32(ccx)],
|
||||||
64 => vec![Type::f64(ccx)],
|
64 => vec![Type::f64(ccx)],
|
||||||
_ => unreachable!()
|
_ => bug!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Pointer(ref t, ref llvm_elem, _const) => {
|
Pointer(ref t, ref llvm_elem, _const) => {
|
||||||
|
@ -1242,7 +1242,7 @@ fn trans_gnu_try<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||||
Some(did) => {
|
Some(did) => {
|
||||||
Callee::def(ccx, did, tcx.mk_substs(Substs::empty())).reify(ccx).val
|
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");
|
let then = bcx.fcx.new_temp_block("then");
|
||||||
|
@ -1357,7 +1357,7 @@ fn generate_filter_fn<'a, 'tcx>(fcx: &FunctionContext<'a, 'tcx>,
|
||||||
Some(did) => {
|
Some(did) => {
|
||||||
Callee::def(ccx, did, tcx.mk_substs(Substs::empty())).reify(ccx).val
|
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);
|
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);
|
do_trans(bcx, exn, rbp);
|
||||||
})
|
})
|
||||||
} else {
|
} 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") {
|
if name.starts_with("simd_shuffle") {
|
||||||
let n: usize = match name["simd_shuffle".len()..].parse() {
|
let n: usize = match name["simd_shuffle".len()..].parse() {
|
||||||
Ok(n) => n,
|
Ok(n) => n,
|
||||||
Err(_) => tcx.sess.span_bug(span,
|
Err(_) => span_bug!(span,
|
||||||
"bad `simd_shuffle` instruction only caught in trans?")
|
"bad `simd_shuffle` instruction only caught in trans?")
|
||||||
};
|
};
|
||||||
|
|
||||||
require_simd!(ret_ty, "return");
|
require_simd!(ret_ty, "return");
|
||||||
|
@ -1687,7 +1687,7 @@ fn generic_simd_intrinsic<'blk, 'tcx, 'a>
|
||||||
simd_or: TyUint, TyInt => Or;
|
simd_or: TyUint, TyInt => Or;
|
||||||
simd_xor: TyUint, TyInt => Xor;
|
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
|
// 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[..] {
|
match &ccx.tcx().sess.target.target.target_pointer_width[..] {
|
||||||
"32" => 32,
|
"32" => 32,
|
||||||
"64" => 64,
|
"64" => 64,
|
||||||
tws => panic!("Unsupported target word size for isize: {}", tws),
|
tws => bug!("Unsupported target word size for isize: {}", tws),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ast::IntTy::I8 => 8,
|
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[..] {
|
match &ccx.tcx().sess.target.target.target_pointer_width[..] {
|
||||||
"32" => 32,
|
"32" => 32,
|
||||||
"64" => 64,
|
"64" => 64,
|
||||||
tws => panic!("Unsupported target word size for usize: {}", tws),
|
tws => bug!("Unsupported target word size for usize: {}", tws),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ast::UintTy::U8 => 8,
|
ast::UintTy::U8 => 8,
|
||||||
|
|
|
@ -43,7 +43,7 @@ extern crate flate;
|
||||||
extern crate getopts;
|
extern crate getopts;
|
||||||
extern crate graphviz;
|
extern crate graphviz;
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
extern crate rustc;
|
#[macro_use] extern crate rustc;
|
||||||
extern crate rustc_back;
|
extern crate rustc_back;
|
||||||
extern crate rustc_data_structures;
|
extern crate rustc_data_structures;
|
||||||
extern crate rustc_front;
|
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
|
// this would imply that the Self type being erased is
|
||||||
// an object type; this cannot happen because we
|
// an object type; this cannot happen because we
|
||||||
// cannot cast an unsized type into a trait object
|
// cannot cast an unsized type into a trait object
|
||||||
tcx.sess.bug(
|
bug!("cannot get vtable for an object type: {:?}",
|
||||||
&format!("cannot get vtable for an object type: {:?}",
|
data);
|
||||||
data));
|
|
||||||
}
|
}
|
||||||
traits::VtableParam(..) => {
|
traits::VtableParam(..) => {
|
||||||
tcx.sess.bug(
|
bug!("resolved vtable for {:?} to bad vtable {:?} in trans",
|
||||||
&format!("resolved vtable for {:?} to bad vtable {:?} in trans",
|
trait_ref,
|
||||||
trait_ref,
|
vtable);
|
||||||
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) {
|
let trt_id = match tcx.impl_trait_ref(impl_id) {
|
||||||
Some(t_id) => t_id.def_id,
|
Some(t_id) => t_id.def_id,
|
||||||
None => ccx.sess().bug("make_impl_vtable: don't know how to \
|
None => bug!("make_impl_vtable: don't know how to \
|
||||||
make a vtable for a type impl!")
|
make a vtable for a type impl!")
|
||||||
};
|
};
|
||||||
|
|
||||||
tcx.populate_implementations_for_trait_if_necessary(trt_id);
|
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) {
|
let trait_method_type = match tcx.impl_or_trait_item(trait_method_def_id) {
|
||||||
ty::MethodTraitItem(m) => m,
|
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;
|
let name = trait_method_type.name;
|
||||||
|
|
||||||
|
@ -330,7 +328,7 @@ pub fn get_impl_method<'tcx>(tcx: &TyCtxt<'tcx>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => {
|
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
|
ty: callee.ty
|
||||||
}, f.abi, &f.sig)
|
}, 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.
|
// Handle intrinsics old trans wants Expr's for, ourselves.
|
||||||
|
@ -295,7 +295,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Fn(f) => f,
|
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
|
// Many different ways to call a function handled here
|
||||||
|
@ -417,7 +417,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||||
}
|
}
|
||||||
Immediate(llval) => (llval, false),
|
Immediate(llval) => (llval, false),
|
||||||
Ref(llval) => (llval, true),
|
Ref(llval) => (llval, true),
|
||||||
FatPtr(_, _) => unreachable!("fat pointers handled above")
|
FatPtr(_, _) => bug!("fat pointers handled above")
|
||||||
};
|
};
|
||||||
|
|
||||||
if by_ref && !arg.is_indirect() {
|
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 lv_ty = lv.ty.to_ty(bcx.tcx());
|
||||||
let result_types = match lv_ty.sty {
|
let result_types = match lv_ty.sty {
|
||||||
ty::TyTuple(ref tys) => tys,
|
ty::TyTuple(ref tys) => tys,
|
||||||
_ => bcx.tcx().sess.span_bug(
|
_ => span_bug!(
|
||||||
self.mir.span,
|
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);
|
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::Struct(_) | ConstVal::Tuple(_) |
|
||||||
ConstVal::Array(..) | ConstVal::Repeat(..) |
|
ConstVal::Array(..) | ConstVal::Repeat(..) |
|
||||||
ConstVal::Function(_) => {
|
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::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());
|
assert!(lvalue.llextra != ptr::null_mut());
|
||||||
lvalue.llextra
|
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) =>
|
TempRef::Lvalue(lvalue) =>
|
||||||
lvalue,
|
lvalue,
|
||||||
TempRef::Operand(..) =>
|
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::Arg(index) => self.args[index as usize],
|
||||||
mir::Lvalue::Static(def_id) => {
|
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 {
|
let tupled_arg_tys = match arg_ty.sty {
|
||||||
ty::TyTuple(ref tys) => tys,
|
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| {
|
let lltemp = bcx.with_block(|bcx| {
|
||||||
|
|
|
@ -79,7 +79,7 @@ impl<'tcx> OperandRef<'tcx> {
|
||||||
pub fn immediate(self) -> ValueRef {
|
pub fn immediate(self) -> ValueRef {
|
||||||
match self.val {
|
match self.val {
|
||||||
OperandValue::Immediate(s) => s,
|
OperandValue::Immediate(s) => s,
|
||||||
_ => unreachable!()
|
_ => bug!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -124,8 +124,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
TempRef::Operand(None) => {
|
TempRef::Operand(None) => {
|
||||||
bcx.tcx().sess.bug(
|
bug!("use of {:?} before def", lvalue);
|
||||||
&format!("use of {:?} before def", lvalue));
|
|
||||||
}
|
}
|
||||||
TempRef::Lvalue(..) => {
|
TempRef::Lvalue(..) => {
|
||||||
// use path below
|
// use path below
|
||||||
|
|
|
@ -70,7 +70,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||||
let operand = self.trans_operand(&bcx, source);
|
let operand = self.trans_operand(&bcx, source);
|
||||||
bcx.with_block(|bcx| {
|
bcx.with_block(|bcx| {
|
||||||
match operand.val {
|
match operand.val {
|
||||||
OperandValue::FatPtr(..) => unreachable!(),
|
OperandValue::FatPtr(..) => bug!(),
|
||||||
OperandValue::Immediate(llval) => {
|
OperandValue::Immediate(llval) => {
|
||||||
// unsize from an immediate structure. We don't
|
// unsize from an immediate structure. We don't
|
||||||
// really need a temporary alloca here, but
|
// really need a temporary alloca here, but
|
||||||
|
@ -185,7 +185,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||||
ty::TySlice(_) | ty::TyStr => {
|
ty::TySlice(_) | ty::TyStr => {
|
||||||
(bcx.gepi(input.llval, &[from_start]), input.llextra)
|
(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 adj = C_uint(ccx, from_start + from_end);
|
||||||
let lllen1 = bcx.sub(lllen, adj);
|
let lllen1 = bcx.sub(lllen, adj);
|
||||||
|
@ -246,7 +246,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||||
.reify(bcx.ccx()).val)
|
.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::FatPtr(lldata, llextra)
|
||||||
}
|
}
|
||||||
OperandValue::Ref(_) => {
|
OperandValue::Ref(_) => {
|
||||||
bcx.sess().bug(
|
bug!("by-ref operand {:?} in trans_rvalue_operand",
|
||||||
&format!("by-ref operand {:?} in trans_rvalue_operand",
|
operand);
|
||||||
operand));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -341,9 +340,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||||
bcx.fptosi(llval, ll_t_out),
|
bcx.fptosi(llval, ll_t_out),
|
||||||
(CastTy::Float, CastTy::Int(_)) =>
|
(CastTy::Float, CastTy::Int(_)) =>
|
||||||
bcx.fptoui(llval, ll_t_out),
|
bcx.fptoui(llval, ll_t_out),
|
||||||
_ => bcx.ccx().sess().bug(
|
_ => bug!("unsupported cast: {:?} to {:?}", operand.ty, cast_ty)
|
||||||
&format!("unsupported cast: {:?} to {:?}", operand.ty, cast_ty)
|
|
||||||
)
|
|
||||||
};
|
};
|
||||||
OperandValue::Immediate(newval)
|
OperandValue::Immediate(newval)
|
||||||
}
|
}
|
||||||
|
@ -364,7 +361,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||||
OperandValue::Immediate(llval)
|
OperandValue::Immediate(llval)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
panic!("Unexpected non-FatPtr operand")
|
bug!("Unexpected non-FatPtr operand")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -425,7 +422,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||||
DebugLoc::None)
|
DebugLoc::None)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
_ => unreachable!()
|
_ => bug!()
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -489,7 +486,8 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||||
mir::Rvalue::Aggregate(..) |
|
mir::Rvalue::Aggregate(..) |
|
||||||
mir::Rvalue::Slice { .. } |
|
mir::Rvalue::Slice { .. } |
|
||||||
mir::Rvalue::InlineAsm { .. } => {
|
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
|
bcx
|
||||||
}
|
}
|
||||||
TempRef::Operand(Some(_)) => {
|
TempRef::Operand(Some(_)) => {
|
||||||
bcx.tcx().sess.span_bug(
|
span_bug!(statement.span,
|
||||||
statement.span,
|
"operand {:?} already assigned",
|
||||||
&format!("operand {:?} already assigned", rvalue));
|
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)
|
Disr::from(inlined_variant_def(ccx, fn_node_id).disr_val)
|
||||||
}
|
}
|
||||||
hir_map::NodeStructCtor(_) => Disr(0),
|
hir_map::NodeStructCtor(_) => Disr(0),
|
||||||
_ => unreachable!()
|
_ => bug!()
|
||||||
};
|
};
|
||||||
attributes::inline(lldecl, attributes::InlineAttr::Hint);
|
attributes::inline(lldecl, attributes::InlineAttr::Hint);
|
||||||
base::trans_ctor_shim(ccx, fn_node_id, disr, psubsts, lldecl);
|
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);
|
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,
|
span_bug!(content_expr.span, "unexpected evec content");
|
||||||
"unexpected evec content");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -236,8 +235,7 @@ fn write_content<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
bcx.tcx().sess.span_bug(content_expr.span,
|
span_bug!(content_expr.span, "unexpected vec content");
|
||||||
"unexpected vec content");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -264,8 +262,7 @@ fn elements_required(bcx: Block, content_expr: &hir::Expr) -> usize {
|
||||||
match lit.node {
|
match lit.node {
|
||||||
ast::LitKind::Str(ref s, _) => s.len(),
|
ast::LitKind::Str(ref s, _) => s.len(),
|
||||||
_ => {
|
_ => {
|
||||||
bcx.tcx().sess.span_bug(content_expr.span,
|
span_bug!(content_expr.span, "unexpected evec content")
|
||||||
"unexpected evec content")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -273,8 +270,7 @@ fn elements_required(bcx: Block, content_expr: &hir::Expr) -> usize {
|
||||||
hir::ExprRepeat(_, ref count_expr) => {
|
hir::ExprRepeat(_, ref count_expr) => {
|
||||||
eval_repeat_count(bcx.tcx(), &count_expr)
|
eval_repeat_count(bcx.tcx(), &count_expr)
|
||||||
}
|
}
|
||||||
_ => bcx.tcx().sess.span_bug(content_expr.span,
|
_ => span_bug!(content_expr.span, "unexpected vec content")
|
||||||
"unexpected vec content")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -298,8 +294,6 @@ pub fn get_base_and_len<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||||
llval: ValueRef,
|
llval: ValueRef,
|
||||||
vec_ty: Ty<'tcx>)
|
vec_ty: Ty<'tcx>)
|
||||||
-> (ValueRef, ValueRef) {
|
-> (ValueRef, ValueRef) {
|
||||||
let ccx = bcx.ccx();
|
|
||||||
|
|
||||||
match vec_ty.sty {
|
match vec_ty.sty {
|
||||||
ty::TyArray(_, n) => get_fixed_base_and_len(bcx, llval, n),
|
ty::TyArray(_, n) => get_fixed_base_and_len(bcx, llval, n),
|
||||||
ty::TySlice(_) | ty::TyStr => {
|
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)
|
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[..] {
|
match &ccx.tcx().sess.target.target.target_pointer_width[..] {
|
||||||
"32" => Type::i32(ccx),
|
"32" => Type::i32(ccx),
|
||||||
"64" => Type::i64(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,
|
Double => 64,
|
||||||
X86_FP80 => 80,
|
X86_FP80 => 80,
|
||||||
FP128 | PPC_FP128 => 128,
|
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 => {
|
ty::TyProjection(..) | ty::TyInfer(..) | ty::TyParam(..) | ty::TyError => {
|
||||||
cx.sess().bug(&format!("fictitious type {:?} in sizing_type_of()",
|
bug!("fictitious type {:?} in sizing_type_of()", t)
|
||||||
t))
|
|
||||||
}
|
}
|
||||||
ty::TySlice(_) | ty::TyTrait(..) | ty::TyStr => unreachable!()
|
ty::TySlice(_) | ty::TyTrait(..) | ty::TyStr => bug!()
|
||||||
};
|
};
|
||||||
|
|
||||||
debug!("--> mapped t={:?} to llsizingty={:?}", t, llsizingty);
|
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)
|
Type::uint_from_ty(ccx, ast::UintTy::Us)
|
||||||
}
|
}
|
||||||
ty::TyTrait(_) => Type::vtable_ptr(ccx),
|
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)
|
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::TyInfer(..) => bug!("type_of with TyInfer"),
|
||||||
ty::TyProjection(..) => cx.sess().bug("type_of with TyProjection"),
|
ty::TyProjection(..) => bug!("type_of with TyProjection"),
|
||||||
ty::TyParam(..) => cx.sess().bug("type_of with ty_param"),
|
ty::TyParam(..) => bug!("type_of with ty_param"),
|
||||||
ty::TyError => cx.sess().bug("type_of with TyError"),
|
ty::TyError => bug!("type_of with TyError"),
|
||||||
};
|
};
|
||||||
|
|
||||||
debug!("--> mapped t={:?} to llty={:?}", t, llty);
|
debug!("--> mapped t={:?} to llty={:?}", t, llty);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue