Skip to content

Commit

Permalink
Fix Rust 1.78.0 Clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
HalidOdat committed May 2, 2024
1 parent 3f6ee22 commit 684d95a
Show file tree
Hide file tree
Showing 53 changed files with 156 additions and 207 deletions.
2 changes: 1 addition & 1 deletion core/ast/src/declaration/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use super::ModuleSpecifier;
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum ImportKind {
/// Default (`import defaultName from "module-name"`) or unnamed (`import "module-name").
/// Default (`import defaultName from "module-name"`) or unnamed (`import "module-name"`).
DefaultOrUnnamed,
/// Namespaced import (`import * as name from "module-name"`).
Namespaced {
Expand Down
2 changes: 1 addition & 1 deletion core/ast/src/expression/literal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub enum Literal {
/// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Grammar_and_types#Numeric_literals
Int(i32),

/// BigInt provides a way to represent whole numbers larger than the largest number ECMAScript
/// `BigInt` provides a way to represent whole numbers larger than the largest number ECMAScript
/// can reliably represent with the `Number` primitive.
///
/// More information:
Expand Down
2 changes: 1 addition & 1 deletion core/ast/src/expression/operator/unary/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub enum UnaryOp {
/// Syntax: `~x`
///
/// NOT `a` yields the inverted value (or one's complement) of `a`.
/// Bitwise NOTing any number x yields -(x + 1). For example, ~-5 yields 4.
/// Bitwise `NOT`ing any number x yields -(x + 1). For example, ~-5 yields 4.
///
/// More information:
/// - [ECMAScript reference][spec]
Expand Down
9 changes: 5 additions & 4 deletions core/ast/src/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub enum ContainsSymbol {
This,
/// A method definition.
MethodDefinition,
/// The BindingIdentifier "eval" or "arguments".
/// The `BindingIdentifier` "eval" or "arguments".
EvalOrArguments,
}

Expand Down Expand Up @@ -1328,9 +1328,10 @@ where

fn visit_module_item(&mut self, node: &'ast ModuleItem) -> ControlFlow<Self::BreakTy> {
match node {
crate::ModuleItem::ImportDeclaration(_)
| crate::ModuleItem::ExportDeclaration(_) => ControlFlow::Continue(()),
crate::ModuleItem::StatementListItem(node) => self.visit_statement_list_item(node),
ModuleItem::ImportDeclaration(_) | ModuleItem::ExportDeclaration(_) => {
ControlFlow::Continue(())
}
ModuleItem::StatementListItem(node) => self.visit_statement_list_item(node),
}
}
}
Expand Down
32 changes: 16 additions & 16 deletions core/ast/src/pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ impl VisitWith for ArrayPattern {
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[derive(Clone, Debug, PartialEq)]
pub enum ObjectPatternElement {
/// SingleName represents one of the following properties:
/// `SingleName` represents one of the following properties:
///
/// - `SingleName` with an identifier and an optional default initializer.
/// - `BindingProperty` with an property name and a `SingleNameBinding` as the `BindingElement`.
Expand All @@ -296,7 +296,7 @@ pub enum ObjectPatternElement {
default_init: Option<Expression>,
},

/// RestProperty represents a `BindingRestProperty` with an identifier.
/// `RestProperty` represents a `BindingRestProperty` with an identifier.
///
/// It also includes a list of the property keys that should be excluded from the rest,
/// because they where already assigned.
Expand All @@ -312,10 +312,10 @@ pub enum ObjectPatternElement {
excluded_keys: Vec<Identifier>,
},

/// AssignmentGetField represents an AssignmentProperty with an expression field member expression AssignmentElement.
/// `AssignmentGetField` represents an `AssignmentProperty` with an expression field member expression `AssignmentElement`.
///
/// Note: According to the spec this is not part of an ObjectBindingPattern.
/// This is only used when a object literal is used to cover an AssignmentPattern.
/// Note: According to the spec this is not part of an `ObjectBindingPattern`.
/// This is only used when a object literal is used to cover an `AssignmentPattern`.
///
/// More information:
/// - [ECMAScript reference][spec]
Expand All @@ -330,10 +330,10 @@ pub enum ObjectPatternElement {
default_init: Option<Expression>,
},

/// AssignmentRestProperty represents a rest property with a DestructuringAssignmentTarget.
/// `AssignmentRestProperty` represents a rest property with a `DestructuringAssignmentTarget`.
///
/// Note: According to the spec this is not part of an ObjectBindingPattern.
/// This is only used when a object literal is used to cover an AssignmentPattern.
/// Note: According to the spec this is not part of an `ObjectBindingPattern`.
/// This is only used when a object literal is used to cover an `AssignmentPattern`.
///
/// More information:
/// - [ECMAScript reference][spec]
Expand Down Expand Up @@ -587,7 +587,7 @@ pub enum ArrayPatternElement {
/// [spec1]: https://tc39.es/ecma262/#prod-Elision
Elision,

/// SingleName represents a `SingleName` with an identifier and an optional default initializer.
/// `SingleName` represents a `SingleName` with an identifier and an optional default initializer.
///
/// More information:
/// - [ECMAScript reference: 14.3.3 Destructuring Binding Patterns - SingleNameBinding][spec1]
Expand All @@ -600,9 +600,9 @@ pub enum ArrayPatternElement {
default_init: Option<Expression>,
},

/// PropertyAccess represents a binding with a property accessor.
/// `PropertyAccess` represents a binding with a property accessor.
///
/// Note: According to the spec this is not part of an ArrayBindingPattern.
/// Note: According to the spec this is not part of an `ArrayBindingPattern`.
/// This is only used when a array literal is used as the left-hand-side of an assignment expression.
///
/// More information:
Expand All @@ -618,7 +618,7 @@ pub enum ArrayPatternElement {

/// Pattern represents a `Pattern` in an `Element` of an array pattern.
///
/// The pattern and the optional default initializer are both stored in the DeclarationPattern.
/// The pattern and the optional default initializer are both stored in the `DeclarationPattern`.
///
/// More information:
/// - [ECMAScript reference: 14.3.3 Destructuring Binding Patterns - BindingElement][spec1]
Expand All @@ -631,7 +631,7 @@ pub enum ArrayPatternElement {
default_init: Option<Expression>,
},

/// SingleNameRest represents a `BindingIdentifier` in a `BindingRestElement` of an array pattern.
/// `SingleNameRest` represents a `BindingIdentifier` in a `BindingRestElement` of an array pattern.
///
/// More information:
/// - [ECMAScript reference: 14.3.3 Destructuring Binding Patterns - BindingRestElement][spec1]
Expand All @@ -642,9 +642,9 @@ pub enum ArrayPatternElement {
ident: Identifier,
},

/// PropertyAccess represents a rest (spread operator) with a property accessor.
/// `PropertyAccess` represents a rest (spread operator) with a property accessor.
///
/// Note: According to the spec this is not part of an ArrayBindingPattern.
/// Note: According to the spec this is not part of an `ArrayBindingPattern`.
/// This is only used when a array literal is used as the left-hand-side of an assignment expression.
///
/// More information:
Expand All @@ -656,7 +656,7 @@ pub enum ArrayPatternElement {
access: PropertyAccess,
},

/// PatternRest represents a `Pattern` in a `RestElement` of an array pattern.
/// `PatternRest` represents a `Pattern` in a `RestElement` of an array pattern.
///
/// More information:
/// - [ECMAScript reference: 14.3.3 Destructuring Binding Patterns - BindingRestElement][spec1]
Expand Down
4 changes: 2 additions & 2 deletions core/ast/src/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -645,13 +645,13 @@ impl VisitWith for Sym {
where
V: Visitor<'a>,
{
core::ops::ControlFlow::Continue(())
ControlFlow::Continue(())
}

fn visit_with_mut<'a, V>(&'a mut self, _visitor: &mut V) -> ControlFlow<V::BreakTy>
where
V: VisitorMut<'a>,
{
core::ops::ControlFlow::Continue(())
ControlFlow::Continue(())
}
}
2 changes: 1 addition & 1 deletion core/engine/src/bigint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ pub struct TryFromF64Error;

impl Display for TryFromF64Error {
#[inline]
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Could not convert f64 value to a BigInt type")
}
}
Expand Down
4 changes: 2 additions & 2 deletions core/engine/src/builtins/atomics/futex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ impl FutexWaiters {
let addr = unsafe { (*node).addr };

let mut wl = match self.waiters.entry(addr) {
crate::small_map::Entry::Occupied(wl) => wl,
crate::small_map::Entry::Vacant(_) => return,
Entry::Occupied(wl) => wl,
Entry::Vacant(_) => return,
};

// SAFETY: `node` must be inside the wait list associated with `node.addr`.
Expand Down
18 changes: 8 additions & 10 deletions core/engine/src/builtins/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,10 @@ impl BuiltInConstructorWithPrototype<'_> {
.length(length)
.build();

debug_assert!(self
debug_assert!(!self
.object_property_table
.map
.get(&binding.binding)
.is_none());
.contains_key(&binding.binding));
self.object_property_table.insert(
binding.binding,
SlotAttributes::WRITABLE | SlotAttributes::CONFIGURABLE,
Expand All @@ -231,7 +230,7 @@ impl BuiltInConstructorWithPrototype<'_> {
{
let key = key.into();

debug_assert!(self.object_property_table.map.get(&key).is_none());
debug_assert!(!self.object_property_table.map.contains_key(&key));
self.object_property_table
.insert(key, SlotAttributes::from_bits_truncate(attribute.bits()));
self.object_storage.push(value.into());
Expand All @@ -256,7 +255,7 @@ impl BuiltInConstructorWithPrototype<'_> {

let key = key.into();

debug_assert!(self.object_property_table.map.get(&key).is_none());
debug_assert!(!self.object_property_table.map.contains_key(&key));
self.object_property_table.insert(key, attributes);
self.object_storage.extend([
get.map(JsValue::new).unwrap_or_default(),
Expand Down Expand Up @@ -289,11 +288,10 @@ impl BuiltInConstructorWithPrototype<'_> {
.length(length)
.build();

debug_assert!(self
debug_assert!(!self
.prototype_property_table
.map
.get(&binding.binding)
.is_none());
.contains_key(&binding.binding));
self.prototype_property_table.insert(
binding.binding,
SlotAttributes::WRITABLE | SlotAttributes::CONFIGURABLE,
Expand All @@ -310,7 +308,7 @@ impl BuiltInConstructorWithPrototype<'_> {
{
let key = key.into();

debug_assert!(self.prototype_property_table.map.get(&key).is_none());
debug_assert!(!self.prototype_property_table.map.contains_key(&key));
self.prototype_property_table
.insert(key, SlotAttributes::from_bits_truncate(attribute.bits()));
self.prototype_storage.push(value.into());
Expand All @@ -335,7 +333,7 @@ impl BuiltInConstructorWithPrototype<'_> {

let key = key.into();

debug_assert!(self.prototype_property_table.map.get(&key).is_none());
debug_assert!(!self.prototype_property_table.map.contains_key(&key));
self.prototype_property_table.insert(key, attributes);
self.prototype_storage.extend([
get.map(JsValue::new).unwrap_or_default(),
Expand Down
20 changes: 10 additions & 10 deletions core/engine/src/builtins/intl/number_format/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl Style {
pub(crate) struct ParseStyleError;

impl fmt::Display for ParseStyleError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("provided string was not a valid style option")
}
}
Expand Down Expand Up @@ -82,7 +82,7 @@ impl CurrencyDisplay {
pub(crate) struct ParseCurrencyDisplayError;

impl fmt::Display for ParseCurrencyDisplayError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("provided string was not a valid currencyDisplay option")
}
}
Expand Down Expand Up @@ -123,7 +123,7 @@ impl CurrencySign {
pub(crate) struct ParseCurrencySignError;

impl fmt::Display for ParseCurrencySignError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("provided string was not a valid currencySign option")
}
}
Expand Down Expand Up @@ -164,7 +164,7 @@ impl UnitDisplay {
pub(crate) struct ParseUnitDisplayError;

impl fmt::Display for ParseUnitDisplayError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("provided string was not a valid unitDisplay option")
}
}
Expand Down Expand Up @@ -205,7 +205,7 @@ impl Currency {
pub(crate) struct ParseCurrencyError;

impl fmt::Display for ParseCurrencyError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("provided string was not a valid currency")
}
}
Expand Down Expand Up @@ -267,7 +267,7 @@ impl Unit {
pub(crate) struct ParseUnitError;

impl fmt::Display for ParseUnitError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("provided string was not a valid unit")
}
}
Expand Down Expand Up @@ -995,7 +995,7 @@ impl CompactDisplay {
pub(crate) struct ParseCompactDisplayError;

impl fmt::Display for ParseCompactDisplayError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("provided string was not a valid compactDisplay option")
}
}
Expand Down Expand Up @@ -1038,7 +1038,7 @@ impl NotationKind {
pub(crate) struct ParseNotationKindError;

impl fmt::Display for ParseNotationKindError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("provided string was not a valid notation option")
}
}
Expand Down Expand Up @@ -1100,7 +1100,7 @@ impl RoundingPriority {
pub(crate) struct ParseRoundingPriorityError;

impl fmt::Display for ParseRoundingPriorityError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("provided string was not a valid rounding priority")
}
}
Expand Down Expand Up @@ -1140,7 +1140,7 @@ impl TrailingZeroDisplay {
pub(crate) struct ParseTrailingZeroDisplayError;

impl fmt::Display for ParseTrailingZeroDisplayError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("provided string was not a valid trailing zero display option")
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/engine/src/builtins/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ impl RoundingMode {
pub(crate) struct ParseRoundingModeError;

impl fmt::Display for ParseRoundingModeError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("provided string was not a valid rounding mode")
}
}
Expand Down
10 changes: 4 additions & 6 deletions core/engine/src/builtins/promise/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -664,10 +664,8 @@ impl Promise {
// iii. If remainingElementsCount.[[Value]] is 0, then
if remaining_elements_count.get() == 0 {
// 1. Let valuesArray be CreateArrayFromList(values).
let values_array = crate::builtins::Array::create_array_from_list(
values.borrow().iter().cloned(),
context,
);
let values_array =
Array::create_array_from_list(values.borrow().iter().cloned(), context);

// 2. Perform ? Call(resultCapability.[[Resolve]], undefined, « valuesArray »).
result_capability.functions.resolve.call(
Expand Down Expand Up @@ -733,7 +731,7 @@ impl Promise {
// 10. If remainingElementsCount.[[Value]] is 0, then
if captures.remaining_elements_count.get() == 0 {
// a. Let valuesArray be CreateArrayFromList(values).
let values_array = crate::builtins::Array::create_array_from_list(
let values_array = Array::create_array_from_list(
captures.values.borrow().as_slice().iter().cloned(),
context,
);
Expand Down Expand Up @@ -892,7 +890,7 @@ impl Promise {
// iii. If remainingElementsCount.[[Value]] is 0, then
if remaining_elements_count.get() == 0 {
// 1. Let valuesArray be CreateArrayFromList(values).
let values_array = crate::builtins::Array::create_array_from_list(
let values_array = Array::create_array_from_list(
values.borrow().as_slice().iter().cloned(),
context,
);
Expand Down
5 changes: 2 additions & 3 deletions core/engine/src/builtins/temporal/calendar/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -915,11 +915,10 @@ impl Calendar {
let additional_fields = args.get_or_undefined(1).to_object(context)?;

// 3. Let fieldsCopy be ? SnapshotOwnProperties(? ToObject(fields), null, « », « undefined »).
let fields_copy = temporal::fields::object_to_temporal_fields(&fields, context)?;
let fields_copy = fields::object_to_temporal_fields(&fields, context)?;

// 4. Let additionalFieldsCopy be ? SnapshotOwnProperties(? ToObject(additionalFields), null, « », « undefined »).
let additional_copy =
temporal::fields::object_to_temporal_fields(&additional_fields, context)?;
let additional_copy = fields::object_to_temporal_fields(&additional_fields, context)?;

// Custom Calendars override the `fields` method.
if let CalendarSlot::Protocol(proto) = &calendar.slot {
Expand Down
Loading

0 comments on commit 684d95a

Please sign in to comment.