Skip to content

Commit

Permalink
Rollup merge of #74623 - lcnr:polymorphize-functions, r=eddyb
Browse files Browse the repository at this point in the history
polymorphize GlobalAlloc::Function

this sadly does not change #74614

r? @eddyb
  • Loading branch information
JohnTitor authored Jul 24, 2020
2 parents a816345 + 40b6bcc commit a02aecb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
13 changes: 13 additions & 0 deletions src/test/ui/polymorphization/promoted-function.rs
Original file line number Diff line number Diff line change
@@ -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)();
}

0 comments on commit a02aecb

Please sign in to comment.