diff options
Diffstat (limited to '')
-rw-r--r-- | src/tools/clippy/tests/ui/cmp_owned/comparison_flip.fixed | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/tools/clippy/tests/ui/cmp_owned/comparison_flip.fixed b/src/tools/clippy/tests/ui/cmp_owned/comparison_flip.fixed new file mode 100644 index 000000000..44e41bdd1 --- /dev/null +++ b/src/tools/clippy/tests/ui/cmp_owned/comparison_flip.fixed @@ -0,0 +1,29 @@ +// run-rustfix + +use std::fmt::{self, Display}; + +fn main() { + let a = Foo; + + if a != "bar" { + println!("foo"); + } + + if a != "bar" { + println!("foo"); + } +} + +struct Foo; + +impl Display for Foo { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "foo") + } +} + +impl PartialEq<&str> for Foo { + fn eq(&self, other: &&str) -> bool { + "foo" == *other + } +} |