mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-12-29 22:43:41 +00:00
9a0b598b73
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
52 lines
776 B
Rust
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
|
|
}
|
|
}
|