]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_trans/mir/block.rs
Auto merge of #43710 - zackmdavis:field_init_shorthand_power_slam, r=Mark-Simulacrum
[rust.git] / src / librustc_trans / mir / block.rs
index 16972a1b1ae249a9683776534d2e241de7a85c66..28fe1044e7454c849db2e8e70c0aeda7dfcb6fa8 100644 (file)
@@ -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())))
                     }
                 };
@@ -436,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::<Vec<_>>();
 
@@ -671,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);
                 }
@@ -695,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);
                 }
@@ -711,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);
                 }