Skip to content

Commit 1c3e887

Browse files
committed
Replace a bunch of manual impls with #[derive(Default)]
Thanks to the #[default] tag we can avoid a bunch of such manual derives on enums.
1 parent 3fb8fd3 commit 1c3e887

File tree

4 files changed

+6
-38
lines changed

4 files changed

+6
-38
lines changed

core/engine/src/builtins/set/ordered_set.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use indexmap::IndexSet;
66
use std::fmt::Debug;
77

88
/// A type wrapping `indexmap::IndexSet`
9-
#[derive(Clone, Finalize, JsData)]
9+
#[derive(Default, Clone, Finalize, JsData)]
1010
pub struct OrderedSet {
1111
inner: IndexSet<MapKey>,
1212
lock: u32,
@@ -29,21 +29,11 @@ impl Debug for OrderedSet {
2929
}
3030
}
3131

32-
impl Default for OrderedSet {
33-
fn default() -> Self {
34-
Self::new()
35-
}
36-
}
37-
3832
impl OrderedSet {
3933
/// Creates a new empty `OrderedSet`.
4034
#[must_use]
4135
pub fn new() -> Self {
42-
Self {
43-
inner: IndexSet::new(),
44-
lock: 0,
45-
empty_count: 0,
46-
}
36+
Self::default()
4737
}
4838

4939
/// Creates a new empty `OrderedSet` with the specified capacity.

core/engine/src/bytecompiler/jump_control.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ pub(crate) enum JumpRecordAction {
4646
/// if (cond) {
4747
/// continue;
4848
/// }
49-
///
49+
///
5050
/// break;
5151
/// } finally {
5252
/// // Must execute the finally, even if `continue` is executed or `break` is executed.
@@ -177,7 +177,7 @@ pub(crate) struct JumpControlInfo {
177177

178178
bitflags! {
179179
/// A bitflag that contains the type flags and relevant booleans for `JumpControlInfo`.
180-
#[derive(Debug, Clone, Copy)]
180+
#[derive(Default, Debug, Clone, Copy)]
181181
pub(crate) struct JumpControlInfoFlags: u8 {
182182
const LOOP = 0b0000_0001;
183183
const SWITCH = 0b0000_0010;
@@ -201,12 +201,6 @@ bitflags! {
201201
}
202202
}
203203

204-
impl Default for JumpControlInfoFlags {
205-
fn default() -> Self {
206-
Self::empty()
207-
}
208-
}
209-
210204
/// ---- `JumpControlInfo` Creation Methods ----
211205
impl JumpControlInfo {
212206
fn new(current_open_environments_count: u32) -> Self {

core/engine/src/object/shape/shared_shape/mod.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,13 @@ const RESEREVED_TRANSITION_TYPE: u8 = 0b0000_0011;
4242

4343
bitflags! {
4444
/// Flags of a shape.
45-
#[derive(Debug, Clone, Copy, PartialEq, Eq, Finalize)]
45+
#[derive(Default, Debug, Clone, Copy, PartialEq, Eq, Finalize)]
4646
pub struct ShapeFlags: u8 {
4747
/// Represents the transition type of a [`SharedShape`].
4848
const TRANSITION_TYPE = 0b0000_0011;
4949
}
5050
}
5151

52-
impl Default for ShapeFlags {
53-
fn default() -> Self {
54-
Self::empty()
55-
}
56-
}
57-
5852
impl ShapeFlags {
5953
// NOTE: Remove type bits and set the new ones.
6054
fn insert_property_transition_from(previous: Self) -> Self {

tests/tester/src/main.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl Config {
7171

7272
/// Structure to allow defining ignored tests, features and files that should
7373
/// be ignored even when reading.
74-
#[derive(Debug, Deserialize)]
74+
#[derive(Default, Debug, Deserialize)]
7575
struct Ignored {
7676
#[serde(default)]
7777
tests: FxHashSet<Box<str>>,
@@ -112,16 +112,6 @@ impl Ignored {
112112
}
113113
}
114114

115-
impl Default for Ignored {
116-
fn default() -> Self {
117-
Self {
118-
tests: FxHashSet::default(),
119-
features: FxHashSet::default(),
120-
flags: TestFlags::empty(),
121-
}
122-
}
123-
}
124-
125115
/// Boa test262 tester
126116
#[derive(Debug, Parser)]
127117
#[command(author, version, about, name = "Boa test262 tester")]

0 commit comments

Comments
 (0)