From 2601d19bac3d5fac3235432d1b97091ea9636f0d Mon Sep 17 00:00:00 2001 From: Tetsuharu Ohzeki Date: Fri, 9 Feb 2024 22:37:42 +0900 Subject: [PATCH] clippy: Enable `non_canonical_clone_impl` rule --- Cargo.toml | 1 - crates/hir-def/src/item_tree.rs | 2 +- crates/hir-def/src/lib.rs | 4 ++-- crates/syntax/src/ptr.rs | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 429c29025c4a..c8adf18a8c18 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -172,7 +172,6 @@ borrowed_box = "allow" derived_hash_with_manual_eq = "allow" forget_non_drop = "allow" needless_doctest_main = "allow" -non_canonical_clone_impl = "allow" non_canonical_partial_ord_impl = "allow" too_many_arguments = "allow" type_complexity = "allow" diff --git a/crates/hir-def/src/item_tree.rs b/crates/hir-def/src/item_tree.rs index 336e0de7fd66..27c5f14b7dc9 100644 --- a/crates/hir-def/src/item_tree.rs +++ b/crates/hir-def/src/item_tree.rs @@ -372,7 +372,7 @@ impl FileItemTreeId { impl Clone for FileItemTreeId { fn clone(&self) -> Self { - Self(self.0) + *self } } impl Copy for FileItemTreeId {} diff --git a/crates/hir-def/src/lib.rs b/crates/hir-def/src/lib.rs index 71bc52133361..6a39e0b695b3 100644 --- a/crates/hir-def/src/lib.rs +++ b/crates/hir-def/src/lib.rs @@ -219,7 +219,7 @@ pub struct ItemLoc { impl Clone for ItemLoc { fn clone(&self) -> Self { - Self { container: self.container, id: self.id } + *self } } @@ -248,7 +248,7 @@ pub struct AssocItemLoc { impl Clone for AssocItemLoc { fn clone(&self) -> Self { - Self { container: self.container, id: self.id } + *self } } diff --git a/crates/syntax/src/ptr.rs b/crates/syntax/src/ptr.rs index b716d3670667..fb8aee9c3b0d 100644 --- a/crates/syntax/src/ptr.rs +++ b/crates/syntax/src/ptr.rs @@ -36,7 +36,7 @@ impl std::fmt::Debug for AstPtr { impl Copy for AstPtr {} impl Clone for AstPtr { fn clone(&self) -> AstPtr { - AstPtr { raw: self.raw, _ty: PhantomData } + *self } }