From 2812591e4a9789eb3a77529da7bc3607d20d36b4 Mon Sep 17 00:00:00 2001 From: Boshen Date: Sat, 13 May 2023 14:59:36 +0800 Subject: [PATCH] chore(rust): allow clippy::new_without_default --- .cargo/config.toml | 8 ++++++-- crates/oxc_ast/src/ast/ts.rs | 2 +- crates/oxc_linter/src/lib.rs | 1 - crates/oxc_parser/src/ts/types.rs | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index b3f705af08..66eda1d0f6 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -18,8 +18,7 @@ protocol = "sparse" rustflags = [ # CLIPPY LINT SETTINGS # This is a workaround to configure lints for the entire workspace, pending the ability to configure this via TOML. - # See: `https://github.com/rust-lang/cargo/issues/5034` - # `https://github.com/EmbarkStudios/rust-ecosystem/issues/22#issuecomment-947011395` + # Wait for [RFC3389](https://github.com/rust-lang/rfcs/pull/3389) and [Tracking Issue](https://github.com/rust-lang/cargo/issues/12115) "-Wclippy::all", # I want to write the best Rust code so both pedantic and nursery is enabled. @@ -68,4 +67,9 @@ rustflags = [ # `const` functions do not make sense for our project because this is not a `const` library. # This rule also confuses new comers and forces them to add `const` blindlessly without any reason. "-Aclippy::missing_const_for_fn", + + # style + + # Having both `new` and `default` for a struct is confusing, just implement the more appropriate one. + "-Aclippy::new_without_default", ] diff --git a/crates/oxc_ast/src/ast/ts.rs b/crates/oxc_ast/src/ast/ts.rs index 584933e1fb..68c9f7f104 100644 --- a/crates/oxc_ast/src/ast/ts.rs +++ b/crates/oxc_ast/src/ast/ts.rs @@ -831,7 +831,7 @@ pub struct Modifier { pub kind: ModifierKind, } -#[derive(Debug, Hash, Default)] +#[derive(Debug, Default, Hash)] #[cfg_attr(feature = "serde", derive(Serialize), serde(transparent))] pub struct Modifiers<'a>(Option>); diff --git a/crates/oxc_linter/src/lib.rs b/crates/oxc_linter/src/lib.rs index 28c4773f09..ce417619bb 100644 --- a/crates/oxc_linter/src/lib.rs +++ b/crates/oxc_linter/src/lib.rs @@ -33,7 +33,6 @@ pub struct Linter { } impl Linter { - #[allow(clippy::new_without_default)] pub fn new() -> Self { let rules = RULES .iter() diff --git a/crates/oxc_parser/src/ts/types.rs b/crates/oxc_parser/src/ts/types.rs index 0588308c53..ca1be7f11e 100644 --- a/crates/oxc_parser/src/ts/types.rs +++ b/crates/oxc_parser/src/ts/types.rs @@ -18,7 +18,7 @@ use crate::{ bitflags! { /// Bitflag of modifiers and contextual modifiers. /// Useful to cheaply track all already seen modifiers of a member (instead of using a HashSet). - #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct ModifierFlags: u16 { const DECLARE = 1 << 0; const PRIVATE = 1 << 1;