Skip to content

Commit

Permalink
chore: update Rust to 1.65.0 (denoland#1116)
Browse files Browse the repository at this point in the history
  • Loading branch information
bartlomieju committed Nov 25, 2022
1 parent f827193 commit 65ff64e
Show file tree
Hide file tree
Showing 23 changed files with 140 additions and 100 deletions.
4 changes: 2 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ fn build_v8() {
fn print_gn_args(gn_out_dir: &Path) {
assert!(Command::new(gn())
.arg("args")
.arg(&gn_out_dir)
.arg(gn_out_dir)
.arg("--list")
.status()
.unwrap()
Expand Down Expand Up @@ -643,7 +643,7 @@ fn ninja(gn_out_dir: &Path, maybe_env: Option<NinjaEnv>) -> Command {
let cmd_string = env::var("NINJA").unwrap_or_else(|_| "ninja".to_owned());
let mut cmd = Command::new(cmd_string);
cmd.arg("-C");
cmd.arg(&gn_out_dir);
cmd.arg(gn_out_dir);
if let Some(env) = maybe_env {
for item in env {
cmd.env(item.0, item.1);
Expand Down
2 changes: 1 addition & 1 deletion examples/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ fn main() {
let context_scope = &mut v8::ContextScope::new(handle_scope, context);
let scope = &mut v8::HandleScope::new(context_scope);

run_main(scope, &*args, &mut run_shell_flag);
run_main(scope, &args, &mut run_shell_flag);

if run_shell_flag {
run_shell(scope);
Expand Down
1 change: 0 additions & 1 deletion rust-toolchain

This file was deleted.

3 changes: 3 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[toolchain]
channel = "1.65.0"
components = ["rustfmt", "clippy"]
8 changes: 4 additions & 4 deletions src/bigint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl BigInt {
#[inline(always)]
pub fn u64_value(&self) -> (u64, bool) {
let mut lossless = MaybeUninit::uninit();
let v = unsafe { v8__BigInt__Uint64Value(&*self, lossless.as_mut_ptr()) };
let v = unsafe { v8__BigInt__Uint64Value(self, lossless.as_mut_ptr()) };
let lossless = unsafe { lossless.assume_init() };
(v, lossless)
}
Expand All @@ -95,7 +95,7 @@ impl BigInt {
#[inline(always)]
pub fn i64_value(&self) -> (i64, bool) {
let mut lossless = MaybeUninit::uninit();
let v = unsafe { v8__BigInt__Int64Value(&*self, lossless.as_mut_ptr()) };
let v = unsafe { v8__BigInt__Int64Value(self, lossless.as_mut_ptr()) };
let lossless = unsafe { lossless.assume_init() };
(v, lossless)
}
Expand All @@ -104,7 +104,7 @@ impl BigInt {
/// `to_words_array`.
#[inline(always)]
pub fn word_count(&self) -> usize {
unsafe { v8__BigInt__WordCount(&*self) as usize }
unsafe { v8__BigInt__WordCount(self) as usize }
}

/// Converts this BigInt to a (sign_bit, words) pair. `sign_bit` will be true
Expand All @@ -119,7 +119,7 @@ impl BigInt {
let mut word_count = words.len() as int;
unsafe {
v8__BigInt__ToWordsArray(
&*self,
self,
sign_bit.as_mut_ptr(),
&mut word_count,
words.as_mut_ptr(),
Expand Down
4 changes: 2 additions & 2 deletions src/external_references.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ impl ExternalReferences {
impl std::ops::Deref for ExternalReferences {
type Target = [intptr_t];
fn deref(&self) -> &Self::Target {
&*self.null_terminated
&self.null_terminated
}
}

impl std::borrow::Borrow<[intptr_t]> for ExternalReferences {
fn borrow(&self) -> &[intptr_t] {
&**self
self
}
}
2 changes: 1 addition & 1 deletion src/fast_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl CTypeInfo {
}
}

#[derive(Clone, Copy, PartialEq, Debug)]
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
#[repr(u8)]
pub enum SequenceType {
Scalar,
Expand Down
4 changes: 2 additions & 2 deletions src/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -810,14 +810,14 @@ impl Function {
#[inline(always)]
pub fn get_script_column_number(&self) -> Option<u32> {
let ret = unsafe { v8__Function__GetScriptColumnNumber(self) };
(ret >= 0).then(|| ret as u32)
(ret >= 0).then_some(ret as u32)
}

/// Get the (zero-indexed) line number of the function's definition, if available.
#[inline(always)]
pub fn get_script_line_number(&self) -> Option<u32> {
let ret = unsafe { v8__Function__GetScriptLineNumber(self) };
(ret >= 0).then(|| ret as u32)
(ret >= 0).then_some(ret as u32)
}

/// Creates and returns code cache for the specified unbound_script.
Expand Down
6 changes: 3 additions & 3 deletions src/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ impl<'a, T> Handle for &'a UnsafeRefHandle<'_, T> {

impl<'s, T> Borrow<T> for Local<'s, T> {
fn borrow(&self) -> &T {
&**self
self
}
}

Expand All @@ -369,7 +369,7 @@ impl<T> Eq for Global<T> where T: Eq {}

impl<'s, T: Hash> Hash for Local<'s, T> {
fn hash<H: Hasher>(&self, state: &mut H) {
(&**self).hash(state)
(**self).hash(state)
}
}

Expand All @@ -396,7 +396,7 @@ where
}
}

impl<'s, T, Rhs: Handle> PartialEq<Rhs> for Global<T>
impl<T, Rhs: Handle> PartialEq<Rhs> for Global<T>
where
T: PartialEq<Rhs::Data>,
{
Expand Down
2 changes: 1 addition & 1 deletion src/inspector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ impl fmt::Display for CharacterArray<'_, u8> {

impl fmt::Display for CharacterArray<'_, u16> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str(&string::String::from_utf16_lossy(&*self))
f.write_str(&string::String::from_utf16_lossy(self))
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/isolate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ use std::sync::Mutex;
/// Isolate::PerformMicrotaskCheckpoint() method;
/// - auto: microtasks are invoked when the script call depth decrements
/// to zero.
#[derive(Debug, Clone, Copy, PartialEq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(C)]
pub enum MicrotasksPolicy {
Explicit = 0,
Expand All @@ -84,7 +84,7 @@ pub enum MicrotasksPolicy {
///
/// PromiseHook with type After is called right at the end of the
/// PromiseReactionJob.
#[derive(Debug, Clone, Copy, PartialEq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(C)]
pub enum PromiseHookType {
Init,
Expand All @@ -100,7 +100,7 @@ pub type PromiseHook =

pub type PromiseRejectCallback = extern "C" fn(PromiseRejectMessage);

#[derive(Debug, Clone, Copy, PartialEq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(C)]
pub enum WasmAsyncSuccess {
Success,
Expand Down
12 changes: 6 additions & 6 deletions src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ impl Location {
/// This corresponds to the states used in ECMAScript except that "evaluated"
/// is split into kEvaluated and kErrored, indicating success and failure,
/// respectively.
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
#[repr(C)]
pub enum ModuleStatus {
Uninstantiated,
Expand Down Expand Up @@ -345,20 +345,20 @@ impl Module {
) -> Option<Local<'s, Value>> {
unsafe {
scope
.cast_local(|sd| v8__Module__Evaluate(&*self, sd.get_current_context()))
.cast_local(|sd| v8__Module__Evaluate(self, sd.get_current_context()))
}
}

/// Returns whether the module is a SourceTextModule.
#[inline(always)]
pub fn is_source_text_module(&self) -> bool {
unsafe { v8__Module__IsSourceTextModule(&*self) }
unsafe { v8__Module__IsSourceTextModule(self) }
}

/// Returns whether the module is a SyntheticModule.
#[inline(always)]
pub fn is_synthetic_module(&self) -> bool {
unsafe { v8__Module__IsSyntheticModule(&*self) }
unsafe { v8__Module__IsSyntheticModule(self) }
}

/// Creates a new SyntheticModule with the specified export names, where
Expand Down Expand Up @@ -406,7 +406,7 @@ impl Module {
) -> Option<bool> {
unsafe {
v8__Module__SetSyntheticModuleExport(
&*self,
self,
scope.get_isolate_ptr(),
&*export_name,
&*export_value,
Expand Down Expand Up @@ -446,7 +446,7 @@ impl Module {

let returned_len = unsafe {
v8__Module__GetStalledTopLevelAwaitMessage(
&*self,
self,
scope.get_isolate_ptr(),
out_vec.as_mut_ptr(),
out_vec.len(),
Expand Down
2 changes: 1 addition & 1 deletion src/private.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ impl Private {
/// Returns the print name string of the private symbol, or undefined if none.
#[inline(always)]
pub fn name<'s>(&self, scope: &mut HandleScope<'s, ()>) -> Local<'s, Value> {
unsafe { scope.cast_local(|_| v8__Private__Name(&*self)) }.unwrap()
unsafe { scope.cast_local(|_| v8__Private__Name(self)) }.unwrap()
}
}
22 changes: 11 additions & 11 deletions src/promise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ extern "C" {
) -> PromiseRejectEvent;
}

#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
#[repr(C)]
pub enum PromiseState {
Pending,
Expand All @@ -69,21 +69,21 @@ impl Promise {
/// Returns the value of the [[PromiseState]] field.
#[inline(always)]
pub fn state(&self) -> PromiseState {
unsafe { v8__Promise__State(&*self) }
unsafe { v8__Promise__State(self) }
}

/// Returns true if the promise has at least one derived promise, and
/// therefore resolve/reject handlers (including default handler).
#[inline(always)]
pub fn has_handler(&self) -> bool {
unsafe { v8__Promise__HasHandler(&*self) }
unsafe { v8__Promise__HasHandler(self) }
}

/// Returns the content of the [[PromiseResult]] field. The Promise must not
/// be pending.
#[inline(always)]
pub fn result<'s>(&self, scope: &mut HandleScope<'s>) -> Local<'s, Value> {
unsafe { scope.cast_local(|_| v8__Promise__Result(&*self)) }.unwrap()
unsafe { scope.cast_local(|_| v8__Promise__Result(self)) }.unwrap()
}

/// Register a rejection handler with a promise.
Expand All @@ -97,7 +97,7 @@ impl Promise {
) -> Option<Local<'s, Promise>> {
unsafe {
scope.cast_local(|sd| {
v8__Promise__Catch(&*self, sd.get_current_context(), &*handler)
v8__Promise__Catch(self, sd.get_current_context(), &*handler)
})
}
}
Expand All @@ -113,7 +113,7 @@ impl Promise {
) -> Option<Local<'s, Promise>> {
unsafe {
scope.cast_local(|sd| {
v8__Promise__Then(&*self, sd.get_current_context(), &*handler)
v8__Promise__Then(self, sd.get_current_context(), &*handler)
})
}
}
Expand All @@ -132,7 +132,7 @@ impl Promise {
unsafe {
scope.cast_local(|sd| {
v8__Promise__Then2(
&*self,
self,
sd.get_current_context(),
&*on_fulfilled,
&*on_rejected,
Expand Down Expand Up @@ -160,7 +160,7 @@ impl PromiseResolver {
&self,
scope: &mut HandleScope<'s>,
) -> Local<'s, Promise> {
unsafe { scope.cast_local(|_| v8__Promise__Resolver__GetPromise(&*self)) }
unsafe { scope.cast_local(|_| v8__Promise__Resolver__GetPromise(self)) }
.unwrap()
}

Expand All @@ -174,7 +174,7 @@ impl PromiseResolver {
) -> Option<bool> {
unsafe {
v8__Promise__Resolver__Resolve(
&*self,
self,
&*scope.get_current_context(),
&*value,
)
Expand All @@ -192,7 +192,7 @@ impl PromiseResolver {
) -> Option<bool> {
unsafe {
v8__Promise__Resolver__Reject(
&*self,
self,
&*scope.get_current_context(),
&*value,
)
Expand All @@ -201,7 +201,7 @@ impl PromiseResolver {
}
}

#[derive(Debug, Clone, Copy, PartialEq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(C)]
pub enum PromiseRejectEvent {
PromiseRejectWithNoHandler,
Expand Down
4 changes: 2 additions & 2 deletions src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ impl Proxy {
&self,
scope: &mut HandleScope<'s>,
) -> Local<'s, Value> {
unsafe { scope.cast_local(|_| v8__Proxy__GetHandler(&*self)) }.unwrap()
unsafe { scope.cast_local(|_| v8__Proxy__GetHandler(self)) }.unwrap()
}

#[inline(always)]
pub fn get_target<'s>(
&self,
scope: &mut HandleScope<'s>,
) -> Local<'s, Value> {
unsafe { scope.cast_local(|_| v8__Proxy__GetTarget(&*self)) }.unwrap()
unsafe { scope.cast_local(|_| v8__Proxy__GetTarget(self)) }.unwrap()
}

#[inline(always)]
Expand Down
4 changes: 2 additions & 2 deletions src/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ impl Deref for StartupData {

impl AsRef<[u8]> for StartupData {
fn as_ref(&self) -> &[u8] {
&**self
self
}
}

impl Borrow<[u8]> for StartupData {
fn borrow(&self) -> &[u8] {
&**self
self
}
}

Expand Down

0 comments on commit 65ff64e

Please sign in to comment.