Skip to content

Commit

Permalink
fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
y21 committed Oct 29, 2024
1 parent 869ff9b commit 39b82d4
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 17 deletions.
2 changes: 0 additions & 2 deletions crates/dash_rt/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use std::cell::OnceCell;
use std::future::Future;

use dash_compiler::FunctionCompiler;
use dash_middle::compiler::CompileResult;
use dash_vm::frame::{Exports, Frame};
use dash_vm::localscope::LocalScope;
use dash_vm::value::function::native::CallContext;
Expand Down
4 changes: 2 additions & 2 deletions crates/dash_vm/src/js_std/array.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::ops::Range;

use dash_middle::interner::sym;
use crate::localscope::LocalScope;
use crate::throw;
use crate::value::array::{Array, ArrayIterator};
Expand All @@ -10,7 +9,8 @@ use crate::value::ops::conversions::ValueConversion;
use crate::value::ops::equality::strict_eq;
use crate::value::root_ext::RootErrExt;
use crate::value::string::JsString;
use crate::value::{array, Root, Unpack, Value, ValueContext, ValueKind};
use crate::value::{array, Root, Unpack, Value, ValueContext};
use dash_middle::interner::sym;

pub fn constructor(cx: CallContext) -> Result<Value, Value> {
let size = cx.args.first().unwrap_or_undefined().to_length_u(cx.scope)?;
Expand Down
2 changes: 1 addition & 1 deletion crates/dash_vm/src/js_std/number.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::util::intern_f64;
use crate::value::function::native::CallContext;
use crate::value::object::Object;
use crate::value::ops::conversions::ValueConversion;
use crate::value::primitive::{InternalSlots, Number, MAX_SAFE_INTEGER, MIN_SAFE_INTEGER};
use crate::value::primitive::{Number, MAX_SAFE_INTEGER, MIN_SAFE_INTEGER};
use crate::value::{boxed, Unpack, Value, ValueContext, ValueKind};

pub fn constructor(cx: CallContext) -> Result<Value, Value> {
Expand Down
9 changes: 1 addition & 8 deletions crates/dash_vm/src/js_std/object.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::ops::ControlFlow;

use dash_middle::interner::sym;
use crate::gc::ObjectId;
use crate::localscope::LocalScope;
use crate::throw;
Expand All @@ -10,6 +9,7 @@ use crate::value::object::{NamedObject, Object, PropertyDataDescriptor, Property
use crate::value::ops::conversions::ValueConversion;
use crate::value::root_ext::RootErrExt;
use crate::value::{Root, Typeof, Unpack, Value, ValueContext, ValueKind};
use dash_middle::interner::sym;

pub fn constructor(cx: CallContext) -> Result<Value, Value> {
match cx.args.first() {
Expand Down Expand Up @@ -138,13 +138,6 @@ pub fn define_property(cx: CallContext) -> Result<Value, Value> {
};

let property = match cx.args.get(1) {
Some(arg) => {
if let ValueKind::Symbol(sym) = arg.unpack() {
PropertyKey::from(sym)
} else {
throw!(cx.scope, TypeError, "Property must be a string or symbol")
}
}
Some(other) => PropertyKey::from(other.to_js_string(cx.scope)?),
_ => throw!(cx.scope, TypeError, "Property must be a string or symbol"),
};
Expand Down
1 change: 1 addition & 0 deletions crates/dash_vm/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![cfg_attr(dash_lints, feature(register_tool))]
#![cfg_attr(dash_lints, register_tool(dash_lints))]
#![allow(clippy::clone_on_copy)] // TODO: Requires large amounts of changes
#![warn(clippy::redundant_clone)]
#![deny(clippy::disallowed_methods)]

Expand Down
4 changes: 2 additions & 2 deletions crates/dash_vm/src/value/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ impl Unpack for Value {
/// Unpacks the value so it can be matched
fn unpack(self) -> Self::Output {
// TODO: find out why codegen is bad
#[expect(clippy::wildcard_in_or_patterns)]
match self.0 & Self::TAG_MASK {
Self::BOOLEAN_MASK => ValueKind::Boolean(self.0 as u8 == 1),
Self::STRING_MASK => ValueKind::String(JsString::from(interner::Symbol::from_raw(self.0 as u32))),
Expand Down Expand Up @@ -496,7 +495,8 @@ impl ExternalValue {
/// The `dyn Object` *must* be `Value`.
// can we make this type safe?
pub fn new(vm: &Vm, inner: ObjectId) -> Self {
// debug_assert!(inner.as_any().downcast_ref::<Value>().is_some());
// TODO: make a ValueId
debug_assert!(inner.as_any(vm).downcast_ref::<Value>().is_some());
Self { inner }
}

Expand Down
4 changes: 2 additions & 2 deletions lints/src/missing_root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ macro_rules! required_items {
required_items!(
trait root => ["dash_vm", "value", "Root"],
struct vm => ["dash_vm", "Vm"],
struct gc => ["dash_vm", "gc", "Gc"],
struct allocator => ["dash_vm", "gc", "Allocator"],
struct scope => ["dash_vm", "localscope", "LocalScope"],
struct dispatchcx => ["dash_vm", "dispatch", "DispatchContext"]
);
Expand All @@ -85,7 +85,7 @@ impl MissingRoot {
self.items.dispatchcx(),
self.items.vm(),
self.items.scope(),
self.items.gc(),
self.items.allocator(),
]
.contains(&def.did()),
ty::Ref(_, pointee, Mutability::Mut) => self.is_scope_like(tcx, pointee, refb),
Expand Down

0 comments on commit 39b82d4

Please sign in to comment.