Skip to content

Commit

Permalink
chore: Fix errors reported by clippy beta
Browse files Browse the repository at this point in the history
This fixes errors like

    error: the following explicit lifetimes could be elided: 'a
    error: empty line after doc comment
    error: unneeded `return` statement
  • Loading branch information
kjarosh authored and Dinnerbone committed Oct 17, 2024
1 parent d69ebd5 commit 7ed23b0
Show file tree
Hide file tree
Showing 72 changed files with 185 additions and 199 deletions.
2 changes: 1 addition & 1 deletion core/src/avm1/activation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ macro_rules! avm_debug {
#[derive(Clone)]
pub struct RegisterSet<'gc>(SmallVec<[Value<'gc>; 8]>);

unsafe impl<'gc> gc_arena::Collect for RegisterSet<'gc> {
unsafe impl gc_arena::Collect for RegisterSet<'_> {
#[inline]
fn trace(&self, cc: &gc_arena::Collection) {
for register in &self.0 {
Expand Down
2 changes: 1 addition & 1 deletion core/src/avm1/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ impl<'gc> Executable<'gc> {
}
}

impl<'gc> From<NativeFunction> for Executable<'gc> {
impl From<NativeFunction> for Executable<'_> {
fn from(nf: NativeFunction) -> Self {
Executable::Native(nf)
}
Expand Down
16 changes: 8 additions & 8 deletions core/src/avm1/property_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ impl<'gc, V> PropertyMap<'gc, V> {
}
}

unsafe impl<'gc, V: Collect> Collect for PropertyMap<'gc, V> {
unsafe impl<V: Collect> Collect for PropertyMap<'_, V> {
fn trace(&self, cc: &gc_arena::Collection) {
for (key, value) in &self.0 {
key.0.trace(cc);
Expand All @@ -127,7 +127,7 @@ pub struct OccupiedEntry<'gc, 'a, V> {
index: usize,
}

impl<'gc, 'a, V> OccupiedEntry<'gc, 'a, V> {
impl<'gc, V> OccupiedEntry<'gc, '_, V> {
pub fn remove_entry(&mut self) -> (AvmString<'gc>, V) {
let (k, v) = self.map.shift_remove_index(self.index).unwrap();
(k.0, v)
Expand All @@ -151,7 +151,7 @@ pub struct VacantEntry<'gc, 'a, V> {
key: AvmString<'gc>,
}

impl<'gc, 'a, V> VacantEntry<'gc, 'a, V> {
impl<V> VacantEntry<'_, '_, V> {
pub fn insert(self, value: V) {
self.map.insert(PropertyName(self.key), value);
}
Expand All @@ -160,13 +160,13 @@ impl<'gc, 'a, V> VacantEntry<'gc, 'a, V> {
/// Wraps a str-like type, causing the hash map to use a case insensitive hash and equality.
struct CaseInsensitive<T>(T);

impl<'a> Hash for CaseInsensitive<&'a WStr> {
impl Hash for CaseInsensitive<&WStr> {
fn hash<H: Hasher>(&self, state: &mut H) {
swf_hash_string_ignore_case(self.0, state);
}
}

impl<'gc, 'a> Equivalent<PropertyName<'gc>> for CaseInsensitive<&'a WStr> {
impl<'gc> Equivalent<PropertyName<'gc>> for CaseInsensitive<&WStr> {
fn equivalent(&self, key: &PropertyName<'gc>) -> bool {
key.0.eq_ignore_case(self.0)
}
Expand All @@ -176,13 +176,13 @@ impl<'gc, 'a> Equivalent<PropertyName<'gc>> for CaseInsensitive<&'a WStr> {
/// but case sensitive equality.
struct CaseSensitive<T>(T);

impl<'a> Hash for CaseSensitive<&'a WStr> {
impl Hash for CaseSensitive<&WStr> {
fn hash<H: Hasher>(&self, state: &mut H) {
swf_hash_string_ignore_case(self.0, state);
}
}

impl<'gc, 'a> Equivalent<PropertyName<'gc>> for CaseSensitive<&'a WStr> {
impl<'gc> Equivalent<PropertyName<'gc>> for CaseSensitive<&WStr> {
fn equivalent(&self, key: &PropertyName<'gc>) -> bool {
key.0 == self.0
}
Expand All @@ -198,7 +198,7 @@ impl<'gc, 'a> Equivalent<PropertyName<'gc>> for CaseSensitive<&'a WStr> {
struct PropertyName<'gc>(AvmString<'gc>);

#[allow(clippy::derive_hash_xor_eq)]
impl<'gc> Hash for PropertyName<'gc> {
impl Hash for PropertyName<'_> {
fn hash<H: Hasher>(&self, state: &mut H) {
swf_hash_string_ignore_case(self.0.as_ref(), state);
}
Expand Down
24 changes: 12 additions & 12 deletions core/src/avm1/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ impl<'gc> From<AvmAtom<'gc>> for Value<'gc> {
}
}

impl<'gc> From<&'static str> for Value<'gc> {
impl From<&'static str> for Value<'_> {
fn from(string: &'static str) -> Self {
Value::String(string.into())
}
}

impl<'gc> From<bool> for Value<'gc> {
impl From<bool> for Value<'_> {
fn from(value: bool) -> Self {
Value::Bool(value)
}
Expand All @@ -68,61 +68,61 @@ where
}
}

impl<'gc> From<f64> for Value<'gc> {
impl From<f64> for Value<'_> {
fn from(value: f64) -> Self {
Value::Number(value)
}
}

impl<'gc> From<f32> for Value<'gc> {
impl From<f32> for Value<'_> {
fn from(value: f32) -> Self {
Value::Number(f64::from(value))
}
}

impl<'gc> From<i8> for Value<'gc> {
impl From<i8> for Value<'_> {
fn from(value: i8) -> Self {
Value::Number(f64::from(value))
}
}

impl<'gc> From<u8> for Value<'gc> {
impl From<u8> for Value<'_> {
fn from(value: u8) -> Self {
Value::Number(f64::from(value))
}
}

impl<'gc> From<i16> for Value<'gc> {
impl From<i16> for Value<'_> {
fn from(value: i16) -> Self {
Value::Number(f64::from(value))
}
}

impl<'gc> From<u16> for Value<'gc> {
impl From<u16> for Value<'_> {
fn from(value: u16) -> Self {
Value::Number(f64::from(value))
}
}

impl<'gc> From<i32> for Value<'gc> {
impl From<i32> for Value<'_> {
fn from(value: i32) -> Self {
Value::Number(f64::from(value))
}
}

impl<'gc> From<u32> for Value<'gc> {
impl From<u32> for Value<'_> {
fn from(value: u32) -> Self {
Value::Number(f64::from(value))
}
}

impl<'gc> From<u64> for Value<'gc> {
impl From<u64> for Value<'_> {
fn from(value: u64) -> Self {
Value::Number(value as f64)
}
}

impl<'gc> From<usize> for Value<'gc> {
impl From<usize> for Value<'_> {
fn from(value: usize) -> Self {
Value::Number(value as f64)
}
Expand Down
3 changes: 1 addition & 2 deletions core/src/avm2/activation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@ use super::error::make_mismatch_error;
/// Represents a particular register set.
///
/// This type exists primarily because SmallVec isn't garbage-collectable.

pub struct RegisterSet<'gc>(SmallVec<[Value<'gc>; 8]>);

unsafe impl<'gc> gc_arena::Collect for RegisterSet<'gc> {
unsafe impl gc_arena::Collect for RegisterSet<'_> {
#[inline]
fn trace(&self, cc: &gc_arena::Collection) {
for register in &self.0 {
Expand Down
10 changes: 4 additions & 6 deletions core/src/avm2/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct ArrayStorageIterator<'a, 'gc> {
index_back: usize,
}

impl<'a, 'gc> Iterator for ArrayStorageIterator<'a, 'gc> {
impl<'gc> Iterator for ArrayStorageIterator<'_, 'gc> {
type Item = Option<Value<'gc>>;

fn next(&mut self) -> Option<Self::Item> {
Expand All @@ -51,7 +51,7 @@ impl<'a, 'gc> Iterator for ArrayStorageIterator<'a, 'gc> {
}
}

impl<'a, 'gc> DoubleEndedIterator for ArrayStorageIterator<'a, 'gc> {
impl DoubleEndedIterator for ArrayStorageIterator<'_, '_> {
fn next_back(&mut self) -> Option<Self::Item> {
if self.index >= self.index_back || self.index_back == 0 {
None
Expand All @@ -66,7 +66,7 @@ impl<'a, 'gc> DoubleEndedIterator for ArrayStorageIterator<'a, 'gc> {
}
}

impl<'a, 'gc> ExactSizeIterator for ArrayStorageIterator<'a, 'gc> {
impl ExactSizeIterator for ArrayStorageIterator<'_, '_> {
fn len(&self) -> usize {
self.index_back - self.index
}
Expand Down Expand Up @@ -139,9 +139,7 @@ impl<'gc> ArrayStorage<'gc> {
/// yielding `None`.
pub fn get(&self, item: usize) -> Option<Value<'gc>> {
match &self {
ArrayStorage::Dense { storage, .. } => {
return storage.get(item).copied().unwrap_or(None);
}
ArrayStorage::Dense { storage, .. } => storage.get(item).copied().unwrap_or(None),
ArrayStorage::Sparse { storage, .. } => storage.get(&item).copied(),
}
}
Expand Down
4 changes: 2 additions & 2 deletions core/src/avm2/call_stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ impl<'gc> CallStack<'gc> {
}
}

impl<'gc> Default for CallStack<'gc> {
impl Default for CallStack<'_> {
fn default() -> Self {
Self::new()
}
}

impl<'gc> std::fmt::Display for CallStack<'gc> {
impl std::fmt::Display for CallStack<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let mut output = WString::new();
self.display(&mut output);
Expand Down
2 changes: 1 addition & 1 deletion core/src/avm2/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ impl Hash for Class<'_> {
}
}

impl<'gc> core::fmt::Debug for Class<'gc> {
impl core::fmt::Debug for Class<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
f.debug_struct("Class").field("name", &self.name()).finish()
}
Expand Down
4 changes: 2 additions & 2 deletions core/src/avm2/domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,10 +427,10 @@ impl<'gc> Domain<'gc> {

pub enum DomainPtr {}

impl<'gc> PartialEq for Domain<'gc> {
impl PartialEq for Domain<'_> {
fn eq(&self, other: &Self) -> bool {
self.0.as_ptr() == other.0.as_ptr()
}
}

impl<'gc> Eq for Domain<'gc> {}
impl Eq for Domain<'_> {}
8 changes: 4 additions & 4 deletions core/src/avm2/e4x.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub struct E4XNodeData<'gc> {
notification: Option<FunctionObject<'gc>>,
}

impl<'gc> Debug for E4XNodeData<'gc> {
impl Debug for E4XNodeData<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("E4XNodeData")
// Don't print the actual parent, to avoid infinite recursion
Expand Down Expand Up @@ -1392,16 +1392,16 @@ impl<'gc> E4XNode<'gc> {
);
}

return to_xml_string(E4XOrXml::E4X(*self), activation);
to_xml_string(E4XOrXml::E4X(*self), activation)
}
E4XNodeKind::Comment(_) | E4XNodeKind::ProcessingInstruction(_) => {
return to_xml_string(E4XOrXml::E4X(*self), activation);
to_xml_string(E4XOrXml::E4X(*self), activation)
}
}
}

pub fn xml_to_xml_string(&self, activation: &mut Activation<'_, 'gc>) -> AvmString<'gc> {
return to_xml_string(E4XOrXml::E4X(*self), activation);
to_xml_string(E4XOrXml::E4X(*self), activation)
}

pub fn kind(&self) -> Ref<'_, E4XNodeKind<'gc>> {
Expand Down
4 changes: 2 additions & 2 deletions core/src/avm2/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub enum Error<'gc> {
RustError(Box<dyn std::error::Error>),
}

impl<'gc> Debug for Error<'gc> {
impl Debug for Error<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
if let Error::AvmError(error) = self {
if let Some(error) = error.as_object().and_then(|obj| obj.as_error_object()) {
Expand Down Expand Up @@ -836,7 +836,7 @@ fn error_constructor<'gc>(
.into())
}

impl<'gc> std::fmt::Display for Error<'gc> {
impl std::fmt::Display for Error<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{self:?}")
}
Expand Down
8 changes: 4 additions & 4 deletions core/src/avm2/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ impl<'gc> DispatchList<'gc> {
}
}

impl<'gc> Default for DispatchList<'gc> {
impl Default for DispatchList<'_> {
fn default() -> Self {
Self::new()
}
Expand Down Expand Up @@ -331,15 +331,15 @@ impl<'gc> EventHandler<'gc> {
}
}

impl<'gc> PartialEq for EventHandler<'gc> {
impl PartialEq for EventHandler<'_> {
fn eq(&self, rhs: &Self) -> bool {
self.use_capture == rhs.use_capture && Object::ptr_eq(self.handler, rhs.handler)
}
}

impl<'gc> Eq for EventHandler<'gc> {}
impl Eq for EventHandler<'_> {}

impl<'gc> Hash for EventHandler<'gc> {
impl Hash for EventHandler<'_> {
fn hash<H: Hasher>(&self, state: &mut H) {
self.use_capture.hash(state);
self.handler.as_ptr().hash(state);
Expand Down
2 changes: 1 addition & 1 deletion core/src/avm2/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ pub fn exec<'gc>(
ret
}

impl<'gc> fmt::Debug for BoundMethod<'gc> {
impl fmt::Debug for BoundMethod<'_> {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.method {
Method::Bytecode(be) => fmt
Expand Down
2 changes: 1 addition & 1 deletion core/src/avm2/globals/flash/system/security.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub fn get_sandbox_type<'gc>(
SandboxType::LocalTrusted => "localTrusted",
SandboxType::Application => "application",
};
return Ok(AvmString::new_utf8(activation.context.gc_context, sandbox_type).into());
Ok(AvmString::new_utf8(activation.context.gc_context, sandbox_type).into())
}

pub fn allow_domain<'gc>(
Expand Down
2 changes: 1 addition & 1 deletion core/src/avm2/globals/reg_exp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub fn call_handler<'gc>(
return Ok(arg);
}
}
return this_class.construct(activation, args).map(|o| o.into());
this_class.construct(activation, args).map(|o| o.into())
}

/// Implements `RegExp.dotall`
Expand Down
Loading

0 comments on commit 7ed23b0

Please sign in to comment.