1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-24 15:19:26 -05:00

Fix clippy errors and upgrade Rust to 1.33.0 in CI (#1945)

This commit is contained in:
Ryan Dahl 2019-03-20 18:55:52 -04:00 committed by GitHub
parent 223a2adbb4
commit 94405bb617
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 135 additions and 150 deletions

View file

@ -154,7 +154,7 @@ install:
Invoke-WebRequest -Uri "https://win.rustup.rs" ` Invoke-WebRequest -Uri "https://win.rustup.rs" `
-OutFile "$env:TEMP\rustup-init.exe" -OutFile "$env:TEMP\rustup-init.exe"
Exec -NoNewLines { 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 @( Delete-Tree @(
"$env:RUSTUP_HOME\downloads", "$env:RUSTUP_HOME\downloads",

View file

@ -5,6 +5,7 @@ git:
depth: 1 depth: 1
env: env:
global: global:
- RUST_VERSION=1.33.0
- CARGO_HOME=$TRAVIS_BUILD_DIR/third_party/rust_crates/ - CARGO_HOME=$TRAVIS_BUILD_DIR/third_party/rust_crates/
- RUSTUP_HOME=$HOME/.rustup/ - RUSTUP_HOME=$HOME/.rustup/
- RUST_BACKTRACE=full - RUST_BACKTRACE=full
@ -37,11 +38,10 @@ install:
- node -v - node -v
- |- - |-
# Install Rust. # Install Rust.
# TODO(ry) Include rustc in third_party. if [ ! $(rustc --version | grep $RUST_VERSION) ]; then
# https://github.com/denoland/deno/issues/386 curl -sSf https://sh.rustup.rs | sh -s -- -y \
if [ ! $(rustc --version | grep 1.31.1) ]; then --default-toolchain $RUST_VERSION
curl -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain 1.31.1 rustup default $RUST_VERSION
rustup default 1.31.1
fi fi
rustc --version rustc --version
cargo --version cargo --version

View file

@ -52,6 +52,6 @@ impl Behavior for CliBehavior {
control: &[u8], control: &[u8],
zero_copy: deno_buf, zero_copy: deno_buf,
) -> (bool, Box<Op>) { ) -> (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)
} }
} }

View file

@ -60,12 +60,7 @@ impl Behavior for CompilerBehavior {
control: &[u8], control: &[u8],
zero_copy: deno_buf, zero_copy: deno_buf,
) -> (bool, Box<Op>) { ) -> (bool, Box<Op>) {
ops::dispatch_all( ops::dispatch_all(self, control, zero_copy, ops::op_selector_compiler)
Box::new(self),
control,
zero_copy,
ops::op_selector_compiler,
)
} }
} }

View file

@ -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); out.source_code = filter_shebang(out.source_code);
} }

View file

@ -14,6 +14,7 @@ use std::time::Instant;
use tokio::sync::oneshot; use tokio::sync::oneshot;
use tokio::timer::Delay; use tokio::timer::Delay;
#[derive(Default)]
pub struct GlobalTimer { pub struct GlobalTimer {
tx: Option<oneshot::Sender<()>>, tx: Option<oneshot::Sender<()>>,
} }

View file

@ -2,7 +2,7 @@
use atty; use atty;
use crate::ansi; use crate::ansi;
use crate::errors; 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::fs as deno_fs;
use crate::http_util; use crate::http_util;
use crate::isolate_state::{IsolateState, IsolateStateContainer}; 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. // 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. // The box is just to make it easier to get a prototype refactor working.
type OpCreator = type OpCreator =
fn(sc: Box<&IsolateStateContainer>, base: &msg::Base<'_>, data: deno_buf) fn(sc: &IsolateStateContainer, base: &msg::Base<'_>, data: deno_buf)
-> Box<OpWithError>; -> Box<OpWithError>;
type OpSelector = fn(inner_type: msg::Any) -> DenoResult<Box<OpCreator>>; type OpSelector = fn(inner_type: msg::Any) -> Option<OpCreator>;
#[inline] #[inline]
fn empty_buf() -> Buf { fn empty_buf() -> Buf {
@ -73,7 +73,7 @@ fn empty_buf() -> Buf {
/// control corresponds to the first argument of libdeno.send(). /// control corresponds to the first argument of libdeno.send().
/// data corresponds to the second argument of libdeno.send(). /// data corresponds to the second argument of libdeno.send().
pub fn dispatch_all( pub fn dispatch_all(
sc: Box<&IsolateStateContainer>, sc: &IsolateStateContainer,
control: &[u8], control: &[u8],
zero_copy: deno_buf, zero_copy: deno_buf,
op_selector: OpSelector, op_selector: OpSelector,
@ -85,12 +85,9 @@ pub fn dispatch_all(
let inner_type = base.inner_type(); let inner_type = base.inner_type();
let cmd_id = base.cmd_id(); let cmd_id = base.cmd_id();
let op_func: Box<OpCreator> = match op_selector(inner_type) { let op_func: OpCreator = match op_selector(inner_type) {
Ok(v) => v, Some(v) => v,
Err(_) => panic!(format!( None => panic!("Unhandled message {}", msg::enum_name_any(inner_type)),
"Unhandled message {}",
msg::enum_name_any(inner_type)
)),
}; };
let state = sc.state().clone(); let state = sc.state().clone();
@ -144,72 +141,65 @@ pub fn dispatch_all(
(base.sync(), boxed_op) (base.sync(), boxed_op)
} }
pub fn op_selector_compiler( pub fn op_selector_compiler(inner_type: msg::Any) -> Option<OpCreator> {
inner_type: msg::Any, match inner_type {
) -> DenoResult<Box<OpCreator>> { msg::Any::FetchModuleMetaData => Some(op_fetch_module_meta_data),
let op_creator: Box<OpCreator> = match inner_type { _ => op_selector_std(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_std(inner_type: msg::Any) -> DenoResult<Box<OpCreator>> { pub fn op_selector_std(inner_type: msg::Any) -> Option<OpCreator> {
let op_creator: OpCreator = match inner_type { match inner_type {
msg::Any::Accept => op_accept, msg::Any::Accept => Some(op_accept),
msg::Any::Chdir => op_chdir, msg::Any::Chdir => Some(op_chdir),
msg::Any::Chmod => op_chmod, msg::Any::Chmod => Some(op_chmod),
msg::Any::Close => op_close, msg::Any::Close => Some(op_close),
msg::Any::CopyFile => op_copy_file, msg::Any::CopyFile => Some(op_copy_file),
msg::Any::Cwd => op_cwd, msg::Any::Cwd => Some(op_cwd),
msg::Any::Dial => op_dial, msg::Any::Dial => Some(op_dial),
msg::Any::Environ => op_env, msg::Any::Environ => Some(op_env),
msg::Any::Exit => op_exit, msg::Any::Exit => Some(op_exit),
msg::Any::Fetch => op_fetch, msg::Any::Fetch => Some(op_fetch),
msg::Any::FormatError => op_format_error, msg::Any::FormatError => Some(op_format_error),
msg::Any::GlobalTimer => op_global_timer, msg::Any::GlobalTimer => Some(op_global_timer),
msg::Any::GlobalTimerStop => op_global_timer_stop, msg::Any::GlobalTimerStop => Some(op_global_timer_stop),
msg::Any::IsTTY => op_is_tty, msg::Any::IsTTY => Some(op_is_tty),
msg::Any::Listen => op_listen, msg::Any::Listen => Some(op_listen),
msg::Any::MakeTempDir => op_make_temp_dir, msg::Any::MakeTempDir => Some(op_make_temp_dir),
msg::Any::Metrics => op_metrics, msg::Any::Metrics => Some(op_metrics),
msg::Any::Mkdir => op_mkdir, msg::Any::Mkdir => Some(op_mkdir),
msg::Any::Now => op_now, msg::Any::Now => Some(op_now),
msg::Any::Open => op_open, msg::Any::Open => Some(op_open),
msg::Any::PermissionRevoke => op_revoke_permission, msg::Any::PermissionRevoke => Some(op_revoke_permission),
msg::Any::Permissions => op_permissions, msg::Any::Permissions => Some(op_permissions),
msg::Any::Read => op_read, msg::Any::Read => Some(op_read),
msg::Any::ReadDir => op_read_dir, msg::Any::ReadDir => Some(op_read_dir),
msg::Any::ReadFile => op_read_file, msg::Any::ReadFile => Some(op_read_file),
msg::Any::Readlink => op_read_link, msg::Any::Readlink => Some(op_read_link),
msg::Any::Remove => op_remove, msg::Any::Remove => Some(op_remove),
msg::Any::Rename => op_rename, msg::Any::Rename => Some(op_rename),
msg::Any::ReplReadline => op_repl_readline, msg::Any::ReplReadline => Some(op_repl_readline),
msg::Any::ReplStart => op_repl_start, msg::Any::ReplStart => Some(op_repl_start),
msg::Any::Resources => op_resources, msg::Any::Resources => Some(op_resources),
msg::Any::Run => op_run, msg::Any::Run => Some(op_run),
msg::Any::RunStatus => op_run_status, msg::Any::RunStatus => Some(op_run_status),
msg::Any::Seek => op_seek, msg::Any::Seek => Some(op_seek),
msg::Any::SetEnv => op_set_env, msg::Any::SetEnv => Some(op_set_env),
msg::Any::Shutdown => op_shutdown, msg::Any::Shutdown => Some(op_shutdown),
msg::Any::Start => op_start, msg::Any::Start => Some(op_start),
msg::Any::Stat => op_stat, msg::Any::Stat => Some(op_stat),
msg::Any::Symlink => op_symlink, msg::Any::Symlink => Some(op_symlink),
msg::Any::Truncate => op_truncate, msg::Any::Truncate => Some(op_truncate),
msg::Any::WorkerGetMessage => op_worker_get_message, msg::Any::WorkerGetMessage => Some(op_worker_get_message),
msg::Any::WorkerPostMessage => op_worker_post_message, msg::Any::WorkerPostMessage => Some(op_worker_post_message),
msg::Any::Write => op_write, msg::Any::Write => Some(op_write),
msg::Any::WriteFile => op_write_file, msg::Any::WriteFile => Some(op_write_file),
_ => return Err(op_not_implemented()), _ => None,
}; }
Ok(Box::new(op_creator))
} }
fn op_now( fn op_now(
_sc: Box<&IsolateStateContainer>, _sc: &IsolateStateContainer,
base: &msg::Base<'_>, base: &msg::Base<'_>,
data: deno_buf, data: deno_buf,
) -> Box<OpWithError> { ) -> Box<OpWithError> {
@ -233,7 +223,7 @@ fn op_now(
} }
fn op_is_tty( fn op_is_tty(
_sc: Box<&IsolateStateContainer>, _sc: &IsolateStateContainer,
base: &msg::Base<'_>, base: &msg::Base<'_>,
_data: deno_buf, _data: deno_buf,
) -> Box<OpWithError> { ) -> Box<OpWithError> {
@ -258,7 +248,7 @@ fn op_is_tty(
} }
fn op_exit( fn op_exit(
_sc: Box<&IsolateStateContainer>, _sc: &IsolateStateContainer,
base: &msg::Base<'_>, base: &msg::Base<'_>,
_data: deno_buf, _data: deno_buf,
) -> Box<OpWithError> { ) -> Box<OpWithError> {
@ -267,7 +257,7 @@ fn op_exit(
} }
fn op_start( fn op_start(
sc: Box<&IsolateStateContainer>, sc: &IsolateStateContainer,
base: &msg::Base<'_>, base: &msg::Base<'_>,
data: deno_buf, data: deno_buf,
) -> Box<OpWithError> { ) -> Box<OpWithError> {
@ -323,7 +313,7 @@ fn op_start(
} }
fn op_format_error( fn op_format_error(
sc: Box<&IsolateStateContainer>, sc: &IsolateStateContainer,
base: &msg::Base<'_>, base: &msg::Base<'_>,
data: deno_buf, data: deno_buf,
) -> Box<OpWithError> { ) -> Box<OpWithError> {
@ -342,7 +332,6 @@ fn op_format_error(
&mut builder, &mut builder,
&msg::FormatErrorResArgs { &msg::FormatErrorResArgs {
error: Some(new_error), 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 // https://github.com/denoland/deno/blob/golang/os.go#L100-L154
fn op_fetch_module_meta_data( fn op_fetch_module_meta_data(
sc: Box<&IsolateStateContainer>, sc: &IsolateStateContainer,
base: &msg::Base<'_>, base: &msg::Base<'_>,
data: deno_buf, data: deno_buf,
) -> Box<OpWithError> { ) -> Box<OpWithError> {
@ -423,7 +412,7 @@ fn op_fetch_module_meta_data(
} }
fn op_chdir( fn op_chdir(
_sc: Box<&IsolateStateContainer>, _sc: &IsolateStateContainer,
base: &msg::Base<'_>, base: &msg::Base<'_>,
data: deno_buf, data: deno_buf,
) -> Box<OpWithError> { ) -> Box<OpWithError> {
@ -437,7 +426,7 @@ fn op_chdir(
} }
fn op_global_timer_stop( fn op_global_timer_stop(
sc: Box<&IsolateStateContainer>, sc: &IsolateStateContainer,
base: &msg::Base<'_>, base: &msg::Base<'_>,
data: deno_buf, data: deno_buf,
) -> Box<OpWithError> { ) -> Box<OpWithError> {
@ -450,7 +439,7 @@ fn op_global_timer_stop(
} }
fn op_global_timer( fn op_global_timer(
sc: Box<&IsolateStateContainer>, sc: &IsolateStateContainer,
base: &msg::Base<'_>, base: &msg::Base<'_>,
data: deno_buf, data: deno_buf,
) -> Box<OpWithError> { ) -> Box<OpWithError> {
@ -483,7 +472,7 @@ fn op_global_timer(
} }
fn op_set_env( fn op_set_env(
sc: Box<&IsolateStateContainer>, sc: &IsolateStateContainer,
base: &msg::Base<'_>, base: &msg::Base<'_>,
data: deno_buf, data: deno_buf,
) -> Box<OpWithError> { ) -> Box<OpWithError> {
@ -499,7 +488,7 @@ fn op_set_env(
} }
fn op_env( fn op_env(
sc: Box<&IsolateStateContainer>, sc: &IsolateStateContainer,
base: &msg::Base<'_>, base: &msg::Base<'_>,
data: deno_buf, data: deno_buf,
) -> Box<OpWithError> { ) -> Box<OpWithError> {
@ -531,7 +520,7 @@ fn op_env(
} }
fn op_permissions( fn op_permissions(
sc: Box<&IsolateStateContainer>, sc: &IsolateStateContainer,
base: &msg::Base<'_>, base: &msg::Base<'_>,
data: deno_buf, data: deno_buf,
) -> Box<OpWithError> { ) -> Box<OpWithError> {
@ -560,7 +549,7 @@ fn op_permissions(
} }
fn op_revoke_permission( fn op_revoke_permission(
sc: Box<&IsolateStateContainer>, sc: &IsolateStateContainer,
base: &msg::Base<'_>, base: &msg::Base<'_>,
data: deno_buf, data: deno_buf,
) -> Box<OpWithError> { ) -> Box<OpWithError> {
@ -582,7 +571,7 @@ fn op_revoke_permission(
} }
fn op_fetch( fn op_fetch(
sc: Box<&IsolateStateContainer>, sc: &IsolateStateContainer,
base: &msg::Base<'_>, base: &msg::Base<'_>,
data: deno_buf, data: deno_buf,
) -> Box<OpWithError> { ) -> Box<OpWithError> {
@ -669,7 +658,7 @@ where
} }
fn op_make_temp_dir( fn op_make_temp_dir(
sc: Box<&IsolateStateContainer>, sc: &IsolateStateContainer,
base: &msg::Base<'_>, base: &msg::Base<'_>,
data: deno_buf, data: deno_buf,
) -> Box<OpWithError> { ) -> Box<OpWithError> {
@ -718,7 +707,7 @@ fn op_make_temp_dir(
} }
fn op_mkdir( fn op_mkdir(
sc: Box<&IsolateStateContainer>, sc: &IsolateStateContainer,
base: &msg::Base<'_>, base: &msg::Base<'_>,
data: deno_buf, data: deno_buf,
) -> Box<OpWithError> { ) -> Box<OpWithError> {
@ -740,7 +729,7 @@ fn op_mkdir(
} }
fn op_chmod( fn op_chmod(
sc: Box<&IsolateStateContainer>, sc: &IsolateStateContainer,
base: &msg::Base<'_>, base: &msg::Base<'_>,
data: deno_buf, data: deno_buf,
) -> Box<OpWithError> { ) -> Box<OpWithError> {
@ -779,7 +768,7 @@ fn op_chmod(
} }
fn op_open( fn op_open(
sc: Box<&IsolateStateContainer>, sc: &IsolateStateContainer,
base: &msg::Base<'_>, base: &msg::Base<'_>,
data: deno_buf, data: deno_buf,
) -> Box<OpWithError> { ) -> Box<OpWithError> {
@ -869,7 +858,7 @@ fn op_open(
} }
fn op_close( fn op_close(
_sc: Box<&IsolateStateContainer>, _sc: &IsolateStateContainer,
base: &msg::Base<'_>, base: &msg::Base<'_>,
data: deno_buf, data: deno_buf,
) -> Box<OpWithError> { ) -> Box<OpWithError> {
@ -886,7 +875,7 @@ fn op_close(
} }
fn op_shutdown( fn op_shutdown(
_sc: Box<&IsolateStateContainer>, _sc: &IsolateStateContainer,
base: &msg::Base<'_>, base: &msg::Base<'_>,
data: deno_buf, data: deno_buf,
) -> Box<OpWithError> { ) -> Box<OpWithError> {
@ -912,7 +901,7 @@ fn op_shutdown(
} }
fn op_read( fn op_read(
_sc: Box<&IsolateStateContainer>, _sc: &IsolateStateContainer,
base: &msg::Base<'_>, base: &msg::Base<'_>,
data: deno_buf, data: deno_buf,
) -> Box<OpWithError> { ) -> Box<OpWithError> {
@ -950,7 +939,7 @@ fn op_read(
} }
fn op_write( fn op_write(
_sc: Box<&IsolateStateContainer>, _sc: &IsolateStateContainer,
base: &msg::Base<'_>, base: &msg::Base<'_>,
data: deno_buf, data: deno_buf,
) -> Box<OpWithError> { ) -> Box<OpWithError> {
@ -987,7 +976,7 @@ fn op_write(
} }
fn op_seek( fn op_seek(
_sc: Box<&IsolateStateContainer>, _sc: &IsolateStateContainer,
base: &msg::Base<'_>, base: &msg::Base<'_>,
data: deno_buf, data: deno_buf,
) -> Box<OpWithError> { ) -> Box<OpWithError> {
@ -1009,7 +998,7 @@ fn op_seek(
} }
fn op_remove( fn op_remove(
sc: Box<&IsolateStateContainer>, sc: &IsolateStateContainer,
base: &msg::Base<'_>, base: &msg::Base<'_>,
data: deno_buf, data: deno_buf,
) -> Box<OpWithError> { ) -> Box<OpWithError> {
@ -1039,7 +1028,7 @@ fn op_remove(
// Prototype https://github.com/denoland/deno/blob/golang/os.go#L171-L184 // Prototype https://github.com/denoland/deno/blob/golang/os.go#L171-L184
fn op_read_file( fn op_read_file(
sc: Box<&IsolateStateContainer>, sc: &IsolateStateContainer,
base: &msg::Base<'_>, base: &msg::Base<'_>,
data: deno_buf, data: deno_buf,
) -> Box<OpWithError> { ) -> Box<OpWithError> {
@ -1077,7 +1066,7 @@ fn op_read_file(
} }
fn op_copy_file( fn op_copy_file(
sc: Box<&IsolateStateContainer>, sc: &IsolateStateContainer,
base: &msg::Base<'_>, base: &msg::Base<'_>,
data: deno_buf, data: deno_buf,
) -> Box<OpWithError> { ) -> Box<OpWithError> {
@ -1133,7 +1122,7 @@ fn get_mode(_perm: &fs::Permissions) -> u32 {
} }
fn op_cwd( fn op_cwd(
_sc: Box<&IsolateStateContainer>, _sc: &IsolateStateContainer,
base: &msg::Base<'_>, base: &msg::Base<'_>,
data: deno_buf, data: deno_buf,
) -> Box<OpWithError> { ) -> Box<OpWithError> {
@ -1159,7 +1148,7 @@ fn op_cwd(
} }
fn op_stat( fn op_stat(
sc: Box<&IsolateStateContainer>, sc: &IsolateStateContainer,
base: &msg::Base<'_>, base: &msg::Base<'_>,
data: deno_buf, data: deno_buf,
) -> Box<OpWithError> { ) -> Box<OpWithError> {
@ -1211,7 +1200,7 @@ fn op_stat(
} }
fn op_read_dir( fn op_read_dir(
sc: Box<&IsolateStateContainer>, sc: &IsolateStateContainer,
base: &msg::Base<'_>, base: &msg::Base<'_>,
data: deno_buf, data: deno_buf,
) -> Box<OpWithError> { ) -> Box<OpWithError> {
@ -1272,7 +1261,7 @@ fn op_read_dir(
} }
fn op_write_file( fn op_write_file(
sc: Box<&IsolateStateContainer>, sc: &IsolateStateContainer,
base: &msg::Base<'_>, base: &msg::Base<'_>,
data: deno_buf, data: deno_buf,
) -> Box<OpWithError> { ) -> Box<OpWithError> {
@ -1302,7 +1291,7 @@ fn op_write_file(
} }
fn op_rename( fn op_rename(
sc: Box<&IsolateStateContainer>, sc: &IsolateStateContainer,
base: &msg::Base<'_>, base: &msg::Base<'_>,
data: deno_buf, data: deno_buf,
) -> Box<OpWithError> { ) -> Box<OpWithError> {
@ -1322,7 +1311,7 @@ fn op_rename(
} }
fn op_symlink( fn op_symlink(
sc: Box<&IsolateStateContainer>, sc: &IsolateStateContainer,
base: &msg::Base<'_>, base: &msg::Base<'_>,
data: deno_buf, data: deno_buf,
) -> Box<OpWithError> { ) -> Box<OpWithError> {
@ -1351,7 +1340,7 @@ fn op_symlink(
} }
fn op_read_link( fn op_read_link(
sc: Box<&IsolateStateContainer>, sc: &IsolateStateContainer,
base: &msg::Base<'_>, base: &msg::Base<'_>,
data: deno_buf, data: deno_buf,
) -> Box<OpWithError> { ) -> Box<OpWithError> {
@ -1389,7 +1378,7 @@ fn op_read_link(
} }
fn op_repl_start( fn op_repl_start(
sc: Box<&IsolateStateContainer>, sc: &IsolateStateContainer,
base: &msg::Base<'_>, base: &msg::Base<'_>,
data: deno_buf, data: deno_buf,
) -> Box<OpWithError> { ) -> Box<OpWithError> {
@ -1420,7 +1409,7 @@ fn op_repl_start(
} }
fn op_repl_readline( fn op_repl_readline(
_sc: Box<&IsolateStateContainer>, _sc: &IsolateStateContainer,
base: &msg::Base<'_>, base: &msg::Base<'_>,
data: deno_buf, data: deno_buf,
) -> Box<OpWithError> { ) -> Box<OpWithError> {
@ -1456,7 +1445,7 @@ fn op_repl_readline(
} }
fn op_truncate( fn op_truncate(
sc: Box<&IsolateStateContainer>, sc: &IsolateStateContainer,
base: &msg::Base<'_>, base: &msg::Base<'_>,
data: deno_buf, data: deno_buf,
) -> Box<OpWithError> { ) -> Box<OpWithError> {
@ -1479,7 +1468,7 @@ fn op_truncate(
} }
fn op_listen( fn op_listen(
sc: Box<&IsolateStateContainer>, sc: &IsolateStateContainer,
base: &msg::Base<'_>, base: &msg::Base<'_>,
data: deno_buf, data: deno_buf,
) -> Box<OpWithError> { ) -> Box<OpWithError> {
@ -1541,7 +1530,7 @@ fn new_conn(cmd_id: u32, tcp_stream: TcpStream) -> OpResult {
} }
fn op_accept( fn op_accept(
sc: Box<&IsolateStateContainer>, sc: &IsolateStateContainer,
base: &msg::Base<'_>, base: &msg::Base<'_>,
data: deno_buf, data: deno_buf,
) -> Box<OpWithError> { ) -> Box<OpWithError> {
@ -1567,7 +1556,7 @@ fn op_accept(
} }
fn op_dial( fn op_dial(
sc: Box<&IsolateStateContainer>, sc: &IsolateStateContainer,
base: &msg::Base<'_>, base: &msg::Base<'_>,
data: deno_buf, data: deno_buf,
) -> Box<OpWithError> { ) -> Box<OpWithError> {
@ -1593,7 +1582,7 @@ fn op_dial(
} }
fn op_metrics( fn op_metrics(
sc: Box<&IsolateStateContainer>, sc: &IsolateStateContainer,
base: &msg::Base<'_>, base: &msg::Base<'_>,
data: deno_buf, data: deno_buf,
) -> Box<OpWithError> { ) -> Box<OpWithError> {
@ -1617,7 +1606,7 @@ fn op_metrics(
} }
fn op_resources( fn op_resources(
_sc: Box<&IsolateStateContainer>, _sc: &IsolateStateContainer,
base: &msg::Base<'_>, base: &msg::Base<'_>,
data: deno_buf, data: deno_buf,
) -> Box<OpWithError> { ) -> Box<OpWithError> {
@ -1669,7 +1658,7 @@ fn subprocess_stdio_map(v: msg::ProcessStdio) -> std::process::Stdio {
} }
fn op_run( fn op_run(
sc: Box<&IsolateStateContainer>, sc: &IsolateStateContainer,
base: &msg::Base<'_>, base: &msg::Base<'_>,
data: deno_buf, data: deno_buf,
) -> Box<OpWithError> { ) -> Box<OpWithError> {
@ -1742,7 +1731,7 @@ fn op_run(
} }
fn op_run_status( fn op_run_status(
sc: Box<&IsolateStateContainer>, sc: &IsolateStateContainer,
base: &msg::Base<'_>, base: &msg::Base<'_>,
data: deno_buf, data: deno_buf,
) -> Box<OpWithError> { ) -> Box<OpWithError> {
@ -1818,7 +1807,7 @@ impl Future for GetMessageFuture {
} }
fn op_worker_get_message( fn op_worker_get_message(
sc: Box<&IsolateStateContainer>, sc: &IsolateStateContainer,
base: &msg::Base<'_>, base: &msg::Base<'_>,
data: deno_buf, data: deno_buf,
) -> Box<OpWithError> { ) -> Box<OpWithError> {
@ -1852,7 +1841,7 @@ fn op_worker_get_message(
} }
fn op_worker_post_message( fn op_worker_post_message(
sc: Box<&IsolateStateContainer>, sc: &IsolateStateContainer,
base: &msg::Base<'_>, base: &msg::Base<'_>,
data: deno_buf, data: deno_buf,
) -> Box<OpWithError> { ) -> Box<OpWithError> {

View file

@ -31,9 +31,10 @@ impl From<usize> for PermissionAccessorState {
impl From<bool> for PermissionAccessorState { impl From<bool> for PermissionAccessorState {
fn from(val: bool) -> Self { fn from(val: bool) -> Self {
match val { if val {
true => PermissionAccessorState::Allow, PermissionAccessorState::Allow
false => PermissionAccessorState::Ask, } else {
PermissionAccessorState::Ask
} }
} }
} }
@ -243,48 +244,48 @@ impl DenoPermissions {
} }
pub fn allows_run(&self) -> bool { pub fn allows_run(&self) -> bool {
return self.allow_run.is_allow(); self.allow_run.is_allow()
} }
pub fn allows_read(&self) -> bool { pub fn allows_read(&self) -> bool {
return self.allow_read.is_allow(); self.allow_read.is_allow()
} }
pub fn allows_write(&self) -> bool { pub fn allows_write(&self) -> bool {
return self.allow_write.is_allow(); self.allow_write.is_allow()
} }
pub fn allows_net(&self) -> bool { pub fn allows_net(&self) -> bool {
return self.allow_net.is_allow(); self.allow_net.is_allow()
} }
pub fn allows_env(&self) -> bool { pub fn allows_env(&self) -> bool {
return self.allow_env.is_allow(); self.allow_env.is_allow()
} }
pub fn revoke_run(&self) -> DenoResult<()> { pub fn revoke_run(&self) -> DenoResult<()> {
self.allow_run.revoke(); self.allow_run.revoke();
return Ok(()); Ok(())
} }
pub fn revoke_read(&self) -> DenoResult<()> { pub fn revoke_read(&self) -> DenoResult<()> {
self.allow_read.revoke(); self.allow_read.revoke();
return Ok(()); Ok(())
} }
pub fn revoke_write(&self) -> DenoResult<()> { pub fn revoke_write(&self) -> DenoResult<()> {
self.allow_write.revoke(); self.allow_write.revoke();
return Ok(()); Ok(())
} }
pub fn revoke_net(&self) -> DenoResult<()> { pub fn revoke_net(&self) -> DenoResult<()> {
self.allow_net.revoke(); self.allow_net.revoke();
return Ok(()); Ok(())
} }
pub fn revoke_env(&self) -> DenoResult<()> { pub fn revoke_env(&self) -> DenoResult<()> {
self.allow_env.revoke(); self.allow_env.revoke();
return Ok(()); Ok(())
} }
} }

View file

@ -451,8 +451,8 @@ pub fn seek(
Some(Repr::FsFile(f)) => { Some(Repr::FsFile(f)) => {
let seek_from = match whence { let seek_from = match whence {
0 => SeekFrom::Start(offset as u64), 0 => SeekFrom::Start(offset as u64),
1 => SeekFrom::Current(offset as i64), 1 => SeekFrom::Current(i64::from(offset)),
2 => SeekFrom::End(offset as i64), 2 => SeekFrom::End(i64::from(offset)),
_ => { _ => {
return Box::new(futures::future::err(errors::new( return Box::new(futures::future::err(errors::new(
errors::ErrorKind::InvalidSeekMode, errors::ErrorKind::InvalidSeekMode,
@ -481,14 +481,13 @@ pub fn seek(
))); )));
} }
let mut std_file_copy = maybe_std_file_copy.unwrap(); 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 let result = std_file_copy
.seek(seek_from) .seek(seek_from)
.map(|_| { .map(|_| {})
return (); .map_err(DenoError::from);
}).map_err(DenoError::from);
futures::future::result(result) futures::future::result(result)
})); }))
} }
_ => panic!("cannot seek"), _ => panic!("cannot seek"),
} }