about summary refs log tree commit diff
path: root/src/librustc_codegen_ssa
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2020-03-09 11:16:23 +0100
committerRalf Jung <post@ralfj.de>2020-03-09 11:16:23 +0100
commit1a9fc18e830dc57731e2976edb5c5f0fabc5019c (patch)
treed4f91a1fa34e83789172d7fbc8fc0a5bf45f47eb /src/librustc_codegen_ssa
parent2cb0b8582ebbf9784db9cec06fff517badbf4553 (diff)
downloadrust-1a9fc18e830dc57731e2976edb5c5f0fabc5019c.tar.gz
rust-1a9fc18e830dc57731e2976edb5c5f0fabc5019c.zip
panic_bounds_check: use caller_location, like PanicFnLangItem
Diffstat (limited to 'src/librustc_codegen_ssa')
-rw-r--r--src/librustc_codegen_ssa/mir/block.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/librustc_codegen_ssa/mir/block.rs b/src/librustc_codegen_ssa/mir/block.rs
index a1b54607b80..f22c0216a78 100644
--- a/src/librustc_codegen_ssa/mir/block.rs
+++ b/src/librustc_codegen_ssa/mir/block.rs
@@ -415,11 +415,15 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
             AssertKind::BoundsCheck { ref len, ref index } => {
                 let len = self.codegen_operand(&mut bx, len).immediate();
                 let index = self.codegen_operand(&mut bx, index).immediate();
-                (lang_items::PanicBoundsCheckFnLangItem, vec![location, index, len])
+                // It's `fn panic_bounds_check(index: usize, len: usize)`, and
+                // `#[track_caller]` adds an implicit third argument.
+                (lang_items::PanicBoundsCheckFnLangItem, vec![index, len, location])
             }
             _ => {
                 let msg_str = Symbol::intern(msg.description());
                 let msg = bx.const_str(msg_str);
+                // It's `pub fn panic(expr: &str)`, with the wide reference being passed
+                // as two arguments, and `#[track_caller]` adds an implicit third argument.
                 (lang_items::PanicFnLangItem, vec![msg.0, msg.1, location])
             }
         };