From 87a6300b22725bfea57f0e4fb95ccf70ed7d8cc8 Mon Sep 17 00:00:00 2001 From: y21 <30553356+y21@users.noreply.github.com> Date: Sun, 21 Jan 2024 13:33:03 +0100 Subject: [PATCH] add a test for rust-lang/rust-clippy#12181 --- tests/ui/unconditional_recursion.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/ui/unconditional_recursion.rs b/tests/ui/unconditional_recursion.rs index 2ad7c410d..263fdf26d 100644 --- a/tests/ui/unconditional_recursion.rs +++ b/tests/ui/unconditional_recursion.rs @@ -321,6 +321,30 @@ mod issue12154 { *other == *self } } + + // Issue #12181 but also fixed by the same PR + struct Foo; + + impl Foo { + fn as_str(&self) -> &str { + "Foo" + } + } + + impl PartialEq for Foo { + fn eq(&self, other: &Self) -> bool { + self.as_str().eq(other.as_str()) + } + } + + impl PartialEq for Foo + where + for<'a> &'a str: PartialEq, + { + fn eq(&self, other: &T) -> bool { + (&self.as_str()).eq(other) + } + } } fn main() {}