summaryrefslogtreecommitdiff
path: root/runtime/ops
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/ops')
-rw-r--r--runtime/ops/fs.rs6
-rw-r--r--runtime/ops/mod.rs3
-rw-r--r--runtime/ops/os/mod.rs16
-rw-r--r--runtime/ops/permissions.rs8
-rw-r--r--runtime/ops/process.rs2
-rw-r--r--runtime/ops/signal.rs7
-rw-r--r--runtime/ops/utils.rs2
-rw-r--r--runtime/ops/web_worker/sync_fetch.rs6
-rw-r--r--runtime/ops/worker_host.rs3
9 files changed, 22 insertions, 31 deletions
diff --git a/runtime/ops/fs.rs b/runtime/ops/fs.rs
index 342b0e35d..f6b9a58eb 100644
--- a/runtime/ops/fs.rs
+++ b/runtime/ops/fs.rs
@@ -337,7 +337,7 @@ fn seek_helper(args: SeekArgs) -> Result<(u32, SeekFrom), AnyError> {
1 => SeekFrom::Current(offset),
2 => SeekFrom::End(offset),
_ => {
- return Err(type_error(format!("Invalid seek mode: {}", whence)));
+ return Err(type_error(format!("Invalid seek mode: {whence}")));
}
};
@@ -542,7 +542,7 @@ fn op_chdir(state: &mut OpState, directory: String) -> Result<(), AnyError> {
.borrow_mut::<PermissionsContainer>()
.check_read(&d, "Deno.chdir()")?;
set_current_dir(&d).map_err(|err| {
- Error::new(err.kind(), format!("{}, chdir '{}'", err, directory))
+ Error::new(err.kind(), format!("{err}, chdir '{directory}'"))
})?;
Ok(())
}
@@ -1747,7 +1747,7 @@ fn make_temp(
let mut rng = thread_rng();
loop {
let unique = rng.gen::<u32>();
- buf.set_file_name(format!("{}{:08x}{}", prefix_, unique, suffix_));
+ buf.set_file_name(format!("{prefix_}{unique:08x}{suffix_}"));
let r = if is_dir {
#[allow(unused_mut)]
let mut builder = std::fs::DirBuilder::new();
diff --git a/runtime/ops/mod.rs b/runtime/ops/mod.rs
index e42f61a7b..ce7c52d64 100644
--- a/runtime/ops/mod.rs
+++ b/runtime/ops/mod.rs
@@ -36,8 +36,7 @@ impl UnstableChecker {
pub fn check_unstable(&self, api_name: &str) {
if !self.unstable {
eprintln!(
- "Unstable API '{}'. The --unstable flag must be provided.",
- api_name
+ "Unstable API '{api_name}'. The --unstable flag must be provided."
);
std::process::exit(70);
}
diff --git a/runtime/ops/os/mod.rs b/runtime/ops/os/mod.rs
index c35d4fc9e..f970c318b 100644
--- a/runtime/ops/os/mod.rs
+++ b/runtime/ops/os/mod.rs
@@ -92,14 +92,12 @@ fn op_set_env(
}
if key.contains(&['=', '\0'] as &[char]) {
return Err(type_error(format!(
- "Key contains invalid characters: {:?}",
- key
+ "Key contains invalid characters: {key:?}"
)));
}
if value.contains('\0') {
return Err(type_error(format!(
- "Value contains invalid characters: {:?}",
- value
+ "Value contains invalid characters: {value:?}"
)));
}
env::set_var(key, value);
@@ -129,8 +127,7 @@ fn op_get_env(
if key.contains(&['=', '\0'] as &[char]) {
return Err(type_error(format!(
- "Key contains invalid characters: {:?}",
- key
+ "Key contains invalid characters: {key:?}"
)));
}
@@ -215,7 +212,7 @@ impl From<netif::Interface> for NetworkInterface {
};
let (address, range) = ifa.cidr();
- let cidr = format!("{:?}/{}", address, range);
+ let cidr = format!("{address:?}/{range}");
let name = ifa.name().to_owned();
let address = format!("{:?}", ifa.address());
@@ -223,10 +220,7 @@ impl From<netif::Interface> for NetworkInterface {
let scopeid = ifa.scope_id();
let [b0, b1, b2, b3, b4, b5] = ifa.mac();
- let mac = format!(
- "{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}",
- b0, b1, b2, b3, b4, b5
- );
+ let mac = format!("{b0:02x}:{b1:02x}:{b2:02x}:{b3:02x}:{b4:02x}:{b5:02x}");
Self {
family,
diff --git a/runtime/ops/permissions.rs b/runtime/ops/permissions.rs
index 2b01da0a9..3c48c1e8d 100644
--- a/runtime/ops/permissions.rs
+++ b/runtime/ops/permissions.rs
@@ -59,7 +59,7 @@ pub fn op_query_permission(
n => {
return Err(custom_error(
"ReferenceError",
- format!("No such permission name: {}", n),
+ format!("No such permission name: {n}"),
))
}
};
@@ -93,7 +93,7 @@ pub fn op_revoke_permission(
n => {
return Err(custom_error(
"ReferenceError",
- format!("No such permission name: {}", n),
+ format!("No such permission name: {n}"),
))
}
};
@@ -127,7 +127,7 @@ pub fn op_request_permission(
n => {
return Err(custom_error(
"ReferenceError",
- format!("No such permission name: {}", n),
+ format!("No such permission name: {n}"),
))
}
};
@@ -135,7 +135,7 @@ pub fn op_request_permission(
}
fn parse_host(host_str: &str) -> Result<(String, Option<u16>), AnyError> {
- let url = url::Url::parse(&format!("http://{}/", host_str))
+ let url = url::Url::parse(&format!("http://{host_str}/"))
.map_err(|_| uri_error("Invalid host"))?;
if url.path() != "/" {
return Err(uri_error("Invalid host"));
diff --git a/runtime/ops/process.rs b/runtime/ops/process.rs
index eebf7e7af..9c7a3243a 100644
--- a/runtime/ops/process.rs
+++ b/runtime/ops/process.rs
@@ -317,7 +317,7 @@ pub fn kill(pid: i32, signal: &str) -> Result<(), AnyError> {
use winapi::um::winnt::PROCESS_TERMINATE;
if !matches!(signal, "SIGKILL" | "SIGTERM") {
- Err(type_error(format!("Invalid signal: {}", signal)))
+ Err(type_error(format!("Invalid signal: {signal}")))
} else if pid <= 0 {
Err(type_error("Invalid pid"))
} else {
diff --git a/runtime/ops/signal.rs b/runtime/ops/signal.rs
index ddee1fb5d..f88d87058 100644
--- a/runtime/ops/signal.rs
+++ b/runtime/ops/signal.rs
@@ -222,7 +222,7 @@ pub fn signal_str_to_int(s: &str) -> Result<libc::c_int, AnyError> {
"SIGIO" => Ok(29),
"SIGPWR" => Ok(30),
"SIGSYS" => Ok(31),
- _ => Err(type_error(format!("Invalid signal : {}", s))),
+ _ => Err(type_error(format!("Invalid signal : {s}"))),
}
}
@@ -260,7 +260,7 @@ pub fn signal_int_to_str(s: libc::c_int) -> Result<&'static str, AnyError> {
29 => Ok("SIGIO"),
30 => Ok("SIGPWR"),
31 => Ok("SIGSYS"),
- _ => Err(type_error(format!("Invalid signal : {}", s))),
+ _ => Err(type_error(format!("Invalid signal : {s}"))),
}
}
@@ -468,8 +468,7 @@ fn op_signal_bind(
let signo = signal_str_to_int(&sig)?;
if signal_hook_registry::FORBIDDEN.contains(&signo) {
return Err(type_error(format!(
- "Binding to signal '{}' is not allowed",
- sig
+ "Binding to signal '{sig}' is not allowed",
)));
}
let resource = SignalStreamResource {
diff --git a/runtime/ops/utils.rs b/runtime/ops/utils.rs
index 29cbaab91..bdbe7f6d0 100644
--- a/runtime/ops/utils.rs
+++ b/runtime/ops/utils.rs
@@ -13,7 +13,7 @@ use std::sync::Arc;
/// A utility function to map OsStrings to Strings
pub fn into_string(s: std::ffi::OsString) -> Result<String, AnyError> {
s.into_string().map_err(|s| {
- let message = format!("File name or path {:?} is not valid UTF-8", s);
+ let message = format!("File name or path {s:?} is not valid UTF-8");
custom_error("InvalidData", message)
})
}
diff --git a/runtime/ops/web_worker/sync_fetch.rs b/runtime/ops/web_worker/sync_fetch.rs
index a9a893572..2049d5ab8 100644
--- a/runtime/ops/web_worker/sync_fetch.rs
+++ b/runtime/ops/web_worker/sync_fetch.rs
@@ -92,7 +92,7 @@ pub fn op_worker_sync_fetch(
}
"data" => {
let data_url = DataUrl::process(&script)
- .map_err(|e| type_error(format!("{:?}", e)))?;
+ .map_err(|e| type_error(format!("{e:?}")))?;
let mime_type = {
let mime = data_url.mime_type();
@@ -101,7 +101,7 @@ pub fn op_worker_sync_fetch(
let (body, _) = data_url
.decode_to_vec()
- .map_err(|e| type_error(format!("{:?}", e)))?;
+ .map_err(|e| type_error(format!("{e:?}")))?;
(Bytes::from(body), Some(mime_type), script)
}
@@ -132,7 +132,7 @@ pub fn op_worker_sync_fetch(
Some(mime_type) => {
return Err(
DomExceptionNetworkError {
- msg: format!("Invalid MIME type {:?}.", mime_type),
+ msg: format!("Invalid MIME type {mime_type:?}."),
}
.into(),
)
diff --git a/runtime/ops/worker_host.rs b/runtime/ops/worker_host.rs
index 8945ff1cc..71009be8f 100644
--- a/runtime/ops/worker_host.rs
+++ b/runtime/ops/worker_host.rs
@@ -193,8 +193,7 @@ fn op_create_worker(
>(1);
// Setup new thread
- let thread_builder =
- std::thread::Builder::new().name(format!("{}", worker_id));
+ let thread_builder = std::thread::Builder::new().name(format!("{worker_id}"));
// Spawn it
thread_builder.spawn(move || {