diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2020-03-11 14:03:49 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-03-11 14:03:49 +0100 |
| commit | 3853da75cbcefc7bb57a853bf3c5406818fb8c45 (patch) | |
| tree | cc10dbb90f7d68568e6cc4318a2f140bbac4e62d /src/librustc_codegen_ssa | |
| parent | 080d41391d84ccf61b1b3667e731981519f9d5b7 (diff) | |
| parent | 0b2329da9a9a61dc70f9e607628977302f8144b4 (diff) | |
| download | rust-3853da75cbcefc7bb57a853bf3c5406818fb8c45.tar.gz rust-3853da75cbcefc7bb57a853bf3c5406818fb8c45.zip | |
Rollup merge of #69850 - RalfJung:panic-bounds-check, r=eddyb
panic_bounds_check: use caller_location, like PanicFnLangItem The `PanicFnLangItem` got switched to using `#[caller_location]` at some point, but `PanicBoundsCheckFnLangItem` was kept in the old style. For consistency, switch that one over to use `#[caller_location]` as well. This is also helpful for Miri as it means the `assert_panic` machine hook never needs to know the current `Span`.
Diffstat (limited to 'src/librustc_codegen_ssa')
| -rw-r--r-- | src/librustc_codegen_ssa/mir/block.rs | 6 |
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 c8d352cd2dd..9ce23ff5f3f 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]) } }; |
