From 7669619f9a7e5ab36448e07205800a8677dd4911 Mon Sep 17 00:00:00 2001 From: Tetsuharu Ohzeki Date: Fri, 9 Feb 2024 22:31:21 +0900 Subject: [PATCH 1/3] clippy: Enable `self_named_constructors` rule --- Cargo.toml | 1 - crates/hir-def/src/attr.rs | 2 +- crates/hir-expand/src/ast_id_map.rs | 2 +- crates/hir-expand/src/db.rs | 2 +- crates/hir/src/attrs.rs | 2 +- 5 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f40156b99e5..429c29025c4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -174,7 +174,6 @@ forget_non_drop = "allow" needless_doctest_main = "allow" non_canonical_clone_impl = "allow" non_canonical_partial_ord_impl = "allow" -self_named_constructors = "allow" too_many_arguments = "allow" type_complexity = "allow" wrong_self_convention = "allow" diff --git a/crates/hir-def/src/attr.rs b/crates/hir-def/src/attr.rs index bee6f0083b1..d2a975e9e67 100644 --- a/crates/hir-def/src/attr.rs +++ b/crates/hir-def/src/attr.rs @@ -317,7 +317,7 @@ fn parse_comma_sep(subtree: &tt::Subtree) -> Vec { } impl AttrsWithOwner { - pub fn attrs_with_owner(db: &dyn DefDatabase, owner: AttrDefId) -> Self { + pub fn new(db: &dyn DefDatabase, owner: AttrDefId) -> Self { Self { attrs: db.attrs(owner), owner } } diff --git a/crates/hir-expand/src/ast_id_map.rs b/crates/hir-expand/src/ast_id_map.rs index 530f10a0684..ab582741f5b 100644 --- a/crates/hir-expand/src/ast_id_map.rs +++ b/crates/hir-expand/src/ast_id_map.rs @@ -155,7 +155,7 @@ impl PartialEq for AstIdMap { impl Eq for AstIdMap {} impl AstIdMap { - pub(crate) fn ast_id_map( + pub(crate) fn new( db: &dyn ExpandDatabase, file_id: span::HirFileId, ) -> triomphe::Arc { diff --git a/crates/hir-expand/src/db.rs b/crates/hir-expand/src/db.rs index d5a1a14099e..6a288cf9197 100644 --- a/crates/hir-expand/src/db.rs +++ b/crates/hir-expand/src/db.rs @@ -61,7 +61,7 @@ pub trait ExpandDatabase: SourceDatabase { #[salsa::input] fn proc_macros(&self) -> Arc; - #[salsa::invoke(AstIdMap::ast_id_map)] + #[salsa::invoke(AstIdMap::new)] fn ast_id_map(&self, file_id: HirFileId) -> Arc; /// Main public API -- parses a hir file, not caring whether it's a real diff --git a/crates/hir/src/attrs.rs b/crates/hir/src/attrs.rs index 5c369f42e6e..7d637bac096 100644 --- a/crates/hir/src/attrs.rs +++ b/crates/hir/src/attrs.rs @@ -30,7 +30,7 @@ macro_rules! impl_has_attrs { impl HasAttrs for $def { fn attrs(self, db: &dyn HirDatabase) -> AttrsWithOwner { let def = AttrDefId::$def_id(self.into()); - AttrsWithOwner::attrs_with_owner(db.upcast(), def) + AttrsWithOwner::new(db.upcast(), def) } fn attr_id(self) -> AttrDefId { AttrDefId::$def_id(self.into()) From 2601d19bac3d5fac3235432d1b97091ea9636f0d Mon Sep 17 00:00:00 2001 From: Tetsuharu Ohzeki Date: Fri, 9 Feb 2024 22:37:42 +0900 Subject: [PATCH 2/3] 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 429c29025c4..c8adf18a8c1 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 336e0de7fd6..27c5f14b7dc 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 71bc5213336..6a39e0b695b 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 b716d367066..fb8aee9c3b0 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 } } From 1e4171bc6e4c47de88eb98f44837a733ef53ce57 Mon Sep 17 00:00:00 2001 From: Tetsuharu Ohzeki Date: Fri, 9 Feb 2024 22:42:16 +0900 Subject: [PATCH 3/3] clippy: Enable `non_canonical_partial_ord_impl` rule --- Cargo.toml | 1 - lib/la-arena/src/lib.rs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c8adf18a8c1..8bec3893ce5 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_partial_ord_impl = "allow" too_many_arguments = "allow" type_complexity = "allow" wrong_self_convention = "allow" diff --git a/lib/la-arena/src/lib.rs b/lib/la-arena/src/lib.rs index 1ded3b00a60..abde5deda4c 100644 --- a/lib/la-arena/src/lib.rs +++ b/lib/la-arena/src/lib.rs @@ -70,7 +70,7 @@ impl Ord for Idx { impl PartialOrd for Idx { fn partial_cmp(&self, other: &Self) -> Option { - self.raw.partial_cmp(&other.raw) + Some(self.cmp(other)) } }