1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-25 08:39:09 -05:00

chore: use Rust 1.65.0 (#16688)

This commit is contained in:
Aaron O'Mullan 2022-11-17 22:59:10 -03:00 committed by Bartek Iwańczuk
parent 2743d42099
commit 53cfa8096f
No known key found for this signature in database
GPG key ID: 0C6BCDDC3B3AD750
48 changed files with 119 additions and 130 deletions

View file

@ -157,15 +157,15 @@ jobs:
# to complete. # to complete.
sudo apt-get remove --purge -y man-db sudo apt-get remove --purge -y man-db
# Install clang-14, lld-14, and debootstrap. # Install clang-15, lld-15, and debootstrap.
echo "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main" | echo "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-15 main" |
sudo dd of=/etc/apt/sources.list.d/llvm-toolchain-focal-14.list sudo dd of=/etc/apt/sources.list.d/llvm-toolchain-focal-15.list
curl https://apt.llvm.org/llvm-snapshot.gpg.key | curl https://apt.llvm.org/llvm-snapshot.gpg.key |
gpg --dearmor | gpg --dearmor |
sudo dd of=/etc/apt/trusted.gpg.d/llvm-snapshot.gpg sudo dd of=/etc/apt/trusted.gpg.d/llvm-snapshot.gpg
sudo apt-get update sudo apt-get update
sudo apt-get install --no-install-recommends debootstrap \ sudo apt-get install --no-install-recommends debootstrap \
clang-14 lld-14 clang-15 lld-15
# Create ubuntu-16.04 sysroot environment, which is used to avoid # Create ubuntu-16.04 sysroot environment, which is used to avoid
# depending on a very recent version of glibc. # depending on a very recent version of glibc.
@ -190,8 +190,8 @@ jobs:
CARGO_PROFILE_RELEASE_LTO=false CARGO_PROFILE_RELEASE_LTO=false
RUSTFLAGS<<__1 RUSTFLAGS<<__1
-C linker-plugin-lto=true -C linker-plugin-lto=true
-C linker=clang-14 -C linker=clang-15
-C link-arg=-fuse-ld=lld-14 -C link-arg=-fuse-ld=lld-15
-C link-arg=--sysroot=/sysroot -C link-arg=--sysroot=/sysroot
-C link-arg=-Wl,--allow-shlib-undefined -C link-arg=-Wl,--allow-shlib-undefined
-C link-arg=-Wl,--thinlto-cache-dir=$(pwd)/target/release/lto-cache -C link-arg=-Wl,--thinlto-cache-dir=$(pwd)/target/release/lto-cache
@ -200,15 +200,15 @@ jobs:
__1 __1
RUSTDOCFLAGS<<__1 RUSTDOCFLAGS<<__1
-C linker-plugin-lto=true -C linker-plugin-lto=true
-C linker=clang-14 -C linker=clang-15
-C link-arg=-fuse-ld=lld-14 -C link-arg=-fuse-ld=lld-15
-C link-arg=--sysroot=/sysroot -C link-arg=--sysroot=/sysroot
-C link-arg=-Wl,--allow-shlib-undefined -C link-arg=-Wl,--allow-shlib-undefined
-C link-arg=-Wl,--thinlto-cache-dir=$(pwd)/target/release/lto-cache -C link-arg=-Wl,--thinlto-cache-dir=$(pwd)/target/release/lto-cache
-C link-arg=-Wl,--thinlto-cache-policy,cache_size_bytes=700m -C link-arg=-Wl,--thinlto-cache-policy,cache_size_bytes=700m
${{ env.RUSTFLAGS }} ${{ env.RUSTFLAGS }}
__1 __1
CC=clang-14 CC=clang-15
CFLAGS=-flto=thin --sysroot=/sysroot CFLAGS=-flto=thin --sysroot=/sysroot
__0 __0

View file

@ -637,7 +637,7 @@ fn clap_root(version: &str) -> Command {
.help("Set log level") .help("Set log level")
.hide(true) .hide(true)
.takes_value(true) .takes_value(true)
.possible_values(&["debug", "info"]) .possible_values(["debug", "info"])
.global(true), .global(true),
) )
.arg( .arg(
@ -811,7 +811,7 @@ fn compile_subcommand<'a>() -> Command<'a> {
.long("target") .long("target")
.help("Target OS architecture") .help("Target OS architecture")
.takes_value(true) .takes_value(true)
.possible_values(&[ .possible_values([
"x86_64-unknown-linux-gnu", "x86_64-unknown-linux-gnu",
"x86_64-pc-windows-msvc", "x86_64-pc-windows-msvc",
"x86_64-apple-darwin", "x86_64-apple-darwin",
@ -848,7 +848,7 @@ fn completions_subcommand<'a>() -> Command<'a> {
.disable_help_subcommand(true) .disable_help_subcommand(true)
.arg( .arg(
Arg::new("shell") Arg::new("shell")
.possible_values(&["bash", "fish", "powershell", "zsh", "fig"]) .possible_values(["bash", "fish", "powershell", "zsh", "fig"])
.required(true), .required(true),
) )
.about("Generate shell completions") .about("Generate shell completions")
@ -1049,7 +1049,7 @@ This command has implicit access to all permissions (--allow-all).",
.help("Set standard input (stdin) content type") .help("Set standard input (stdin) content type")
.takes_value(true) .takes_value(true)
.default_value("js") .default_value("js")
.possible_values(&["ts", "tsx", "js", "jsx"]), .possible_values(["ts", "tsx", "js", "jsx"]),
) )
.arg( .arg(
Arg::new("print") Arg::new("print")
@ -1106,7 +1106,7 @@ Ignore formatting a file by adding an ignore comment at the top of the file:
.help("Set standard input (stdin) content type") .help("Set standard input (stdin) content type")
.takes_value(true) .takes_value(true)
.default_value("ts") .default_value("ts")
.possible_values(&["ts", "tsx", "js", "jsx", "md", "json", "jsonc"]), .possible_values(["ts", "tsx", "js", "jsx", "md", "json", "jsonc"]),
) )
.arg( .arg(
Arg::new("ignore") Arg::new("ignore")
@ -1165,7 +1165,7 @@ Ignore formatting a file by adding an ignore comment at the top of the file:
Arg::new("options-prose-wrap") Arg::new("options-prose-wrap")
.long("options-prose-wrap") .long("options-prose-wrap")
.takes_value(true) .takes_value(true)
.possible_values(&["always", "never", "preserve"]) .possible_values(["always", "never", "preserve"])
.help("Define how prose should be wrapped. Defaults to always."), .help("Define how prose should be wrapped. Defaults to always."),
) )
} }

View file

@ -343,7 +343,7 @@ fn run_max_mem_benchmark(deno_exe: &Path) -> Result<HashMap<String, i64>> {
for (name, args, return_code) in EXEC_TIME_BENCHMARKS { for (name, args, return_code) in EXEC_TIME_BENCHMARKS {
let proc = Command::new("time") let proc = Command::new("time")
.args(&["-v", deno_exe.to_str().unwrap()]) .args(["-v", deno_exe.to_str().unwrap()])
.args(args.iter()) .args(args.iter())
.stdout(Stdio::null()) .stdout(Stdio::null())
.stderr(Stdio::piped()) .stderr(Stdio::piped())
@ -501,7 +501,7 @@ async fn main() -> Result<()> {
let mut file = secure_tempfile::NamedTempFile::new()?; let mut file = secure_tempfile::NamedTempFile::new()?;
let exit_status = Command::new("strace") let exit_status = Command::new("strace")
.args(&[ .args([
"-c", "-c",
"-f", "-f",
"-o", "-o",

View file

@ -39,7 +39,7 @@ fn create_snapshot(
} }
let snapshot = js_runtime.snapshot(); let snapshot = js_runtime.snapshot();
let snapshot_slice: &[u8] = &*snapshot; let snapshot_slice: &[u8] = &snapshot;
println!("Snapshot size: {}", snapshot_slice.len()); println!("Snapshot size: {}", snapshot_slice.len());
let compressed_snapshot_with_size = { let compressed_snapshot_with_size = {
@ -64,7 +64,7 @@ fn create_snapshot(
compressed_snapshot_with_size.len() compressed_snapshot_with_size.len()
); );
std::fs::write(&snapshot_path, compressed_snapshot_with_size).unwrap(); std::fs::write(snapshot_path, compressed_snapshot_with_size).unwrap();
println!("Snapshot written to: {} ", snapshot_path.display()); println!("Snapshot written to: {} ", snapshot_path.display());
} }

View file

@ -40,7 +40,7 @@ impl DiskCache {
if path.is_dir() { if path.is_dir() {
return Ok(()); return Ok(());
} }
fs::create_dir_all(&path).map_err(|e| { fs::create_dir_all(path).map_err(|e| {
io::Error::new(e.kind(), format!( io::Error::new(e.kind(), format!(
"Could not create TypeScript compiler cache location: {:?}\nCheck the permission of the directory.", "Could not create TypeScript compiler cache location: {:?}\nCheck the permission of the directory.",
path path

View file

@ -333,9 +333,9 @@ pub async fn remove_dir_all_if_exists(path: &Path) -> std::io::Result<()> {
/// ///
/// Note: Does not handle symlinks. /// Note: Does not handle symlinks.
pub fn copy_dir_recursive(from: &Path, to: &Path) -> Result<(), AnyError> { pub fn copy_dir_recursive(from: &Path, to: &Path) -> Result<(), AnyError> {
std::fs::create_dir_all(&to) std::fs::create_dir_all(to)
.with_context(|| format!("Creating {}", to.display()))?; .with_context(|| format!("Creating {}", to.display()))?;
let read_dir = std::fs::read_dir(&from) let read_dir = std::fs::read_dir(from)
.with_context(|| format!("Reading {}", from.display()))?; .with_context(|| format!("Reading {}", from.display()))?;
for entry in read_dir { for entry in read_dir {
@ -362,9 +362,9 @@ pub fn copy_dir_recursive(from: &Path, to: &Path) -> Result<(), AnyError> {
/// ///
/// Note: Does not handle symlinks. /// Note: Does not handle symlinks.
pub fn hard_link_dir_recursive(from: &Path, to: &Path) -> Result<(), AnyError> { pub fn hard_link_dir_recursive(from: &Path, to: &Path) -> Result<(), AnyError> {
std::fs::create_dir_all(&to) std::fs::create_dir_all(to)
.with_context(|| format!("Creating {}", to.display()))?; .with_context(|| format!("Creating {}", to.display()))?;
let read_dir = std::fs::read_dir(&from) let read_dir = std::fs::read_dir(from)
.with_context(|| format!("Reading {}", from.display()))?; .with_context(|| format!("Reading {}", from.display()))?;
for entry in read_dir { for entry in read_dir {
@ -451,7 +451,7 @@ pub fn symlink_dir(oldpath: &Path, newpath: &Path) -> Result<(), AnyError> {
#[cfg(unix)] #[cfg(unix)]
{ {
use std::os::unix::fs::symlink; use std::os::unix::fs::symlink;
symlink(&oldpath, &newpath).map_err(err_mapper)?; symlink(oldpath, newpath).map_err(err_mapper)?;
} }
#[cfg(not(unix))] #[cfg(not(unix))]
{ {

View file

@ -123,7 +123,7 @@ impl HttpCache {
if path.is_dir() { if path.is_dir() {
return Ok(()); return Ok(());
} }
fs::create_dir_all(&path).map_err(|e| { fs::create_dir_all(path).map_err(|e| {
io::Error::new( io::Error::new(
e.kind(), e.kind(),
format!( format!(

View file

@ -469,7 +469,7 @@ fn get_workspace_completions(
specifier_strings specifier_strings
.into_iter() .into_iter()
.filter_map(|label| { .filter_map(|label| {
if label.starts_with(&current) { if label.starts_with(current) {
let detail = Some( let detail = Some(
if label.starts_with("http:") || label.starts_with("https:") { if label.starts_with("http:") || label.starts_with("https:") {
"(remote)".to_string() "(remote)".to_string()

View file

@ -877,7 +877,7 @@ mod tests {
assert!(result.is_ok(), "Could not parse path: \"{}\"", path); assert!(result.is_ok(), "Could not parse path: \"{}\"", path);
let (re, _) = result.unwrap(); let (re, _) = result.unwrap();
for (fixture, expected) in fixtures { for (fixture, expected) in fixtures {
let result = re.find(*fixture); let result = re.find(fixture);
assert!( assert!(
result.is_ok(), result.is_ok(),
"Find failure for path \"{}\" and fixture \"{}\"", "Find failure for path \"{}\" and fixture \"{}\"",

View file

@ -772,7 +772,7 @@ async fn test_command(
test_flags: TestFlags, test_flags: TestFlags,
) -> Result<i32, AnyError> { ) -> Result<i32, AnyError> {
if let Some(ref coverage_dir) = flags.coverage_dir { if let Some(ref coverage_dir) = flags.coverage_dir {
std::fs::create_dir_all(&coverage_dir)?; std::fs::create_dir_all(coverage_dir)?;
env::set_var( env::set_var(
"DENO_UNSTABLE_COVERAGE_DIR", "DENO_UNSTABLE_COVERAGE_DIR",
PathBuf::from(coverage_dir).canonicalize()?, PathBuf::from(coverage_dir).canonicalize()?,
@ -994,7 +994,7 @@ pub fn main() {
Err(err) => unwrap_or_exit(Err(AnyError::from(err))), Err(err) => unwrap_or_exit(Err(AnyError::from(err))),
}; };
if !flags.v8_flags.is_empty() { if !flags.v8_flags.is_empty() {
init_v8_flags(&*flags.v8_flags); init_v8_flags(&flags.v8_flags);
} }
logger::init(flags.log_level); logger::init(flags.log_level);

View file

@ -140,7 +140,7 @@ impl CliModuleLoader {
let file_path = specifier.to_file_path().unwrap(); let file_path = specifier.to_file_path().unwrap();
let code = std::fs::read_to_string(&file_path).with_context(|| { let code = std::fs::read_to_string(&file_path).with_context(|| {
let mut msg = "Unable to load ".to_string(); let mut msg = "Unable to load ".to_string();
msg.push_str(&*file_path.to_string_lossy()); msg.push_str(&file_path.to_string_lossy());
if let Some(referrer) = &maybe_referrer { if let Some(referrer) = &maybe_referrer {
msg.push_str(" imported from "); msg.push_str(" imported from ");
msg.push_str(referrer.as_str()); msg.push_str(referrer.as_str());

View file

@ -78,7 +78,7 @@ pub fn with_folder_sync_lock(
match inner(output_folder, action) { match inner(output_folder, action) {
Ok(()) => Ok(()), Ok(()) => Ok(()),
Err(err) => { Err(err) => {
if let Err(remove_err) = fs::remove_dir_all(&output_folder) { if let Err(remove_err) = fs::remove_dir_all(output_folder) {
if remove_err.kind() != std::io::ErrorKind::NotFound { if remove_err.kind() != std::io::ErrorKind::NotFound {
bail!( bail!(
concat!( concat!(
@ -156,7 +156,7 @@ impl ReadonlyNpmCache {
root_dir: &Path, root_dir: &Path,
) -> Result<PathBuf, AnyError> { ) -> Result<PathBuf, AnyError> {
if !root_dir.exists() { if !root_dir.exists() {
std::fs::create_dir_all(&root_dir) std::fs::create_dir_all(root_dir)
.with_context(|| format!("Error creating {}", root_dir.display()))?; .with_context(|| format!("Error creating {}", root_dir.display()))?;
} }
Ok(crate::fs_util::canonicalize_path(root_dir)?) Ok(crate::fs_util::canonicalize_path(root_dir)?)

View file

@ -397,7 +397,7 @@ impl RealNpmRegistryApiInner {
) -> Result<(), AnyError> { ) -> Result<(), AnyError> {
let file_cache_path = self.get_package_file_cache_path(name); let file_cache_path = self.get_package_file_cache_path(name);
let file_text = serde_json::to_string(&package_info)?; let file_text = serde_json::to_string(&package_info)?;
std::fs::create_dir_all(&file_cache_path.parent().unwrap())?; std::fs::create_dir_all(file_cache_path.parent().unwrap())?;
fs_util::atomic_write_file(&file_cache_path, file_text, CACHE_PERM)?; fs_util::atomic_write_file(&file_cache_path, file_text, CACHE_PERM)?;
Ok(()) Ok(())
} }

View file

@ -245,7 +245,7 @@ pub fn resolve_npm_package_reqs(graph: &ModuleGraph) -> Vec<NpmPackageReq> {
for specifier in &specifiers { for specifier in &specifiers {
if let Ok(npm_ref) = NpmPackageReference::from_specifier(specifier) { if let Ok(npm_ref) = NpmPackageReference::from_specifier(specifier) {
leaf.reqs.insert(npm_ref.req); leaf.reqs.insert(npm_ref.req);
} else if !specifier.as_str().starts_with(&parent_specifier.as_str()) { } else if !specifier.as_str().starts_with(parent_specifier.as_str()) {
leaf leaf
.dependencies .dependencies
.insert(get_folder_path_specifier(specifier)); .insert(get_folder_path_specifier(specifier));

View file

@ -104,7 +104,7 @@ pub fn ensure_registry_read_permission(
path: &Path, path: &Path,
) -> Result<(), AnyError> { ) -> Result<(), AnyError> {
// allow reading if it's in the node_modules // allow reading if it's in the node_modules
if path.starts_with(&registry_path) if path.starts_with(registry_path)
&& path && path
.components() .components()
.all(|c| !matches!(c, std::path::Component::ParentDir)) .all(|c| !matches!(c, std::path::Component::ParentDir))

View file

@ -110,8 +110,8 @@ fn extract_tarball(data: &[u8], output_folder: &Path) -> Result<(), AnyError> {
absolute_path.parent().unwrap() absolute_path.parent().unwrap()
}; };
if created_dirs.insert(dir_path.to_path_buf()) { if created_dirs.insert(dir_path.to_path_buf()) {
fs::create_dir_all(&dir_path)?; fs::create_dir_all(dir_path)?;
let canonicalized_dir = fs::canonicalize(&dir_path)?; let canonicalized_dir = fs::canonicalize(dir_path)?;
if !canonicalized_dir.starts_with(&output_folder) { if !canonicalized_dir.starts_with(&output_folder) {
bail!( bail!(
"Extracted directory '{}' of npm tarball was not in output directory.", "Extracted directory '{}' of npm tarball was not in output directory.",

View file

@ -15,7 +15,7 @@ fn info_with_compiled_source() {
.env("DENO_DIR", t.path()) .env("DENO_DIR", t.path())
.current_dir(util::testdata_path()) .current_dir(util::testdata_path())
.arg("cache") .arg("cache")
.arg(&module_path) .arg(module_path)
.spawn() .spawn()
.unwrap(); .unwrap();
let status = deno.wait().unwrap(); let status = deno.wait().unwrap();
@ -26,7 +26,7 @@ fn info_with_compiled_source() {
.env("NO_COLOR", "1") .env("NO_COLOR", "1")
.current_dir(util::testdata_path()) .current_dir(util::testdata_path())
.arg("info") .arg("info")
.arg(&module_path) .arg(module_path)
.output() .output()
.unwrap(); .unwrap();

View file

@ -6077,7 +6077,7 @@ Deno.test({
} }
}); });
"#; "#;
fs::write(&module_path, &contents).unwrap(); fs::write(&module_path, contents).unwrap();
fs::write(temp_dir.path().join("./deno.jsonc"), r#"{}"#).unwrap(); fs::write(temp_dir.path().join("./deno.jsonc"), r#"{}"#).unwrap();
params.root_uri = Some(root_specifier); params.root_uri = Some(root_specifier);

View file

@ -1703,8 +1703,7 @@ fn exec_path() {
.unwrap(); .unwrap();
assert!(output.status.success()); assert!(output.status.success());
let stdout_str = std::str::from_utf8(&output.stdout).unwrap().trim(); let stdout_str = std::str::from_utf8(&output.stdout).unwrap().trim();
let actual = let actual = std::fs::canonicalize(std::path::Path::new(stdout_str)).unwrap();
std::fs::canonicalize(&std::path::Path::new(stdout_str)).unwrap();
let expected = std::fs::canonicalize(util::deno_exe_path()).unwrap(); let expected = std::fs::canonicalize(util::deno_exe_path()).unwrap();
assert_eq!(expected, actual); assert_eq!(expected, actual);
} }

View file

@ -120,7 +120,7 @@ fn upgrade_with_out_in_tmpdir() {
.arg("--version") .arg("--version")
.arg("1.11.5") .arg("1.11.5")
.arg("--output") .arg("--output")
.arg(&new_exe_path.to_str().unwrap()) .arg(new_exe_path.to_str().unwrap())
.spawn() .spawn()
.unwrap() .unwrap()
.wait() .wait()

View file

@ -262,7 +262,7 @@ fn existing_import_map_no_remote() {
let import_map_filename = "imports2.json"; let import_map_filename = "imports2.json";
let import_map_text = let import_map_text =
r#"{ "imports": { "http://localhost:4545/vendor/": "./logger/" } }"#; r#"{ "imports": { "http://localhost:4545/vendor/": "./logger/" } }"#;
t.write(import_map_filename, &import_map_text); t.write(import_map_filename, import_map_text);
t.create_dir_all("logger"); t.create_dir_all("logger");
t.write("logger/logger.ts", "export class Logger {}"); t.write("logger/logger.ts", "export class Logger {}");

View file

@ -219,7 +219,7 @@ fn lint_all_files_on_each_change_test() {
let mut child = util::deno_cmd() let mut child = util::deno_cmd()
.current_dir(util::testdata_path()) .current_dir(util::testdata_path())
.arg("lint") .arg("lint")
.arg(&t.path()) .arg(t.path())
.arg("--watch") .arg("--watch")
.arg("--unstable") .arg("--unstable")
.stdout(std::process::Stdio::piped()) .stdout(std::process::Stdio::piped())
@ -349,7 +349,7 @@ fn fmt_check_all_files_on_each_change_test() {
let mut child = util::deno_cmd() let mut child = util::deno_cmd()
.current_dir(&fmt_testdata_path) .current_dir(&fmt_testdata_path)
.arg("fmt") .arg("fmt")
.arg(&t.path()) .arg(t.path())
.arg("--watch") .arg("--watch")
.arg("--check") .arg("--check")
.arg("--unstable") .arg("--unstable")
@ -832,7 +832,7 @@ fn test_watch() {
.arg("--watch") .arg("--watch")
.arg("--unstable") .arg("--unstable")
.arg("--no-check") .arg("--no-check")
.arg(&t.path()) .arg(t.path())
.env("NO_COLOR", "1") .env("NO_COLOR", "1")
.stdout(std::process::Stdio::piped()) .stdout(std::process::Stdio::piped())
.stderr(std::process::Stdio::piped()) .stderr(std::process::Stdio::piped())
@ -973,7 +973,7 @@ fn test_watch_doc() {
.arg("--watch") .arg("--watch")
.arg("--doc") .arg("--doc")
.arg("--unstable") .arg("--unstable")
.arg(&t.path()) .arg(t.path())
.env("NO_COLOR", "1") .env("NO_COLOR", "1")
.stdout(std::process::Stdio::piped()) .stdout(std::process::Stdio::piped())
.stderr(std::process::Stdio::piped()) .stderr(std::process::Stdio::piped())

View file

@ -210,7 +210,7 @@ impl BenchReporter for ConsoleReporter {
println!(); println!();
} }
if None == self.group || group != self.group.as_ref().unwrap() { if self.group.is_none() || group != self.group.as_ref().unwrap() {
self.report_group_summary(); self.report_group_summary();
} }

View file

@ -126,8 +126,7 @@ pub fn merge_functions(
trees.push(tree); trees.push(tree);
} }
} }
let merged = let merged = RangeTree::normalize(merge_range_trees(&rta, trees).unwrap());
RangeTree::normalize(&rta, merge_range_trees(&rta, trees).unwrap());
let ranges = merged.to_ranges(); let ranges = merged.to_ranges();
let is_block_coverage: bool = !(ranges.len() == 1 && ranges[0].count == 0); let is_block_coverage: bool = !(ranges.len() == 1 && ranges[0].count == 0);

View file

@ -71,10 +71,7 @@ impl<'rt> RangeTree<'rt> {
(rta.alloc(left), rta.alloc(right)) (rta.alloc(left), rta.alloc(right))
} }
pub fn normalize<'a>( pub fn normalize<'a>(tree: &'a mut RangeTree<'a>) -> &'a mut RangeTree<'a> {
rta: &'a RangeTreeArena<'a>,
tree: &'a mut RangeTree<'a>,
) -> &'a mut RangeTree<'a> {
tree.children = { tree.children = {
let mut children: Vec<&'a mut RangeTree<'a>> = Vec::new(); let mut children: Vec<&'a mut RangeTree<'a>> = Vec::new();
let mut chain: Vec<&'a mut RangeTree<'a>> = Vec::new(); let mut chain: Vec<&'a mut RangeTree<'a>> = Vec::new();
@ -96,7 +93,7 @@ impl<'rt> RangeTree<'rt> {
head.children.push(sub_child); head.children.push(sub_child);
} }
} }
children.push(RangeTree::normalize(rta, head)); children.push(RangeTree::normalize(head));
} }
chain.push(child) chain.push(child)
} }
@ -110,7 +107,7 @@ impl<'rt> RangeTree<'rt> {
head.children.push(sub_child); head.children.push(sub_child);
} }
} }
children.push(RangeTree::normalize(rta, head)); children.push(RangeTree::normalize(head));
} }
if children.len() == 1 if children.len() == 1

View file

@ -635,7 +635,7 @@ struct FileContents {
} }
fn read_file_contents(file_path: &Path) -> Result<FileContents, AnyError> { fn read_file_contents(file_path: &Path) -> Result<FileContents, AnyError> {
let file_bytes = fs::read(&file_path) let file_bytes = fs::read(file_path)
.with_context(|| format!("Error reading {}", file_path.display()))?; .with_context(|| format!("Error reading {}", file_path.display()))?;
let charset = text_encoding::detect_charset(&file_bytes); let charset = text_encoding::detect_charset(&file_bytes);
let file_text = text_encoding::convert_to_utf8(&file_bytes, charset)?; let file_text = text_encoding::convert_to_utf8(&file_bytes, charset)?;

View file

@ -85,9 +85,9 @@ async fn download_base_binary(
std::process::exit(1) std::process::exit(1)
}; };
std::fs::create_dir_all(&output_directory)?; std::fs::create_dir_all(output_directory)?;
let output_path = output_directory.join(binary_path_suffix); let output_path = output_directory.join(binary_path_suffix);
std::fs::create_dir_all(&output_path.parent().unwrap())?; std::fs::create_dir_all(output_path.parent().unwrap())?;
tokio::fs::write(output_path, binary_content).await?; tokio::fs::write(output_path, binary_content).await?;
Ok(()) Ok(())
} }

View file

@ -742,9 +742,7 @@ fn extract_files_from_regex_blocks(
let files = blocks_regex let files = blocks_regex
.captures_iter(source) .captures_iter(source)
.filter_map(|block| { .filter_map(|block| {
if block.get(1) == None { block.get(1)?;
return None;
}
let maybe_attributes: Option<Vec<_>> = block let maybe_attributes: Option<Vec<_>> = block
.get(1) .get(1)

View file

@ -502,7 +502,7 @@ mod test {
let output = builder let output = builder
.with_loader(|loader| { .with_loader(|loader| {
loader loader
.add("/mod.ts", &mod_file_text) .add("/mod.ts", mod_file_text)
.add("https://localhost/mod.ts", "export class Example {}"); .add("https://localhost/mod.ts", "export class Example {}");
}) })
.build() .build()

View file

@ -113,7 +113,7 @@ fn validate_options(
.and_then(|p| fs_util::canonicalize_path(&p).ok()) .and_then(|p| fs_util::canonicalize_path(&p).ok())
{ {
// make the output directory in order to canonicalize it for the check below // make the output directory in order to canonicalize it for the check below
std::fs::create_dir_all(&output_dir)?; std::fs::create_dir_all(output_dir)?;
let output_dir = let output_dir =
fs_util::canonicalize_path(output_dir).with_context(|| { fs_util::canonicalize_path(output_dir).with_context(|| {
format!("Failed to canonicalize: {}", output_dir.display()) format!("Failed to canonicalize: {}", output_dir.display())
@ -248,7 +248,7 @@ fn update_config_text(
} }
fn is_dir_empty(dir_path: &Path) -> Result<bool, AnyError> { fn is_dir_empty(dir_path: &Path) -> Result<bool, AnyError> {
match std::fs::read_dir(&dir_path) { match std::fs::read_dir(dir_path) {
Ok(mut dir) => Ok(dir.next().is_none()), Ok(mut dir) => Ok(dir.next().is_none()),
Err(err) if err.kind() == std::io::ErrorKind::NotFound => Ok(true), Err(err) if err.kind() == std::io::ErrorKind::NotFound => Ok(true),
Err(err) => { Err(err) => {

View file

@ -80,7 +80,7 @@ pub static COMPILER_SNAPSHOT: Lazy<Box<[u8]>> = Lazy::new(
); );
pub fn compiler_snapshot() -> Snapshot { pub fn compiler_snapshot() -> Snapshot {
Snapshot::Static(&*COMPILER_SNAPSHOT) Snapshot::Static(&COMPILER_SNAPSHOT)
} }
macro_rules! inc { macro_rules! inc {

View file

@ -220,13 +220,13 @@ impl<T> Deref for RcRef<T> {
impl<T> Borrow<T> for RcRef<T> { impl<T> Borrow<T> for RcRef<T> {
fn borrow(&self) -> &T { fn borrow(&self) -> &T {
&**self self
} }
} }
impl<T> AsRef<T> for RcRef<T> { impl<T> AsRef<T> for RcRef<T> {
fn as_ref(&self) -> &T { fn as_ref(&self) -> &T {
&**self self
} }
} }
@ -478,13 +478,13 @@ mod internal {
impl<T, M: BorrowModeTrait> Borrow<T> for AsyncBorrowImpl<T, M> { impl<T, M: BorrowModeTrait> Borrow<T> for AsyncBorrowImpl<T, M> {
fn borrow(&self) -> &T { fn borrow(&self) -> &T {
&**self self
} }
} }
impl<T, M: BorrowModeTrait> AsRef<T> for AsyncBorrowImpl<T, M> { impl<T, M: BorrowModeTrait> AsRef<T> for AsyncBorrowImpl<T, M> {
fn as_ref(&self) -> &T { fn as_ref(&self) -> &T {
&**self self
} }
} }
@ -500,13 +500,13 @@ mod internal {
impl<T> BorrowMut<T> for AsyncBorrowImpl<T, Exclusive> { impl<T> BorrowMut<T> for AsyncBorrowImpl<T, Exclusive> {
fn borrow_mut(&mut self) -> &mut T { fn borrow_mut(&mut self) -> &mut T {
&mut **self self
} }
} }
impl<T> AsMut<T> for AsyncBorrowImpl<T, Exclusive> { impl<T> AsMut<T> for AsyncBorrowImpl<T, Exclusive> {
fn as_mut(&mut self) -> &mut T { fn as_mut(&mut self) -> &mut T {
&mut **self self
} }
} }

View file

@ -242,7 +242,7 @@ impl JsError {
serde_v8::from_v8(scope, exception.into()).unwrap_or_default(); serde_v8::from_v8(scope, exception.into()).unwrap_or_default();
// Get the message by formatting error.name and error.message. // Get the message by formatting error.name and error.message.
let name = e.name.clone().unwrap_or_else(|| "Error".to_string()); let name = e.name.clone().unwrap_or_else(|| "Error".to_string());
let message_prop = e.message.clone().unwrap_or_else(|| "".to_string()); let message_prop = e.message.clone().unwrap_or_default();
let exception_message = exception_message.unwrap_or_else(|| { let exception_message = exception_message.unwrap_or_else(|| {
if !name.is_empty() && !message_prop.is_empty() { if !name.is_empty() && !message_prop.is_empty() {
format!("Uncaught {}: {}", name, message_prop) format!("Uncaught {}: {}", name, message_prop)

View file

@ -131,7 +131,7 @@ fn create_js_runtime() -> JsRuntime {
fn op_listen(state: &mut OpState) -> Result<ResourceId, Error> { fn op_listen(state: &mut OpState) -> Result<ResourceId, Error> {
log::debug!("listen"); log::debug!("listen");
let addr = "127.0.0.1:4570".parse::<SocketAddr>().unwrap(); let addr = "127.0.0.1:4570".parse::<SocketAddr>().unwrap();
let std_listener = std::net::TcpListener::bind(&addr)?; let std_listener = std::net::TcpListener::bind(addr)?;
std_listener.set_nonblocking(true)?; std_listener.set_nonblocking(true)?;
let listener = TcpListener::try_from(std_listener)?; let listener = TcpListener::try_from(std_listener)?;
let rid = state.resource_table.add(listener); let rid = state.resource_table.add(listener);

View file

@ -2888,7 +2888,7 @@ pub mod tests {
..Default::default() ..Default::default()
}); });
runtime.execute_script("a.js", "a = 1 + 2").unwrap(); runtime.execute_script("a.js", "a = 1 + 2").unwrap();
let snap: &[u8] = &*runtime.snapshot(); let snap: &[u8] = &runtime.snapshot();
Vec::from(snap).into_boxed_slice() Vec::from(snap).into_boxed_slice()
}; };
@ -4051,7 +4051,7 @@ Deno.core.ops.op_async_serialize_object_with_numbers_as_keys({
will_snapshot: true, will_snapshot: true,
..Default::default() ..Default::default()
}); });
let snap: &[u8] = &*runtime.snapshot(); let snap: &[u8] = &runtime.snapshot();
Vec::from(snap).into_boxed_slice() Vec::from(snap).into_boxed_slice()
}; };

View file

@ -198,14 +198,14 @@ pub async fn op_crypto_sign_key(
let signature = match algorithm { let signature = match algorithm {
Algorithm::RsassaPkcs1v15 => { Algorithm::RsassaPkcs1v15 => {
let private_key = RsaPrivateKey::from_pkcs1_der(&*args.key.data)?; let private_key = RsaPrivateKey::from_pkcs1_der(&args.key.data)?;
let (padding, hashed) = match args let (padding, hashed) = match args
.hash .hash
.ok_or_else(|| type_error("Missing argument hash".to_string()))? .ok_or_else(|| type_error("Missing argument hash".to_string()))?
{ {
CryptoHash::Sha1 => { CryptoHash::Sha1 => {
let mut hasher = Sha1::new(); let mut hasher = Sha1::new();
hasher.update(&data); hasher.update(data);
( (
PaddingScheme::PKCS1v15Sign { PaddingScheme::PKCS1v15Sign {
hash: Some(rsa::hash::Hash::SHA1), hash: Some(rsa::hash::Hash::SHA1),
@ -215,7 +215,7 @@ pub async fn op_crypto_sign_key(
} }
CryptoHash::Sha256 => { CryptoHash::Sha256 => {
let mut hasher = Sha256::new(); let mut hasher = Sha256::new();
hasher.update(&data); hasher.update(data);
( (
PaddingScheme::PKCS1v15Sign { PaddingScheme::PKCS1v15Sign {
hash: Some(rsa::hash::Hash::SHA2_256), hash: Some(rsa::hash::Hash::SHA2_256),
@ -225,7 +225,7 @@ pub async fn op_crypto_sign_key(
} }
CryptoHash::Sha384 => { CryptoHash::Sha384 => {
let mut hasher = Sha384::new(); let mut hasher = Sha384::new();
hasher.update(&data); hasher.update(data);
( (
PaddingScheme::PKCS1v15Sign { PaddingScheme::PKCS1v15Sign {
hash: Some(rsa::hash::Hash::SHA2_384), hash: Some(rsa::hash::Hash::SHA2_384),
@ -235,7 +235,7 @@ pub async fn op_crypto_sign_key(
} }
CryptoHash::Sha512 => { CryptoHash::Sha512 => {
let mut hasher = Sha512::new(); let mut hasher = Sha512::new();
hasher.update(&data); hasher.update(data);
( (
PaddingScheme::PKCS1v15Sign { PaddingScheme::PKCS1v15Sign {
hash: Some(rsa::hash::Hash::SHA2_512), hash: Some(rsa::hash::Hash::SHA2_512),
@ -248,7 +248,7 @@ pub async fn op_crypto_sign_key(
private_key.sign(padding, &hashed)? private_key.sign(padding, &hashed)?
} }
Algorithm::RsaPss => { Algorithm::RsaPss => {
let private_key = RsaPrivateKey::from_pkcs1_der(&*args.key.data)?; let private_key = RsaPrivateKey::from_pkcs1_der(&args.key.data)?;
let salt_len = args let salt_len = args
.salt_length .salt_length
@ -262,7 +262,7 @@ pub async fn op_crypto_sign_key(
{ {
CryptoHash::Sha1 => { CryptoHash::Sha1 => {
let mut hasher = Sha1::new(); let mut hasher = Sha1::new();
hasher.update(&data); hasher.update(data);
( (
PaddingScheme::new_pss_with_salt::<Sha1, _>(rng, salt_len), PaddingScheme::new_pss_with_salt::<Sha1, _>(rng, salt_len),
hasher.finalize()[..].to_vec(), hasher.finalize()[..].to_vec(),
@ -270,7 +270,7 @@ pub async fn op_crypto_sign_key(
} }
CryptoHash::Sha256 => { CryptoHash::Sha256 => {
let mut hasher = Sha256::new(); let mut hasher = Sha256::new();
hasher.update(&data); hasher.update(data);
( (
PaddingScheme::new_pss_with_salt::<Sha256, _>(rng, salt_len), PaddingScheme::new_pss_with_salt::<Sha256, _>(rng, salt_len),
hasher.finalize()[..].to_vec(), hasher.finalize()[..].to_vec(),
@ -278,7 +278,7 @@ pub async fn op_crypto_sign_key(
} }
CryptoHash::Sha384 => { CryptoHash::Sha384 => {
let mut hasher = Sha384::new(); let mut hasher = Sha384::new();
hasher.update(&data); hasher.update(data);
( (
PaddingScheme::new_pss_with_salt::<Sha384, _>(rng, salt_len), PaddingScheme::new_pss_with_salt::<Sha384, _>(rng, salt_len),
hasher.finalize()[..].to_vec(), hasher.finalize()[..].to_vec(),
@ -286,7 +286,7 @@ pub async fn op_crypto_sign_key(
} }
CryptoHash::Sha512 => { CryptoHash::Sha512 => {
let mut hasher = Sha512::new(); let mut hasher = Sha512::new();
hasher.update(&data); hasher.update(data);
( (
PaddingScheme::new_pss_with_salt::<Sha512, _>(rng, salt_len), PaddingScheme::new_pss_with_salt::<Sha512, _>(rng, salt_len),
hasher.finalize()[..].to_vec(), hasher.finalize()[..].to_vec(),
@ -301,7 +301,7 @@ pub async fn op_crypto_sign_key(
let curve: &EcdsaSigningAlgorithm = let curve: &EcdsaSigningAlgorithm =
args.named_curve.ok_or_else(not_supported)?.try_into()?; args.named_curve.ok_or_else(not_supported)?.try_into()?;
let key_pair = EcdsaKeyPair::from_pkcs8(curve, &*args.key.data)?; let key_pair = EcdsaKeyPair::from_pkcs8(curve, &args.key.data)?;
// We only support P256-SHA256 & P384-SHA384. These are recommended signature pairs. // We only support P256-SHA256 & P384-SHA384. These are recommended signature pairs.
// https://briansmith.org/rustdoc/ring/signature/index.html#statics // https://briansmith.org/rustdoc/ring/signature/index.html#statics
if let Some(hash) = args.hash { if let Some(hash) = args.hash {
@ -320,7 +320,7 @@ pub async fn op_crypto_sign_key(
Algorithm::Hmac => { Algorithm::Hmac => {
let hash: HmacAlgorithm = args.hash.ok_or_else(not_supported)?.into(); let hash: HmacAlgorithm = args.hash.ok_or_else(not_supported)?.into();
let key = HmacKey::new(hash, &*args.key.data); let key = HmacKey::new(hash, &args.key.data);
let signature = ring::hmac::sign(&key, data); let signature = ring::hmac::sign(&key, data);
signature.as_ref().to_vec() signature.as_ref().to_vec()
@ -359,7 +359,7 @@ pub async fn op_crypto_verify_key(
{ {
CryptoHash::Sha1 => { CryptoHash::Sha1 => {
let mut hasher = Sha1::new(); let mut hasher = Sha1::new();
hasher.update(&data); hasher.update(data);
( (
PaddingScheme::PKCS1v15Sign { PaddingScheme::PKCS1v15Sign {
hash: Some(rsa::hash::Hash::SHA1), hash: Some(rsa::hash::Hash::SHA1),
@ -369,7 +369,7 @@ pub async fn op_crypto_verify_key(
} }
CryptoHash::Sha256 => { CryptoHash::Sha256 => {
let mut hasher = Sha256::new(); let mut hasher = Sha256::new();
hasher.update(&data); hasher.update(data);
( (
PaddingScheme::PKCS1v15Sign { PaddingScheme::PKCS1v15Sign {
hash: Some(rsa::hash::Hash::SHA2_256), hash: Some(rsa::hash::Hash::SHA2_256),
@ -379,7 +379,7 @@ pub async fn op_crypto_verify_key(
} }
CryptoHash::Sha384 => { CryptoHash::Sha384 => {
let mut hasher = Sha384::new(); let mut hasher = Sha384::new();
hasher.update(&data); hasher.update(data);
( (
PaddingScheme::PKCS1v15Sign { PaddingScheme::PKCS1v15Sign {
hash: Some(rsa::hash::Hash::SHA2_384), hash: Some(rsa::hash::Hash::SHA2_384),
@ -389,7 +389,7 @@ pub async fn op_crypto_verify_key(
} }
CryptoHash::Sha512 => { CryptoHash::Sha512 => {
let mut hasher = Sha512::new(); let mut hasher = Sha512::new();
hasher.update(&data); hasher.update(data);
( (
PaddingScheme::PKCS1v15Sign { PaddingScheme::PKCS1v15Sign {
hash: Some(rsa::hash::Hash::SHA2_512), hash: Some(rsa::hash::Hash::SHA2_512),
@ -399,9 +399,7 @@ pub async fn op_crypto_verify_key(
} }
}; };
public_key public_key.verify(padding, &hashed, &args.signature).is_ok()
.verify(padding, &hashed, &*args.signature)
.is_ok()
} }
Algorithm::RsaPss => { Algorithm::RsaPss => {
let salt_len = args let salt_len = args
@ -417,7 +415,7 @@ pub async fn op_crypto_verify_key(
{ {
CryptoHash::Sha1 => { CryptoHash::Sha1 => {
let mut hasher = Sha1::new(); let mut hasher = Sha1::new();
hasher.update(&data); hasher.update(data);
( (
PaddingScheme::new_pss_with_salt::<Sha1, _>(rng, salt_len), PaddingScheme::new_pss_with_salt::<Sha1, _>(rng, salt_len),
hasher.finalize()[..].to_vec(), hasher.finalize()[..].to_vec(),
@ -425,7 +423,7 @@ pub async fn op_crypto_verify_key(
} }
CryptoHash::Sha256 => { CryptoHash::Sha256 => {
let mut hasher = Sha256::new(); let mut hasher = Sha256::new();
hasher.update(&data); hasher.update(data);
( (
PaddingScheme::new_pss_with_salt::<Sha256, _>(rng, salt_len), PaddingScheme::new_pss_with_salt::<Sha256, _>(rng, salt_len),
hasher.finalize()[..].to_vec(), hasher.finalize()[..].to_vec(),
@ -433,7 +431,7 @@ pub async fn op_crypto_verify_key(
} }
CryptoHash::Sha384 => { CryptoHash::Sha384 => {
let mut hasher = Sha384::new(); let mut hasher = Sha384::new();
hasher.update(&data); hasher.update(data);
( (
PaddingScheme::new_pss_with_salt::<Sha384, _>(rng, salt_len), PaddingScheme::new_pss_with_salt::<Sha384, _>(rng, salt_len),
hasher.finalize()[..].to_vec(), hasher.finalize()[..].to_vec(),
@ -441,7 +439,7 @@ pub async fn op_crypto_verify_key(
} }
CryptoHash::Sha512 => { CryptoHash::Sha512 => {
let mut hasher = Sha512::new(); let mut hasher = Sha512::new();
hasher.update(&data); hasher.update(data);
( (
PaddingScheme::new_pss_with_salt::<Sha512, _>(rng, salt_len), PaddingScheme::new_pss_with_salt::<Sha512, _>(rng, salt_len),
hasher.finalize()[..].to_vec(), hasher.finalize()[..].to_vec(),
@ -449,14 +447,12 @@ pub async fn op_crypto_verify_key(
} }
}; };
public_key public_key.verify(padding, &hashed, &args.signature).is_ok()
.verify(padding, &hashed, &*args.signature)
.is_ok()
} }
Algorithm::Hmac => { Algorithm::Hmac => {
let hash: HmacAlgorithm = args.hash.ok_or_else(not_supported)?.into(); let hash: HmacAlgorithm = args.hash.ok_or_else(not_supported)?.into();
let key = HmacKey::new(hash, &*args.key.data); let key = HmacKey::new(hash, &args.key.data);
ring::hmac::verify(&key, data, &*args.signature).is_ok() ring::hmac::verify(&key, data, &args.signature).is_ok()
} }
Algorithm::Ecdsa => { Algorithm::Ecdsa => {
let signing_alg: &EcdsaSigningAlgorithm = let signing_alg: &EcdsaSigningAlgorithm =
@ -468,7 +464,7 @@ pub async fn op_crypto_verify_key(
let public_key_bytes = match args.key.r#type { let public_key_bytes = match args.key.r#type {
KeyType::Private => { KeyType::Private => {
private_key = EcdsaKeyPair::from_pkcs8(signing_alg, &*args.key.data)?; private_key = EcdsaKeyPair::from_pkcs8(signing_alg, &args.key.data)?;
private_key.public_key().as_ref() private_key.public_key().as_ref()
} }
@ -479,7 +475,7 @@ pub async fn op_crypto_verify_key(
let public_key = let public_key =
ring::signature::UnparsedPublicKey::new(verify_alg, public_key_bytes); ring::signature::UnparsedPublicKey::new(verify_alg, public_key_bytes);
public_key.verify(data, &*args.signature).is_ok() public_key.verify(data, &args.signature).is_ok()
} }
_ => return Err(type_error("Unsupported algorithm".to_string())), _ => return Err(type_error("Unsupported algorithm".to_string())),
}; };
@ -659,9 +655,9 @@ pub async fn op_crypto_derive_bits(
fn read_rsa_public_key(key_data: KeyData) -> Result<RsaPublicKey, AnyError> { fn read_rsa_public_key(key_data: KeyData) -> Result<RsaPublicKey, AnyError> {
let public_key = match key_data.r#type { let public_key = match key_data.r#type {
KeyType::Private => { KeyType::Private => {
RsaPrivateKey::from_pkcs1_der(&*key_data.data)?.to_public_key() RsaPrivateKey::from_pkcs1_der(&key_data.data)?.to_public_key()
} }
KeyType::Public => RsaPublicKey::from_pkcs1_der(&*key_data.data)?, KeyType::Public => RsaPublicKey::from_pkcs1_der(&key_data.data)?,
KeyType::Secret => unreachable!("unexpected KeyType::Secret"), KeyType::Secret => unreachable!("unexpected KeyType::Secret"),
}; };
Ok(public_key) Ok(public_key)

View file

@ -89,7 +89,7 @@ impl RawKeyData {
match self { match self {
RawKeyData::Public(data) => { RawKeyData::Public(data) => {
// public_key is a serialized EncodedPoint // public_key is a serialized EncodedPoint
p256::EncodedPoint::from_bytes(&data) p256::EncodedPoint::from_bytes(data)
.map_err(|_| type_error("expected valid public EC key")) .map_err(|_| type_error("expected valid public EC key"))
} }
RawKeyData::Private(data) => { RawKeyData::Private(data) => {
@ -106,7 +106,7 @@ impl RawKeyData {
match self { match self {
RawKeyData::Public(data) => { RawKeyData::Public(data) => {
// public_key is a serialized EncodedPoint // public_key is a serialized EncodedPoint
p384::EncodedPoint::from_bytes(&data) p384::EncodedPoint::from_bytes(data)
.map_err(|_| type_error("expected valid public EC key")) .map_err(|_| type_error("expected valid public EC key"))
} }
RawKeyData::Private(data) => { RawKeyData::Private(data) => {

View file

@ -198,7 +198,7 @@ where
let permissions = state.borrow_mut::<NP>(); let permissions = state.borrow_mut::<NP>();
permissions.check_read(address_path, "Deno.listen()")?; permissions.check_read(address_path, "Deno.listen()")?;
permissions.check_write(address_path, "Deno.listen()")?; permissions.check_write(address_path, "Deno.listen()")?;
let listener = UnixListener::bind(&address_path)?; let listener = UnixListener::bind(address_path)?;
let local_addr = listener.local_addr()?; let local_addr = listener.local_addr()?;
let pathname = local_addr.as_pathname().map(pathstring).transpose()?; let pathname = local_addr.as_pathname().map(pathstring).transpose()?;
let listener_resource = UnixListenerResource { let listener_resource = UnixListenerResource {
@ -220,7 +220,7 @@ where
let permissions = state.borrow_mut::<NP>(); let permissions = state.borrow_mut::<NP>();
permissions.check_read(address_path, "Deno.listenDatagram()")?; permissions.check_read(address_path, "Deno.listenDatagram()")?;
permissions.check_write(address_path, "Deno.listenDatagram()")?; permissions.check_write(address_path, "Deno.listenDatagram()")?;
let socket = UnixDatagram::bind(&address_path)?; let socket = UnixDatagram::bind(address_path)?;
let local_addr = socket.local_addr()?; let local_addr = socket.local_addr()?;
let pathname = local_addr.as_pathname().map(pathstring).transpose()?; let pathname = local_addr.as_pathname().map(pathstring).transpose()?;
let datagram_resource = UnixDatagramResource { let datagram_resource = UnixDatagramResource {

View file

@ -47,8 +47,6 @@ struct Op {
impl Op { impl Op {
fn new(mut item: ItemFn, attrs: Attributes) -> Self { fn new(mut item: ItemFn, attrs: Attributes) -> Self {
add_scope_lifetime(&mut item);
// Preserve the original function. Change the name to `call`. // Preserve the original function. Change the name to `call`.
// //
// impl op_foo { // impl op_foo {
@ -58,6 +56,8 @@ impl Op {
let mut orig = item.clone(); let mut orig = item.clone();
orig.sig.ident = Ident::new("call", Span::call_site()); orig.sig.ident = Ident::new("call", Span::call_site());
add_scope_lifetime(&mut item);
let is_async = item.sig.asyncness.is_some() || is_future(&item.sig.output); let is_async = item.sig.asyncness.is_some() || is_future(&item.sig.output);
let type_params = exclude_lifetime_params(&item.sig.generics.params); let type_params = exclude_lifetime_params(&item.sig.generics.params);
let core = deno::import(); let core = deno::import();

View file

@ -36,7 +36,7 @@ mod not_docs {
} }
let snapshot = js_runtime.snapshot(); let snapshot = js_runtime.snapshot();
let snapshot_slice: &[u8] = &*snapshot; let snapshot_slice: &[u8] = &snapshot;
println!("Snapshot size: {}", snapshot_slice.len()); println!("Snapshot size: {}", snapshot_slice.len());
let compressed_snapshot_with_size = { let compressed_snapshot_with_size = {
@ -63,7 +63,7 @@ mod not_docs {
compressed_snapshot_with_size.len() compressed_snapshot_with_size.len()
); );
std::fs::write(&snapshot_path, compressed_snapshot_with_size).unwrap(); std::fs::write(snapshot_path, compressed_snapshot_with_size).unwrap();
println!("Snapshot written to: {} ", snapshot_path.display()); println!("Snapshot written to: {} ", snapshot_path.display());
} }

View file

@ -165,7 +165,7 @@ pub fn get_error_class_name(e: &AnyError) -> Option<&'static str> {
.or_else(|| e.downcast_ref::<hyper::Error>().map(get_hyper_error_class)) .or_else(|| e.downcast_ref::<hyper::Error>().map(get_hyper_error_class))
.or_else(|| { .or_else(|| {
e.downcast_ref::<Arc<hyper::Error>>() e.downcast_ref::<Arc<hyper::Error>>()
.map(|e| get_hyper_error_class(&**e)) .map(|e| get_hyper_error_class(e))
}) })
.or_else(|| { .or_else(|| {
e.downcast_ref::<deno_core::Canceled>().map(|e| { e.downcast_ref::<deno_core::Canceled>().map(|e| {

View file

@ -195,7 +195,7 @@ fn find_recursive_cause(js_error: &JsError) -> Option<ErrorReference> {
{ {
return Some(ErrorReference { return Some(ErrorReference {
from: current_error, from: current_error,
to: *seen, to: seen,
}); });
} else { } else {
current_error = cause; current_error = cause;

View file

@ -30,7 +30,7 @@ pub static CLI_SNAPSHOT: Lazy<Box<[u8]>> = Lazy::new(
pub fn deno_isolate_init() -> Snapshot { pub fn deno_isolate_init() -> Snapshot {
debug!("Deno isolate init with snapshots."); debug!("Deno isolate init with snapshots.");
Snapshot::Static(&*CLI_SNAPSHOT) Snapshot::Static(&CLI_SNAPSHOT)
} }
#[cfg(test)] #[cfg(test)]

View file

@ -271,7 +271,7 @@ async fn op_write_file_async(
None => None, None => None,
}; };
let (path, open_options) = open_helper( let (path, open_options) = open_helper(
&mut *state.borrow_mut(), &mut state.borrow_mut(),
&path, &path,
mode, mode,
Some(&write_open_options(create, append)), Some(&write_open_options(create, append)),
@ -646,7 +646,7 @@ fn raw_chmod(path: &Path, _raw_mode: u32) -> Result<(), AnyError> {
{ {
use std::os::unix::fs::PermissionsExt; use std::os::unix::fs::PermissionsExt;
let permissions = PermissionsExt::from_mode(_raw_mode); let permissions = PermissionsExt::from_mode(_raw_mode);
std::fs::set_permissions(&path, permissions).map_err(err_mapper)?; std::fs::set_permissions(path, permissions).map_err(err_mapper)?;
Ok(()) Ok(())
} }
// TODO Implement chmod for Windows (#4357) // TODO Implement chmod for Windows (#4357)

View file

@ -184,7 +184,7 @@ fn op_create_worker(
state.put::<WorkerId>(worker_id.next().unwrap()); state.put::<WorkerId>(worker_id.next().unwrap());
let module_specifier = deno_core::resolve_url(&specifier)?; let module_specifier = deno_core::resolve_url(&specifier)?;
let worker_name = args_name.unwrap_or_else(|| "".to_string()); let worker_name = args_name.unwrap_or_default();
let (handle_sender, handle_receiver) = std::sync::mpsc::sync_channel::< let (handle_sender, handle_receiver) = std::sync::mpsc::sync_channel::<
Result<SendableWebWorkerHandle, AnyError>, Result<SendableWebWorkerHandle, AnyError>,

View file

@ -1,3 +1,3 @@
[toolchain] [toolchain]
channel = "1.64.0" channel = "1.65.0"
components = ["rustfmt", "clippy"] components = ["rustfmt", "clippy"]

View file

@ -434,7 +434,7 @@ impl<'de, 'a, 'b, 's, 'x> de::Deserializer<'de>
V: Visitor<'de>, V: Visitor<'de>,
{ {
magic::buffer::ZeroCopyBuf::from_v8(self.scope, self.input) magic::buffer::ZeroCopyBuf::from_v8(self.scope, self.input)
.and_then(|zb| visitor.visit_bytes(&*zb)) .and_then(|zb| visitor.visit_bytes(&zb))
} }
fn deserialize_byte_buf<V>(self, visitor: V) -> Result<V::Value> fn deserialize_byte_buf<V>(self, visitor: V) -> Result<V::Value>

View file

@ -1088,7 +1088,7 @@ async fn download_npm_registry_file(
.into_bytes() .into_bytes()
}; };
std::fs::create_dir_all(file_path.parent().unwrap())?; std::fs::create_dir_all(file_path.parent().unwrap())?;
std::fs::write(&file_path, bytes)?; std::fs::write(file_path, bytes)?;
Ok(()) Ok(())
} }
@ -1918,7 +1918,7 @@ impl<'a> CheckOutputIntegrationTest<'a> {
command.env_clear(); command.env_clear();
} }
command.envs(self.envs.clone()); command.envs(self.envs.clone());
command.current_dir(&cwd); command.current_dir(cwd);
command.stdin(Stdio::piped()); command.stdin(Stdio::piped());
let writer_clone = writer.try_clone().unwrap(); let writer_clone = writer.try_clone().unwrap();
command.stderr(writer_clone); command.stderr(writer_clone);
@ -2163,13 +2163,13 @@ pub fn parse_wrk_output(output: &str) -> WrkOutput {
let mut latency = None; let mut latency = None;
for line in output.lines() { for line in output.lines() {
if requests == None { if requests.is_none() {
if let Some(cap) = REQUESTS_RX.captures(line) { if let Some(cap) = REQUESTS_RX.captures(line) {
requests = requests =
Some(str::parse::<u64>(cap.get(1).unwrap().as_str()).unwrap()); Some(str::parse::<u64>(cap.get(1).unwrap().as_str()).unwrap());
} }
} }
if latency == None { if latency.is_none() {
if let Some(cap) = LATENCY_RX.captures(line) { if let Some(cap) = LATENCY_RX.captures(line) {
let time = cap.get(1).unwrap(); let time = cap.get(1).unwrap();
let unit = cap.get(2).unwrap(); let unit = cap.get(2).unwrap();