rust/tests/ui/cmp_owned/without_suggestion.rs
Philipp Hansch 9a0b598b73
Split up cmp_owned tests, add run-rustfix
Some of the cmp_owned tests emitted non-machine-applicable suggestions,
so I moved them to `tests/ui/cmp_owned/without_suggestion.rs` and added
`// run-rustfix` to the other half.

cc #3630
2019-08-24 10:38:45 +02:00

52 lines
776 B
Rust

#[allow(clippy::unnecessary_operation)]
fn main() {
let x = &Baz;
let y = &Baz;
y.to_owned() == *x;
let x = &&Baz;
let y = &Baz;
y.to_owned() == **x;
}
struct Foo;
impl PartialEq for Foo {
fn eq(&self, other: &Self) -> bool {
self.to_owned() == *other
}
}
impl ToOwned for Foo {
type Owned = Bar;
fn to_owned(&self) -> Bar {
Bar
}
}
#[derive(PartialEq)]
struct Baz;
impl ToOwned for Baz {
type Owned = Baz;
fn to_owned(&self) -> Baz {
Baz
}
}
#[derive(PartialEq)]
struct Bar;
impl PartialEq<Foo> for Bar {
fn eq(&self, _: &Foo) -> bool {
true
}
}
impl std::borrow::Borrow<Foo> for Bar {
fn borrow(&self) -> &Foo {
static FOO: Foo = Foo;
&FOO
}
}