Skip to content

Commit

Permalink
chore: upgrade to Rust 1.67 (denoland#17548)
Browse files Browse the repository at this point in the history
Co-authored-by: Bartek Iwańczuk <[email protected]>
  • Loading branch information
dsherret and bartlomieju authored Jan 27, 2023
1 parent 1a1faff commit f5840bd
Show file tree
Hide file tree
Showing 148 changed files with 576 additions and 681 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ const ci = {
].join("\n"),
key: "never_saved",
"restore-keys":
"18-cargo-target-${{ matrix.os }}-${{ matrix.profile }}-",
"19-cargo-target-${{ matrix.os }}-${{ matrix.profile }}-",
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ jobs:
!./target/*/*.zip
!./target/*/*.tar.gz
key: never_saved
restore-keys: '18-cargo-target-${{ matrix.os }}-${{ matrix.profile }}-'
restore-keys: '19-cargo-target-${{ matrix.os }}-${{ matrix.profile }}-'
- name: Apply and update mtime cache
if: '!(github.event_name == ''pull_request'' && matrix.skip_pr) && (steps.exit_early.outputs.EXIT_EARLY != ''true'' && (!startsWith(github.ref, ''refs/tags/'')))'
uses: ./.github/mtime_cache
Expand Down
2 changes: 1 addition & 1 deletion bench_util/js_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub fn create_js_runtime(setup: impl FnOnce() -> Vec<Extension>) -> JsRuntime {
}

fn loop_code(iters: u64, src: &str) -> String {
format!(r#"for(let i=0; i < {}; i++) {{ {} }}"#, iters, src,)
format!(r#"for(let i=0; i < {iters}; i++) {{ {src} }}"#,)
}

#[derive(Copy, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion cli/args/config_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ pub const IGNORED_COMPILER_OPTIONS: &[&str] = &[
/// A function that works like JavaScript's `Object.assign()`.
pub fn json_merge(a: &mut Value, b: &Value) {
match (a, b) {
(&mut Value::Object(ref mut a), &Value::Object(ref b)) => {
(&mut Value::Object(ref mut a), Value::Object(b)) => {
for (k, v) in b {
json_merge(a.entry(k.clone()).or_insert(Value::Null), v);
}
Expand Down
6 changes: 3 additions & 3 deletions cli/args/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1904,7 +1904,7 @@ fn permission_args(app: Command) -> Command {
.validator(|keys| {
for key in keys.split(',') {
if key.is_empty() || key.contains(&['=', '\0'] as &[char]) {
return Err(format!("invalid key \"{}\"", key));
return Err(format!("invalid key \"{key}\""));
}
}
Ok(())
Expand Down Expand Up @@ -3164,7 +3164,7 @@ fn seed_arg_parse(flags: &mut Flags, matches: &ArgMatches) {
let seed = seed_string.parse::<u64>().unwrap();
flags.seed = Some(seed);

flags.v8_flags.push(format!("--random-seed={}", seed));
flags.v8_flags.push(format!("--random-seed={seed}"));
}
}

Expand Down Expand Up @@ -3293,7 +3293,7 @@ pub fn resolve_urls(urls: Vec<String>) -> Vec<String> {
}
out.push(full_url);
} else {
panic!("Bad Url: {}", urlstr);
panic!("Bad Url: {urlstr}");
}
}
out
Expand Down
8 changes: 4 additions & 4 deletions cli/args/flags_allow_net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ impl FromStr for BarePort {
}

pub fn validator(host_and_port: &str) -> Result<(), String> {
if Url::parse(&format!("deno://{}", host_and_port)).is_ok()
if Url::parse(&format!("deno://{host_and_port}")).is_ok()
|| host_and_port.parse::<IpAddr>().is_ok()
|| host_and_port.parse::<BarePort>().is_ok()
{
Ok(())
} else {
Err(format!("Bad host:port pair: {}", host_and_port))
Err(format!("Bad host:port pair: {host_and_port}"))
}
}

Expand All @@ -43,7 +43,7 @@ pub fn validator(host_and_port: &str) -> Result<(), String> {
pub fn parse(paths: Vec<String>) -> clap::Result<Vec<String>> {
let mut out: Vec<String> = vec![];
for host_and_port in paths.iter() {
if Url::parse(&format!("deno://{}", host_and_port)).is_ok()
if Url::parse(&format!("deno://{host_and_port}")).is_ok()
|| host_and_port.parse::<IpAddr>().is_ok()
{
out.push(host_and_port.to_owned())
Expand All @@ -55,7 +55,7 @@ pub fn parse(paths: Vec<String>) -> clap::Result<Vec<String>> {
} else {
return Err(clap::Error::raw(
clap::ErrorKind::InvalidValue,
format!("Bad host:port pair: {}", host_and_port),
format!("Bad host:port pair: {host_and_port}"),
));
}
}
Expand Down
2 changes: 1 addition & 1 deletion cli/args/import_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fn print_import_map_diagnostics(diagnostics: &[ImportMapDiagnostic]) {
"Import map diagnostics:\n{}",
diagnostics
.iter()
.map(|d| format!(" - {}", d))
.map(|d| format!(" - {d}"))
.collect::<Vec<_>>()
.join("\n")
);
Expand Down
12 changes: 5 additions & 7 deletions cli/args/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl CacheSetting {
if list.iter().any(|i| i == "npm:") {
return false;
}
let specifier = format!("npm:{}", package_name);
let specifier = format!("npm:{package_name}");
if list.contains(&specifier) {
return false;
}
Expand Down Expand Up @@ -491,7 +491,7 @@ impl CliOptions {
format!("for: {}", insecure_allowlist.join(", "))
};
let msg =
format!("DANGER: TLS certificate validation is disabled {}", domains);
format!("DANGER: TLS certificate validation is disabled {domains}");
// use eprintln instead of log::warn so this always gets shown
eprintln!("{}", colors::yellow(msg));
}
Expand Down Expand Up @@ -579,8 +579,7 @@ impl CliOptions {
)
.await
.context(format!(
"Unable to load '{}' import map",
import_map_specifier
"Unable to load '{import_map_specifier}' import map"
))
.map(Some)
}
Expand Down Expand Up @@ -929,7 +928,7 @@ fn resolve_import_map_specifier(
}
}
let specifier = deno_core::resolve_url_or_path(import_map_path)
.context(format!("Bad URL (\"{}\") for import map.", import_map_path))?;
.context(format!("Bad URL (\"{import_map_path}\") for import map."))?;
return Ok(Some(specifier));
} else if let Some(config_file) = &maybe_config_file {
// if the config file is an import map we prefer to use it, over `importMap`
Expand Down Expand Up @@ -970,8 +969,7 @@ fn resolve_import_map_specifier(
} else {
deno_core::resolve_import(&import_map_path, config_file.specifier.as_str())
.context(format!(
"Bad URL (\"{}\") for import map.",
import_map_path
"Bad URL (\"{import_map_path}\") for import map."
))?
};
return Ok(Some(specifier));
Expand Down
4 changes: 2 additions & 2 deletions cli/auth_tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ pub struct AuthToken {
impl fmt::Display for AuthToken {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match &self.token {
AuthTokenData::Bearer(token) => write!(f, "Bearer {}", token),
AuthTokenData::Bearer(token) => write!(f, "Bearer {token}"),
AuthTokenData::Basic { username, password } => {
let credentials = format!("{}:{}", username, password);
let credentials = format!("{username}:{password}");
write!(f, "Basic {}", base64::encode(credentials))
}
}
Expand Down
8 changes: 4 additions & 4 deletions cli/bench/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub fn benchmark(
let name = entry.file_name().into_string().unwrap();
let file_stem = pathbuf.file_stem().unwrap().to_str().unwrap();

let lua_script = http_dir.join(format!("{}.lua", file_stem));
let lua_script = http_dir.join(format!("{file_stem}.lua"));
let mut maybe_lua = None;
if lua_script.exists() {
maybe_lua = Some(lua_script.to_str().unwrap());
Expand Down Expand Up @@ -158,7 +158,7 @@ fn run(
let wrk = test_util::prebuilt_tool_path("wrk");
assert!(wrk.is_file());

let addr = format!("http://127.0.0.1:{}/", port);
let addr = format!("http://127.0.0.1:{port}/");
let mut wrk_cmd =
vec![wrk.to_str().unwrap(), "-d", DURATION, "--latency", &addr];

Expand All @@ -172,7 +172,7 @@ fn run(

std::thread::sleep(Duration::from_secs(1)); // wait to capture failure. TODO racy.

println!("{}", output);
println!("{output}");
assert!(
server.try_wait()?.map_or(true, |s| s.success()),
"server ended with error"
Expand All @@ -194,7 +194,7 @@ fn get_port() -> u16 {
}

fn server_addr(port: u16) -> String {
format!("0.0.0.0:{}", port)
format!("0.0.0.0:{port}")
}

fn core_http_json_ops(exe: &str) -> Result<HttpBenchmarkResult> {
Expand Down
6 changes: 3 additions & 3 deletions cli/bench/lsp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ fn bench_find_replace(deno_exe: &Path) -> Result<Duration, AnyError> {
"textDocument/didOpen",
json!({
"textDocument": {
"uri": format!("file:///a/file_{}.ts", i),
"uri": format!("file:///a/file_{i}.ts"),
"languageId": "typescript",
"version": 1,
"text": "console.log(\"000\");\n"
Expand All @@ -223,7 +223,7 @@ fn bench_find_replace(deno_exe: &Path) -> Result<Duration, AnyError> {
}

for i in 0..10 {
let file_name = format!("file:///a/file_{}.ts", i);
let file_name = format!("file:///a/file_{i}.ts");
client.write_notification(
"textDocument/didChange",
lsp::DidChangeTextDocumentParams {
Expand All @@ -250,7 +250,7 @@ fn bench_find_replace(deno_exe: &Path) -> Result<Duration, AnyError> {
}

for i in 0..10 {
let file_name = format!("file:///a/file_{}.ts", i);
let file_name = format!("file:///a/file_{i}.ts");
let (maybe_res, maybe_err) = client.write_request::<_, _, Value>(
"textDocument/formatting",
lsp::DocumentFormattingParams {
Expand Down
2 changes: 1 addition & 1 deletion cli/bench/lsp_bench_standalone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fn incremental_change_wait(bench: &mut Bencher) {

let mut document_version: u64 = 0;
bench.iter(|| {
let text = format!("m{:05}", document_version);
let text = format!("m{document_version:05}");
client
.write_notification(
"textDocument/didChange",
Expand Down
14 changes: 7 additions & 7 deletions cli/bench/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ fn run_exec_time(
let ret_code_test = if let Some(code) = return_code {
// Bash test which asserts the return code value of the previous command
// $? contains the return code of the previous command
format!("; test $? -eq {}", code)
format!("; test $? -eq {code}")
} else {
"".to_string()
};
Expand Down Expand Up @@ -244,11 +244,11 @@ fn rlib_size(target_dir: &std::path::Path, prefix: &str) -> i64 {
if name.starts_with(prefix) && name.ends_with(".rlib") {
let start = name.split('-').next().unwrap().to_string();
if seen.contains(&start) {
println!("skip {}", name);
println!("skip {name}");
} else {
seen.insert(start);
size += entry.metadata().unwrap().len();
println!("check size {} {}", name, size);
println!("check size {name} {size}");
}
}
}
Expand All @@ -269,11 +269,11 @@ fn get_binary_sizes(target_dir: &Path) -> Result<HashMap<String, i64>> {

// add up size for everything in target/release/deps/libswc*
let swc_size = rlib_size(target_dir, "libswc");
println!("swc {} bytes", swc_size);
println!("swc {swc_size} bytes");
sizes.insert("swc_rlib".to_string(), swc_size);

let v8_size = rlib_size(target_dir, "libv8");
println!("v8 {} bytes", v8_size);
println!("v8 {v8_size} bytes");
sizes.insert("rusty_v8_rlib".to_string(), v8_size);

// Because cargo's OUT_DIR is not predictable, search the build tree for
Expand Down Expand Up @@ -314,7 +314,7 @@ fn bundle_benchmark(deno_exe: &Path) -> Result<HashMap<String, i64>> {
let mut sizes = HashMap::<String, i64>::new();

for (name, url) in BUNDLES {
let path = format!("{}.bundle.js", name);
let path = format!("{name}.bundle.js");
test_util::run(
&[
deno_exe.to_str().unwrap(),
Expand Down Expand Up @@ -374,7 +374,7 @@ fn cargo_deps() -> usize {
count += 1
}
}
println!("cargo_deps {}", count);
println!("cargo_deps {count}");
assert!(count > 10); // Sanity check.
count
}
Expand Down
6 changes: 3 additions & 3 deletions cli/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ mod ts {
for name in libs.iter() {
println!(
"cargo:rerun-if-changed={}",
path_dts.join(format!("lib.{}.d.ts", name)).display()
path_dts.join(format!("lib.{name}.d.ts")).display()
);
}
println!(
Expand Down Expand Up @@ -229,7 +229,7 @@ mod ts {
PathBuf::from(op_crate_lib).canonicalize()?
// otherwise we are will generate the path ourself
} else {
path_dts.join(format!("lib.{}.d.ts", lib))
path_dts.join(format!("lib.{lib}.d.ts"))
};
let data = std::fs::read_to_string(path)?;
Ok(json!({
Expand Down Expand Up @@ -431,7 +431,7 @@ fn main() {
// op_fetch_asset::trace_serializer();

if let Ok(c) = env::var("DENO_CANARY") {
println!("cargo:rustc-env=DENO_CANARY={}", c);
println!("cargo:rustc-env=DENO_CANARY={c}");
}
println!("cargo:rerun-if-env-changed=DENO_CANARY");

Expand Down
6 changes: 3 additions & 3 deletions cli/cache/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl TypeCheckCache {
Ok(val) => val,
Err(err) => {
if cfg!(debug_assertions) {
panic!("Error retrieving hash: {}", err);
panic!("Error retrieving hash: {err}");
} else {
log::debug!("Error retrieving hash: {}", err);
// fail silently when not debugging
Expand All @@ -94,7 +94,7 @@ impl TypeCheckCache {
pub fn add_check_hash(&self, check_hash: u64) {
if let Err(err) = self.add_check_hash_result(check_hash) {
if cfg!(debug_assertions) {
panic!("Error saving check hash: {}", err);
panic!("Error saving check hash: {err}");
} else {
log::debug!("Error saving check hash: {}", err);
}
Expand Down Expand Up @@ -134,7 +134,7 @@ impl TypeCheckCache {
if let Err(err) = self.set_tsbuildinfo_result(specifier, text) {
// should never error here, but if it ever does don't fail
if cfg!(debug_assertions) {
panic!("Error saving tsbuildinfo: {}", err);
panic!("Error saving tsbuildinfo: {err}");
} else {
log::debug!("Error saving tsbuildinfo: {}", err);
}
Expand Down
7 changes: 3 additions & 4 deletions cli/cache/disk_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ impl DiskCache {
}
fs::create_dir_all(path).map_err(|e| {
io::Error::new(e.kind(), format!(
"Could not create TypeScript compiler cache location: {:?}\nCheck the permission of the directory.",
path
"Could not create TypeScript compiler cache location: {path:?}\nCheck the permission of the directory."
))
})
}
Expand All @@ -61,7 +60,7 @@ impl DiskCache {
let host_port = match url.port() {
// Windows doesn't support ":" in filenames, so we represent port using a
// special string.
Some(port) => format!("{}_PORT{}", host, port),
Some(port) => format!("{host}_PORT{port}"),
None => host.to_string(),
};
out.push(host_port);
Expand Down Expand Up @@ -128,7 +127,7 @@ impl DiskCache {
None => Some(base.with_extension(extension)),
Some(ext) => {
let original_extension = OsStr::to_str(ext).unwrap();
let final_extension = format!("{}.{}", original_extension, extension);
let final_extension = format!("{original_extension}.{extension}");
Some(base.with_extension(final_extension))
}
}
Expand Down
2 changes: 1 addition & 1 deletion cli/cache/emit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl EmitCache {
if let Err(err) = self.set_emit_code_result(specifier, source_hash, code) {
// should never error here, but if it ever does don't fail
if cfg!(debug_assertions) {
panic!("Error saving emit data ({}): {}", specifier, err);
panic!("Error saving emit data ({specifier}): {err}");
} else {
log::debug!("Error saving emit data({}): {}", specifier, err);
}
Expand Down
Loading

0 comments on commit f5840bd

Please sign in to comment.