diff options
| author | Yuki Okushi <huyuumi.dev@gmail.com> | 2020-07-24 18:56:31 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-24 18:56:31 +0900 |
| commit | a02aecba211ba82e79350db9e4dcd2675fd79423 (patch) | |
| tree | cda4a8b95d8da7fac22116e16afec0294a688bfb | |
| parent | a816345536b1651bd05d9b9a8eed6db043a5e14d (diff) | |
| parent | 40b6bccd6431e5d3032279ec5f6d269cacc7fe9b (diff) | |
| download | rust-a02aecba211ba82e79350db9e4dcd2675fd79423.tar.gz rust-a02aecba211ba82e79350db9e4dcd2675fd79423.zip | |
Rollup merge of #74623 - lcnr:polymorphize-functions, r=eddyb
polymorphize GlobalAlloc::Function this sadly does not change #74614 r? @eddyb
| -rw-r--r-- | src/librustc_codegen_llvm/common.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/polymorphization/promoted-function.rs | 13 |
2 files changed, 14 insertions, 1 deletions
diff --git a/src/librustc_codegen_llvm/common.rs b/src/librustc_codegen_llvm/common.rs index 0e1cd8e493d..2a50d4a46d2 100644 --- a/src/librustc_codegen_llvm/common.rs +++ b/src/librustc_codegen_llvm/common.rs @@ -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) => { diff --git a/src/test/ui/polymorphization/promoted-function.rs b/src/test/ui/polymorphization/promoted-function.rs new file mode 100644 index 00000000000..0d3af7a89c2 --- /dev/null +++ b/src/test/ui/polymorphization/promoted-function.rs @@ -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)(); +} |
