summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.appveyor.yml2
-rw-r--r--.travis.yml10
-rw-r--r--cli/cli_behavior.rs2
-rw-r--r--cli/compiler.rs7
-rw-r--r--cli/deno_dir.rs2
-rw-r--r--cli/global_timer.rs1
-rw-r--r--cli/ops.rs221
-rw-r--r--cli/permissions.rs27
-rw-r--r--cli/resources.rs13
9 files changed, 135 insertions, 150 deletions
diff --git a/.appveyor.yml b/.appveyor.yml
index e81800424..70d26f773 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -154,7 +154,7 @@ install:
Invoke-WebRequest -Uri "https://win.rustup.rs" `
-OutFile "$env:TEMP\rustup-init.exe"
Exec -NoNewLines {
- & "$env:TEMP\rustup-init.exe" -y --default-toolchain 1.31.1
+ & "$env:TEMP\rustup-init.exe" -y --default-toolchain 1.33.0
}
Delete-Tree @(
"$env:RUSTUP_HOME\downloads",
diff --git a/.travis.yml b/.travis.yml
index df7aab214..2e5991d93 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,6 +5,7 @@ git:
depth: 1
env:
global:
+ - RUST_VERSION=1.33.0
- CARGO_HOME=$TRAVIS_BUILD_DIR/third_party/rust_crates/
- RUSTUP_HOME=$HOME/.rustup/
- RUST_BACKTRACE=full
@@ -37,11 +38,10 @@ install:
- node -v
- |-
# Install Rust.
- # TODO(ry) Include rustc in third_party.
- # https://github.com/denoland/deno/issues/386
- if [ ! $(rustc --version | grep 1.31.1) ]; then
- curl -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain 1.31.1
- rustup default 1.31.1
+ if [ ! $(rustc --version | grep $RUST_VERSION) ]; then
+ curl -sSf https://sh.rustup.rs | sh -s -- -y \
+ --default-toolchain $RUST_VERSION
+ rustup default $RUST_VERSION
fi
rustc --version
cargo --version
diff --git a/cli/cli_behavior.rs b/cli/cli_behavior.rs
index f1bd5a555..a297bdef9 100644
--- a/cli/cli_behavior.rs
+++ b/cli/cli_behavior.rs
@@ -52,6 +52,6 @@ impl Behavior for CliBehavior {
control: &[u8],
zero_copy: deno_buf,
) -> (bool, Box<Op>) {
- ops::dispatch_all(Box::new(self), control, zero_copy, ops::op_selector_std)
+ ops::dispatch_all(self, control, zero_copy, ops::op_selector_std)
}
}
diff --git a/cli/compiler.rs b/cli/compiler.rs
index 17006b2b9..e90a10c16 100644
--- a/cli/compiler.rs
+++ b/cli/compiler.rs
@@ -60,12 +60,7 @@ impl Behavior for CompilerBehavior {
control: &[u8],
zero_copy: deno_buf,
) -> (bool, Box<Op>) {
- ops::dispatch_all(
- Box::new(self),
- control,
- zero_copy,
- ops::op_selector_compiler,
- )
+ ops::dispatch_all(self, control, zero_copy, ops::op_selector_compiler)
}
}
diff --git a/cli/deno_dir.rs b/cli/deno_dir.rs
index 65656d7dd..40612e970 100644
--- a/cli/deno_dir.rs
+++ b/cli/deno_dir.rs
@@ -256,7 +256,7 @@ impl DenoDir {
}
};
- if out.source_code.starts_with("#!".as_bytes()) {
+ if out.source_code.starts_with(b"#!") {
out.source_code = filter_shebang(out.source_code);
}
diff --git a/cli/global_timer.rs b/cli/global_timer.rs
index eef70ddc2..d3ca52f46 100644
--- a/cli/global_timer.rs
+++ b/cli/global_timer.rs
@@ -14,6 +14,7 @@ use std::time::Instant;
use tokio::sync::oneshot;
use tokio::timer::Delay;
+#[derive(Default)]
pub struct GlobalTimer {
tx: Option<oneshot::Sender<()>>,
}
diff --git a/cli/ops.rs b/cli/ops.rs
index 826f6b1cc..6d0acef04 100644
--- a/cli/ops.rs
+++ b/cli/ops.rs
@@ -2,7 +2,7 @@
use atty;
use crate::ansi;
use crate::errors;
-use crate::errors::{op_not_implemented, DenoError, DenoResult, ErrorKind};
+use crate::errors::{DenoError, DenoResult, ErrorKind};
use crate::fs as deno_fs;
use crate::http_util;
use crate::isolate_state::{IsolateState, IsolateStateContainer};
@@ -58,10 +58,10 @@ pub type OpWithError = dyn Future<Item = Buf, Error = DenoError> + Send;
// TODO Ideally we wouldn't have to box the OpWithError being returned.
// The box is just to make it easier to get a prototype refactor working.
type OpCreator =
- fn(sc: Box<&IsolateStateContainer>, base: &msg::Base<'_>, data: deno_buf)
+ fn(sc: &IsolateStateContainer, base: &msg::Base<'_>, data: deno_buf)
-> Box<OpWithError>;
-type OpSelector = fn(inner_type: msg::Any) -> DenoResult<Box<OpCreator>>;
+type OpSelector = fn(inner_type: msg::Any) -> Option<OpCreator>;
#[inline]
fn empty_buf() -> Buf {
@@ -73,7 +73,7 @@ fn empty_buf() -> Buf {
/// control corresponds to the first argument of libdeno.send().
/// data corresponds to the second argument of libdeno.send().
pub fn dispatch_all(
- sc: Box<&IsolateStateContainer>,
+ sc: &IsolateStateContainer,
control: &[u8],
zero_copy: deno_buf,
op_selector: OpSelector,
@@ -85,12 +85,9 @@ pub fn dispatch_all(
let inner_type = base.inner_type();
let cmd_id = base.cmd_id();
- let op_func: Box<OpCreator> = match op_selector(inner_type) {
- Ok(v) => v,
- Err(_) => panic!(format!(
- "Unhandled message {}",
- msg::enum_name_any(inner_type)
- )),
+ let op_func: OpCreator = match op_selector(inner_type) {
+ Some(v) => v,
+ None => panic!("Unhandled message {}", msg::enum_name_any(inner_type)),
};
let state = sc.state().clone();
@@ -144,72 +141,65 @@ pub fn dispatch_all(
(base.sync(), boxed_op)
}
-pub fn op_selector_compiler(
- inner_type: msg::Any,
-) -> DenoResult<Box<OpCreator>> {
- let op_creator: Box<OpCreator> = match inner_type {
- msg::Any::FetchModuleMetaData => Box::new(op_fetch_module_meta_data),
- _ => match op_selector_std(inner_type) {
- Ok(v) => v,
- Err(e) => return Err(e),
- },
- };
- Ok(op_creator)
+pub fn op_selector_compiler(inner_type: msg::Any) -> Option<OpCreator> {
+ match inner_type {
+ msg::Any::FetchModuleMetaData => Some(op_fetch_module_meta_data),
+ _ => op_selector_std(inner_type),
+ }
}
-pub fn op_selector_std(inner_type: msg::Any) -> DenoResult<Box<OpCreator>> {
- let op_creator: OpCreator = match inner_type {
- msg::Any::Accept => op_accept,
- msg::Any::Chdir => op_chdir,
- msg::Any::Chmod => op_chmod,
- msg::Any::Close => op_close,
- msg::Any::CopyFile => op_copy_file,
- msg::Any::Cwd => op_cwd,
- msg::Any::Dial => op_dial,
- msg::Any::Environ => op_env,
- msg::Any::Exit => op_exit,
- msg::Any::Fetch => op_fetch,
- msg::Any::FormatError => op_format_error,
- msg::Any::GlobalTimer => op_global_timer,
- msg::Any::GlobalTimerStop => op_global_timer_stop,
- msg::Any::IsTTY => op_is_tty,
- msg::Any::Listen => op_listen,
- msg::Any::MakeTempDir => op_make_temp_dir,
- msg::Any::Metrics => op_metrics,
- msg::Any::Mkdir => op_mkdir,
- msg::Any::Now => op_now,
- msg::Any::Open => op_open,
- msg::Any::PermissionRevoke => op_revoke_permission,
- msg::Any::Permissions => op_permissions,
- msg::Any::Read => op_read,
- msg::Any::ReadDir => op_read_dir,
- msg::Any::ReadFile => op_read_file,
- msg::Any::Readlink => op_read_link,
- msg::Any::Remove => op_remove,
- msg::Any::Rename => op_rename,
- msg::Any::ReplReadline => op_repl_readline,
- msg::Any::ReplStart => op_repl_start,
- msg::Any::Resources => op_resources,
- msg::Any::Run => op_run,
- msg::Any::RunStatus => op_run_status,
- msg::Any::Seek => op_seek,
- msg::Any::SetEnv => op_set_env,
- msg::Any::Shutdown => op_shutdown,
- msg::Any::Start => op_start,
- msg::Any::Stat => op_stat,
- msg::Any::Symlink => op_symlink,
- msg::Any::Truncate => op_truncate,
- msg::Any::WorkerGetMessage => op_worker_get_message,
- msg::Any::WorkerPostMessage => op_worker_post_message,
- msg::Any::Write => op_write,
- msg::Any::WriteFile => op_write_file,
- _ => return Err(op_not_implemented()),
- };
- Ok(Box::new(op_creator))
+pub fn op_selector_std(inner_type: msg::Any) -> Option<OpCreator> {
+ match inner_type {
+ msg::Any::Accept => Some(op_accept),
+ msg::Any::Chdir => Some(op_chdir),
+ msg::Any::Chmod => Some(op_chmod),
+ msg::Any::Close => Some(op_close),
+ msg::Any::CopyFile => Some(op_copy_file),
+ msg::Any::Cwd => Some(op_cwd),
+ msg::Any::Dial => Some(op_dial),
+ msg::Any::Environ => Some(op_env),
+ msg::Any::Exit => Some(op_exit),
+ msg::Any::Fetch => Some(op_fetch),
+ msg::Any::FormatError => Some(op_format_error),
+ msg::Any::GlobalTimer => Some(op_global_timer),
+ msg::Any::GlobalTimerStop => Some(op_global_timer_stop),
+ msg::Any::IsTTY => Some(op_is_tty),
+ msg::Any::Listen => Some(op_listen),
+ msg::Any::MakeTempDir => Some(op_make_temp_dir),
+ msg::Any::Metrics => Some(op_metrics),
+ msg::Any::Mkdir => Some(op_mkdir),
+ msg::Any::Now => Some(op_now),
+ msg::Any::Open => Some(op_open),
+ msg::Any::PermissionRevoke => Some(op_revoke_permission),
+ msg::Any::Permissions => Some(op_permissions),
+ msg::Any::Read => Some(op_read),
+ msg::Any::ReadDir => Some(op_read_dir),
+ msg::Any::ReadFile => Some(op_read_file),
+ msg::Any::Readlink => Some(op_read_link),
+ msg::Any::Remove => Some(op_remove),
+ msg::Any::Rename => Some(op_rename),
+ msg::Any::ReplReadline => Some(op_repl_readline),
+ msg::Any::ReplStart => Some(op_repl_start),
+ msg::Any::Resources => Some(op_resources),
+ msg::Any::Run => Some(op_run),
+ msg::Any::RunStatus => Some(op_run_status),
+ msg::Any::Seek => Some(op_seek),
+ msg::Any::SetEnv => Some(op_set_env),
+ msg::Any::Shutdown => Some(op_shutdown),
+ msg::Any::Start => Some(op_start),
+ msg::Any::Stat => Some(op_stat),
+ msg::Any::Symlink => Some(op_symlink),
+ msg::Any::Truncate => Some(op_truncate),
+ msg::Any::WorkerGetMessage => Some(op_worker_get_message),
+ msg::Any::WorkerPostMessage => Some(op_worker_post_message),
+ msg::Any::Write => Some(op_write),
+ msg::Any::WriteFile => Some(op_write_file),
+ _ => None,
+ }
}
fn op_now(
- _sc: Box<&IsolateStateContainer>,
+ _sc: &IsolateStateContainer,
base: &msg::Base<'_>,
data: deno_buf,
) -> Box<OpWithError> {
@@ -233,7 +223,7 @@ fn op_now(
}
fn op_is_tty(
- _sc: Box<&IsolateStateContainer>,
+ _sc: &IsolateStateContainer,
base: &msg::Base<'_>,
_data: deno_buf,
) -> Box<OpWithError> {
@@ -258,7 +248,7 @@ fn op_is_tty(
}
fn op_exit(
- _sc: Box<&IsolateStateContainer>,
+ _sc: &IsolateStateContainer,
base: &msg::Base<'_>,
_data: deno_buf,
) -> Box<OpWithError> {
@@ -267,7 +257,7 @@ fn op_exit(
}
fn op_start(
- sc: Box<&IsolateStateContainer>,
+ sc: &IsolateStateContainer,
base: &msg::Base<'_>,
data: deno_buf,
) -> Box<OpWithError> {
@@ -323,7 +313,7 @@ fn op_start(
}
fn op_format_error(
- sc: Box<&IsolateStateContainer>,
+ sc: &IsolateStateContainer,
base: &msg::Base<'_>,
data: deno_buf,
) -> Box<OpWithError> {
@@ -342,7 +332,6 @@ fn op_format_error(
&mut builder,
&msg::FormatErrorResArgs {
error: Some(new_error),
- ..Default::default()
},
);
@@ -383,7 +372,7 @@ pub fn odd_future(err: DenoError) -> Box<OpWithError> {
// https://github.com/denoland/deno/blob/golang/os.go#L100-L154
fn op_fetch_module_meta_data(
- sc: Box<&IsolateStateContainer>,
+ sc: &IsolateStateContainer,
base: &msg::Base<'_>,
data: deno_buf,
) -> Box<OpWithError> {
@@ -423,7 +412,7 @@ fn op_fetch_module_meta_data(
}
fn op_chdir(
- _sc: Box<&IsolateStateContainer>,
+ _sc: &IsolateStateContainer,
base: &msg::Base<'_>,
data: deno_buf,
) -> Box<OpWithError> {
@@ -437,7 +426,7 @@ fn op_chdir(
}
fn op_global_timer_stop(
- sc: Box<&IsolateStateContainer>,
+ sc: &IsolateStateContainer,
base: &msg::Base<'_>,
data: deno_buf,
) -> Box<OpWithError> {
@@ -450,7 +439,7 @@ fn op_global_timer_stop(
}
fn op_global_timer(
- sc: Box<&IsolateStateContainer>,
+ sc: &IsolateStateContainer,
base: &msg::Base<'_>,
data: deno_buf,
) -> Box<OpWithError> {
@@ -483,7 +472,7 @@ fn op_global_timer(
}
fn op_set_env(
- sc: Box<&IsolateStateContainer>,
+ sc: &IsolateStateContainer,
base: &msg::Base<'_>,
data: deno_buf,
) -> Box<OpWithError> {
@@ -499,7 +488,7 @@ fn op_set_env(
}
fn op_env(
- sc: Box<&IsolateStateContainer>,
+ sc: &IsolateStateContainer,
base: &msg::Base<'_>,
data: deno_buf,
) -> Box<OpWithError> {
@@ -531,7 +520,7 @@ fn op_env(
}
fn op_permissions(
- sc: Box<&IsolateStateContainer>,
+ sc: &IsolateStateContainer,
base: &msg::Base<'_>,
data: deno_buf,
) -> Box<OpWithError> {
@@ -560,7 +549,7 @@ fn op_permissions(
}
fn op_revoke_permission(
- sc: Box<&IsolateStateContainer>,
+ sc: &IsolateStateContainer,
base: &msg::Base<'_>,
data: deno_buf,
) -> Box<OpWithError> {
@@ -582,7 +571,7 @@ fn op_revoke_permission(
}
fn op_fetch(
- sc: Box<&IsolateStateContainer>,
+ sc: &IsolateStateContainer,
base: &msg::Base<'_>,
data: deno_buf,
) -> Box<OpWithError> {
@@ -669,7 +658,7 @@ where
}
fn op_make_temp_dir(
- sc: Box<&IsolateStateContainer>,
+ sc: &IsolateStateContainer,
base: &msg::Base<'_>,
data: deno_buf,
) -> Box<OpWithError> {
@@ -718,7 +707,7 @@ fn op_make_temp_dir(
}
fn op_mkdir(
- sc: Box<&IsolateStateContainer>,
+ sc: &IsolateStateContainer,
base: &msg::Base<'_>,
data: deno_buf,
) -> Box<OpWithError> {
@@ -740,7 +729,7 @@ fn op_mkdir(
}
fn op_chmod(
- sc: Box<&IsolateStateContainer>,
+ sc: &IsolateStateContainer,
base: &msg::Base<'_>,
data: deno_buf,
) -> Box<OpWithError> {
@@ -779,7 +768,7 @@ fn op_chmod(
}
fn op_open(
- sc: Box<&IsolateStateContainer>,
+ sc: &IsolateStateContainer,
base: &msg::Base<'_>,
data: deno_buf,
) -> Box<OpWithError> {
@@ -869,7 +858,7 @@ fn op_open(
}
fn op_close(
- _sc: Box<&IsolateStateContainer>,
+ _sc: &IsolateStateContainer,
base: &msg::Base<'_>,
data: deno_buf,
) -> Box<OpWithError> {
@@ -886,7 +875,7 @@ fn op_close(
}
fn op_shutdown(
- _sc: Box<&IsolateStateContainer>,
+ _sc: &IsolateStateContainer,
base: &msg::Base<'_>,
data: deno_buf,
) -> Box<OpWithError> {
@@ -912,7 +901,7 @@ fn op_shutdown(
}
fn op_read(
- _sc: Box<&IsolateStateContainer>,
+ _sc: &IsolateStateContainer,
base: &msg::Base<'_>,
data: deno_buf,
) -> Box<OpWithError> {
@@ -950,7 +939,7 @@ fn op_read(
}
fn op_write(
- _sc: Box<&IsolateStateContainer>,
+ _sc: &IsolateStateContainer,
base: &msg::Base<'_>,
data: deno_buf,
) -> Box<OpWithError> {
@@ -987,7 +976,7 @@ fn op_write(
}
fn op_seek(
- _sc: Box<&IsolateStateContainer>,
+ _sc: &IsolateStateContainer,
base: &msg::Base<'_>,
data: deno_buf,
) -> Box<OpWithError> {
@@ -1009,7 +998,7 @@ fn op_seek(
}
fn op_remove(
- sc: Box<&IsolateStateContainer>,
+ sc: &IsolateStateContainer,
base: &msg::Base<'_>,
data: deno_buf,
) -> Box<OpWithError> {
@@ -1039,7 +1028,7 @@ fn op_remove(
// Prototype https://github.com/denoland/deno/blob/golang/os.go#L171-L184
fn op_read_file(
- sc: Box<&IsolateStateContainer>,
+ sc: &IsolateStateContainer,
base: &msg::Base<'_>,
data: deno_buf,
) -> Box<OpWithError> {
@@ -1077,7 +1066,7 @@ fn op_read_file(
}
fn op_copy_file(
- sc: Box<&IsolateStateContainer>,
+ sc: &IsolateStateContainer,
base: &msg::Base<'_>,
data: deno_buf,
) -> Box<OpWithError> {
@@ -1133,7 +1122,7 @@ fn get_mode(_perm: &fs::Permissions) -> u32 {
}
fn op_cwd(
- _sc: Box<&IsolateStateContainer>,
+ _sc: &IsolateStateContainer,
base: &msg::Base<'_>,
data: deno_buf,
) -> Box<OpWithError> {
@@ -1159,7 +1148,7 @@ fn op_cwd(
}
fn op_stat(
- sc: Box<&IsolateStateContainer>,
+ sc: &IsolateStateContainer,
base: &msg::Base<'_>,
data: deno_buf,
) -> Box<OpWithError> {
@@ -1211,7 +1200,7 @@ fn op_stat(
}
fn op_read_dir(
- sc: Box<&IsolateStateContainer>,
+ sc: &IsolateStateContainer,
base: &msg::Base<'_>,
data: deno_buf,
) -> Box<OpWithError> {
@@ -1272,7 +1261,7 @@ fn op_read_dir(
}
fn op_write_file(
- sc: Box<&IsolateStateContainer>,
+ sc: &IsolateStateContainer,
base: &msg::Base<'_>,
data: deno_buf,
) -> Box<OpWithError> {
@@ -1302,7 +1291,7 @@ fn op_write_file(
}
fn op_rename(
- sc: Box<&IsolateStateContainer>,
+ sc: &IsolateStateContainer,
base: &msg::Base<'_>,
data: deno_buf,
) -> Box<OpWithError> {
@@ -1322,7 +1311,7 @@ fn op_rename(
}
fn op_symlink(
- sc: Box<&IsolateStateContainer>,
+ sc: &IsolateStateContainer,
base: &msg::Base<'_>,
data: deno_buf,
) -> Box<OpWithError> {
@@ -1351,7 +1340,7 @@ fn op_symlink(
}
fn op_read_link(
- sc: Box<&IsolateStateContainer>,
+ sc: &IsolateStateContainer,
base: &msg::Base<'_>,
data: deno_buf,
) -> Box<OpWithError> {
@@ -1389,7 +1378,7 @@ fn op_read_link(
}
fn op_repl_start(
- sc: Box<&IsolateStateContainer>,
+ sc: &IsolateStateContainer,
base: &msg::Base<'_>,
data: deno_buf,
) -> Box<OpWithError> {
@@ -1420,7 +1409,7 @@ fn op_repl_start(
}
fn op_repl_readline(
- _sc: Box<&IsolateStateContainer>,
+ _sc: &IsolateStateContainer,
base: &msg::Base<'_>,
data: deno_buf,
) -> Box<OpWithError> {
@@ -1456,7 +1445,7 @@ fn op_repl_readline(
}
fn op_truncate(
- sc: Box<&IsolateStateContainer>,
+ sc: &IsolateStateContainer,
base: &msg::Base<'_>,
data: deno_buf,
) -> Box<OpWithError> {
@@ -1479,7 +1468,7 @@ fn op_truncate(
}
fn op_listen(
- sc: Box<&IsolateStateContainer>,
+ sc: &IsolateStateContainer,
base: &msg::Base<'_>,
data: deno_buf,
) -> Box<OpWithError> {
@@ -1541,7 +1530,7 @@ fn new_conn(cmd_id: u32, tcp_stream: TcpStream) -> OpResult {
}
fn op_accept(
- sc: Box<&IsolateStateContainer>,
+ sc: &IsolateStateContainer,
base: &msg::Base<'_>,
data: deno_buf,
) -> Box<OpWithError> {
@@ -1567,7 +1556,7 @@ fn op_accept(
}
fn op_dial(
- sc: Box<&IsolateStateContainer>,
+ sc: &IsolateStateContainer,
base: &msg::Base<'_>,
data: deno_buf,
) -> Box<OpWithError> {
@@ -1593,7 +1582,7 @@ fn op_dial(
}
fn op_metrics(
- sc: Box<&IsolateStateContainer>,
+ sc: &IsolateStateContainer,
base: &msg::Base<'_>,
data: deno_buf,
) -> Box<OpWithError> {
@@ -1617,7 +1606,7 @@ fn op_metrics(
}
fn op_resources(
- _sc: Box<&IsolateStateContainer>,
+ _sc: &IsolateStateContainer,
base: &msg::Base<'_>,
data: deno_buf,
) -> Box<OpWithError> {
@@ -1669,7 +1658,7 @@ fn subprocess_stdio_map(v: msg::ProcessStdio) -> std::process::Stdio {
}
fn op_run(
- sc: Box<&IsolateStateContainer>,
+ sc: &IsolateStateContainer,
base: &msg::Base<'_>,
data: deno_buf,
) -> Box<OpWithError> {
@@ -1742,7 +1731,7 @@ fn op_run(
}
fn op_run_status(
- sc: Box<&IsolateStateContainer>,
+ sc: &IsolateStateContainer,
base: &msg::Base<'_>,
data: deno_buf,
) -> Box<OpWithError> {
@@ -1818,7 +1807,7 @@ impl Future for GetMessageFuture {
}
fn op_worker_get_message(
- sc: Box<&IsolateStateContainer>,
+ sc: &IsolateStateContainer,
base: &msg::Base<'_>,
data: deno_buf,
) -> Box<OpWithError> {
@@ -1852,7 +1841,7 @@ fn op_worker_get_message(
}
fn op_worker_post_message(
- sc: Box<&IsolateStateContainer>,
+ sc: &IsolateStateContainer,
base: &msg::Base<'_>,
data: deno_buf,
) -> Box<OpWithError> {
diff --git a/cli/permissions.rs b/cli/permissions.rs
index 9093c14f0..2240d94c1 100644
--- a/cli/permissions.rs
+++ b/cli/permissions.rs
@@ -31,9 +31,10 @@ impl From<usize> for PermissionAccessorState {
impl From<bool> for PermissionAccessorState {
fn from(val: bool) -> Self {
- match val {
- true => PermissionAccessorState::Allow,
- false => PermissionAccessorState::Ask,
+ if val {
+ PermissionAccessorState::Allow
+ } else {
+ PermissionAccessorState::Ask
}
}
}
@@ -243,48 +244,48 @@ impl DenoPermissions {
}
pub fn allows_run(&self) -> bool {
- return self.allow_run.is_allow();
+ self.allow_run.is_allow()
}
pub fn allows_read(&self) -> bool {
- return self.allow_read.is_allow();
+ self.allow_read.is_allow()
}
pub fn allows_write(&self) -> bool {
- return self.allow_write.is_allow();
+ self.allow_write.is_allow()
}
pub fn allows_net(&self) -> bool {
- return self.allow_net.is_allow();
+ self.allow_net.is_allow()
}
pub fn allows_env(&self) -> bool {
- return self.allow_env.is_allow();
+ self.allow_env.is_allow()
}
pub fn revoke_run(&self) -> DenoResult<()> {
self.allow_run.revoke();
- return Ok(());
+ Ok(())
}
pub fn revoke_read(&self) -> DenoResult<()> {
self.allow_read.revoke();
- return Ok(());
+ Ok(())
}
pub fn revoke_write(&self) -> DenoResult<()> {
self.allow_write.revoke();
- return Ok(());
+ Ok(())
}
pub fn revoke_net(&self) -> DenoResult<()> {
self.allow_net.revoke();
- return Ok(());
+ Ok(())
}
pub fn revoke_env(&self) -> DenoResult<()> {
self.allow_env.revoke();
- return Ok(());
+ Ok(())
}
}
diff --git a/cli/resources.rs b/cli/resources.rs
index 2f07f0f11..385b3d5ca 100644
--- a/cli/resources.rs
+++ b/cli/resources.rs
@@ -451,8 +451,8 @@ pub fn seek(
Some(Repr::FsFile(f)) => {
let seek_from = match whence {
0 => SeekFrom::Start(offset as u64),
- 1 => SeekFrom::Current(offset as i64),
- 2 => SeekFrom::End(offset as i64),
+ 1 => SeekFrom::Current(i64::from(offset)),
+ 2 => SeekFrom::End(i64::from(offset)),
_ => {
return Box::new(futures::future::err(errors::new(
errors::ErrorKind::InvalidSeekMode,
@@ -481,14 +481,13 @@ pub fn seek(
)));
}
let mut std_file_copy = maybe_std_file_copy.unwrap();
- return Box::new(futures::future::lazy(move || {
+ Box::new(futures::future::lazy(move || {
let result = std_file_copy
.seek(seek_from)
- .map(|_| {
- return ();
- }).map_err(DenoError::from);
+ .map(|_| {})
+ .map_err(DenoError::from);
futures::future::result(result)
- }));
+ }))
}
_ => panic!("cannot seek"),
}