about summary refs log tree commit diff
path: root/tests/codegen-units/partitioning
diff options
context:
space:
mode:
authorMark Rousskov <mark.simulacrum@gmail.com>2024-11-23 13:19:17 -0500
committerMark Rousskov <mark.simulacrum@gmail.com>2024-11-28 13:43:05 -0500
commit4a216a25d143e88eefac2655c1fce042571e1f6e (patch)
treedd8b394804ef4dcee527cfa8e31f3b2ebded7612 /tests/codegen-units/partitioning
parent39cb3386ddc6c71657418be28dbb3987eea4aa4b (diff)
downloadrust-4a216a25d143e88eefac2655c1fce042571e1f6e.tar.gz
rust-4a216a25d143e88eefac2655c1fce042571e1f6e.zip
Share inline(never) generics across crates
This reduces code sizes and better respects programmer intent when
marking inline(never). Previously such a marking was essentially ignored
for generic functions, as we'd still inline them in remote crates.
Diffstat (limited to 'tests/codegen-units/partitioning')
-rw-r--r--tests/codegen-units/partitioning/auxiliary/cgu_generic_function.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/codegen-units/partitioning/auxiliary/cgu_generic_function.rs b/tests/codegen-units/partitioning/auxiliary/cgu_generic_function.rs
index 3926f295742..8bb78eb788a 100644
--- a/tests/codegen-units/partitioning/auxiliary/cgu_generic_function.rs
+++ b/tests/codegen-units/partitioning/auxiliary/cgu_generic_function.rs
@@ -11,10 +11,21 @@ pub fn foo<T>(x: T) -> (T, u32, i8) {
 #[inline(never)]
 fn bar<T>(x: T) -> (T, Struct) {
     let _ = not_exported_and_not_generic(0);
+    exported_and_generic::<u32>(0);
     (x, Struct(1))
 }
 
+pub static F: fn(u32) -> u32 = exported_and_generic::<u32>;
+
 // These should not contribute to the codegen items of other crates.
+
+// This is generic, but it's only instantiated with a u32 argument and that instantiation is present
+// in the local crate (see F above).
+#[inline(never)]
+pub fn exported_and_generic<T>(x: T) -> T {
+    x
+}
+
 #[inline(never)]
 pub fn exported_but_not_generic(x: i32) -> i64 {
     x as i64