summaryrefslogtreecommitdiffstats
path: root/tests/codegen-units/item-collection/auxiliary
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
commit218caa410aa38c29984be31a5229b9fa717560ee (patch)
treec54bd55eeb6e4c508940a30e94c0032fbd45d677 /tests/codegen-units/item-collection/auxiliary
parentReleasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz
rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/codegen-units/item-collection/auxiliary')
-rw-r--r--tests/codegen-units/item-collection/auxiliary/cgu_export_trait_method.rs24
-rw-r--r--tests/codegen-units/item-collection/auxiliary/cgu_extern_closures.rs23
-rw-r--r--tests/codegen-units/item-collection/auxiliary/cgu_generic_function.rs26
3 files changed, 73 insertions, 0 deletions
diff --git a/tests/codegen-units/item-collection/auxiliary/cgu_export_trait_method.rs b/tests/codegen-units/item-collection/auxiliary/cgu_export_trait_method.rs
new file mode 100644
index 000000000..ecea26dc4
--- /dev/null
+++ b/tests/codegen-units/item-collection/auxiliary/cgu_export_trait_method.rs
@@ -0,0 +1,24 @@
+#![crate_type = "lib"]
+
+pub trait Trait : Sized {
+ fn without_self() -> u32;
+ fn without_self_default() -> u32 { 0 }
+
+ fn with_default_impl(self) -> Self { self }
+ fn with_default_impl_generic<T>(self, x: T) -> (Self, T) { (self, x) }
+
+ fn without_default_impl(x: u32) -> (Self, u32);
+ fn without_default_impl_generic<T>(x: T) -> (Self, T);
+}
+
+impl Trait for char {
+ fn without_self() -> u32 { 2 }
+ fn without_default_impl(x: u32) -> (Self, u32) { ('c', x) }
+ fn without_default_impl_generic<T>(x: T) -> (Self, T) { ('c', x) }
+}
+
+impl Trait for u32 {
+ fn without_self() -> u32 { 1 }
+ fn without_default_impl(x: u32) -> (Self, u32) { (0, x) }
+ fn without_default_impl_generic<T>(x: T) -> (Self, T) { (0, x) }
+}
diff --git a/tests/codegen-units/item-collection/auxiliary/cgu_extern_closures.rs b/tests/codegen-units/item-collection/auxiliary/cgu_extern_closures.rs
new file mode 100644
index 000000000..05ea0a89f
--- /dev/null
+++ b/tests/codegen-units/item-collection/auxiliary/cgu_extern_closures.rs
@@ -0,0 +1,23 @@
+#![crate_type = "lib"]
+
+#[inline]
+pub fn inlined_fn(x: i32, y: i32) -> i32 {
+
+ let closure = |a, b| { a + b };
+
+ closure(x, y)
+}
+
+pub fn inlined_fn_generic<T>(x: i32, y: i32, z: T) -> (i32, T) {
+
+ let closure = |a, b| { a + b };
+
+ (closure(x, y), z)
+}
+
+pub fn non_inlined_fn(x: i32, y: i32) -> i32 {
+
+ let closure = |a, b| { a + b };
+
+ closure(x, y)
+}
diff --git a/tests/codegen-units/item-collection/auxiliary/cgu_generic_function.rs b/tests/codegen-units/item-collection/auxiliary/cgu_generic_function.rs
new file mode 100644
index 000000000..3926f2957
--- /dev/null
+++ b/tests/codegen-units/item-collection/auxiliary/cgu_generic_function.rs
@@ -0,0 +1,26 @@
+#![crate_type = "lib"]
+
+struct Struct(u32);
+
+#[inline(never)]
+pub fn foo<T>(x: T) -> (T, u32, i8) {
+ let (x, Struct(y)) = bar(x);
+ (x, y, 2)
+}
+
+#[inline(never)]
+fn bar<T>(x: T) -> (T, Struct) {
+ let _ = not_exported_and_not_generic(0);
+ (x, Struct(1))
+}
+
+// These should not contribute to the codegen items of other crates.
+#[inline(never)]
+pub fn exported_but_not_generic(x: i32) -> i64 {
+ x as i64
+}
+
+#[inline(never)]
+fn not_exported_and_not_generic(x: u32) -> u64 {
+ x as u64
+}