Skip to content

Commit eafee71

Browse files
committed
hopefully fix lints
1 parent ca6ef18 commit eafee71

5 files changed

Lines changed: 53 additions & 36 deletions

File tree

‎nova_vm/src/ecmascript/abstract_operations/testing_and_comparison.rs‎

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -365,23 +365,28 @@ pub(crate) fn is_less_than<'a, const LEFT_FIRST: bool>(
365365
let (px, py, gc) = match (Primitive::try_from(x.into()), Primitive::try_from(y.into())) {
366366
(Ok(px), Ok(py)) => {
367367
let gc = gc.into_nogc();
368-
(px.bind(gc), py.bind(gc), gc)
368+
let px = px.bind(gc);
369+
let py = py.bind(gc);
370+
(px, py, gc)
369371
}
370372
(Ok(px), Err(_)) => {
371373
let px = px.scope(agent, gc.nogc());
372374
let py = to_primitive(agent, y.into(), Some(PreferredType::Number), gc.reborrow())
373375
.unbind()?;
374376
let gc = gc.into_nogc();
375-
let px = px.get(agent);
376-
(px.bind(gc), py.bind(gc), gc)
377+
let px = px.get(agent).bind(gc);
378+
let py = py.bind(gc);
379+
(px, py, gc)
377380
}
378381
(Err(_), Ok(py)) => {
379382
let py = py.scope(agent, gc.nogc());
380383
let px = to_primitive(agent, x.into(), Some(PreferredType::Number), gc.reborrow())
381384
.unbind()?;
382385
let gc = gc.into_nogc();
383-
let py = py.get(agent);
384-
(px.bind(gc), py.bind(gc), gc)
386+
let px = px.bind(gc);
387+
// SAFETY: not shared.
388+
let py = unsafe { py.take(agent) }.bind(gc);
389+
(px, py, gc)
385390
}
386391
(Err(_), Err(_)) => {
387392
if LEFT_FIRST {
@@ -392,17 +397,22 @@ pub(crate) fn is_less_than<'a, const LEFT_FIRST: bool>(
392397
let y = y.scope(agent, gc.nogc());
393398
let px = to_primitive(agent, x.into(), Some(PreferredType::Number), gc.reborrow())
394399
.unbind()?
395-
.scope(agent, gc.nogc());
400+
.bind(gc.nogc());
401+
let py = y.get(agent).bind(gc.nogc());
402+
// SAFETY: not shared.
403+
let px = unsafe { y.replace_self(agent, px.unbind()) };
396404
let py = to_primitive(
397405
agent,
398-
y.get(agent),
406+
py.unbind(),
399407
Some(PreferredType::Number),
400408
gc.reborrow(),
401409
)
402410
.unbind()?;
403411
let gc = gc.into_nogc();
404-
let px = px.get(agent);
405-
(px.bind(gc), py.bind(gc), gc)
412+
// SAFETY: not shared.
413+
let px = unsafe { px.take(agent) }.bind(gc);
414+
let py = py.bind(gc);
415+
(px, py, gc)
406416
} else {
407417
// 2. Else,
408418
// a. NOTE: The order of evaluation needs to be reversed to preserve left to right evaluation.
@@ -412,17 +422,21 @@ pub(crate) fn is_less_than<'a, const LEFT_FIRST: bool>(
412422
let x = x.scope(agent, gc.nogc());
413423
let py = to_primitive(agent, y.into(), Some(PreferredType::Number), gc.reborrow())
414424
.unbind()?
415-
.scope(agent, gc.nogc());
425+
.bind(gc.nogc());
426+
let px = x.get(agent).bind(gc.nogc());
427+
// SAFETY: not shared.
428+
let py = unsafe { x.replace_self(agent, py.unbind()) };
416429
let px = to_primitive(
417430
agent,
418-
x.get(agent),
431+
px.unbind(),
419432
Some(PreferredType::Number),
420433
gc.reborrow(),
421434
)
422435
.unbind()?;
423436
let gc = gc.into_nogc();
424-
let py = py.get(agent);
425-
(px.bind(gc), py.bind(gc), gc)
437+
let px = px.bind(gc);
438+
let py = unsafe { py.take(agent) }.bind(gc);
439+
(px, py, gc)
426440
}
427441
}
428442
};

‎nova_vm/src/ecmascript/builtins/indexed_collections/array_objects/array_prototype.rs‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3793,16 +3793,18 @@ impl ArrayPrototype {
37933793
// d. Set i to i + 1.
37943794
i += 1;
37953795
}
3796+
let local_a = scoped_a.get(agent).bind(gc.nogc());
37963797
// 17. For each element E of items, do
37973798
for e in items {
37983799
// a. Let Pi be ! ToString(𝔽(i)).
37993800
let pi = i.try_into().unwrap();
38003801
// b. Perform ! CreateDataPropertyOrThrow(A, Pi, E).
38013802
unwrap_try(try_create_data_property_or_throw(
38023803
agent,
3803-
scoped_a.get(agent),
3804+
local_a,
38043805
pi,
3805-
e.get(agent).unbind(),
3806+
// SAFETY: not shared.
3807+
unsafe { e.take(agent) },
38063808
None,
38073809
gc.nogc(),
38083810
));
@@ -3833,9 +3835,9 @@ impl ArrayPrototype {
38333835
// f. Set r to r + 1.
38343836
r += 1;
38353837
}
3836-
let a = scoped_a.get(agent);
38373838
// 19. Return A.
3838-
Ok(a.into_value())
3839+
// SAFETY: not shared.
3840+
Ok(unsafe { scoped_a.take(agent) }.into_value())
38393841
}
38403842

38413843
/// ### [23.1.3.36 Array.prototype.toString ( )](https://tc39.es/ecma262/#sec-array.prototype.tostring)

‎nova_vm/src/ecmascript/builtins/indexed_collections/typed_array_objects/typed_array_intrinsic_object.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,8 @@ impl TypedArrayIntrinsicObject {
301301
// f. Set k to k + 1.
302302
k += 1;
303303
}
304-
let target_obj = scoped_target_obj.get(agent);
305-
Ok(target_obj.into_value())
304+
// SAFETY: not shared.
305+
Ok(unsafe { scoped_target_obj.take(agent) }.into_value())
306306
}
307307

308308
/// ### [23.2.2.2 %TypedArray%.of ( ...items )](https://tc39.es/ecma262/#sec-properties-of-the-%typedarray%-intrinsic-object)

‎nova_vm/src/ecmascript/builtins/ordinary.rs‎

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -917,8 +917,8 @@ pub(crate) fn ordinary_get<'gc>(
917917
let object = object.bind(gc.nogc());
918918
let property_key = property_key.bind(gc.nogc());
919919
// Note: We scope here because it's likely we've already tried.
920-
let scoped_object = object.scope(agent, gc.nogc());
921920
let scoped_property_key = property_key.scope(agent, gc.nogc());
921+
let scoped_object = object.scope(agent, gc.nogc());
922922
// 1. Let desc be ? O.[[GetOwnProperty]](P).
923923
let Some(descriptor) = object
924924
.unbind()
@@ -929,17 +929,16 @@ pub(crate) fn ordinary_get<'gc>(
929929
// 2. If desc is undefined, then
930930

931931
// a. Let parent be ? O.[[GetPrototypeOf]]().
932-
let object = scoped_object.get(agent).bind(gc.nogc());
932+
// SAFETY: not shared.
933+
let object = unsafe { scoped_object.take(agent) }.bind(gc.nogc());
933934
let (parent, property_key, receiver) =
934935
if let TryResult::Continue(parent) = object.try_get_prototype_of(agent, gc.nogc()) {
935936
let Some(parent) = parent else {
936937
return Ok(Value::Undefined);
937938
};
938-
(
939-
parent,
940-
scoped_property_key.get(agent).bind(gc.nogc()),
941-
receiver,
942-
)
939+
// SAFETY: not shared.
940+
let property_key = unsafe { scoped_property_key.take(agent) }.bind(gc.nogc());
941+
(parent, property_key, receiver)
943942
} else {
944943
// Note: We should root property_key and receiver here.
945944
let receiver = receiver.scope(agent, gc.nogc());
@@ -952,18 +951,17 @@ pub(crate) fn ordinary_get<'gc>(
952951
return Ok(Value::Undefined);
953952
};
954953
let parent = parent.unbind().bind(gc.nogc());
955-
let receiver = receiver.get(agent);
956-
(
957-
parent,
958-
scoped_property_key.get(agent).bind(gc.nogc()),
959-
receiver,
960-
)
954+
// SAFETY: not shared.
955+
let receiver = unsafe { receiver.take(agent) }.bind(gc.nogc());
956+
// SAFETY: not shared.
957+
let property_key = unsafe { scoped_property_key.take(agent) }.bind(gc.nogc());
958+
(parent, property_key, receiver)
961959
};
962960

963961
// c. Return ? parent.[[Get]](P, Receiver).
964962
return parent
965963
.unbind()
966-
.internal_get(agent, property_key.unbind(), receiver, gc);
964+
.internal_get(agent, property_key.unbind(), receiver.unbind(), gc);
967965
};
968966

969967
// 3. If IsDataDescriptor(desc) is true, return desc.[[Value]].

‎nova_vm/src/ecmascript/execution/environments/global_environment.rs‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -607,14 +607,17 @@ impl<'e> GlobalEnvironment<'e> {
607607
.unbind()
608608
.delete_binding(agent, scoped_name.get(agent), gc.reborrow())
609609
.unbind()?;
610-
let env = unsafe { env.take(agent) }.bind(gc.nogc());
610+
let gc = gc.into_nogc();
611+
// SAFETY: not shared.
612+
let env = unsafe { env.take(agent) }.bind(gc);
611613
// b. If status is true and envRec.[[VarNames]] contains N, then
612614
if status {
613-
let name = scoped_name.get(agent);
615+
// SAFETY: not shared.
616+
let name = unsafe { scoped_name.take(agent) }.bind(gc);
614617
let env_rec = &mut agent[env];
615618
if env_rec.var_names.contains(&name) {
616619
// i. Remove N from envRec.[[VarNames]].
617-
env_rec.var_names.remove(&name);
620+
env_rec.var_names.remove(&name.unbind());
618621
}
619622
}
620623
// c. Return status.

0 commit comments

Comments
 (0)