mirror of
https://github.com/denoland/deno.git
synced 2024-11-24 15:19:26 -05:00
chore: use Rust 1.62.0 (#15028)
This commit is contained in:
parent
77c25beaa5
commit
b8b82c3ea4
20 changed files with 105 additions and 76 deletions
13
cli/diff.rs
13
cli/diff.rs
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
use crate::colors;
|
use crate::colors;
|
||||||
use dissimilar::{diff as difference, Chunk};
|
use dissimilar::{diff as difference, Chunk};
|
||||||
|
use std::fmt::Write as _;
|
||||||
|
|
||||||
/// Print diff of the same file_path, before and after formatting.
|
/// Print diff of the same file_path, before and after formatting.
|
||||||
///
|
///
|
||||||
|
@ -113,12 +114,14 @@ impl DiffBuilder {
|
||||||
fn write_line_diff(&mut self) {
|
fn write_line_diff(&mut self) {
|
||||||
let split = self.orig.split('\n').enumerate();
|
let split = self.orig.split('\n').enumerate();
|
||||||
for (i, s) in split {
|
for (i, s) in split {
|
||||||
self.output.push_str(&format!(
|
write!(
|
||||||
|
self.output,
|
||||||
"{:width$}{} ",
|
"{:width$}{} ",
|
||||||
self.orig_line + i,
|
self.orig_line + i,
|
||||||
colors::gray(" |"),
|
colors::gray(" |"),
|
||||||
width = self.line_number_width
|
width = self.line_number_width
|
||||||
));
|
)
|
||||||
|
.unwrap();
|
||||||
self.output.push_str(&fmt_rem());
|
self.output.push_str(&fmt_rem());
|
||||||
self.output.push_str(s);
|
self.output.push_str(s);
|
||||||
self.output.push('\n');
|
self.output.push('\n');
|
||||||
|
@ -126,12 +129,14 @@ impl DiffBuilder {
|
||||||
|
|
||||||
let split = self.edit.split('\n').enumerate();
|
let split = self.edit.split('\n').enumerate();
|
||||||
for (i, s) in split {
|
for (i, s) in split {
|
||||||
self.output.push_str(&format!(
|
write!(
|
||||||
|
self.output,
|
||||||
"{:width$}{} ",
|
"{:width$}{} ",
|
||||||
self.edit_line + i,
|
self.edit_line + i,
|
||||||
colors::gray(" |"),
|
colors::gray(" |"),
|
||||||
width = self.line_number_width
|
width = self.line_number_width
|
||||||
));
|
)
|
||||||
|
.unwrap();
|
||||||
self.output.push_str(&fmt_add());
|
self.output.push_str(&fmt_add());
|
||||||
self.output.push_str(s);
|
self.output.push_str(s);
|
||||||
self.output.push('\n');
|
self.output.push('\n');
|
||||||
|
|
|
@ -7,6 +7,7 @@ use crate::colors::yellow;
|
||||||
use deno_core::error::format_file_name;
|
use deno_core::error::format_file_name;
|
||||||
use deno_core::error::JsError;
|
use deno_core::error::JsError;
|
||||||
use deno_core::error::JsStackFrame;
|
use deno_core::error::JsStackFrame;
|
||||||
|
use std::fmt::Write as _;
|
||||||
|
|
||||||
// Keep in sync with `/core/error.js`.
|
// Keep in sync with `/core/error.js`.
|
||||||
pub fn format_location(frame: &JsStackFrame) -> String {
|
pub fn format_location(frame: &JsStackFrame) -> String {
|
||||||
|
@ -29,9 +30,9 @@ pub fn format_location(frame: &JsStackFrame) -> String {
|
||||||
result += &cyan("<anonymous>").to_string();
|
result += &cyan("<anonymous>").to_string();
|
||||||
}
|
}
|
||||||
if let Some(line_number) = frame.line_number {
|
if let Some(line_number) = frame.line_number {
|
||||||
result += &format!("{}{}", ":", yellow(&line_number.to_string()));
|
write!(result, ":{}", yellow(&line_number.to_string())).unwrap();
|
||||||
if let Some(column_number) = frame.column_number {
|
if let Some(column_number) = frame.column_number {
|
||||||
result += &format!("{}{}", ":", yellow(&column_number.to_string()));
|
write!(result, ":{}", yellow(&column_number.to_string())).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result
|
result
|
||||||
|
@ -61,18 +62,18 @@ fn format_frame(frame: &JsStackFrame) -> String {
|
||||||
if let Some(function_name) = &frame.function_name {
|
if let Some(function_name) = &frame.function_name {
|
||||||
if let Some(type_name) = &frame.type_name {
|
if let Some(type_name) = &frame.type_name {
|
||||||
if !function_name.starts_with(type_name) {
|
if !function_name.starts_with(type_name) {
|
||||||
formatted_method += &format!("{}.", type_name);
|
write!(formatted_method, "{}.", type_name).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
formatted_method += function_name;
|
formatted_method += function_name;
|
||||||
if let Some(method_name) = &frame.method_name {
|
if let Some(method_name) = &frame.method_name {
|
||||||
if !function_name.ends_with(method_name) {
|
if !function_name.ends_with(method_name) {
|
||||||
formatted_method += &format!(" [as {}]", method_name);
|
write!(formatted_method, " [as {}]", method_name).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if let Some(type_name) = &frame.type_name {
|
if let Some(type_name) = &frame.type_name {
|
||||||
formatted_method += &format!("{}.", type_name);
|
write!(formatted_method, "{}.", type_name).unwrap();
|
||||||
}
|
}
|
||||||
if let Some(method_name) = &frame.method_name {
|
if let Some(method_name) = &frame.method_name {
|
||||||
formatted_method += method_name
|
formatted_method += method_name
|
||||||
|
@ -84,7 +85,7 @@ fn format_frame(frame: &JsStackFrame) -> String {
|
||||||
} else if frame.is_constructor {
|
} else if frame.is_constructor {
|
||||||
result += "new ";
|
result += "new ";
|
||||||
if let Some(function_name) = &frame.function_name {
|
if let Some(function_name) = &frame.function_name {
|
||||||
result += &italic_bold(&function_name).to_string();
|
write!(result, "{}", italic_bold(&function_name)).unwrap();
|
||||||
} else {
|
} else {
|
||||||
result += &cyan("<anonymous>").to_string();
|
result += &cyan("<anonymous>").to_string();
|
||||||
}
|
}
|
||||||
|
@ -94,7 +95,7 @@ fn format_frame(frame: &JsStackFrame) -> String {
|
||||||
result += &format_location(frame);
|
result += &format_location(frame);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
result += &format!(" ({})", format_location(frame));
|
write!(result, " ({})", format_location(frame)).unwrap();
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +157,7 @@ fn format_js_error_inner(js_error: &JsError, is_child: bool) -> String {
|
||||||
for aggregated_error in aggregated {
|
for aggregated_error in aggregated {
|
||||||
let error_string = format_js_error_inner(aggregated_error, true);
|
let error_string = format_js_error_inner(aggregated_error, true);
|
||||||
for line in error_string.trim_start_matches("Uncaught ").lines() {
|
for line in error_string.trim_start_matches("Uncaught ").lines() {
|
||||||
s.push_str(&format!("\n {}", line));
|
write!(s, "\n {}", line).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -174,14 +175,16 @@ fn format_js_error_inner(js_error: &JsError, is_child: bool) -> String {
|
||||||
0,
|
0,
|
||||||
));
|
));
|
||||||
for frame in &js_error.frames {
|
for frame in &js_error.frames {
|
||||||
s.push_str(&format!("\n at {}", format_frame(frame)));
|
write!(s, "\n at {}", format_frame(frame)).unwrap();
|
||||||
}
|
}
|
||||||
if let Some(cause) = &js_error.cause {
|
if let Some(cause) = &js_error.cause {
|
||||||
let error_string = format_js_error_inner(cause, true);
|
let error_string = format_js_error_inner(cause, true);
|
||||||
s.push_str(&format!(
|
write!(
|
||||||
|
s,
|
||||||
"\nCaused by: {}",
|
"\nCaused by: {}",
|
||||||
error_string.trim_start_matches("Uncaught ")
|
error_string.trim_start_matches("Uncaught ")
|
||||||
));
|
)
|
||||||
|
.unwrap();
|
||||||
}
|
}
|
||||||
s
|
s
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ use log::error;
|
||||||
use log::warn;
|
use log::warn;
|
||||||
use serde_json::from_value;
|
use serde_json::from_value;
|
||||||
use std::env;
|
use std::env;
|
||||||
|
use std::fmt::Write as _;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tokio::fs;
|
use tokio::fs;
|
||||||
|
@ -2878,7 +2879,8 @@ impl Inner {
|
||||||
let measures = self.performance.to_vec();
|
let measures = self.performance.to_vec();
|
||||||
let workspace_settings = self.config.get_workspace_settings();
|
let workspace_settings = self.config.get_workspace_settings();
|
||||||
|
|
||||||
contents.push_str(&format!(
|
write!(
|
||||||
|
contents,
|
||||||
r#"# Deno Language Server Status
|
r#"# Deno Language Server Status
|
||||||
|
|
||||||
## Workspace Settings
|
## Workspace Settings
|
||||||
|
@ -2914,16 +2916,19 @@ impl Inner {
|
||||||
.map(|m| m.to_string())
|
.map(|m| m.to_string())
|
||||||
.collect::<Vec<String>>()
|
.collect::<Vec<String>>()
|
||||||
.join("\n - ")
|
.join("\n - ")
|
||||||
));
|
)
|
||||||
|
.unwrap();
|
||||||
contents
|
contents
|
||||||
.push_str("\n## Performance\n\n|Name|Duration|Count|\n|---|---|---|\n");
|
.push_str("\n## Performance\n\n|Name|Duration|Count|\n|---|---|---|\n");
|
||||||
let mut averages = self.performance.averages();
|
let mut averages = self.performance.averages();
|
||||||
averages.sort();
|
averages.sort();
|
||||||
for average in averages {
|
for average in averages {
|
||||||
contents.push_str(&format!(
|
writeln!(
|
||||||
|
contents,
|
||||||
"|{}|{}ms|{}|\n",
|
"|{}|{}ms|{}|\n",
|
||||||
average.name, average.average_duration, average.count
|
average.name, average.average_duration, average.count
|
||||||
));
|
)
|
||||||
|
.unwrap();
|
||||||
}
|
}
|
||||||
Some(contents)
|
Some(contents)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -33,6 +33,7 @@ use once_cell::sync::Lazy;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
use std::fmt::Write as _;
|
||||||
use std::iter::Peekable;
|
use std::iter::Peekable;
|
||||||
|
|
||||||
static ESCAPE_STRING_RE: Lazy<Regex> =
|
static ESCAPE_STRING_RE: Lazy<Regex> =
|
||||||
|
@ -268,9 +269,9 @@ impl StringOrVec {
|
||||||
let mut s = String::new();
|
let mut s = String::new();
|
||||||
for (i, segment) in v.iter().enumerate() {
|
for (i, segment) in v.iter().enumerate() {
|
||||||
if omit_initial_prefix && i == 0 {
|
if omit_initial_prefix && i == 0 {
|
||||||
s.push_str(&format!("{}{}", segment, suffix));
|
write!(s, "{}{}", segment, suffix).unwrap();
|
||||||
} else {
|
} else {
|
||||||
s.push_str(&format!("{}{}{}", prefix, segment, suffix));
|
write!(s, "{}{}{}", prefix, segment, suffix).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s
|
s
|
||||||
|
@ -618,10 +619,10 @@ pub fn tokens_to_regex(
|
||||||
|
|
||||||
if end {
|
if end {
|
||||||
if !strict {
|
if !strict {
|
||||||
route.push_str(&format!(r"{}?", delimiter));
|
write!(route, r"{}?", delimiter).unwrap();
|
||||||
}
|
}
|
||||||
if has_ends_with {
|
if has_ends_with {
|
||||||
route.push_str(&format!(r"(?={})", ends_with));
|
write!(route, r"(?={})", ends_with).unwrap();
|
||||||
} else {
|
} else {
|
||||||
route.push('$');
|
route.push('$');
|
||||||
}
|
}
|
||||||
|
@ -639,11 +640,11 @@ pub fn tokens_to_regex(
|
||||||
};
|
};
|
||||||
|
|
||||||
if !strict {
|
if !strict {
|
||||||
route.push_str(&format!(r"(?:{}(?={}))?", delimiter, ends_with));
|
write!(route, r"(?:{}(?={}))?", delimiter, ends_with).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
if !is_end_deliminated {
|
if !is_end_deliminated {
|
||||||
route.push_str(&format!(r"(?={}|{})", delimiter, ends_with));
|
write!(route, r"(?={}|{})", delimiter, ends_with).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -753,7 +754,7 @@ impl Compiler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
path.push_str(&format!("{}{}{}", prefix, segment, suffix));
|
write!(path, "{}{}{}", prefix, segment, suffix).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -772,7 +773,7 @@ impl Compiler {
|
||||||
}
|
}
|
||||||
let prefix = k.prefix.clone().unwrap_or_default();
|
let prefix = k.prefix.clone().unwrap_or_default();
|
||||||
let suffix = k.suffix.clone().unwrap_or_default();
|
let suffix = k.suffix.clone().unwrap_or_default();
|
||||||
path.push_str(&format!("{}{}{}", prefix, s, suffix));
|
write!(path, "{}{}{}", prefix, s, suffix).unwrap();
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
if !optional {
|
if !optional {
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
use deno_core::serde_json;
|
use deno_core::serde_json;
|
||||||
use deno_core::serde_json::json;
|
use deno_core::serde_json::json;
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
|
use std::fmt::Write as _;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::process::Stdio;
|
use std::process::Stdio;
|
||||||
use test_util as util;
|
use test_util as util;
|
||||||
|
@ -530,20 +531,19 @@ fn update_existing_config_test() {
|
||||||
fn success_text(module_count: &str, dir: &str, has_import_map: bool) -> String {
|
fn success_text(module_count: &str, dir: &str, has_import_map: bool) -> String {
|
||||||
let mut text = format!("Vendored {} into {} directory.", module_count, dir);
|
let mut text = format!("Vendored {} into {} directory.", module_count, dir);
|
||||||
if has_import_map {
|
if has_import_map {
|
||||||
text.push_str(&
|
let f = format!(
|
||||||
format!(
|
concat!(
|
||||||
concat!(
|
"\n\nTo use vendored modules, specify the `--import-map {}import_map.json` flag when ",
|
||||||
"\n\nTo use vendored modules, specify the `--import-map {}import_map.json` flag when ",
|
r#"invoking Deno subcommands or add an `"importMap": "<path_to_vendored_import_map>"` "#,
|
||||||
r#"invoking Deno subcommands or add an `"importMap": "<path_to_vendored_import_map>"` "#,
|
"entry to a deno.json file.",
|
||||||
"entry to a deno.json file.",
|
),
|
||||||
),
|
if dir != "vendor/" {
|
||||||
if dir != "vendor/" {
|
format!("{}{}", dir.trim_end_matches('/'), if cfg!(windows) { '\\' } else {'/'})
|
||||||
format!("{}{}", dir.trim_end_matches('/'), if cfg!(windows) { '\\' } else {'/'})
|
} else {
|
||||||
} else {
|
dir.to_string()
|
||||||
dir.to_string()
|
}
|
||||||
}
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
write!(text, "{}", f).unwrap();
|
||||||
}
|
}
|
||||||
text
|
text
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,7 @@ use serde::Deserialize;
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
use std::fmt::Write as _;
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::num::NonZeroUsize;
|
use std::num::NonZeroUsize;
|
||||||
|
@ -618,27 +619,33 @@ impl TestReporter for PrettyTestReporter {
|
||||||
|
|
||||||
let mut summary_result = String::new();
|
let mut summary_result = String::new();
|
||||||
|
|
||||||
summary_result.push_str(&format!(
|
write!(
|
||||||
|
summary_result,
|
||||||
"{} passed{} | {} failed{}",
|
"{} passed{} | {} failed{}",
|
||||||
summary.passed,
|
summary.passed,
|
||||||
get_steps_text(summary.passed_steps),
|
get_steps_text(summary.passed_steps),
|
||||||
summary.failed,
|
summary.failed,
|
||||||
get_steps_text(summary.failed_steps + summary.pending_steps),
|
get_steps_text(summary.failed_steps + summary.pending_steps),
|
||||||
));
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let ignored_steps = get_steps_text(summary.ignored_steps);
|
let ignored_steps = get_steps_text(summary.ignored_steps);
|
||||||
if summary.ignored > 0 || !ignored_steps.is_empty() {
|
if summary.ignored > 0 || !ignored_steps.is_empty() {
|
||||||
summary_result
|
write!(
|
||||||
.push_str(&format!(" | {} ignored{}", summary.ignored, ignored_steps))
|
summary_result,
|
||||||
};
|
" | {} ignored{}",
|
||||||
|
summary.ignored, ignored_steps
|
||||||
|
)
|
||||||
|
.unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
if summary.measured > 0 {
|
if summary.measured > 0 {
|
||||||
summary_result.push_str(&format!(" | {} measured", summary.measured,))
|
write!(summary_result, " | {} measured", summary.measured,).unwrap();
|
||||||
};
|
}
|
||||||
|
|
||||||
if summary.filtered_out > 0 {
|
if summary.filtered_out > 0 {
|
||||||
summary_result
|
write!(summary_result, " | {} filtered out", summary.filtered_out)
|
||||||
.push_str(&format!(" | {} filtered out", summary.filtered_out,))
|
.unwrap()
|
||||||
};
|
};
|
||||||
|
|
||||||
println!(
|
println!(
|
||||||
|
@ -891,7 +898,7 @@ fn extract_files_from_regex_blocks(
|
||||||
let mut file_source = String::new();
|
let mut file_source = String::new();
|
||||||
for line in lines_regex.captures_iter(text) {
|
for line in lines_regex.captures_iter(text) {
|
||||||
let text = line.get(1).unwrap();
|
let text = line.get(1).unwrap();
|
||||||
file_source.push_str(&format!("{}\n", text.as_str()));
|
writeln!(file_source, "{}", text.as_str()).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
let file_specifier = deno_core::resolve_url_or_path(&format!(
|
let file_specifier = deno_core::resolve_url_or_path(&format!(
|
||||||
|
|
2
cli/tools/vendor/analyze.rs
vendored
2
cli/tools/vendor/analyze.rs
vendored
|
@ -25,7 +25,7 @@ struct DefaultExportFinder {
|
||||||
has_default_export: bool,
|
has_default_export: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Visit for DefaultExportFinder {
|
impl Visit for DefaultExportFinder {
|
||||||
noop_visit_type!();
|
noop_visit_type!();
|
||||||
|
|
||||||
fn visit_export_default_decl(&mut self, _: &ExportDefaultDecl) {
|
fn visit_export_default_decl(&mut self, _: &ExportDefaultDecl) {
|
||||||
|
|
21
cli/tools/vendor/build.rs
vendored
21
cli/tools/vendor/build.rs
vendored
|
@ -1,5 +1,6 @@
|
||||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
|
use std::fmt::Write as _;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
@ -164,10 +165,14 @@ fn build_proxy_module_source(
|
||||||
module: &Module,
|
module: &Module,
|
||||||
proxied_module: &ProxiedModule,
|
proxied_module: &ProxiedModule,
|
||||||
) -> String {
|
) -> String {
|
||||||
let mut text = format!(
|
let mut text = String::new();
|
||||||
"// @deno-types=\"{}\"\n",
|
writeln!(
|
||||||
|
text,
|
||||||
|
"// @deno-types=\"{}\"",
|
||||||
proxied_module.declaration_specifier
|
proxied_module.declaration_specifier
|
||||||
);
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let relative_specifier = format!(
|
let relative_specifier = format!(
|
||||||
"./{}",
|
"./{}",
|
||||||
proxied_module
|
proxied_module
|
||||||
|
@ -179,15 +184,17 @@ fn build_proxy_module_source(
|
||||||
|
|
||||||
// for simplicity, always include the `export *` statement as it won't error
|
// for simplicity, always include the `export *` statement as it won't error
|
||||||
// even when the module does not contain a named export
|
// even when the module does not contain a named export
|
||||||
text.push_str(&format!("export * from \"{}\";\n", relative_specifier));
|
writeln!(text, "export * from \"{}\";", relative_specifier).unwrap();
|
||||||
|
|
||||||
// add a default export if one exists in the module
|
// add a default export if one exists in the module
|
||||||
if let Some(parsed_source) = module.maybe_parsed_source.as_ref() {
|
if let Some(parsed_source) = module.maybe_parsed_source.as_ref() {
|
||||||
if has_default_export(parsed_source) {
|
if has_default_export(parsed_source) {
|
||||||
text.push_str(&format!(
|
writeln!(
|
||||||
"export {{ default }} from \"{}\";\n",
|
text,
|
||||||
|
"export {{ default }} from \"{}\";",
|
||||||
relative_specifier
|
relative_specifier
|
||||||
));
|
)
|
||||||
|
.unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1012,7 +1012,8 @@ Pending dynamic modules:\n".to_string();
|
||||||
let module_info = module_map
|
let module_info = module_map
|
||||||
.get_info_by_id(&pending_evaluate.module_id)
|
.get_info_by_id(&pending_evaluate.module_id)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
msg.push_str(&format!("- {}", module_info.name.as_str()));
|
msg.push_str("- ");
|
||||||
|
msg.push_str(module_info.name.as_str());
|
||||||
}
|
}
|
||||||
return Poll::Ready(Err(generic_error(msg)));
|
return Poll::Ready(Err(generic_error(msg)));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -573,9 +573,8 @@ where
|
||||||
// By default, Err returned by this function does not tell
|
// By default, Err returned by this function does not tell
|
||||||
// which symbol wasn't exported. So we'll modify the error
|
// which symbol wasn't exported. So we'll modify the error
|
||||||
// message to include the name of symbol.
|
// message to include the name of symbol.
|
||||||
//
|
|
||||||
// SAFETY: The obtained T symbol is the size of a pointer.
|
|
||||||
let fn_ptr =
|
let fn_ptr =
|
||||||
|
// SAFETY: The obtained T symbol is the size of a pointer.
|
||||||
match unsafe { resource.lib.symbol::<*const c_void>(symbol) } {
|
match unsafe { resource.lib.symbol::<*const c_void>(symbol) } {
|
||||||
Ok(value) => Ok(value),
|
Ok(value) => Ok(value),
|
||||||
Err(err) => Err(generic_error(format!(
|
Err(err) => Err(generic_error(format!(
|
||||||
|
|
|
@ -754,13 +754,14 @@ fn rdata_to_return_record(
|
||||||
let mut s = String::new();
|
let mut s = String::new();
|
||||||
|
|
||||||
if let Some(name) = name {
|
if let Some(name) = name {
|
||||||
s.push_str(&format!("{}", name));
|
s.push_str(&name.to_string());
|
||||||
} else if name.is_none() && key_values.is_empty() {
|
} else if name.is_none() && key_values.is_empty() {
|
||||||
s.push(';');
|
s.push(';');
|
||||||
}
|
}
|
||||||
|
|
||||||
for key_value in key_values {
|
for key_value in key_values {
|
||||||
s.push_str(&format!("; {}", key_value));
|
s.push_str("; ");
|
||||||
|
s.push_str(&key_value.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
s
|
s
|
||||||
|
|
|
@ -152,9 +152,9 @@ pub fn op_webgpu_render_bundle_encoder_set_bind_group(
|
||||||
|
|
||||||
// Align the data
|
// Align the data
|
||||||
assert!(args.dynamic_offsets_data.len() % std::mem::size_of::<u32>() == 0);
|
assert!(args.dynamic_offsets_data.len() % std::mem::size_of::<u32>() == 0);
|
||||||
// SAFETY: A u8 to u32 cast is safe because we asserted that the length is a
|
|
||||||
// multiple of 4.
|
|
||||||
let (prefix, dynamic_offsets_data, suffix) =
|
let (prefix, dynamic_offsets_data, suffix) =
|
||||||
|
// SAFETY: A u8 to u32 cast is safe because we asserted that the length is a
|
||||||
|
// multiple of 4.
|
||||||
unsafe { args.dynamic_offsets_data.align_to::<u32>() };
|
unsafe { args.dynamic_offsets_data.align_to::<u32>() };
|
||||||
assert!(prefix.is_empty());
|
assert!(prefix.is_empty());
|
||||||
assert!(suffix.is_empty());
|
assert!(suffix.is_empty());
|
||||||
|
|
|
@ -241,9 +241,9 @@ pub fn op_webgpu_compute_pass_set_bind_group(
|
||||||
|
|
||||||
// Align the data
|
// Align the data
|
||||||
assert!(args.dynamic_offsets_data_start % std::mem::size_of::<u32>() == 0);
|
assert!(args.dynamic_offsets_data_start % std::mem::size_of::<u32>() == 0);
|
||||||
// SAFETY: A u8 to u32 cast is safe because we asserted that the length is a
|
|
||||||
// multiple of 4.
|
|
||||||
let (prefix, dynamic_offsets_data, suffix) =
|
let (prefix, dynamic_offsets_data, suffix) =
|
||||||
|
// SAFETY: A u8 to u32 cast is safe because we asserted that the length is a
|
||||||
|
// multiple of 4.
|
||||||
unsafe { args.dynamic_offsets_data.align_to::<u32>() };
|
unsafe { args.dynamic_offsets_data.align_to::<u32>() };
|
||||||
assert!(prefix.is_empty());
|
assert!(prefix.is_empty());
|
||||||
assert!(suffix.is_empty());
|
assert!(suffix.is_empty());
|
||||||
|
|
|
@ -305,9 +305,9 @@ pub fn op_webgpu_render_pass_set_bind_group(
|
||||||
|
|
||||||
// Align the data
|
// Align the data
|
||||||
assert!(args.dynamic_offsets_data_start % std::mem::size_of::<u32>() == 0);
|
assert!(args.dynamic_offsets_data_start % std::mem::size_of::<u32>() == 0);
|
||||||
// SAFETY: A u8 to u32 cast is safe because we asserted that the length is a
|
|
||||||
// multiple of 4.
|
|
||||||
let (prefix, dynamic_offsets_data, suffix) =
|
let (prefix, dynamic_offsets_data, suffix) =
|
||||||
|
// SAFETY: A u8 to u32 cast is safe because we asserted that the length is a
|
||||||
|
// multiple of 4.
|
||||||
unsafe { args.dynamic_offsets_data.align_to::<u32>() };
|
unsafe { args.dynamic_offsets_data.align_to::<u32>() };
|
||||||
assert!(prefix.is_empty());
|
assert!(prefix.is_empty());
|
||||||
assert!(suffix.is_empty());
|
assert!(suffix.is_empty());
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
[toolchain]
|
[toolchain]
|
||||||
channel = "1.61.0"
|
channel = "1.62.0"
|
||||||
components = ["rustfmt", "clippy"]
|
components = ["rustfmt", "clippy"]
|
||||||
|
|
|
@ -580,7 +580,7 @@ struct EnumAccess<'a, 'b, 's> {
|
||||||
// p1: std::marker::PhantomData<&'x ()>,
|
// p1: std::marker::PhantomData<&'x ()>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'de, 'a, 'b, 's, 'x> de::EnumAccess<'de> for EnumAccess<'a, 'b, 's> {
|
impl<'de, 'a, 'b, 's> de::EnumAccess<'de> for EnumAccess<'a, 'b, 's> {
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
type Variant = VariantDeserializer<'a, 'b, 's>;
|
type Variant = VariantDeserializer<'a, 'b, 's>;
|
||||||
|
|
||||||
|
|
|
@ -51,9 +51,9 @@ impl FromV8 for ByteString {
|
||||||
}
|
}
|
||||||
let len = v8str.length();
|
let len = v8str.length();
|
||||||
let mut buffer = SmallVec::with_capacity(len);
|
let mut buffer = SmallVec::with_capacity(len);
|
||||||
|
#[allow(clippy::uninit_vec)]
|
||||||
// SAFETY: we set length == capacity (see previous line),
|
// SAFETY: we set length == capacity (see previous line),
|
||||||
// before immediately writing into that buffer and sanity check with an assert
|
// before immediately writing into that buffer and sanity check with an assert
|
||||||
#[allow(clippy::uninit_vec)]
|
|
||||||
unsafe {
|
unsafe {
|
||||||
buffer.set_len(len);
|
buffer.set_len(len);
|
||||||
let written = v8str.write_one_byte(
|
let written = v8str.write_one_byte(
|
||||||
|
|
|
@ -87,11 +87,11 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn bytes_layout() {
|
fn bytes_layout() {
|
||||||
// SAFETY: ensuring layout is the same
|
|
||||||
let u1: [usize; 4] =
|
let u1: [usize; 4] =
|
||||||
|
// SAFETY: ensuring layout is the same
|
||||||
unsafe { mem::transmute(from_static(HELLO.as_bytes())) };
|
unsafe { mem::transmute(from_static(HELLO.as_bytes())) };
|
||||||
// SAFETY: ensuring layout is the same
|
|
||||||
let u2: [usize; 4] =
|
let u2: [usize; 4] =
|
||||||
|
// SAFETY: ensuring layout is the same
|
||||||
unsafe { mem::transmute(bytes::Bytes::from_static(HELLO.as_bytes())) };
|
unsafe { mem::transmute(bytes::Bytes::from_static(HELLO.as_bytes())) };
|
||||||
assert_eq!(u1[..3], u2[..3]); // Struct bytes are equal besides Vtables
|
assert_eq!(u1[..3], u2[..3]); // Struct bytes are equal besides Vtables
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,9 +34,9 @@ impl FromV8 for U16String {
|
||||||
.map_err(|_| Error::ExpectedString)?;
|
.map_err(|_| Error::ExpectedString)?;
|
||||||
let len = v8str.length();
|
let len = v8str.length();
|
||||||
let mut buffer = Vec::with_capacity(len);
|
let mut buffer = Vec::with_capacity(len);
|
||||||
|
#[allow(clippy::uninit_vec)]
|
||||||
// SAFETY: we set length == capacity (see previous line),
|
// SAFETY: we set length == capacity (see previous line),
|
||||||
// before immediately writing into that buffer and sanity check with an assert
|
// before immediately writing into that buffer and sanity check with an assert
|
||||||
#[allow(clippy::uninit_vec)]
|
|
||||||
unsafe {
|
unsafe {
|
||||||
buffer.set_len(len);
|
buffer.set_len(len);
|
||||||
let written = v8str.write(
|
let written = v8str.write(
|
||||||
|
|
|
@ -50,6 +50,7 @@ impl V8Slice {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn as_slice_mut(&mut self) -> &mut [u8] {
|
fn as_slice_mut(&mut self) -> &mut [u8] {
|
||||||
|
#[allow(clippy::cast_ref_to_mut)]
|
||||||
// SAFETY: v8::SharedRef<v8::BackingStore> is similar to Arc<[u8]>,
|
// SAFETY: v8::SharedRef<v8::BackingStore> is similar to Arc<[u8]>,
|
||||||
// it points to a fixed continuous slice of bytes on the heap.
|
// it points to a fixed continuous slice of bytes on the heap.
|
||||||
// It's safe-ish to mutate concurrently because it can not be
|
// It's safe-ish to mutate concurrently because it can not be
|
||||||
|
@ -59,7 +60,6 @@ impl V8Slice {
|
||||||
// concurrent mutation is simply an accepted fact of life.
|
// concurrent mutation is simply an accepted fact of life.
|
||||||
// And in practice V8Slices also do not have overallping read/write phases.
|
// And in practice V8Slices also do not have overallping read/write phases.
|
||||||
// TLDR: permissive interior mutability on slices of bytes is "fine"
|
// TLDR: permissive interior mutability on slices of bytes is "fine"
|
||||||
#[allow(clippy::cast_ref_to_mut)]
|
|
||||||
unsafe {
|
unsafe {
|
||||||
&mut *(&self.store[self.range.clone()] as *const _ as *mut [u8])
|
&mut *(&self.store[self.range.clone()] as *const _ as *mut [u8])
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue