summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/async_cell.rs4
-rw-r--r--core/bindings.rs3
-rw-r--r--core/error.rs24
-rw-r--r--core/examples/eval_js_value.rs6
-rw-r--r--core/examples/fs_module_loader.rs2
-rw-r--r--core/examples/schedule_task.rs2
-rw-r--r--core/examples/ts_module_loader.rs2
-rw-r--r--core/module_specifier.rs10
-rw-r--r--core/modules.rs14
-rw-r--r--core/ops.rs2
-rw-r--r--core/ops_builtin_v8.rs6
-rw-r--r--core/runtime.rs20
12 files changed, 51 insertions, 44 deletions
diff --git a/core/async_cell.rs b/core/async_cell.rs
index f95dc3a84..a5b8d5467 100644
--- a/core/async_cell.rs
+++ b/core/async_cell.rs
@@ -577,7 +577,7 @@ mod internal {
pub fn add(self, mode: BorrowMode) -> BorrowCount {
match self.try_add(mode) {
Some(value) => value,
- None => panic!("Can't add {:?} to {:?}", mode, self),
+ None => panic!("Can't add {mode:?} to {self:?}"),
}
}
@@ -596,7 +596,7 @@ mod internal {
pub fn remove(self, mode: BorrowMode) -> BorrowCount {
match self.try_remove(mode) {
Some(value) => value,
- None => panic!("Can't remove {:?} from {:?}", mode, self),
+ None => panic!("Can't remove {mode:?} from {self:?}"),
}
}
}
diff --git a/core/bindings.rs b/core/bindings.rs
index bf0da18e4..d5f38d3c2 100644
--- a/core/bindings.rs
+++ b/core/bindings.rs
@@ -613,8 +613,7 @@ pub fn module_resolve_callback<'s>(
}
let msg = format!(
- r#"Cannot resolve module "{}" from "{}""#,
- specifier_str, referrer_name
+ r#"Cannot resolve module "{specifier_str}" from "{referrer_name}""#
);
throw_type_error(scope, msg);
None
diff --git a/core/error.rs b/core/error.rs
index a682c69aa..79b37d529 100644
--- a/core/error.rs
+++ b/core/error.rs
@@ -45,7 +45,7 @@ pub fn range_error(message: impl Into<Cow<'static, str>>) -> Error {
}
pub fn invalid_hostname(hostname: &str) -> Error {
- type_error(format!("Invalid hostname: '{}'", hostname))
+ type_error(format!("Invalid hostname: '{hostname}'"))
}
pub fn uri_error(message: impl Into<Cow<'static, str>>) -> Error {
@@ -109,7 +109,7 @@ pub fn to_v8_error<'a>(
let cb = cb.open(tc_scope);
let this = v8::undefined(tc_scope).into();
let class = v8::String::new(tc_scope, get_class(error)).unwrap();
- let message = v8::String::new(tc_scope, &format!("{:#}", error)).unwrap();
+ let message = v8::String::new(tc_scope, &format!("{error:#}")).unwrap();
let mut args = vec![class.into(), message.into()];
if let Some(code) = crate::error_codes::get_error_code(error) {
args.push(v8::String::new(tc_scope, code).unwrap().into());
@@ -339,11 +339,11 @@ impl JsError {
let message_prop = e.message.clone().unwrap_or_default();
let exception_message = exception_message.unwrap_or_else(|| {
if !name.is_empty() && !message_prop.is_empty() {
- format!("Uncaught {}: {}", name, message_prop)
+ format!("Uncaught {name}: {message_prop}")
} else if !name.is_empty() {
- format!("Uncaught {}", name)
+ format!("Uncaught {name}")
} else if !message_prop.is_empty() {
- format!("Uncaught {}", message_prop)
+ format!("Uncaught {message_prop}")
} else {
"Uncaught".to_string()
}
@@ -509,7 +509,7 @@ fn format_source_loc(
) -> String {
let line_number = line_number;
let column_number = column_number;
- format!("{}:{}:{}", file_name, line_number, column_number)
+ format!("{file_name}:{line_number}:{column_number}")
}
impl Display for JsError {
@@ -517,7 +517,7 @@ impl Display for JsError {
if let Some(stack) = &self.stack {
let stack_lines = stack.lines();
if stack_lines.count() > 1 {
- return write!(f, "{}", stack);
+ return write!(f, "{stack}");
}
}
write!(f, "{}", self.exception_message)?;
@@ -527,7 +527,7 @@ impl Display for JsError {
(&frame.file_name, frame.line_number, frame.column_number)
{
let source_loc = format_source_loc(f_, l, c);
- write!(f, "\n at {}", source_loc)?;
+ write!(f, "\n at {source_loc}")?;
}
}
Ok(())
@@ -568,8 +568,8 @@ pub(crate) fn to_v8_type_error(
/// of `instanceof`. `Value::is_native_error()` also checks for static class
/// inheritance rather than just scanning the prototype chain, which doesn't
/// work with our WebIDL implementation of `DOMException`.
-pub(crate) fn is_instance_of_error<'s>(
- scope: &mut v8::HandleScope<'s>,
+pub(crate) fn is_instance_of_error(
+ scope: &mut v8::HandleScope,
value: v8::Local<v8::Value>,
) -> bool {
if !value.is_object() {
@@ -603,8 +603,8 @@ pub(crate) fn is_instance_of_error<'s>(
/// NOTE: There is currently no way to detect `AggregateError` via `rusty_v8`,
/// as v8 itself doesn't expose `v8__Exception__AggregateError`,
/// and we cannot create bindings for it. This forces us to rely on `name` inference.
-pub(crate) fn is_aggregate_error<'s>(
- scope: &mut v8::HandleScope<'s>,
+pub(crate) fn is_aggregate_error(
+ scope: &mut v8::HandleScope,
value: v8::Local<v8::Value>,
) -> bool {
let mut maybe_prototype = Some(value);
diff --git a/core/examples/eval_js_value.rs b/core/examples/eval_js_value.rs
index 7bb954371..6990abb85 100644
--- a/core/examples/eval_js_value.rs
+++ b/core/examples/eval_js_value.rs
@@ -18,7 +18,7 @@ fn main() {
let output: serde_json::Value =
eval(&mut runtime, code).expect("Eval failed");
- println!("Output: {:?}", output);
+ println!("Output: {output:?}");
let expected_output = serde_json::json!(10);
assert_eq!(expected_output, output);
@@ -40,9 +40,9 @@ fn eval(
match deserialized_value {
Ok(value) => Ok(value),
- Err(err) => Err(format!("Cannot deserialize value: {:?}", err)),
+ Err(err) => Err(format!("Cannot deserialize value: {err:?}")),
}
}
- Err(err) => Err(format!("Evaling error: {:?}", err)),
+ Err(err) => Err(format!("Evaling error: {err:?}")),
}
}
diff --git a/core/examples/fs_module_loader.rs b/core/examples/fs_module_loader.rs
index 620204c60..a8d33e104 100644
--- a/core/examples/fs_module_loader.rs
+++ b/core/examples/fs_module_loader.rs
@@ -13,7 +13,7 @@ fn main() -> Result<(), Error> {
std::process::exit(1);
}
let main_url = &args[1];
- println!("Run {}", main_url);
+ println!("Run {main_url}");
let mut js_runtime = JsRuntime::new(RuntimeOptions {
module_loader: Some(Rc::new(FsModuleLoader)),
diff --git a/core/examples/schedule_task.rs b/core/examples/schedule_task.rs
index 6a61619d8..56c8f6dd6 100644
--- a/core/examples/schedule_task.rs
+++ b/core/examples/schedule_task.rs
@@ -65,7 +65,7 @@ fn main() {
#[op]
fn op_schedule_task(state: &mut OpState, i: u8) -> Result<(), Error> {
let tx = state.borrow_mut::<mpsc::UnboundedSender<Task>>();
- tx.unbounded_send(Box::new(move || println!("Hello, world! x{}", i)))
+ tx.unbounded_send(Box::new(move || println!("Hello, world! x{i}")))
.expect("unbounded_send failed");
Ok(())
}
diff --git a/core/examples/ts_module_loader.rs b/core/examples/ts_module_loader.rs
index c78c1f868..82a3c1079 100644
--- a/core/examples/ts_module_loader.rs
+++ b/core/examples/ts_module_loader.rs
@@ -99,7 +99,7 @@ fn main() -> Result<(), Error> {
std::process::exit(1);
}
let main_url = &args[1];
- println!("Run {}", main_url);
+ println!("Run {main_url}");
let mut js_runtime = JsRuntime::new(RuntimeOptions {
module_loader: Some(Rc::new(TypescriptModuleLoader)),
diff --git a/core/module_specifier.rs b/core/module_specifier.rs
index 832208758..c65f34110 100644
--- a/core/module_specifier.rs
+++ b/core/module_specifier.rs
@@ -32,17 +32,17 @@ impl Error for ModuleResolutionError {
impl fmt::Display for ModuleResolutionError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
- InvalidUrl(ref err) => write!(f, "invalid URL: {}", err),
+ InvalidUrl(ref err) => write!(f, "invalid URL: {err}"),
InvalidBaseUrl(ref err) => {
- write!(f, "invalid base URL for relative import: {}", err)
+ write!(f, "invalid base URL for relative import: {err}")
}
- InvalidPath(ref path) => write!(f, "invalid module path: {:?}", path),
+ InvalidPath(ref path) => write!(f, "invalid module path: {path:?}"),
ImportPrefixMissing(ref specifier, ref maybe_referrer) => write!(
f,
"Relative import path \"{}\" not prefixed with / or ./ or ../{}",
specifier,
match maybe_referrer {
- Some(referrer) => format!(" from \"{}\"", referrer),
+ Some(referrer) => format!(" from \"{referrer}\""),
None => String::new(),
}
),
@@ -425,7 +425,7 @@ mod tests {
]);
// Relative local path.
- let expected_url = format!("file://{}/tests/006_url_imports.ts", cwd_str);
+ let expected_url = format!("file://{cwd_str}/tests/006_url_imports.ts");
tests.extend(vec![
("tests/006_url_imports.ts", expected_url.to_string()),
("./tests/006_url_imports.ts", expected_url.to_string()),
diff --git a/core/modules.rs b/core/modules.rs
index 6ce9f4614..9a7445959 100644
--- a/core/modules.rs
+++ b/core/modules.rs
@@ -51,7 +51,7 @@ pub(crate) fn validate_import_assertions(
if key == "type" && !SUPPORTED_TYPE_ASSERTIONS.contains(&value.as_str()) {
let message = v8::String::new(
scope,
- &format!("\"{}\" is not a valid module type.", value),
+ &format!("\"{value}\" is not a valid module type."),
)
.unwrap();
let exception = v8::Exception::type_error(scope, message);
@@ -318,8 +318,7 @@ impl ModuleLoader for FsModuleLoader {
async move {
let path = module_specifier.to_file_path().map_err(|_| {
generic_error(format!(
- "Provided module specifier \"{}\" is not a file URL.",
- module_specifier
+ "Provided module specifier \"{module_specifier}\" is not a file URL."
))
})?;
let module_type = if let Some(extension) = path.extension() {
@@ -1483,6 +1482,7 @@ import "/a.js";
let a_id_fut = runtime.load_main_module(&spec, None);
let a_id = futures::executor::block_on(a_id_fut).unwrap();
+ #[allow(clippy::let_underscore_future)]
let _ = runtime.mod_evaluate(a_id);
futures::executor::block_on(runtime.run_event_loop(false)).unwrap();
let l = loads.lock();
@@ -1662,6 +1662,7 @@ import "/a.js";
runtime.instantiate_module(mod_a).unwrap();
assert_eq!(DISPATCH_COUNT.load(Ordering::Relaxed), 0);
+ #[allow(clippy::let_underscore_future)]
let _ = runtime.mod_evaluate(mod_a);
assert_eq!(DISPATCH_COUNT.load(Ordering::Relaxed), 1);
}
@@ -2042,6 +2043,7 @@ import "/a.js";
let result = runtime.load_main_module(&spec, None).await;
assert!(result.is_ok());
let circular1_id = result.unwrap();
+ #[allow(clippy::let_underscore_future)]
let _ = runtime.mod_evaluate(circular1_id);
runtime.run_event_loop(false).await.unwrap();
@@ -2122,6 +2124,7 @@ import "/a.js";
let result = runtime.load_main_module(&spec, None).await;
assert!(result.is_ok());
let redirect1_id = result.unwrap();
+ #[allow(clippy::let_underscore_future)]
let _ = runtime.mod_evaluate(redirect1_id);
runtime.run_event_loop(false).await.unwrap();
let l = loads.lock();
@@ -2280,6 +2283,7 @@ if (import.meta.url != 'file:///main_with_code.js') throw Error();
.boxed_local();
let main_id = futures::executor::block_on(main_id_fut).unwrap();
+ #[allow(clippy::let_underscore_future)]
let _ = runtime.mod_evaluate(main_id);
futures::executor::block_on(runtime.run_event_loop(false)).unwrap();
@@ -2397,6 +2401,7 @@ if (import.meta.url != 'file:///main_with_code.js') throw Error();
.boxed_local();
let main_id = futures::executor::block_on(main_id_fut).unwrap();
+ #[allow(clippy::let_underscore_future)]
let _ = runtime.mod_evaluate(main_id);
futures::executor::block_on(runtime.run_event_loop(false)).unwrap();
@@ -2412,6 +2417,7 @@ if (import.meta.url != 'file:///main_with_code.js') throw Error();
.boxed_local();
let side_id = futures::executor::block_on(side_id_fut).unwrap();
+ #[allow(clippy::let_underscore_future)]
let _ = runtime.mod_evaluate(side_id);
futures::executor::block_on(runtime.run_event_loop(false)).unwrap();
}
@@ -2440,6 +2446,7 @@ if (import.meta.url != 'file:///main_with_code.js') throw Error();
.boxed_local();
let main_id = futures::executor::block_on(main_id_fut).unwrap();
+ #[allow(clippy::let_underscore_future)]
let _ = runtime.mod_evaluate(main_id);
futures::executor::block_on(runtime.run_event_loop(false)).unwrap();
runtime.snapshot()
@@ -2479,6 +2486,7 @@ if (import.meta.url != 'file:///main_with_code.js') throw Error();
.boxed_local();
let main_id = futures::executor::block_on(main_id_fut).unwrap();
+ #[allow(clippy::let_underscore_future)]
let _ = runtime.mod_evaluate(main_id);
futures::executor::block_on(runtime.run_event_loop(false)).unwrap();
runtime.snapshot()
diff --git a/core/ops.rs b/core/ops.rs
index 098de8c93..ca465c821 100644
--- a/core/ops.rs
+++ b/core/ops.rs
@@ -134,7 +134,7 @@ impl OpError {
pub fn new(get_class: GetErrorClassFn, err: Error) -> Self {
Self {
class_name: (get_class)(&err),
- message: format!("{:#}", err),
+ message: format!("{err:#}"),
code: crate::error_codes::get_error_code(&err),
}
}
diff --git a/core/ops_builtin_v8.rs b/core/ops_builtin_v8.rs
index 225a81901..a94f8a50b 100644
--- a/core/ops_builtin_v8.rs
+++ b/core/ops_builtin_v8.rs
@@ -471,7 +471,7 @@ fn op_serialize(
if buf.was_detached() {
return Err(custom_error(
"DOMExceptionOperationError",
- format!("ArrayBuffer at index {} is already detached", index),
+ format!("ArrayBuffer at index {index} is already detached"),
));
}
@@ -593,8 +593,8 @@ fn op_get_promise_details<'a>(
}
#[op(v8)]
-fn op_set_promise_hooks<'a>(
- scope: &mut v8::HandleScope<'a>,
+fn op_set_promise_hooks(
+ scope: &mut v8::HandleScope,
init_cb: serde_v8::Value,
before_cb: serde_v8::Value,
after_cb: serde_v8::Value,
diff --git a/core/runtime.rs b/core/runtime.rs
index 0788cc08c..29a6ca450 100644
--- a/core/runtime.rs
+++ b/core/runtime.rs
@@ -435,12 +435,11 @@ impl JsRuntime {
match err {
v8::DataError::BadType { actual, expected } => {
panic!(
- "Invalid type for snapshot data: expected {}, got {}",
- expected, actual
+ "Invalid type for snapshot data: expected {expected}, got {actual}"
);
}
v8::DataError::NoData { expected } => {
- panic!("No data for snapshot data: expected {}", expected);
+ panic!("No data for snapshot data: expected {expected}");
}
}
}
@@ -1528,8 +1527,8 @@ impl JsRuntimeState {
}
}
-pub(crate) fn exception_to_err_result<'s, T>(
- scope: &mut v8::HandleScope<'s>,
+pub(crate) fn exception_to_err_result<T>(
+ scope: &mut v8::HandleScope,
exception: v8::Local<v8::Value>,
in_promise: bool,
) -> Result<T, Error> {
@@ -3393,6 +3392,7 @@ pub mod tests {
)
.unwrap();
+ #[allow(clippy::let_underscore_future)]
let _ = runtime.mod_evaluate(module_id);
let module_namespace = runtime.get_module_namespace(module_id).unwrap();
@@ -3570,6 +3570,7 @@ pub mod tests {
};
assert_eq!(i, id);
+ #[allow(clippy::let_underscore_future)]
let _ = runtime.mod_evaluate(id);
futures::executor::block_on(runtime.run_event_loop(false)).unwrap();
@@ -3622,6 +3623,7 @@ pub mod tests {
)
.unwrap();
+ #[allow(clippy::let_underscore_future)]
let _ = runtime.mod_evaluate(id);
futures::executor::block_on(runtime.run_event_loop(false)).unwrap();
@@ -3820,7 +3822,7 @@ Deno.core.initializeAsyncOps();
match runtime.poll_value(&promise, cx) {
Poll::Ready(Ok(_)) => {}
- Poll::Ready(Err(err)) => panic!("{:?}", err),
+ Poll::Ready(Err(err)) => panic!("{err:?}"),
_ => panic!(),
}
})
@@ -4344,9 +4346,7 @@ Deno.core.ops.op_async_serialize_object_with_numbers_as_keys({
globalThis.rejectValue = `{realm_name}/${{reason}}`;
}});
Deno.core.ops.op_void_async().then(() => Promise.reject({number}));
- "#,
- realm_name=realm_name,
- number=number
+ "#
),
)
.unwrap();
@@ -4362,7 +4362,7 @@ Deno.core.ops.op_async_serialize_object_with_numbers_as_keys({
let reject_value = v8::Local::new(scope, reject_value);
assert!(reject_value.is_string());
let reject_value_string = reject_value.to_rust_string_lossy(scope);
- assert_eq!(reject_value_string, format!("{}/{}", realm_name, number));
+ assert_eq!(reject_value_string, format!("{realm_name}/{number}"));
}
}