about summary refs log tree commit diff
path: root/tests/ui/traits/default-method/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/ui/traits/default-method/auxiliary
parentca855e6e42787ecd062d81d53336fe6788ef51a9 (diff)
downloadrust-cf2dff2b1e3fa55fa5415d524200070d0d7aacfe.tar.gz
rust-cf2dff2b1e3fa55fa5415d524200070d0d7aacfe.zip
Move /src/test to /tests
Diffstat (limited to 'tests/ui/traits/default-method/auxiliary')
-rw-r--r--tests/ui/traits/default-method/auxiliary/xc.rs40
-rw-r--r--tests/ui/traits/default-method/auxiliary/xc_2.rs17
2 files changed, 57 insertions, 0 deletions
diff --git a/tests/ui/traits/default-method/auxiliary/xc.rs b/tests/ui/traits/default-method/auxiliary/xc.rs
new file mode 100644
index 00000000000..0fb26af80c7
--- /dev/null
+++ b/tests/ui/traits/default-method/auxiliary/xc.rs
@@ -0,0 +1,40 @@
+pub struct Something { pub x: isize }
+
+pub trait A {
+    fn f(&self) -> isize;
+    fn g(&self) -> isize { 10 }
+    fn h(&self) -> isize { 11 }
+    fn lurr(x: &Self, y: &Self) -> isize { x.g() + y.h() }
+}
+
+
+impl A for isize {
+    fn f(&self) -> isize { 10 }
+}
+
+impl A for Something {
+    fn f(&self) -> isize { 10 }
+}
+
+pub trait B<T> {
+    fn thing<U>(&self, x: T, y: U) -> (T, U) { (x, y) }
+    fn staticthing<U>(_z: &Self, x: T, y: U) -> (T, U) { (x, y) }
+}
+
+impl<T> B<T> for isize { }
+impl B<f64> for bool { }
+
+
+
+pub trait TestEquality {
+    fn test_eq(&self, rhs: &Self) -> bool;
+    fn test_neq(&self, rhs: &Self) -> bool {
+        !self.test_eq(rhs)
+    }
+}
+
+impl TestEquality for isize {
+    fn test_eq(&self, rhs: &isize) -> bool {
+        *self == *rhs
+    }
+}
diff --git a/tests/ui/traits/default-method/auxiliary/xc_2.rs b/tests/ui/traits/default-method/auxiliary/xc_2.rs
new file mode 100644
index 00000000000..9792338204c
--- /dev/null
+++ b/tests/ui/traits/default-method/auxiliary/xc_2.rs
@@ -0,0 +1,17 @@
+// aux-build:xc.rs
+
+extern crate xc as aux;
+use aux::A;
+
+pub struct a_struct { pub x: isize }
+
+impl A for a_struct {
+    fn f(&self) -> isize { 10 }
+}
+
+// This function will need to get inlined, and badness may result.
+pub fn welp<A>(x: A) -> A {
+    let a = a_struct { x: 0 };
+    a.g();
+    x
+}