about summary refs log tree commit diff
path: root/tests/codegen-units/item-collection/auxiliary
diff options
context:
space:
mode:
authorAlbert Larsan <74931857+albertlarsan68@users.noreply.github.com>2023-01-05 09:13:28 +0100
committerAlbert Larsan <74931857+albertlarsan68@users.noreply.github.com>2023-01-11 09:32:08 +0000
commitcf2dff2b1e3fa55fa5415d524200070d0d7aacfe (patch)
tree40a88d9a46aaf3e8870676eb2538378b75a263eb /tests/codegen-units/item-collection/auxiliary
parentca855e6e42787ecd062d81d53336fe6788ef51a9 (diff)
downloadrust-cf2dff2b1e3fa55fa5415d524200070d0d7aacfe.tar.gz
rust-cf2dff2b1e3fa55fa5415d524200070d0d7aacfe.zip
Move /src/test to /tests
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 00000000000..ecea26dc4be
--- /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 00000000000..05ea0a89ff2
--- /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 00000000000..3926f295742
--- /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
+}