Skip to content

Commit

Permalink
cargo clippy --fix
Browse files Browse the repository at this point in the history
  • Loading branch information
voltrevo committed Jul 16, 2024
1 parent e62cebb commit 0bbf100
Show file tree
Hide file tree
Showing 17 changed files with 90 additions and 90 deletions.
4 changes: 2 additions & 2 deletions valuescript_compiler/src/gather_modules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ where
// FIXME: This diagnostic should really be attached to the import statement
gm.diagnostics
.entry(dependency.path.clone())
.or_insert(vec![])
.or_default()
.push(Diagnostic {
level: DiagnosticLevel::Error,
message: match dependency.reason {
Expand All @@ -82,7 +82,7 @@ where

gm.diagnostics
.entry(dependency.path.clone())
.or_insert(vec![])
.or_default()
.append(&mut compiler_output.diagnostics);

let path_and_module = PathAndModule {
Expand Down
10 changes: 5 additions & 5 deletions valuescript_compiler/src/scope_analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ impl ScopeAnalysis {
self
.reg_allocators
.entry(scope.clone())
.or_insert_with(RegAllocator::default)
.or_default()
.allocate(based_on_name)
}

Expand Down Expand Up @@ -232,7 +232,7 @@ impl ScopeAnalysis {
self
.owners
.entry(name.owner_id.clone())
.or_insert_with(HashSet::new)
.or_default()
.insert(origin_ident.span);

scope.set(
Expand Down Expand Up @@ -336,7 +336,7 @@ impl ScopeAnalysis {
let inserted = self
.captures
.entry(captor_id.clone())
.or_insert_with(HashSet::new)
.or_default()
.insert(name_id.clone());

if inserted {
Expand All @@ -347,7 +347,7 @@ impl ScopeAnalysis {
let reg = self
.reg_allocators
.entry(captor_id.clone())
.or_insert_with(RegAllocator::default)
.or_default()
.allocate(&name.sym);

self.capture_values.insert(key, Value::Register(reg));
Expand Down Expand Up @@ -1895,7 +1895,7 @@ impl ScopeAnalysis {
let reg = self
.reg_allocators
.entry(captor.clone())
.or_insert_with(RegAllocator::default)
.or_default()
.allocate(&name.sym);

Value::Register(reg)
Expand Down
18 changes: 9 additions & 9 deletions valuescript_vm/src/array_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ pub fn op_sub_array_index(array: &mut Rc<VsArray>, index: usize) -> Result<Val,

static AT: NativeFunction = native_fn(|this, params| {
Ok(match this.get() {
Val::Array(array_data) => match to_wrapping_index(params.get(0), array_data.elements.len()) {
Val::Array(array_data) => match to_wrapping_index(params.first(), array_data.elements.len()) {
None => Val::Undefined,
Some(i) => array_data.elements[i].clone(),
},
Expand Down Expand Up @@ -133,7 +133,7 @@ static COPY_WITHIN: NativeFunction = native_fn(|mut this, params| {
return Err("TODO: array len exceeds isize".to_internal_error());
}

let mut target = match params.get(0) {
let mut target = match params.first() {
None => 0,
Some(p) => to_wrapping_index_clamped(p, ulen),
};
Expand Down Expand Up @@ -205,7 +205,7 @@ static FILL: NativeFunction = native_fn(|mut this, params| {
let array_data_mut = Rc::make_mut(array_data);
let len = array_data_mut.elements.len();

let fill_val = params.get(0).unwrap_or(&Val::Undefined);
let fill_val = params.first().unwrap_or(&Val::Undefined);

let start = match params.get(1) {
None => 0,
Expand Down Expand Up @@ -258,7 +258,7 @@ static FLAT: NativeFunction = native_fn(|this, params| {
static INCLUDES: NativeFunction = native_fn(|this, params| {
Ok(match this.get() {
Val::Array(array_data) => {
let search_param = params.get(0).unwrap_or(&Val::Undefined);
let search_param = params.first().unwrap_or(&Val::Undefined);

for elem in &array_data.elements {
let is_eq = op_triple_eq_impl(elem, search_param)
Expand All @@ -279,7 +279,7 @@ static INCLUDES: NativeFunction = native_fn(|this, params| {
static INDEX_OF: NativeFunction = native_fn(|this, params| {
Ok(match this.get() {
Val::Array(array_data) => {
let search_param = params.get(0).unwrap_or(&Val::Undefined);
let search_param = params.first().unwrap_or(&Val::Undefined);

for i in 0..array_data.elements.len() {
let is_eq = op_triple_eq_impl(&array_data.elements[i], search_param)
Expand Down Expand Up @@ -308,7 +308,7 @@ static JOIN: NativeFunction = native_fn(|this, params| {
return Ok(vals.elements[0].clone().to_val_string());
}

let separator = match params.get(0) {
let separator = match params.first() {
None => ",".to_string(),
Some(v) => v.to_string(),
};
Expand Down Expand Up @@ -336,7 +336,7 @@ static JOIN: NativeFunction = native_fn(|this, params| {
static LAST_INDEX_OF: NativeFunction = native_fn(|this, params| {
Ok(match this.get() {
Val::Array(array_data) => {
let search_param = params.get(0).unwrap_or(&Val::Undefined);
let search_param = params.first().unwrap_or(&Val::Undefined);

for i in (0..array_data.elements.len()).rev() {
let is_eq = op_triple_eq_impl(&array_data.elements[i], search_param)
Expand Down Expand Up @@ -440,7 +440,7 @@ static SLICE: NativeFunction = native_fn(|this, params| {
Val::Array(array_data) => {
let mut new_elems = Vec::<Val>::new();

let start = match params.get(0) {
let start = match params.first() {
None => 0,
Some(v) => to_wrapping_index_clamped(v, array_data.elements.len()),
};
Expand Down Expand Up @@ -468,7 +468,7 @@ static SPLICE: NativeFunction = native_fn(|mut this, params| {
let array_data_mut = Rc::make_mut(array_data);
let len = array_data_mut.elements.len();

let start = match params.get(0) {
let start = match params.first() {
None => 0,
Some(v) => to_wrapping_index_clamped(v, len),
} as usize;
Expand Down
2 changes: 1 addition & 1 deletion valuescript_vm/src/bigint_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub fn op_sub_bigint(_bigint: &BigInt, subscript: &Val) -> Val {

static TO_STRING: NativeFunction = native_fn(|this, params| {
Ok(match this.get() {
Val::BigInt(bigint) => match params.get(0) {
Val::BigInt(bigint) => match params.first() {
Some(_) => {
return Err("TODO: toString with radix".to_internal_error());
}
Expand Down
4 changes: 2 additions & 2 deletions valuescript_vm/src/builtins/array_builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl fmt::Display for ArrayBuiltin {
}

static IS_ARRAY: NativeFunction = native_fn(|_this, params| {
Ok(match params.get(0) {
Ok(match params.first() {
None => Val::Bool(false),
Some(p) => match p.as_array_data() {
None => Val::Bool(false),
Expand All @@ -55,7 +55,7 @@ static IS_ARRAY: NativeFunction = native_fn(|_this, params| {
});

static FROM: NativeFunction = native_fn(|_this, params| {
let mut first_param = match params.get(0) {
let mut first_param = match params.first() {
None => return Err("undefined is not iterable".to_type_error()),
Some(p) => p.clone(),
};
Expand Down
2 changes: 1 addition & 1 deletion valuescript_vm/src/builtins/bigint_builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl BuiltinObject for BigIntBuiltin {

fn bo_load_function() -> LoadFunctionResult {
LoadFunctionResult::NativeFunction(|_: ThisWrapper, params: Vec<Val>| -> Result<Val, Val> {
match params.get(0) {
match params.first() {
Some(Val::Number(value)) => {
if *value != f64::floor(*value) {
Err(
Expand Down
2 changes: 1 addition & 1 deletion valuescript_vm/src/builtins/boolean_builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl BuiltinObject for BooleanBuiltin {

fn bo_load_function() -> LoadFunctionResult {
LoadFunctionResult::NativeFunction(|_: ThisWrapper, params: Vec<Val>| -> Result<Val, Val> {
Ok(if let Some(value) = params.get(0) {
Ok(if let Some(value) = params.first() {
Val::Bool(value.is_truthy())
} else {
Val::Bool(false)
Expand Down
4 changes: 2 additions & 2 deletions valuescript_vm/src/builtins/error_builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl BuiltinObject for ErrorBuiltin {
fn bo_load_function() -> LoadFunctionResult {
LoadFunctionResult::NativeFunction(|_: ThisWrapper, params: Vec<Val>| -> Result<Val, Val> {
Ok(
match params.get(0) {
match params.first() {
Some(param) => param.clone().to_val_string(),
None => "".to_val(),
}
Expand Down Expand Up @@ -96,7 +96,7 @@ fn make_error_prototype() -> Val {
}

static SET_MESSAGE: NativeFunction = native_fn(|mut this, params| {
let message = match params.get(0) {
let message = match params.first() {
Some(param) => param.to_string(),
None => "".to_string(),
};
Expand Down
4 changes: 2 additions & 2 deletions valuescript_vm/src/builtins/internal_error_builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl BuiltinObject for InternalErrorBuiltin {
fn bo_load_function() -> LoadFunctionResult {
LoadFunctionResult::NativeFunction(|_: ThisWrapper, params: Vec<Val>| -> Result<Val, Val> {
Ok(
match params.get(0) {
match params.first() {
Some(param) => param.clone().to_val_string(),
None => "".to_val(),
}
Expand Down Expand Up @@ -68,7 +68,7 @@ fn make_internal_error_prototype() -> Val {
}

static SET_MESSAGE: NativeFunction = native_fn(|mut this, params| {
let message = match params.get(0) {
let message = match params.first() {
Some(param) => param.to_string(),
None => "".to_string(),
};
Expand Down
Loading

0 comments on commit 0bbf100

Please sign in to comment.