use type_::Type;
use syntax::symbol::Symbol;
+use syntax_pos::Pos;
use std::cmp;
}
mir::TerminatorKind::Drop { ref location, target, unwind } => {
- let ty = location.ty(&self.mir, bcx.tcx()).to_ty(bcx.tcx());
+ let ty = location.ty(self.mir, bcx.tcx()).to_ty(bcx.tcx());
let ty = self.monomorphize(&ty);
let drop_fn = monomorphize::resolve_drop_in_place(bcx.ccx.shared(), ty);
let filename = Symbol::intern(&loc.file.name).as_str();
let filename = C_str_slice(bcx.ccx, filename);
let line = C_u32(bcx.ccx, loc.line as u32);
+ let col = C_u32(bcx.ccx, loc.col.to_usize() as u32 + 1);
// Put together the arguments to the panic entry point.
let (lang_item, args, const_err) = match *msg {
index: index as u64
}));
- let file_line = C_struct(bcx.ccx, &[filename, line], false);
- let align = llalign_of_min(bcx.ccx, common::val_ty(file_line));
- let file_line = consts::addr_of(bcx.ccx,
- file_line,
- align,
- "panic_bounds_check_loc");
+ let file_line_col = C_struct(bcx.ccx, &[filename, line, col], false);
+ let align = llalign_of_min(bcx.ccx, common::val_ty(file_line_col));
+ let file_line_col = consts::addr_of(bcx.ccx,
+ file_line_col,
+ align,
+ "panic_bounds_check_loc");
(lang_items::PanicBoundsCheckFnLangItem,
- vec![file_line, index, len],
+ vec![file_line_col, index, len],
const_err)
}
mir::AssertMessage::Math(ref err) => {
let msg_str = Symbol::intern(err.description()).as_str();
let msg_str = C_str_slice(bcx.ccx, msg_str);
- let msg_file_line = C_struct(bcx.ccx,
- &[msg_str, filename, line],
+ let msg_file_line_col = C_struct(bcx.ccx,
+ &[msg_str, filename, line, col],
false);
- let align = llalign_of_min(bcx.ccx, common::val_ty(msg_file_line));
- let msg_file_line = consts::addr_of(bcx.ccx,
- msg_file_line,
- align,
- "panic_loc");
+ let align = llalign_of_min(bcx.ccx, common::val_ty(msg_file_line_col));
+ let msg_file_line_col = consts::addr_of(bcx.ccx,
+ msg_file_line_col,
+ align,
+ "panic_loc");
(lang_items::PanicFnLangItem,
- vec![msg_file_line],
+ vec![msg_file_line_col],
Some(ErrKind::Math(err.clone())))
}
};
// Create the callee. This is a fn ptr or zero-sized and hence a kind of scalar.
let callee = self.trans_operand(&bcx, func);
- let (instance, mut llfn, sig) = match callee.ty.sty {
- ty::TyFnDef(def_id, substs, sig) => {
+ let (instance, mut llfn) = match callee.ty.sty {
+ ty::TyFnDef(def_id, substs) => {
(Some(monomorphize::resolve(bcx.ccx.shared(), def_id, substs)),
- None,
- sig)
+ None)
}
- ty::TyFnPtr(sig) => {
- (None,
- Some(callee.immediate()),
- sig)
+ ty::TyFnPtr(_) => {
+ (None, Some(callee.immediate()))
}
_ => bug!("{} is not callable", callee.ty)
};
let def = instance.map(|i| i.def);
+ let sig = callee.ty.fn_sig(bcx.tcx());
let sig = bcx.tcx().erase_late_bound_regions_and_normalize(&sig);
let abi = sig.abi;
let extra_args = &args[sig.inputs().len()..];
let extra_args = extra_args.iter().map(|op_arg| {
- let op_ty = op_arg.ty(&self.mir, bcx.tcx());
+ let op_ty = op_arg.ty(self.mir, bcx.tcx());
self.monomorphize(&op_ty)
}).collect::<Vec<_>>();
Ref(ptr, align)
};
let op = OperandRef {
- val: val,
- ty: ty
+ val,
+ ty,
};
self.trans_argument(bcx, op, llargs, fn_ty, next_idx, llfn, def);
}
// If the tuple is immediate, the elements are as well
let op = OperandRef {
val: Immediate(elem),
- ty: ty
+ ty,
};
self.trans_argument(bcx, op, llargs, fn_ty, next_idx, llfn, def);
}
// Pair is always made up of immediates
let op = OperandRef {
val: Immediate(elem),
- ty: ty
+ ty,
};
self.trans_argument(bcx, op, llargs, fn_ty, next_idx, llfn, def);
}