Skip to content

Commit

Permalink
chore: update to Rust 1.70.0 (denoland#1277)
Browse files Browse the repository at this point in the history
  • Loading branch information
bartlomieju committed Jul 11, 2023
1 parent 4110d1b commit 4dd8b60
Show file tree
Hide file tree
Showing 13 changed files with 46 additions and 50 deletions.
4 changes: 2 additions & 2 deletions examples/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,9 @@ where
}

/// Utility function that extracts the http request object from a wrapper object.
fn unwrap_request<'a>(
fn unwrap_request(
scope: &mut v8::HandleScope,
request: v8::Local<'a, v8::Object>,
request: v8::Local<v8::Object>,
) -> *mut Box<dyn HttpRequest> {
let external = request.get_internal_field(scope, 0).unwrap();
let external = unsafe { v8::Local::<v8::External>::cast(external) };
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "1.66.0"
channel = "1.70.0"
components = ["rustfmt", "clippy"]
34 changes: 15 additions & 19 deletions src/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,30 +567,26 @@ impl Object {
// Note: This function converts the key to a name, which possibly calls back
// into JavaScript.
#[inline(always)]
pub fn has<'s>(
pub fn has(
&self,
scope: &mut HandleScope<'s>,
scope: &mut HandleScope,
key: Local<Value>,
) -> Option<bool> {
unsafe { v8__Object__Has(self, &*scope.get_current_context(), &*key) }
.into()
}

#[inline(always)]
pub fn has_index<'s>(
&self,
scope: &mut HandleScope<'s>,
index: u32,
) -> Option<bool> {
pub fn has_index(&self, scope: &mut HandleScope, index: u32) -> Option<bool> {
unsafe { v8__Object__HasIndex(self, &*scope.get_current_context(), index) }
.into()
}

/// HasOwnProperty() is like JavaScript's Object.prototype.hasOwnProperty().
#[inline(always)]
pub fn has_own_property<'s>(
pub fn has_own_property(
&self,
scope: &mut HandleScope<'s>,
scope: &mut HandleScope,
key: Local<Name>,
) -> Option<bool> {
unsafe {
Expand All @@ -600,18 +596,18 @@ impl Object {
}

#[inline(always)]
pub fn delete<'s>(
pub fn delete(
&self,
scope: &mut HandleScope<'s>,
scope: &mut HandleScope,
key: Local<Value>,
) -> Option<bool> {
unsafe { v8__Object__Delete(self, &*scope.get_current_context(), &*key) }
.into()
}

pub fn delete_index<'s>(
pub fn delete_index(
&self,
scope: &mut HandleScope<'s>,
scope: &mut HandleScope,
index: u32,
) -> Option<bool> {
unsafe {
Expand Down Expand Up @@ -724,9 +720,9 @@ impl Object {
/// Note: Private properties are not inherited. Do not rely on this, since it
/// may change.
#[inline(always)]
pub fn set_private<'s>(
pub fn set_private(
&self,
scope: &mut HandleScope<'s>,
scope: &mut HandleScope,
key: Local<Private>,
value: Local<Value>,
) -> Option<bool> {
Expand All @@ -746,9 +742,9 @@ impl Object {
/// Note: Private properties are not inherited. Do not rely on this, since it
/// may change.
#[inline(always)]
pub fn delete_private<'s>(
pub fn delete_private(
&self,
scope: &mut HandleScope<'s>,
scope: &mut HandleScope,
key: Local<Private>,
) -> Option<bool> {
unsafe {
Expand All @@ -762,9 +758,9 @@ impl Object {
/// Note: Private properties are not inherited. Do not rely on this, since it
/// may change.
#[inline(always)]
pub fn has_private<'s>(
pub fn has_private(
&self,
scope: &mut HandleScope<'s>,
scope: &mut HandleScope,
key: Local<Private>,
) -> Option<bool> {
unsafe {
Expand Down
4 changes: 2 additions & 2 deletions src/primitive_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ impl PrimitiveArray {
}

#[inline(always)]
pub fn set<'s>(
pub fn set(
&self,
scope: &mut HandleScope<'s>,
scope: &mut HandleScope,
index: usize,
item: Local<'_, Primitive>,
) {
Expand Down
9 changes: 2 additions & 7 deletions src/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,13 @@ extern "C" {
}

#[repr(C)]
#[derive(Debug)]
#[derive(Debug, Default)]
pub enum NewStringType {
#[default]
Normal,
Internalized,
}

impl Default for NewStringType {
fn default() -> Self {
NewStringType::Normal
}
}

bitflags! {
#[derive(Default)]
#[repr(transparent)]
Expand Down
18 changes: 9 additions & 9 deletions src/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -568,9 +568,9 @@ impl Value {

/// Convenience function not present in the original V8 API.
#[inline(always)]
pub fn to_rust_string_lossy<'s>(
pub fn to_rust_string_lossy(
&self,
scope: &mut HandleScope<'s>,
scope: &mut HandleScope,
) -> std::string::String {
self
.to_string(scope)
Expand Down Expand Up @@ -646,9 +646,9 @@ impl Value {
}

#[inline(always)]
pub fn instance_of<'s>(
pub fn instance_of(
&self,
scope: &mut HandleScope<'s>,
scope: &mut HandleScope,
object: Local<Object>,
) -> Option<bool> {
let mut out = Maybe::<bool>::default();
Expand All @@ -664,7 +664,7 @@ impl Value {
}

#[inline(always)]
pub fn number_value<'s>(&self, scope: &mut HandleScope<'s>) -> Option<f64> {
pub fn number_value(&self, scope: &mut HandleScope) -> Option<f64> {
let mut out = Maybe::<f64>::default();
unsafe {
v8__Value__NumberValue(self, &*scope.get_current_context(), &mut out)
Expand All @@ -673,7 +673,7 @@ impl Value {
}

#[inline(always)]
pub fn integer_value<'s>(&self, scope: &mut HandleScope<'s>) -> Option<i64> {
pub fn integer_value(&self, scope: &mut HandleScope) -> Option<i64> {
let mut out = Maybe::<i64>::default();
unsafe {
v8__Value__IntegerValue(self, &*scope.get_current_context(), &mut out)
Expand All @@ -682,7 +682,7 @@ impl Value {
}

#[inline(always)]
pub fn uint32_value<'s>(&self, scope: &mut HandleScope<'s>) -> Option<u32> {
pub fn uint32_value(&self, scope: &mut HandleScope) -> Option<u32> {
let mut out = Maybe::<u32>::default();
unsafe {
v8__Value__Uint32Value(self, &*scope.get_current_context(), &mut out)
Expand All @@ -691,7 +691,7 @@ impl Value {
}

#[inline(always)]
pub fn int32_value<'s>(&self, scope: &mut HandleScope<'s>) -> Option<i32> {
pub fn int32_value(&self, scope: &mut HandleScope) -> Option<i32> {
let mut out = Maybe::<i32>::default();
unsafe {
v8__Value__Int32Value(self, &*scope.get_current_context(), &mut out)
Expand All @@ -700,7 +700,7 @@ impl Value {
}

#[inline(always)]
pub fn boolean_value<'s>(&self, scope: &mut HandleScope<'s, ()>) -> bool {
pub fn boolean_value(&self, scope: &mut HandleScope<'_, ()>) -> bool {
unsafe { v8__Value__BooleanValue(self, scope.get_isolate_ptr()) }
}

Expand Down
3 changes: 2 additions & 1 deletion tests/compile_fail/boxed_local.stderr
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
error[E0597]: `scope2` does not live long enough
--> $DIR/boxed_local.rs:9:43
--> tests/compile_fail/boxed_local.rs:9:43
|
7 | let _boxed_local = {
| ------------ borrow later stored here
8 | let mut scope2 = v8::HandleScope::new(&mut scope1);
| ---------- binding `scope2` declared here
9 | let mut scope3 = v8::HandleScope::new(&mut scope2);
| ^^^^^^^^^^^ borrowed value does not live long enough
10 | Box::new(v8::Integer::new(&mut scope3, 123))
Expand Down
3 changes: 2 additions & 1 deletion tests/compile_fail/handle_scope_escape_lifetime.stderr
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
error[E0597]: `scope2` does not live long enough
--> $DIR/handle_scope_escape_lifetime.rs:9:43
--> tests/compile_fail/handle_scope_escape_lifetime.rs:9:43
|
7 | let _local = {
| ------ borrow later stored here
8 | let mut scope2 = v8::HandleScope::new(&mut scope1);
| ---------- binding `scope2` declared here
9 | let mut scope3 = v8::HandleScope::new(&mut scope2);
| ^^^^^^^^^^^ borrowed value does not live long enough
...
Expand Down
3 changes: 2 additions & 1 deletion tests/compile_fail/handle_scope_lifetime_4.stderr
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
error[E0597]: `scope2` does not live long enough
--> $DIR/handle_scope_lifetime_4.rs:9:35
--> tests/compile_fail/handle_scope_lifetime_4.rs:9:35
|
7 | let mut _scope3 = {
| ----------- borrow later stored here
8 | let mut scope2 = v8::HandleScope::new(&mut scope1);
| ---------- binding `scope2` declared here
9 | v8::EscapableHandleScope::new(&mut scope2)
| ^^^^^^^^^^^ borrowed value does not live long enough
10 | };
Expand Down
2 changes: 1 addition & 1 deletion tests/compile_fail/object_without_context_scope.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> tests/compile_fail/object_without_context_scope.rs:6:33
|
6 | let _object = v8::Object::new(&mut scope);
| --------------- ^^^^^^^^^^ expected struct `v8::Context`, found `()`
| --------------- ^^^^^^^^^^ expected `&mut HandleScope<'_>`, found `&mut HandleScope<'_, ()>`
| |
| arguments to this function are incorrect
|
Expand Down
3 changes: 2 additions & 1 deletion tests/compile_fail/try_catch_exception_lifetime.stderr
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
error[E0597]: `scope3` does not live long enough
--> $DIR/try_catch_exception_lifetime.rs:11:43
--> tests/compile_fail/try_catch_exception_lifetime.rs:11:43
|
9 | let _exception = {
| ---------- borrow later stored here
10 | let mut scope3 = v8::HandleScope::new(&mut scope2);
| ---------- binding `scope3` declared here
11 | let mut scope4 = v8::HandleScope::new(&mut scope3);
| ^^^^^^^^^^^ borrowed value does not live long enough
...
Expand Down
3 changes: 2 additions & 1 deletion tests/compile_fail/try_catch_message_lifetime.stderr
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
error[E0597]: `scope3` does not live long enough
--> $DIR/try_catch_message_lifetime.rs:11:43
--> tests/compile_fail/try_catch_message_lifetime.rs:11:43
|
9 | let _message = {
| -------- borrow later stored here
10 | let mut scope3 = v8::HandleScope::new(&mut scope2);
| ---------- binding `scope3` declared here
11 | let mut scope4 = v8::HandleScope::new(&mut scope3);
| ^^^^^^^^^^^ borrowed value does not live long enough
...
Expand Down
8 changes: 4 additions & 4 deletions tests/test_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -679,8 +679,8 @@ fn get_isolate_from_handle() {
check_handle_helper(scope, expect_some, local2);
}

fn check_eval<'s>(
scope: &mut v8::HandleScope<'s>,
fn check_eval(
scope: &mut v8::HandleScope,
expect_some: Option<bool>,
code: &str,
) {
Expand Down Expand Up @@ -4482,8 +4482,8 @@ fn mock_script_origin<'s>(
)
}

fn mock_source<'s>(
scope: &mut v8::HandleScope<'s>,
fn mock_source(
scope: &mut v8::HandleScope,
resource_name: &str,
source: &str,
) -> v8::script_compiler::Source {
Expand Down

0 comments on commit 4dd8b60

Please sign in to comment.