Rollup merge of #74623 - lcnr:polymorphize-functions, r=eddyb

polymorphize GlobalAlloc::Function

this sadly does not change #74614

r? @eddyb
This commit is contained in:
Yuki Okushi 2020-07-24 18:56:31 +09:00 committed by GitHub
commit a02aecba21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -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) => {

View 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)();
}