Skip to content

Commit

Permalink
Re-enable must_use clippy rule (#3180)
Browse files Browse the repository at this point in the history
  • Loading branch information
tunz authored Jul 28, 2023
1 parent 93e3b2f commit 72b7ee5
Show file tree
Hide file tree
Showing 26 changed files with 323 additions and 1 deletion.
5 changes: 5 additions & 0 deletions boa_engine/src/builtins/function/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ pub struct Function {

impl Function {
/// Returns the codeblock of the function, or `None` if the function is a [`NativeFunction`].
#[must_use]
pub fn codeblock(&self) -> Option<&CodeBlock> {
match &self.kind {
FunctionKind::Native { .. } => None,
Expand Down Expand Up @@ -438,6 +439,7 @@ impl Function {
}

/// Gets the `Realm` from where this function originates.
#[must_use]
pub const fn realm(&self) -> &Realm {
&self.realm
}
Expand Down Expand Up @@ -1128,16 +1130,19 @@ impl BoundFunction {
}

/// Get a reference to the bound function's this.
#[must_use]
pub const fn this(&self) -> &JsValue {
&self.this
}

/// Get a reference to the bound function's target function.
#[must_use]
pub const fn target_function(&self) -> &JsObject {
&self.target_function
}

/// Get a reference to the bound function's args.
#[must_use]
pub fn args(&self) -> &[JsValue] {
self.args.as_slice()
}
Expand Down
11 changes: 11 additions & 0 deletions boa_engine/src/builtins/iterable/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,60 +77,70 @@ pub struct IteratorPrototypes {
impl IteratorPrototypes {
/// Returns the `ArrayIteratorPrototype` object.
#[inline]
#[must_use]
pub fn array(&self) -> JsObject {
self.array.clone()
}

/// Returns the `IteratorPrototype` object.
#[inline]
#[must_use]
pub fn iterator(&self) -> JsObject {
self.iterator.clone()
}

/// Returns the `AsyncIteratorPrototype` object.
#[inline]
#[must_use]
pub fn async_iterator(&self) -> JsObject {
self.async_iterator.clone()
}

/// Returns the `AsyncFromSyncIteratorPrototype` object.
#[inline]
#[must_use]
pub fn async_from_sync_iterator(&self) -> JsObject {
self.async_from_sync_iterator.clone()
}

/// Returns the `SetIteratorPrototype` object.
#[inline]
#[must_use]
pub fn set(&self) -> JsObject {
self.set.clone()
}

/// Returns the `StringIteratorPrototype` object.
#[inline]
#[must_use]
pub fn string(&self) -> JsObject {
self.string.clone()
}

/// Returns the `RegExpStringIteratorPrototype` object.
#[inline]
#[must_use]
pub fn regexp_string(&self) -> JsObject {
self.regexp_string.clone()
}

/// Returns the `MapIteratorPrototype` object.
#[inline]
#[must_use]
pub fn map(&self) -> JsObject {
self.map.clone()
}

/// Returns the `ForInIteratorPrototype` object.
#[inline]
#[must_use]
pub fn for_in(&self) -> JsObject {
self.for_in.clone()
}

/// Returns the `%SegmentIteratorPrototype%` object.
#[inline]
#[must_use]
#[cfg(feature = "intl")]
pub fn segment(&self) -> JsObject {
self.segment.clone()
Expand Down Expand Up @@ -378,6 +388,7 @@ pub struct IteratorRecord {
impl IteratorRecord {
/// Creates a new `IteratorRecord` with the given iterator object, next method and `done` flag.
#[inline]
#[must_use]
pub fn new(iterator: JsObject, next_method: JsValue) -> Self {
Self {
iterator,
Expand Down
1 change: 1 addition & 0 deletions boa_engine/src/builtins/map/ordered_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ impl<V> OrderedMap<V> {
/// Return `true` if an equivalent to `key` exists in the map.
///
/// Computes in **O(1)** time (average).
#[must_use]
pub fn contains_key(&self, key: &JsValue) -> bool {
self.map.contains_key(key)
}
Expand Down
2 changes: 2 additions & 0 deletions boa_engine/src/builtins/promise/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ unsafe impl Trace for PromiseState {
impl PromiseState {
/// Gets the inner `JsValue` of a fulfilled promise state, or returns `None` if
/// the state is not `Fulfilled`.
#[must_use]
pub const fn as_fulfilled(&self) -> Option<&JsValue> {
match self {
Self::Fulfilled(v) => Some(v),
Expand All @@ -60,6 +61,7 @@ impl PromiseState {

/// Gets the inner `JsValue` of a rejected promise state, or returns `None` if
/// the state is not `Rejected`.
#[must_use]
pub const fn as_rejected(&self) -> Option<&JsValue> {
match self {
Self::Rejected(v) => Some(v),
Expand Down
1 change: 1 addition & 0 deletions boa_engine/src/builtins/set/ordered_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ impl OrderedSet {
/// Return `true` if `value` is present in set, false otherwise.
///
/// Computes in **O(n)** time (average).
#[must_use]
pub fn contains(&self, value: &JsValue) -> bool {
self.inner.contains(value)
}
Expand Down
4 changes: 4 additions & 0 deletions boa_engine/src/builtins/typed_array/integer_indexed_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ impl IntegerIndexed {
}

/// Get the integer indexed object's byte offset.
#[must_use]
pub const fn byte_offset(&self) -> u64 {
self.byte_offset
}
Expand All @@ -81,6 +82,7 @@ impl IntegerIndexed {
}

/// Get a reference to the integer indexed object's viewed array buffer.
#[must_use]
pub const fn viewed_array_buffer(&self) -> Option<&JsObject> {
self.viewed_array_buffer.as_ref()
}
Expand All @@ -91,6 +93,7 @@ impl IntegerIndexed {
}

/// Get the integer indexed object's byte length.
#[must_use]
pub const fn byte_length(&self) -> u64 {
self.byte_length
}
Expand All @@ -101,6 +104,7 @@ impl IntegerIndexed {
}

/// Get the integer indexed object's array length.
#[must_use]
pub const fn array_length(&self) -> u64 {
self.array_length
}
Expand Down
Loading

0 comments on commit 72b7ee5

Please sign in to comment.