From 040efd42bca6835c81c28fd70a59d326978ce25d Mon Sep 17 00:00:00 2001 From: samypr100 <3933065+samypr100@users.noreply.github.com> Date: Sat, 11 Jan 2025 21:39:11 -0500 Subject: [PATCH] Upgrade Rust toolchain to 1.84.0 --- Cargo.toml | 3 +++ crates/uv-auth/src/middleware.rs | 6 +++--- crates/uv-configuration/src/dev.rs | 2 +- crates/uv-dispatch/src/lib.rs | 2 +- crates/uv-extract/src/stream.rs | 4 ++-- crates/uv-fs/src/lib.rs | 4 ++-- crates/uv-install-wheel/src/wheel.rs | 4 ++-- crates/uv-pep508/src/lib.rs | 6 +++--- crates/uv-pep508/src/unnamed.rs | 6 +++--- crates/uv-pep508/src/verbatim_url.rs | 2 +- crates/uv-python/src/discovery.rs | 2 +- crates/uv-python/src/installation.rs | 8 ++++---- crates/uv-python/src/interpreter.rs | 8 ++++---- crates/uv-python/src/lib.rs | 12 ++++++------ crates/uv-resolver/src/lock/mod.rs | 4 ++-- crates/uv-resolver/src/resolver/provider.rs | 2 +- crates/uv-resolver/src/yanks.rs | 2 +- crates/uv-scripts/src/lib.rs | 4 ++-- crates/uv-trampoline-builder/src/lib.rs | 12 ++++++------ crates/uv/src/commands/pip/latest.rs | 2 +- crates/uv/src/commands/project/init.rs | 12 ++++++------ crates/uv/src/commands/project/mod.rs | 2 +- crates/uv/src/commands/project/run.rs | 8 +++----- crates/uv/tests/it/common/mod.rs | 2 +- crates/uv/tests/it/pip_compile.rs | 4 ++-- crates/uv/tests/it/pip_install.rs | 4 ++-- rust-toolchain.toml | 2 +- 27 files changed, 65 insertions(+), 64 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f26f2de4c7b2..e97d1ae6657c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -225,6 +225,9 @@ rc_mutex = "warn" rest_pat_in_fully_bound_structs = "warn" if_not_else = "allow" +# Diagnostics are not actionable: Enable once https://github.com/rust-lang/rust-clippy/issues/13774 is resolved. +large_stack_arrays = "allow" + [profile.release] strip = true lto = "fat" diff --git a/crates/uv-auth/src/middleware.rs b/crates/uv-auth/src/middleware.rs index 3c78600d865b..16c4e542b72b 100644 --- a/crates/uv-auth/src/middleware.rs +++ b/crates/uv-auth/src/middleware.rs @@ -741,7 +741,7 @@ mod tests { let mut netrc_file = NamedTempFile::new()?; writeln!( netrc_file, - r#"machine {} login {username} password {password}"#, + r"machine {} login {username} password {password}", base_url.host_str().unwrap() )?; @@ -788,7 +788,7 @@ mod tests { let mut netrc_file = NamedTempFile::new()?; writeln!( netrc_file, - r#"machine example.com login {username} password {password}"#, + r"machine example.com login {username} password {password}", )?; let client = test_client_builder() @@ -829,7 +829,7 @@ mod tests { let mut netrc_file = NamedTempFile::new()?; writeln!( netrc_file, - r#"machine {} login {username} password {password}"#, + r"machine {} login {username} password {password}", base_url.host_str().unwrap() )?; diff --git a/crates/uv-configuration/src/dev.rs b/crates/uv-configuration/src/dev.rs index cce967ba1f89..3a94c6f4be16 100644 --- a/crates/uv-configuration/src/dev.rs +++ b/crates/uv-configuration/src/dev.rs @@ -292,7 +292,7 @@ impl DevGroupsSpecification { self.groups .as_ref() - .map_or(false, |groups| groups.contains(group)) + .is_some_and(|groups| groups.contains(group)) } } diff --git a/crates/uv-dispatch/src/lib.rs b/crates/uv-dispatch/src/lib.rs index c84e81271c0a..28a0a5ba0564 100644 --- a/crates/uv-dispatch/src/lib.rs +++ b/crates/uv-dispatch/src/lib.rs @@ -163,7 +163,7 @@ impl<'a> BuildDispatch<'a> { } #[allow(refining_impl_trait)] -impl<'a> BuildContext for BuildDispatch<'a> { +impl BuildContext for BuildDispatch<'_> { type SourceDistBuilder = SourceBuild; fn interpreter(&self) -> &Interpreter { diff --git a/crates/uv-extract/src/stream.rs b/crates/uv-extract/src/stream.rs index 483be2f50588..49ae138c451d 100644 --- a/crates/uv-extract/src/stream.rs +++ b/crates/uv-extract/src/stream.rs @@ -139,8 +139,8 @@ pub async fn unzip( /// Unpack the given tar archive into the destination directory. /// /// This is equivalent to `archive.unpack_in(dst)`, but it also preserves the executable bit. -async fn untar_in<'a>( - mut archive: tokio_tar::Archive<&'a mut (dyn tokio::io::AsyncRead + Unpin)>, +async fn untar_in( + mut archive: tokio_tar::Archive<&'_ mut (dyn tokio::io::AsyncRead + Unpin)>, dst: &Path, ) -> std::io::Result<()> { let mut entries = archive.entries()?; diff --git a/crates/uv-fs/src/lib.rs b/crates/uv-fs/src/lib.rs index f7dadb6aeddb..8f6cbc9377e4 100644 --- a/crates/uv-fs/src/lib.rs +++ b/crates/uv-fs/src/lib.rs @@ -516,7 +516,7 @@ pub fn is_temporary(path: impl AsRef) -> bool { path.as_ref() .file_name() .and_then(|name| name.to_str()) - .map_or(false, |name| name.starts_with(".tmp")) + .is_some_and(|name| name.starts_with(".tmp")) } /// A file lock that is automatically released when dropped. @@ -588,7 +588,7 @@ impl LockedFile { impl Drop for LockedFile { fn drop(&mut self) { - if let Err(err) = self.0.file().unlock() { + if let Err(err) = fs2::FileExt::unlock(self.0.file()) { error!( "Failed to unlock {}; program may be stuck: {}", self.0.path().display(), diff --git a/crates/uv-install-wheel/src/wheel.rs b/crates/uv-install-wheel/src/wheel.rs index 8218f75ae758..9e5698e0db8a 100644 --- a/crates/uv-install-wheel/src/wheel.rs +++ b/crates/uv-install-wheel/src/wheel.rs @@ -34,7 +34,7 @@ fn get_script_launcher(entry_point: &Script, shebang: &str) -> String { let import_name = entry_point.import_name(); format!( - r##"{shebang} + r#"{shebang} # -*- coding: utf-8 -*- import re import sys @@ -42,7 +42,7 @@ from {module} import {import_name} if __name__ == "__main__": sys.argv[0] = re.sub(r"(-script\.pyw|\.exe)?$", "", sys.argv[0]) sys.exit({function}()) -"## +"# ) } diff --git a/crates/uv-pep508/src/lib.rs b/crates/uv-pep508/src/lib.rs index 087f69d316f4..b30bbc670a97 100644 --- a/crates/uv-pep508/src/lib.rs +++ b/crates/uv-pep508/src/lib.rs @@ -930,12 +930,12 @@ fn parse_pep508_requirement( if let Some((pos, char)) = cursor.next().filter(|(_, c)| *c != '#') { let message = if char == '#' { format!( - r#"Expected end of input or `;`, found `{char}`; comments must be preceded by a leading space"# + r"Expected end of input or `;`, found `{char}`; comments must be preceded by a leading space" ) } else if marker.is_none() { - format!(r#"Expected end of input or `;`, found `{char}`"#) + format!(r"Expected end of input or `;`, found `{char}`") } else { - format!(r#"Expected end of input, found `{char}`"#) + format!(r"Expected end of input, found `{char}`") }; return Err(Pep508Error { message: Pep508ErrorSource::String(message), diff --git a/crates/uv-pep508/src/unnamed.rs b/crates/uv-pep508/src/unnamed.rs index 2e4361b940cc..0893cc989b04 100644 --- a/crates/uv-pep508/src/unnamed.rs +++ b/crates/uv-pep508/src/unnamed.rs @@ -176,12 +176,12 @@ fn parse_unnamed_requirement( if let Some((pos, char)) = cursor.next() { let message = if char == '#' { format!( - r#"Expected end of input or `;`, found `{char}`; comments must be preceded by a leading space"# + r"Expected end of input or `;`, found `{char}`; comments must be preceded by a leading space" ) } else if marker.is_none() { - format!(r#"Expected end of input or `;`, found `{char}`"#) + format!(r"Expected end of input or `;`, found `{char}`") } else { - format!(r#"Expected end of input, found `{char}`"#) + format!(r"Expected end of input, found `{char}`") }; return Err(Pep508Error { message: Pep508ErrorSource::String(message), diff --git a/crates/uv-pep508/src/verbatim_url.rs b/crates/uv-pep508/src/verbatim_url.rs index 73b06158a916..4d715b389989 100644 --- a/crates/uv-pep508/src/verbatim_url.rs +++ b/crates/uv-pep508/src/verbatim_url.rs @@ -406,7 +406,7 @@ pub fn looks_like_git_repository(url: &Url) -> bool { .map_or(true, |ext| ext.eq_ignore_ascii_case("git")) && url .path_segments() - .map_or(false, |segments| segments.count() == 2) + .is_some_and(|segments| segments.count() == 2) } /// Split the fragment from a URL. diff --git a/crates/uv-python/src/discovery.rs b/crates/uv-python/src/discovery.rs index 879bb8b240ef..77fb6acf64be 100644 --- a/crates/uv-python/src/discovery.rs +++ b/crates/uv-python/src/discovery.rs @@ -1154,7 +1154,7 @@ pub(crate) fn is_windows_store_shim(path: &Path) -> bool { component.starts_with("python") && std::path::Path::new(component) .extension() - .map_or(false, |ext| ext.eq_ignore_ascii_case("exe")) + .is_some_and(|ext| ext.eq_ignore_ascii_case("exe")) }) { return false; diff --git a/crates/uv-python/src/installation.rs b/crates/uv-python/src/installation.rs index 2733a14a0885..e7fc3994056c 100644 --- a/crates/uv-python/src/installation.rs +++ b/crates/uv-python/src/installation.rs @@ -78,12 +78,12 @@ impl PythonInstallation { /// Find or fetch a [`PythonInstallation`]. /// /// Unlike [`PythonInstallation::find`], if the required Python is not installed it will be installed automatically. - pub async fn find_or_download<'a>( + pub async fn find_or_download( request: Option<&PythonRequest>, environments: EnvironmentPreference, preference: PythonPreference, python_downloads: PythonDownloads, - client_builder: &BaseClientBuilder<'a>, + client_builder: &BaseClientBuilder<'_>, cache: &Cache, reporter: Option<&dyn Reporter>, python_install_mirror: Option<&str>, @@ -127,9 +127,9 @@ impl PythonInstallation { } /// Download and install the requested installation. - pub async fn fetch<'a>( + pub async fn fetch( request: PythonDownloadRequest, - client_builder: &BaseClientBuilder<'a>, + client_builder: &BaseClientBuilder<'_>, cache: &Cache, reporter: Option<&dyn Reporter>, python_install_mirror: Option<&str>, diff --git a/crates/uv-python/src/interpreter.rs b/crates/uv-python/src/interpreter.rs index e725fbccd0f0..13a12be575f0 100644 --- a/crates/uv-python/src/interpreter.rs +++ b/crates/uv-python/src/interpreter.rs @@ -894,10 +894,10 @@ mod tests { fs::write( &mocked_interpreter, - formatdoc! {r##" + formatdoc! {r" #!/bin/bash echo '{json}' - "##}, + "}, ) .unwrap(); @@ -913,10 +913,10 @@ mod tests { ); fs::write( &mocked_interpreter, - formatdoc! {r##" + formatdoc! {r" #!/bin/bash echo '{}' - "##, json.replace("3.12", "3.13")}, + ", json.replace("3.12", "3.13")}, ) .unwrap(); let interpreter = Interpreter::query(&mocked_interpreter, &cache).unwrap(); diff --git a/crates/uv-python/src/lib.rs b/crates/uv-python/src/lib.rs index 982878ff3d56..ea5b3e57275a 100644 --- a/crates/uv-python/src/lib.rs +++ b/crates/uv-python/src/lib.rs @@ -282,10 +282,10 @@ mod tests { fs_err::create_dir_all(path.parent().unwrap())?; fs_err::write( path, - formatdoc! {r##" + formatdoc! {r" #!/bin/bash echo '{json}' - "##}, + "}, )?; fs_err::set_permissions(path, std::os::unix::fs::PermissionsExt::from_mode(0o770))?; @@ -304,10 +304,10 @@ mod tests { fs_err::write( path, - formatdoc! {r##" + formatdoc! {r" #!/bin/bash echo '{output}' 1>&2 - "##}, + "}, )?; fs_err::set_permissions(path, std::os::unix::fs::PermissionsExt::from_mode(0o770))?; @@ -525,10 +525,10 @@ mod tests { #[cfg(unix)] fs_err::write( children[0].join(format!("python{}", env::consts::EXE_SUFFIX)), - formatdoc! {r##" + formatdoc! {r" #!/bin/bash echo 'foo' - "##}, + "}, )?; fs_err::set_permissions( children[0].join(format!("python{}", env::consts::EXE_SUFFIX)), diff --git a/crates/uv-resolver/src/lock/mod.rs b/crates/uv-resolver/src/lock/mod.rs index c0255804641c..283889b91eca 100644 --- a/crates/uv-resolver/src/lock/mod.rs +++ b/crates/uv-resolver/src/lock/mod.rs @@ -953,7 +953,7 @@ impl Lock { .ok() .flatten() .map(|package| matches!(package.id.source, Source::Virtual(_))); - if actual.map_or(true, |actual| actual != expected) { + if actual != Some(expected) { return Ok(SatisfiesResult::MismatchedSources(name.clone(), expected)); } } @@ -973,7 +973,7 @@ impl Lock { .ok() .flatten() .map(|package| &package.id.version); - if actual.map_or(true, |actual| actual != expected) { + if actual != Some(expected) { return Ok(SatisfiesResult::MismatchedVersion( name.clone(), expected.clone(), diff --git a/crates/uv-resolver/src/resolver/provider.rs b/crates/uv-resolver/src/resolver/provider.rs index 2d6173a8c6ba..dc9b38e08ec9 100644 --- a/crates/uv-resolver/src/resolver/provider.rs +++ b/crates/uv-resolver/src/resolver/provider.rs @@ -145,7 +145,7 @@ impl<'a, Context: BuildContext> DefaultResolverProvider<'a, Context> { } } -impl<'a, Context: BuildContext> ResolverProvider for DefaultResolverProvider<'a, Context> { +impl ResolverProvider for DefaultResolverProvider<'_, Context> { /// Make a "Simple API" request for the package and convert the result to a [`VersionMap`]. async fn get_package_versions<'io>( &'io self, diff --git a/crates/uv-resolver/src/yanks.rs b/crates/uv-resolver/src/yanks.rs index 6ed70a57e93f..6c43f2ed9802 100644 --- a/crates/uv-resolver/src/yanks.rs +++ b/crates/uv-resolver/src/yanks.rs @@ -55,6 +55,6 @@ impl AllowedYanks { pub fn contains(&self, package_name: &PackageName, version: &Version) -> bool { self.0 .get(package_name) - .map_or(false, |versions| versions.contains(version)) + .is_some_and(|versions| versions.contains(version)) } } diff --git a/crates/uv-scripts/src/lib.rs b/crates/uv-scripts/src/lib.rs index a17398e278a0..ad25ac131c9d 100644 --- a/crates/uv-scripts/src/lib.rs +++ b/crates/uv-scripts/src/lib.rs @@ -205,10 +205,10 @@ impl Pep723Script { let metadata = serialize_metadata(&default_metadata); let script = if let Some(existing_contents) = existing_contents { - indoc::formatdoc! {r#" + indoc::formatdoc! {r" {metadata} {content} - "#, + ", content = String::from_utf8(existing_contents).map_err(|err| Pep723Error::Utf8(err.utf8_error()))?} } else { indoc::formatdoc! {r#" diff --git a/crates/uv-trampoline-builder/src/lib.rs b/crates/uv-trampoline-builder/src/lib.rs index a5920fd2d054..2fb461fc8e5b 100644 --- a/crates/uv-trampoline-builder/src/lib.rs +++ b/crates/uv-trampoline-builder/src/lib.rs @@ -268,7 +268,7 @@ pub fn windows_script_launcher( launcher.extend_from_slice(&payload); launcher.extend_from_slice(python_path.as_bytes()); launcher.extend_from_slice( - &u32::try_from(python_path.as_bytes().len()) + &u32::try_from(python_path.len()) .expect("file path should be smaller than 4GB") .to_le_bytes(), ); @@ -300,7 +300,7 @@ pub fn windows_python_launcher( launcher.extend_from_slice(launcher_bin); launcher.extend_from_slice(python_path.as_bytes()); launcher.extend_from_slice( - &u32::try_from(python_path.as_bytes().len()) + &u32::try_from(python_path.len()) .expect("file path should be smaller than 4GB") .to_le_bytes(), ); @@ -377,7 +377,7 @@ mod test { fn get_script_launcher(shebang: &str, is_gui: bool) -> String { if is_gui { format!( - r##"{shebang} + r#"{shebang} # -*- coding: utf-8 -*- import re import sys @@ -394,11 +394,11 @@ def make_gui() -> None: if __name__ == "__main__": sys.argv[0] = re.sub(r"(-script\.pyw|\.exe)?$", "", sys.argv[0]) sys.exit(make_gui()) -"## +"# ) } else { format!( - r##"{shebang} + r#"{shebang} # -*- coding: utf-8 -*- import re import sys @@ -412,7 +412,7 @@ def main_console() -> None: if __name__ == "__main__": sys.argv[0] = re.sub(r"(-script\.pyw|\.exe)?$", "", sys.argv[0]) sys.exit(main_console()) -"## +"# ) } } diff --git a/crates/uv/src/commands/pip/latest.rs b/crates/uv/src/commands/pip/latest.rs index 1331c29f5bc1..abc028a0076b 100644 --- a/crates/uv/src/commands/pip/latest.rs +++ b/crates/uv/src/commands/pip/latest.rs @@ -21,7 +21,7 @@ pub(crate) struct LatestClient<'env> { pub(crate) requires_python: &'env RequiresPython, } -impl<'env> LatestClient<'env> { +impl LatestClient<'_> { /// Find the latest version of a package from an index. pub(crate) async fn find_latest( &self, diff --git a/crates/uv/src/commands/project/init.rs b/crates/uv/src/commands/project/init.rs index faa3302493d3..75f8008a6a88 100644 --- a/crates/uv/src/commands/project/init.rs +++ b/crates/uv/src/commands/project/init.rs @@ -1006,7 +1006,7 @@ fn pyproject_build_backend_prerequisites( if !build_file.try_exists()? { fs_err::write( build_file, - indoc::formatdoc! {r#" + indoc::formatdoc! {r" cmake_minimum_required(VERSION 3.15) project(${{SKBUILD_PROJECT_NAME}} LANGUAGES CXX) @@ -1015,7 +1015,7 @@ fn pyproject_build_backend_prerequisites( pybind11_add_module(_core MODULE src/main.cpp) install(TARGETS _core DESTINATION ${{SKBUILD_PROJECT_NAME}}) - "#}, + "}, )?; } } @@ -1052,21 +1052,21 @@ fn generate_package_scripts( // Python script for binary-based packaged apps or libs let binary_call_script = if is_lib { - indoc::formatdoc! {r#" + indoc::formatdoc! {r" from {module_name}._core import hello_from_bin def hello() -> str: return hello_from_bin() - "#} + "} } else { - indoc::formatdoc! {r#" + indoc::formatdoc! {r" from {module_name}._core import hello_from_bin def main() -> None: print(hello_from_bin()) - "#} + "} }; // .pyi file for binary script diff --git a/crates/uv/src/commands/project/mod.rs b/crates/uv/src/commands/project/mod.rs index 4f3c1416efcb..74cfbe5ffc09 100644 --- a/crates/uv/src/commands/project/mod.rs +++ b/crates/uv/src/commands/project/mod.rs @@ -1117,7 +1117,7 @@ impl<'lock> EnvironmentSpecification<'lock> { } /// Run dependency resolution for an interpreter, returning the [`ResolverOutput`]. -pub(crate) async fn resolve_environment<'a>( +pub(crate) async fn resolve_environment( spec: EnvironmentSpecification<'_>, interpreter: &Interpreter, settings: ResolverSettingsRef<'_>, diff --git a/crates/uv/src/commands/project/run.rs b/crates/uv/src/commands/project/run.rs index dd327ede6c91..16cd4b8f01ed 100644 --- a/crates/uv/src/commands/project/run.rs +++ b/crates/uv/src/commands/project/run.rs @@ -1535,8 +1535,8 @@ impl RunCommand { } let metadata = target_path.metadata(); - let is_file = metadata.as_ref().map_or(false, std::fs::Metadata::is_file); - let is_dir = metadata.as_ref().map_or(false, std::fs::Metadata::is_dir); + let is_file = metadata.as_ref().is_ok_and(std::fs::Metadata::is_file); + let is_dir = metadata.as_ref().is_ok_and(std::fs::Metadata::is_dir); if target.eq_ignore_ascii_case("python") { Ok(Self::Python(args.to_vec())) @@ -1569,9 +1569,7 @@ impl RunCommand { fn is_python_zipapp(target: &Path) -> bool { if let Ok(file) = fs_err::File::open(target) { if let Ok(mut archive) = zip::ZipArchive::new(file) { - return archive - .by_name("__main__.py") - .map_or(false, |f| f.is_file()); + return archive.by_name("__main__.py").is_ok_and(|f| f.is_file()); } } false diff --git a/crates/uv/tests/it/common/mod.rs b/crates/uv/tests/it/common/mod.rs index b34a6faaf585..f19f28f8cea2 100644 --- a/crates/uv/tests/it/common/mod.rs +++ b/crates/uv/tests/it/common/mod.rs @@ -922,7 +922,7 @@ impl TestContext { /// For when we add pypy to the test suite. #[allow(clippy::unused_self)] - pub fn python_kind(&self) -> &str { + pub fn python_kind(&self) -> &'static str { "python" } diff --git a/crates/uv/tests/it/pip_compile.rs b/crates/uv/tests/it/pip_compile.rs index c222d619f436..7adf4a635f0e 100644 --- a/crates/uv/tests/it/pip_compile.rs +++ b/crates/uv/tests/it/pip_compile.rs @@ -6859,10 +6859,10 @@ dependencies = [ // Write to a requirements file. let requirements_in = context.temp_dir.child("requirements.in"); - requirements_in.write_str(&indoc::formatdoc! {r#" + requirements_in.write_str(&indoc::formatdoc! {r" -e {} -e {} - "#, + ", editable_dir1.path().display(), editable_dir2.path().display() })?; diff --git a/crates/uv/tests/it/pip_install.rs b/crates/uv/tests/it/pip_install.rs index 93d410560a9c..14e7dee5008b 100644 --- a/crates/uv/tests/it/pip_install.rs +++ b/crates/uv/tests/it/pip_install.rs @@ -7077,10 +7077,10 @@ fn local_index_requirements_txt_absolute() -> Result<()> { "#, Url::from_directory_path(context.workspace_root.join("scripts/links/")).unwrap().as_str()})?; let requirements_txt = context.temp_dir.child("requirements.txt"); - requirements_txt.write_str(&indoc::formatdoc! {r#" + requirements_txt.write_str(&indoc::formatdoc! {r" --index-url {} tqdm - "#, Url::from_directory_path(root).unwrap().as_str()})?; + ", Url::from_directory_path(root).unwrap().as_str()})?; uv_snapshot!(context.filters(), context.pip_install() .env_remove(EnvVars::UV_EXCLUDE_NEWER) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index a718dc2fc84c..9db33c0e40d1 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.83" +channel = "1.84"