polymorphize GlobalAlloc::Function
This commit is contained in:
parent
e22b61bff0
commit
6a9c5fb4cc
3 changed files with 15 additions and 1 deletions
|
@ -257,7 +257,7 @@ impl ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
|||
(value, AddressSpace::DATA)
|
||||
}
|
||||
GlobalAlloc::Function(fn_instance) => (
|
||||
self.get_fn_addr(fn_instance),
|
||||
self.get_fn_addr(fn_instance.polymorphize(self.tcx)),
|
||||
self.data_layout().instruction_address_space,
|
||||
),
|
||||
GlobalAlloc::Static(def_id) => {
|
||||
|
|
|
@ -1197,6 +1197,7 @@ fn collect_miri<'tcx>(
|
|||
}
|
||||
}
|
||||
GlobalAlloc::Function(fn_instance) => {
|
||||
let fn_instance = fn_instance.polymorphize(tcx);
|
||||
if should_codegen_locally(tcx, &fn_instance) {
|
||||
trace!("collecting {:?} with {:#?}", alloc_id, fn_instance);
|
||||
output.push(create_fn_mono_item(tcx, fn_instance, DUMMY_SP));
|
||||
|
|
13
src/test/ui/polymorphization/promoted-function.rs
Normal file
13
src/test/ui/polymorphization/promoted-function.rs
Normal file
|
@ -0,0 +1,13 @@
|
|||
// run-pass
|
||||
fn fop<T>() {}
|
||||
|
||||
fn bar<T>() -> &'static fn() {
|
||||
&(fop::<T> as fn())
|
||||
}
|
||||
pub const FN: &'static fn() = &(fop::<i32> as fn());
|
||||
|
||||
fn main() {
|
||||
bar::<u32>();
|
||||
bar::<i32>();
|
||||
(FN)();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue