summaryrefslogtreecommitdiffstats
path: root/tests/ui/traits/default-method/rustc_must_implement_one_of.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:58 +0000
commita4b7ed7a42c716ab9f05e351f003d589124fd55d (patch)
treeb620cd3f223850b28716e474e80c58059dca5dd4 /tests/ui/traits/default-method/rustc_must_implement_one_of.rs
parentAdding upstream version 1.67.1+dfsg1. (diff)
downloadrustc-a4b7ed7a42c716ab9f05e351f003d589124fd55d.tar.xz
rustc-a4b7ed7a42c716ab9f05e351f003d589124fd55d.zip
Adding upstream version 1.68.2+dfsg1.upstream/1.68.2+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/traits/default-method/rustc_must_implement_one_of.rs')
-rw-r--r--tests/ui/traits/default-method/rustc_must_implement_one_of.rs44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/ui/traits/default-method/rustc_must_implement_one_of.rs b/tests/ui/traits/default-method/rustc_must_implement_one_of.rs
new file mode 100644
index 000000000..5ba2f5ce3
--- /dev/null
+++ b/tests/ui/traits/default-method/rustc_must_implement_one_of.rs
@@ -0,0 +1,44 @@
+#![feature(rustc_attrs)]
+
+#[rustc_must_implement_one_of(eq, neq)]
+trait Equal {
+ fn eq(&self, other: &Self) -> bool {
+ !self.neq(other)
+ }
+
+ fn neq(&self, other: &Self) -> bool {
+ !self.eq(other)
+ }
+}
+
+struct T0;
+struct T1;
+struct T2;
+struct T3;
+
+impl Equal for T0 {
+ fn eq(&self, _other: &Self) -> bool {
+ true
+ }
+}
+
+impl Equal for T1 {
+ fn neq(&self, _other: &Self) -> bool {
+ false
+ }
+}
+
+impl Equal for T2 {
+ fn eq(&self, _other: &Self) -> bool {
+ true
+ }
+
+ fn neq(&self, _other: &Self) -> bool {
+ false
+ }
+}
+
+impl Equal for T3 {}
+//~^ not all trait items implemented, missing one of: `eq`, `neq`
+
+fn main() {}