about summary refs log tree commit diff
path: root/src/test/codegen-units/polymorphization
diff options
context:
space:
mode:
authorDavid Wood <david@davidtw.co>2020-08-07 17:57:21 +0100
committerDavid Wood <david@davidtw.co>2020-08-07 18:41:45 +0100
commitac50d61785ae5112b9b4e30a58cfcffe096b31ec (patch)
tree193546fbb3d2110e3c9db793b84abf79b3fa7743 /src/test/codegen-units/polymorphization
parent4ccaf6f38ce5b617635ec5dc738275c681090eff (diff)
downloadrust-ac50d61785ae5112b9b4e30a58cfcffe096b31ec.tar.gz
rust-ac50d61785ae5112b9b4e30a58cfcffe096b31ec.zip
instance: polymorphize `FnDef` substs
This commit extends previous polymorphization of substs to polymorphize
`FnDef`.

Signed-off-by: David Wood <david@davidtw.co>
Diffstat (limited to 'src/test/codegen-units/polymorphization')
-rw-r--r--src/test/codegen-units/polymorphization/pr-75255.rs23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/test/codegen-units/polymorphization/pr-75255.rs b/src/test/codegen-units/polymorphization/pr-75255.rs
index ea9a6e8b181..af47b440640 100644
--- a/src/test/codegen-units/polymorphization/pr-75255.rs
+++ b/src/test/codegen-units/polymorphization/pr-75255.rs
@@ -3,20 +3,33 @@
 
 #![crate_type = "rlib"]
 
-// Test that only one copy of `Iter::map` is generated.
+// Test that only one copy of `Iter::map` and `iter::repeat` are generated.
+
+fn unused<T>() -> u64 {
+    42
+}
 
 fn foo<T>() {
     let x = [1, 2, 3, std::mem::size_of::<T>()];
     x.iter().map(|_| ());
 }
 
+//~ MONO_ITEM fn core::iter[0]::adapters[0]::{{impl}}[29]::new[0]<core::slice[0]::Iter[0]<usize>, pr_75255::foo[0]::{{closure}}[0]<T>> @@ pr_75255-cgu.0[External]
+//~ MONO_ITEM fn core::iter[0]::traits[0]::iterator[0]::Iterator[0]::map[0]<core::slice[0]::Iter[0]<usize>, (), pr_75255::foo[0]::{{closure}}[0]<T>> @@ pr_75255-cgu.1[Internal]
+
+fn bar<T>() {
+    std::iter::repeat(unused::<T>);
+}
+
+//~ MONO_ITEM fn core::iter[0]::sources[0]::repeat[0]<fn() -> u64> @@ pr_75255-cgu.1[Internal]
+
 pub fn dispatch() {
     foo::<String>();
     foo::<Vec<String>>();
-}
 
-//~ MONO_ITEM fn core::iter[0]::adapters[0]::{{impl}}[29]::new[0]<core::slice[0]::Iter[0]<usize>, pr_75255::foo[0]::{{closure}}[0]<T>> @@ pr_75255-cgu.0[External]
-//~ MONO_ITEM fn core::iter[0]::traits[0]::iterator[0]::Iterator[0]::map[0]<core::slice[0]::Iter[0]<usize>, (), pr_75255::foo[0]::{{closure}}[0]<T>> @@ pr_75255-cgu.1[Internal]
+    bar::<String>();
+    bar::<Vec<String>>();
+}
 
 // These are all the items that aren't relevant to the test.
 //~ MONO_ITEM fn core::mem[0]::size_of[0]<alloc::string[0]::String[0]> @@ pr_75255-cgu.1[Internal]
@@ -35,3 +48,5 @@ pub fn dispatch() {
 //~ MONO_ITEM fn pr_75255::dispatch[0] @@ pr_75255-cgu.1[External]
 //~ MONO_ITEM fn pr_75255::foo[0]<alloc::string[0]::String[0]> @@ pr_75255-cgu.1[Internal]
 //~ MONO_ITEM fn pr_75255::foo[0]<alloc::vec[0]::Vec[0]<alloc::string[0]::String[0]>> @@ pr_75255-cgu.1[Internal]
+//~ MONO_ITEM fn pr_75255::bar[0]<alloc::string[0]::String[0]> @@ pr_75255-cgu.1[Internal]
+//~ MONO_ITEM fn pr_75255::bar[0]<alloc::vec[0]::Vec[0]<alloc::string[0]::String[0]>> @@ pr_75255-cgu.1[Internal]