Skip to content

Commit 9961fa6

Browse files
committed
ty::Instance::fn_sig inserts caller location arg.
1 parent ba3b6ed commit 9961fa6

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/librustc/ty/instance.rs

+19
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,25 @@ impl<'tcx> Instance<'tcx> {
121121
fn_sig.inputs_and_output = tcx.intern_type_list(&inputs_and_output);
122122
fn_sig
123123
});
124+
} else if let InstanceDef::ReifyShim(..) = self.def {
125+
// Modify fn(...) to fn(_location: &core::panic::Location, ...)
126+
#[cfg(not(bootstrap))]
127+
{
128+
use rustc::middle::lang_items::PanicLocationLangItem;
129+
let panic_loc_item = tcx.require_lang_item(PanicLocationLangItem, None);
130+
let panic_loc_ty = tcx.type_of(panic_loc_item);
131+
132+
fn_sig = fn_sig.map_bound(|mut fn_sig| {
133+
let mut inputs_and_output = fn_sig.inputs_and_output.to_vec();
134+
inputs_and_output.insert(0, panic_loc_ty);
135+
fn_sig.inputs_and_output = tcx.intern_type_list(&inputs_and_output);
136+
fn_sig
137+
});
138+
}
139+
#[cfg(bootstrap)]
140+
{
141+
bug!("#[track_caller] isn't supported during bootstrap (yet).");
142+
}
124143
}
125144
fn_sig
126145
}

src/test/ui/rfc-2091-track-caller/should-pass.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ LL | #![feature(track_caller)]
66
|
77
= note: `#[warn(incomplete_features)]` on by default
88

9-
thread 'rustc' panicked at 'index out of bounds: the len is 0 but the index is 0', $SRC_DIR/libcore/slice/mod.rs:LL:COL
9+
thread 'rustc' panicked at 'assertion failed: !value.needs_subst()', src/librustc/traits/query/normalize_erasing_regions.rs:59:9
1010
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
1111

1212
error: internal compiler error: unexpected panic

0 commit comments

Comments
 (0)