From b708da962f8de758ccc60fbf9387ff79eae14bb7 Mon Sep 17 00:00:00 2001 From: y21 <30553356+y21@users.noreply.github.com> Date: Wed, 13 Nov 2024 18:09:05 +0100 Subject: [PATCH] enable `unused_qualifications` lint --- crates/dash_vm/src/gc/mod.rs | 6 +-- crates/dash_vm/src/js_std/array.rs | 6 +-- crates/dash_vm/src/lib.rs | 2 +- crates/dash_vm/src/value/function/async.rs | 2 +- crates/dash_vm/src/value/function/mod.rs | 2 +- crates/dash_vm/src/value/promise.rs | 46 ++++++++-------------- crates/dash_vm/src/value/string.rs | 15 +++---- 7 files changed, 31 insertions(+), 48 deletions(-) diff --git a/crates/dash_vm/src/gc/mod.rs b/crates/dash_vm/src/gc/mod.rs index 1153a160..aac60d84 100644 --- a/crates/dash_vm/src/gc/mod.rs +++ b/crates/dash_vm/src/gc/mod.rs @@ -185,7 +185,7 @@ fn const_checks_for_alloc() { assert!(size_of::() < 1024); assert!(size_of::() < 256); // We could store its `drop_in_place` as well to support it but it's not needed ATP. - assert!(!std::mem::needs_drop::()); + assert!(!mem::needs_drop::()); } } @@ -364,7 +364,7 @@ impl Chunk { alloc_start: allocation_start as u16, data_index, drop_in_place: unsafe { - std::mem::transmute::(std::ptr::drop_in_place:: as _) + mem::transmute::(ptr::drop_in_place:: as _) }, }; let info_id = if let Some(info_id) = info_id { @@ -407,7 +407,7 @@ impl Chunk { data_index, alloc_start: self.at as u16, drop_in_place: unsafe { - std::mem::transmute::(std::ptr::drop_in_place:: as _) + mem::transmute::(ptr::drop_in_place:: as _) }, }); diff --git a/crates/dash_vm/src/js_std/array.rs b/crates/dash_vm/src/js_std/array.rs index 1dec6e36..41b09e9b 100644 --- a/crates/dash_vm/src/js_std/array.rs +++ b/crates/dash_vm/src/js_std/array.rs @@ -644,12 +644,12 @@ pub fn for_each_js_iterator_element, Value) -> R break; } let value = item.get_property(scope, sym::value.into()).root(scope)?; - if let ControlFlow::Break(val) = f(scope, value)? { - return Ok(ControlFlow::Break(val)); + if let Break(val) = f(scope, value)? { + return Ok(Break(val)); } } - Ok(ControlFlow::Continue(())) + Ok(Continue(())) } pub fn from(cx: CallContext) -> Result { diff --git a/crates/dash_vm/src/lib.rs b/crates/dash_vm/src/lib.rs index acf9dc0a..9d229b8a 100644 --- a/crates/dash_vm/src/lib.rs +++ b/crates/dash_vm/src/lib.rs @@ -1,6 +1,6 @@ #![cfg_attr(dash_lints, feature(register_tool))] #![cfg_attr(dash_lints, register_tool(dash_lints))] -#![warn(clippy::redundant_clone)] +#![warn(clippy::redundant_clone, unused_qualifications)] #![deny(clippy::disallowed_methods)] use std::ops::RangeBounds; diff --git a/crates/dash_vm/src/value/function/async.rs b/crates/dash_vm/src/value/function/async.rs index a1cb417e..46e3aab6 100644 --- a/crates/dash_vm/src/value/function/async.rs +++ b/crates/dash_vm/src/value/function/async.rs @@ -130,7 +130,7 @@ impl Object for ThenTask { fn apply( &self, - scope: &mut crate::localscope::LocalScope, + scope: &mut LocalScope, _callee: ObjectId, _this: This, args: Vec, diff --git a/crates/dash_vm/src/value/function/mod.rs b/crates/dash_vm/src/value/function/mod.rs index 4c98f633..5682c715 100755 --- a/crates/dash_vm/src/value/function/mod.rs +++ b/crates/dash_vm/src/value/function/mod.rs @@ -53,7 +53,7 @@ unsafe impl Trace for FunctionKind { } } -impl fmt::Debug for FunctionKind { +impl Debug for FunctionKind { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { Self::Native(..) => f.write_str("NativeFunction"), diff --git a/crates/dash_vm/src/value/promise.rs b/crates/dash_vm/src/value/promise.rs index 2ceb9d12..0d441030 100644 --- a/crates/dash_vm/src/value/promise.rs +++ b/crates/dash_vm/src/value/promise.rs @@ -78,32 +78,28 @@ impl Object for Promise { fn set_property( &self, - sc: &mut crate::localscope::LocalScope, + sc: &mut LocalScope, key: crate::value::object::PropertyKey, value: crate::value::object::PropertyValue, ) -> Result<(), Value> { self.obj.set_property(sc, key, value) } - fn delete_property( - &self, - sc: &mut crate::localscope::LocalScope, - key: crate::value::object::PropertyKey, - ) -> Result { + fn delete_property(&self, sc: &mut LocalScope, key: crate::value::object::PropertyKey) -> Result { self.obj.delete_property(sc, key) } - fn set_prototype(&self, sc: &mut crate::localscope::LocalScope, value: Value) -> Result<(), Value> { + fn set_prototype(&self, sc: &mut LocalScope, value: Value) -> Result<(), Value> { self.obj.set_prototype(sc, value) } - fn get_prototype(&self, sc: &mut crate::localscope::LocalScope) -> Result { + fn get_prototype(&self, sc: &mut LocalScope) -> Result { self.obj.get_prototype(sc) } fn apply( &self, - scope: &mut crate::localscope::LocalScope, + scope: &mut LocalScope, callee: ObjectId, this: This, args: Vec, @@ -144,32 +140,28 @@ impl Object for PromiseResolver { fn set_property( &self, - sc: &mut crate::localscope::LocalScope, + sc: &mut LocalScope, key: crate::value::object::PropertyKey, value: crate::value::object::PropertyValue, ) -> Result<(), Value> { self.obj.set_property(sc, key, value) } - fn delete_property( - &self, - sc: &mut crate::localscope::LocalScope, - key: crate::value::object::PropertyKey, - ) -> Result { + fn delete_property(&self, sc: &mut LocalScope, key: crate::value::object::PropertyKey) -> Result { self.obj.delete_property(sc, key) } - fn set_prototype(&self, sc: &mut crate::localscope::LocalScope, value: Value) -> Result<(), Value> { + fn set_prototype(&self, sc: &mut LocalScope, value: Value) -> Result<(), Value> { self.obj.set_prototype(sc, value) } - fn get_prototype(&self, sc: &mut crate::localscope::LocalScope) -> Result { + fn get_prototype(&self, sc: &mut LocalScope) -> Result { self.obj.get_prototype(sc) } fn apply( &self, - scope: &mut crate::localscope::LocalScope, + scope: &mut LocalScope, _callee: ObjectId, _this: This, args: Vec, @@ -187,7 +179,7 @@ impl Object for PromiseResolver { self.obj.own_keys(sc) } - fn type_of(&self, _: &Vm) -> super::Typeof { + fn type_of(&self, _: &Vm) -> Typeof { Typeof::Function } @@ -220,32 +212,28 @@ impl Object for PromiseRejecter { fn set_property( &self, - sc: &mut crate::localscope::LocalScope, + sc: &mut LocalScope, key: crate::value::object::PropertyKey, value: crate::value::object::PropertyValue, ) -> Result<(), Value> { self.obj.set_property(sc, key, value) } - fn delete_property( - &self, - sc: &mut crate::localscope::LocalScope, - key: crate::value::object::PropertyKey, - ) -> Result { + fn delete_property(&self, sc: &mut LocalScope, key: crate::value::object::PropertyKey) -> Result { self.obj.delete_property(sc, key) } - fn set_prototype(&self, sc: &mut crate::localscope::LocalScope, value: Value) -> Result<(), Value> { + fn set_prototype(&self, sc: &mut LocalScope, value: Value) -> Result<(), Value> { self.obj.set_prototype(sc, value) } - fn get_prototype(&self, sc: &mut crate::localscope::LocalScope) -> Result { + fn get_prototype(&self, sc: &mut LocalScope) -> Result { self.obj.get_prototype(sc) } fn apply( &self, - scope: &mut crate::localscope::LocalScope, + scope: &mut LocalScope, _callee: ObjectId, _this: This, args: Vec, @@ -263,7 +251,7 @@ impl Object for PromiseRejecter { self.obj.own_keys(sc) } - fn type_of(&self, _: &Vm) -> super::Typeof { + fn type_of(&self, _: &Vm) -> Typeof { Typeof::Function } diff --git a/crates/dash_vm/src/value/string.rs b/crates/dash_vm/src/value/string.rs index 6e2aea36..f4082230 100644 --- a/crates/dash_vm/src/value/string.rs +++ b/crates/dash_vm/src/value/string.rs @@ -77,8 +77,8 @@ impl Object for JsString { fn get_own_property_descriptor( &self, sc: &mut LocalScope, - key: super::object::PropertyKey, - ) -> Result, super::Unrooted> { + key: PropertyKey, + ) -> Result, Unrooted> { if let PropertyKey::String(st) = key { if st.sym() == sym::length { return Ok(Some(PropertyValue::static_empty(Value::number(self.len(sc) as f64)))); @@ -96,16 +96,11 @@ impl Object for JsString { Ok(None) } - fn set_property( - &self, - _: &mut LocalScope, - _: super::object::PropertyKey, - _: super::object::PropertyValue, - ) -> Result<(), Value> { + fn set_property(&self, _: &mut LocalScope, _: PropertyKey, _: PropertyValue) -> Result<(), Value> { Ok(()) } - fn delete_property(&self, _: &mut LocalScope, _: super::object::PropertyKey) -> Result { + fn delete_property(&self, _: &mut LocalScope, _: PropertyKey) -> Result { Ok(Unrooted::new(Value::undefined())) } @@ -123,7 +118,7 @@ impl Object for JsString { _: crate::gc::ObjectId, _: This, _: Vec, - ) -> Result { + ) -> Result { let v = self.res(scope).to_owned(); throw!(scope, TypeError, "'{}' is not a function", v) }