X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibrustc_trans%2Fmir%2Fblock.rs;h=28fe1044e7454c849db2e8e70c0aeda7dfcb6fa8;hb=6f4ab9458a7ad06c8ce630604f533c8c0c0acef4;hp=8863c7ffae6f4f38c959059ed0891b728fc75639;hpb=80271e8edfb188cfb9e2f02ac26136b4f58fbef0;p=rust.git diff --git a/src/librustc_trans/mir/block.rs b/src/librustc_trans/mir/block.rs index 8863c7ffae6..28fe1044e74 100644 --- a/src/librustc_trans/mir/block.rs +++ b/src/librustc_trans/mir/block.rs @@ -28,6 +28,7 @@ use type_::Type; use syntax::symbol::Symbol; +use syntax_pos::Pos; use std::cmp; @@ -262,7 +263,7 @@ fn trans_terminator(&mut self, } 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); @@ -333,6 +334,7 @@ fn trans_terminator(&mut self, 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 { @@ -347,29 +349,29 @@ fn trans_terminator(&mut self, 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()))) } }; @@ -404,20 +406,18 @@ fn trans_terminator(&mut self, // 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; @@ -438,7 +438,7 @@ fn trans_terminator(&mut self, 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::>(); @@ -673,8 +673,8 @@ fn trans_arguments_untupled(&mut self, Ref(ptr, align) }; let op = OperandRef { - val: val, - ty: ty + val, + ty, }; self.trans_argument(bcx, op, llargs, fn_ty, next_idx, llfn, def); } @@ -697,7 +697,7 @@ fn trans_arguments_untupled(&mut self, // 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); } @@ -713,7 +713,7 @@ fn trans_arguments_untupled(&mut self, // 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); }