From 42dcea0ee2a38d949e54e05a2ef1608f9f5fff73 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Fri, 4 Apr 2025 11:49:26 -0400 Subject: [PATCH] Bump MSRV to 1.84 (#12670) ## Summary Closes https://github.com/astral-sh/uv/issues/12649. --- Cargo.toml | 2 +- crates/uv-auth/src/credentials.rs | 2 +- crates/uv-auth/src/middleware.rs | 8 +++--- crates/uv-build-backend/src/metadata.rs | 7 ++--- crates/uv-build-backend/src/source_dist.rs | 2 +- crates/uv-build-backend/src/wheel.rs | 2 +- crates/uv-build-frontend/src/lib.rs | 2 +- crates/uv-client/src/base_client.rs | 17 +++++++----- crates/uv-client/src/html.rs | 2 +- crates/uv-client/src/httpcache/control.rs | 5 ++-- crates/uv-client/src/registry_client.rs | 2 +- crates/uv-console/src/lib.rs | 2 +- crates/uv-dev/src/generate_cli_reference.rs | 3 ++- .../uv-dev/src/generate_options_reference.rs | 1 + .../uv-distribution-filename/src/splitter.rs | 2 +- crates/uv-distribution-filename/src/wheel.rs | 4 +-- crates/uv-distribution-types/src/installed.rs | 2 +- crates/uv-distribution-types/src/lib.rs | 8 +++--- .../uv-distribution-types/src/requirement.rs | 4 +-- .../src/metadata/requires_dist.rs | 6 +++-- crates/uv-distribution/src/source/mod.rs | 4 --- crates/uv-fs/src/lib.rs | 10 +++---- crates/uv-fs/src/path.rs | 4 +-- crates/uv-git-types/src/github.rs | 2 +- crates/uv-globfilter/src/main.rs | 2 +- crates/uv-installer/src/plan.rs | 2 +- crates/uv-metadata/src/lib.rs | 6 ++--- crates/uv-once-map/src/lib.rs | 2 +- crates/uv-pep508/src/lib.rs | 2 +- crates/uv-pep508/src/marker/parse.rs | 4 +-- crates/uv-pep508/src/marker/tree.rs | 4 +-- .../uv-pypi-types/src/metadata/metadata23.rs | 14 +++++----- crates/uv-python/src/discovery.rs | 8 +++--- crates/uv-python/src/downloads.rs | 4 +-- crates/uv-python/src/environment.rs | 4 +-- crates/uv-python/src/lib.rs | 2 +- crates/uv-python/src/managed.rs | 2 +- crates/uv-python/src/sysconfig/mod.rs | 2 +- crates/uv-python/src/virtualenv.rs | 2 +- crates/uv-python/src/windows_registry.rs | 4 +-- crates/uv-resolver/src/candidate_selector.rs | 2 +- crates/uv-resolver/src/lock/mod.rs | 8 +++--- crates/uv-resolver/src/lock/tree.rs | 7 ++--- crates/uv-resolver/src/pubgrub/priority.rs | 4 +-- crates/uv-resolver/src/pubgrub/report.rs | 6 ++--- crates/uv-resolver/src/resolver/mod.rs | 4 +-- crates/uv-resolver/src/resolver/urls.rs | 2 +- crates/uv-virtualenv/src/virtualenv.rs | 2 +- crates/uv-workspace/src/pyproject.rs | 6 ++--- crates/uv-workspace/src/pyproject_mut.rs | 2 +- crates/uv-workspace/src/workspace.rs | 8 +++--- crates/uv/src/commands/pip/tree.rs | 26 ++++++++++++------- crates/uv/src/commands/project/add.rs | 2 +- crates/uv/src/commands/project/init.rs | 6 ++--- crates/uv/src/commands/project/mod.rs | 20 ++++++++------ crates/uv/src/commands/project/run.rs | 14 +++++----- crates/uv/src/commands/python/find.rs | 2 +- crates/uv/src/commands/python/install.rs | 2 +- crates/uv/src/commands/python/list.rs | 4 +-- crates/uv/src/commands/python/pin.rs | 4 +-- crates/uv/src/commands/venv.rs | 2 +- crates/uv/src/commands/version.rs | 2 +- crates/uv/tests/it/common/mod.rs | 2 +- rust-toolchain.toml | 2 +- 64 files changed, 162 insertions(+), 144 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e7ceb113f..75ab8ccf8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ resolver = "2" [workspace.package] edition = "2021" -rust-version = "1.83" +rust-version = "1.84" homepage = "https://pypi.org/project/uv/" documentation = "https://pypi.org/project/uv/" repository = "https://github.com/astral-sh/uv" diff --git a/crates/uv-auth/src/credentials.rs b/crates/uv-auth/src/credentials.rs index c1a957dae..88f49425c 100644 --- a/crates/uv-auth/src/credentials.rs +++ b/crates/uv-auth/src/credentials.rs @@ -131,7 +131,7 @@ impl Credentials { // Ensure the username matches if provided if username.is_some_and(|username| username != entry.login) { return None; - }; + } Some(Credentials::Basic { username: Username::new(Some(entry.login.clone())), diff --git a/crates/uv-auth/src/middleware.rs b/crates/uv-auth/src/middleware.rs index 38c268f29..31f116a63 100644 --- a/crates/uv-auth/src/middleware.rs +++ b/crates/uv-auth/src/middleware.rs @@ -361,7 +361,7 @@ impl AuthMiddleware { { trace!("Updating cached credentials for {url} to {credentials:?}"); self.cache().insert(&url, credentials); - }; + } result } @@ -449,7 +449,7 @@ impl AuthMiddleware { trace!("Using credentials from previous fetch for {url}"); } else { trace!("Skipping fetch of credentials for {url}, previous attempt failed"); - }; + } return credentials; } @@ -513,14 +513,14 @@ fn tracing_url(request: &Request, credentials: Option<&Credentials>) -> String { .and_then(|credentials| credentials.username()) { let _ = url.set_username(username); - }; + } if credentials .as_ref() .and_then(|credentials| credentials.password()) .is_some() { let _ = url.set_password(Some("****")); - }; + } url.to_string() } else { request.url().to_string() diff --git a/crates/uv-build-backend/src/metadata.rs b/crates/uv-build-backend/src/metadata.rs index 50de430af..c5acb35bd 100644 --- a/crates/uv-build-backend/src/metadata.rs +++ b/crates/uv-build-backend/src/metadata.rs @@ -1,6 +1,7 @@ use std::collections::{BTreeMap, Bound}; use std::ffi::OsStr; use std::fmt::Display; +use std::fmt::Write; use std::path::{Path, PathBuf}; use std::str::FromStr; @@ -603,7 +604,7 @@ impl PyProjectToml { return Err(ValidationError::InvalidGroup(group.to_string())); } - writer.push_str(&format!("[{group}]\n")); + let _ = writeln!(writer, "[{group}]"); for (name, object_reference) in entries { // More strict than the spec, we enforce the recommendation if !name @@ -614,7 +615,7 @@ impl PyProjectToml { } // TODO(konsti): Validate that the object references are valid Python identifiers. - writer.push_str(&format!("{name} = {object_reference}\n")); + let _ = writeln!(writer, "{name} = {object_reference}"); } writer.push('\n'); Ok(()) @@ -963,7 +964,7 @@ mod tests { fn format_err(err: impl std::error::Error) -> String { let mut formatted = err.to_string(); for source in iter::successors(err.source(), |&err| err.source()) { - formatted += &format!("\n Caused by: {source}"); + let _ = write!(formatted, "\n Caused by: {source}"); } formatted } diff --git a/crates/uv-build-backend/src/source_dist.rs b/crates/uv-build-backend/src/source_dist.rs index 3449ee4e0..eec039cc9 100644 --- a/crates/uv-build-backend/src/source_dist.rs +++ b/crates/uv-build-backend/src/source_dist.rs @@ -231,7 +231,7 @@ fn write_source_dist( if !include_matcher.match_path(relative) || exclude_matcher.is_match(relative) { trace!("Excluding: `{}`", relative.user_display()); continue; - }; + } debug!("Including {}", relative.user_display()); if entry.file_type().is_dir() { diff --git a/crates/uv-build-backend/src/wheel.rs b/crates/uv-build-backend/src/wheel.rs index 5a3f27765..80074f116 100644 --- a/crates/uv-build-backend/src/wheel.rs +++ b/crates/uv-build-backend/src/wheel.rs @@ -560,7 +560,7 @@ fn wheel_subdir_from_globs( if !matcher.match_path(relative) { trace!("Excluding {}: `{}`", globs_field, relative.user_display()); continue; - }; + } let relative_licenses = Path::new(target) .join(relative) diff --git a/crates/uv-build-frontend/src/lib.rs b/crates/uv-build-frontend/src/lib.rs index af3491217..bd426d596 100644 --- a/crates/uv-build-frontend/src/lib.rs +++ b/crates/uv-build-frontend/src/lib.rs @@ -568,7 +568,7 @@ impl SourceBuild { nor `setup.cfg` are present in the directory", source_tree.simplified_display().cyan(), ); - }; + } } default_backend.clone() }; diff --git a/crates/uv-client/src/base_client.rs b/crates/uv-client/src/base_client.rs index 43a59139f..071779fbe 100644 --- a/crates/uv-client/src/base_client.rs +++ b/crates/uv-client/src/base_client.rs @@ -1,3 +1,11 @@ +use std::error::Error; +use std::fmt::Debug; +use std::fmt::Write; +use std::path::Path; +use std::sync::Arc; +use std::time::Duration; +use std::{env, iter}; + use itertools::Itertools; use reqwest::{Client, ClientBuilder, Proxy, Response}; use reqwest_middleware::{ClientWithMiddleware, Middleware}; @@ -5,14 +13,9 @@ use reqwest_retry::policies::ExponentialBackoff; use reqwest_retry::{ DefaultRetryableStrategy, RetryTransientMiddleware, Retryable, RetryableStrategy, }; -use std::error::Error; -use std::fmt::Debug; -use std::path::Path; -use std::sync::Arc; -use std::time::Duration; -use std::{env, iter}; use tracing::{debug, trace}; use url::Url; + use uv_auth::{AuthMiddleware, UrlAuthPolicies}; use uv_configuration::{KeyringProviderType, TrustedHost}; use uv_fs::Simplified; @@ -186,7 +189,7 @@ impl<'a> BaseClientBuilder<'a> { if let Some(markers) = self.markers { let linehaul = LineHaul::new(markers, self.platform); if let Ok(output) = serde_json::to_string(&linehaul) { - user_agent_string += &format!(" {output}"); + let _ = write!(user_agent_string, " {output}"); } } diff --git a/crates/uv-client/src/html.rs b/crates/uv-client/src/html.rs index d393475be..56776c5ef 100644 --- a/crates/uv-client/src/html.rs +++ b/crates/uv-client/src/html.rs @@ -130,7 +130,7 @@ impl SimpleHtml { // the final path component of the URL. let filename = path .split('/') - .last() + .next_back() .ok_or_else(|| Error::MissingFilename(href.to_string()))?; // Strip any query string from the filename. diff --git a/crates/uv-client/src/httpcache/control.rs b/crates/uv-client/src/httpcache/control.rs index f35850892..724683188 100644 --- a/crates/uv-client/src/httpcache/control.rs +++ b/crates/uv-client/src/httpcache/control.rs @@ -415,9 +415,8 @@ impl<'b, B: 'b + ?Sized + AsRef<[u8]>, I: Iterator> Iterator self.skip_whitespace(); self.maybe_parse_directive_delimiter(); let directive = CacheControlDirective { name, value }; - match self.emit_directive(directive) { - None => continue, - Some(d) => return Some(d), + if let Some(d) = self.emit_directive(directive) { + return Some(d); } } } diff --git a/crates/uv-client/src/registry_client.rs b/crates/uv-client/src/registry_client.rs index cb6a33b68..9450352a1 100644 --- a/crates/uv-client/src/registry_client.rs +++ b/crates/uv-client/src/registry_client.rs @@ -912,7 +912,7 @@ impl RegistryClient { return Err(err); } } - }; + } } // Create a request to stream the file. diff --git a/crates/uv-console/src/lib.rs b/crates/uv-console/src/lib.rs index 43eb677dc..b31762fd1 100644 --- a/crates/uv-console/src/lib.rs +++ b/crates/uv-console/src/lib.rs @@ -43,7 +43,7 @@ pub fn confirm(message: &str, term: &Term, default: bool) -> std::io::Result {} - }; + } }; let report = format!( diff --git a/crates/uv-dev/src/generate_cli_reference.rs b/crates/uv-dev/src/generate_cli_reference.rs index f57e4d665..bb4125dbe 100644 --- a/crates/uv-dev/src/generate_cli_reference.rs +++ b/crates/uv-dev/src/generate_cli_reference.rs @@ -113,6 +113,7 @@ fn generate() -> String { output } +#[allow(clippy::format_push_string)] fn generate_command<'a>(output: &mut String, command: &'a Command, parents: &mut Vec<&'a Command>) { if command.is_hide_set() && !SHOW_HIDDEN_COMMANDS.contains(&command.get_name()) { return; @@ -137,7 +138,7 @@ fn generate_command<'a>(output: &mut String, command: &'a Command, parents: &mut if let Some(about) = command.get_long_about().or_else(|| command.get_about()) { output.push_str(&about.to_string()); output.push_str("\n\n"); - }; + } // Display the usage { diff --git a/crates/uv-dev/src/generate_options_reference.rs b/crates/uv-dev/src/generate_options_reference.rs index 96ae15340..ce2648ecf 100644 --- a/crates/uv-dev/src/generate_options_reference.rs +++ b/crates/uv-dev/src/generate_options_reference.rs @@ -204,6 +204,7 @@ impl Set { } } +#[allow(clippy::format_push_string)] fn emit_field(output: &mut String, name: &str, field: &OptionField, parents: &[Set]) { let header_level = if parents.len() > 1 { "####" } else { "###" }; let parents_anchor = parents.iter().filter_map(|parent| parent.name()).join("_"); diff --git a/crates/uv-distribution-filename/src/splitter.rs b/crates/uv-distribution-filename/src/splitter.rs index 1e6177d23..b692bd1fa 100644 --- a/crates/uv-distribution-filename/src/splitter.rs +++ b/crates/uv-distribution-filename/src/splitter.rs @@ -43,7 +43,7 @@ impl<'a> Iterator for MemchrSplitter<'a> { let min = usize::from(self.offset < self.haystack.len()); // Maximum possible splits is remaining length divided by 2 (minimum one char between delimiters). - let max = (self.haystack.len() - self.offset + 1) / 2 + min; + let max = (self.haystack.len() - self.offset).div_ceil(2) + min; (min, Some(max)) } diff --git a/crates/uv-distribution-filename/src/wheel.rs b/crates/uv-distribution-filename/src/wheel.rs index 4db9bea80..95ee8de93 100644 --- a/crates/uv-distribution-filename/src/wheel.rs +++ b/crates/uv-distribution-filename/src/wheel.rs @@ -243,7 +243,7 @@ impl WheelFilename { // Determine whether any of the tag types contain a period, which would indicate // that at least one of the tag types includes multiple tags (which in turn // necessitates taking the slow path). - memchr(b'.', stem[build_tag_or_python_tag..].as_bytes()).is_none(), + memchr(b'.', &stem.as_bytes()[build_tag_or_python_tag..]).is_none(), ) }; @@ -312,7 +312,7 @@ impl TryFrom<&Url> for WheelFilename { "URL must have a path".to_string(), ) })? - .last() + .next_back() .ok_or_else(|| { WheelFilenameError::InvalidWheelFileName( url.to_string(), diff --git a/crates/uv-distribution-types/src/installed.rs b/crates/uv-distribution-types/src/installed.rs index c5917b31d..c96002729 100644 --- a/crates/uv-distribution-types/src/installed.rs +++ b/crates/uv-distribution-types/src/installed.rs @@ -202,7 +202,7 @@ impl InstalledDist { path: path.to_path_buf().into_boxed_path(), }))); } - }; + } if metadata.is_dir() { let Some(egg_metadata) = read_metadata(&path.join("PKG-INFO")) else { diff --git a/crates/uv-distribution-types/src/lib.rs b/crates/uv-distribution-types/src/lib.rs index b94094f68..1cb983be2 100644 --- a/crates/uv-distribution-types/src/lib.rs +++ b/crates/uv-distribution-types/src/lib.rs @@ -942,12 +942,14 @@ impl RemoteSource for File { impl RemoteSource for Url { fn filename(&self) -> Result, Error> { // Identify the last segment of the URL as the filename. - let path_segments = self + let mut path_segments = self .path_segments() .ok_or_else(|| Error::MissingPathSegments(self.to_string()))?; // This is guaranteed by the contract of `Url::path_segments`. - let last = path_segments.last().expect("path segments is non-empty"); + let last = path_segments + .next_back() + .expect("path segments is non-empty"); // Decode the filename, which may be percent-encoded. let filename = percent_encoding::percent_decode_str(last).decode_utf8()?; @@ -966,7 +968,7 @@ impl RemoteSource for UrlString { let last = self .base_str() .split('/') - .last() + .next_back() .ok_or_else(|| Error::MissingPathSegments(self.to_string()))?; // Decode the filename, which may be percent-encoded. diff --git a/crates/uv-distribution-types/src/requirement.rs b/crates/uv-distribution-types/src/requirement.rs index 79474646c..991eac1ea 100644 --- a/crates/uv-distribution-types/src/requirement.rs +++ b/crates/uv-distribution-types/src/requirement.rs @@ -838,8 +838,8 @@ impl TryFrom for RequirementSource { "subdirectory" => { subdirectory = Some(PortablePathBuf::from(val.as_ref())); } - _ => continue, - }; + _ => {} + } } let precise = repository.fragment().map(GitOid::from_str).transpose()?; diff --git a/crates/uv-distribution/src/metadata/requires_dist.rs b/crates/uv-distribution/src/metadata/requires_dist.rs index 290e72663..393f67f4f 100644 --- a/crates/uv-distribution/src/metadata/requires_dist.rs +++ b/crates/uv-distribution/src/metadata/requires_dist.rs @@ -497,12 +497,14 @@ mod test { } async fn format_err(input: &str) -> String { + use std::fmt::Write; + let err = requires_dist_from_pyproject_toml(input).await.unwrap_err(); let mut causes = err.chain(); let mut message = String::new(); - message.push_str(&format!("error: {}\n", causes.next().unwrap())); + let _ = writeln!(message, "error: {}", causes.next().unwrap()); for err in causes { - message.push_str(&format!(" Caused by: {err}\n")); + let _ = writeln!(message, " Caused by: {err}"); } message } diff --git a/crates/uv-distribution/src/source/mod.rs b/crates/uv-distribution/src/source/mod.rs index 9051f7ace..8357c5226 100644 --- a/crates/uv-distribution/src/source/mod.rs +++ b/crates/uv-distribution/src/source/mod.rs @@ -2420,8 +2420,6 @@ pub fn prune(cache: &Cache) -> Result { } } } - - continue; } // If we find a `revision.rev` file, read the pointer, and remove any extraneous @@ -2445,8 +2443,6 @@ pub fn prune(cache: &Cache) -> Result { } } } - - continue; } } } diff --git a/crates/uv-fs/src/lib.rs b/crates/uv-fs/src/lib.rs index e13672f6c..f06a8f817 100644 --- a/crates/uv-fs/src/lib.rs +++ b/crates/uv-fs/src/lib.rs @@ -24,7 +24,7 @@ pub fn is_same_file_allow_missing(left: &Path, right: &Path) -> Option { // Second, check the files directly. if let Ok(value) = same_file::is_same_file(left, right) { return Some(value); - }; + } // Often, one of the directories won't exist yet so perform the comparison up a level. if let (Some(left_parent), Some(right_parent), Some(left_name), Some(right_name)) = ( @@ -38,7 +38,7 @@ pub fn is_same_file_allow_missing(left: &Path, right: &Path) -> Option { Ok(false) => return Some(false), _ => (), } - }; + } // We couldn't determine if they're the same. None @@ -106,7 +106,7 @@ pub fn replace_symlink(src: impl AsRef, dst: impl AsRef) -> std::io: }, Err(err) if err.kind() == std::io::ErrorKind::NotFound => {} Err(err) => return Err(err), - }; + } // Replace it with a new symlink. junction::create( @@ -411,7 +411,7 @@ pub async fn persist_with_retry( to.display(), error_message, ); - }; + } }) .await; @@ -485,7 +485,7 @@ pub fn persist_with_retry_sync( to.display(), error_message, ); - }; + } }) .call(); diff --git a/crates/uv-fs/src/path.rs b/crates/uv-fs/src/path.rs index 68da241b7..5bfa7a72d 100644 --- a/crates/uv-fs/src/path.rs +++ b/crates/uv-fs/src/path.rs @@ -258,7 +258,7 @@ fn normalized(path: &Path) -> PathBuf { normalized.push(component); } Component::ParentDir => { - match normalized.components().last() { + match normalized.components().next_back() { None | Some(Component::ParentDir | Component::RootDir) => { // Preserve leading and above-root `..` normalized.push(component); @@ -331,7 +331,7 @@ pub fn relative_to( // go as many levels up as required let levels_up = base.components().count() - common_prefix.components().count(); - let up = std::iter::repeat("..").take(levels_up).collect::(); + let up = std::iter::repeat_n("..", levels_up).collect::(); Ok(up.join(stripped)) } diff --git a/crates/uv-git-types/src/github.rs b/crates/uv-git-types/src/github.rs index 006178a21..4c536af4f 100644 --- a/crates/uv-git-types/src/github.rs +++ b/crates/uv-git-types/src/github.rs @@ -20,7 +20,7 @@ impl<'a> GitHubRepository<'a> { // The fast path is only available for GitHub repositories. if url.host_str() != Some("github.com") { return None; - }; + } // The GitHub URL must take the form: `https://github.com/{user}/{repo}`, e.g., // `https://github.com/astral-sh/uv`. diff --git a/crates/uv-globfilter/src/main.rs b/crates/uv-globfilter/src/main.rs index 30a12b665..32174d780 100644 --- a/crates/uv-globfilter/src/main.rs +++ b/crates/uv-globfilter/src/main.rs @@ -56,7 +56,7 @@ fn main() { if !include_matcher.match_path(&relative) || exclude_matcher.is_match(&relative) { trace!("Excluding: `{}`", relative.display()); continue; - }; + } println!("{}", relative.display()); } } diff --git a/crates/uv-installer/src/plan.rs b/crates/uv-installer/src/plan.rs index b420ba118..7b1b38dca 100644 --- a/crates/uv-installer/src/plan.rs +++ b/crates/uv-installer/src/plan.rs @@ -287,7 +287,7 @@ impl<'a> Planner<'a> { } if entry.dist.filename.version != sdist.version { return None; - }; + } if entry.built && no_build { return None; } diff --git a/crates/uv-metadata/src/lib.rs b/crates/uv-metadata/src/lib.rs index 5d9fd7079..d1b38aed2 100644 --- a/crates/uv-metadata/src/lib.rs +++ b/crates/uv-metadata/src/lib.rs @@ -96,7 +96,7 @@ pub fn find_archive_dist_info<'a, T: Copy>( dist_info_prefix.to_string(), filename.name.to_string(), )); - }; + } Ok((payload, dist_info_prefix)) } @@ -125,7 +125,7 @@ pub fn is_metadata_entry(path: &str, filename: &WheelFilename) -> Result OnceMap { // Make sure the value wasn't inserted in-between us checking the map and registering the waiter. if let Value::Filled(value) = self.items.get(key).expect("map is append-only").value() { return Some(value.clone()); - }; + } // Wait until the value is inserted. notification.await; diff --git a/crates/uv-pep508/src/lib.rs b/crates/uv-pep508/src/lib.rs index 08f3f2521..0a9991654 100644 --- a/crates/uv-pep508/src/lib.rs +++ b/crates/uv-pep508/src/lib.rs @@ -635,7 +635,7 @@ fn parse_extras_cursor( }); } _ => {} - }; + } // wsp* after the identifier cursor.eat_whitespace(); diff --git a/crates/uv-pep508/src/marker/parse.rs b/crates/uv-pep508/src/marker/parse.rs index 21e41eff7..13620662b 100644 --- a/crates/uv-pep508/src/marker/parse.rs +++ b/crates/uv-pep508/src/marker/parse.rs @@ -50,7 +50,7 @@ fn parse_marker_operator( input: cursor.to_string(), }); } - }; + } cursor.eat_whitespace(); cursor.next_expect_char('i', cursor.pos())?; cursor.next_expect_char('n', cursor.pos())?; @@ -607,7 +607,7 @@ pub(crate) fn parse_markers_cursor( len: cursor.remaining(), input: cursor.to_string(), }); - }; + } Ok(marker) } diff --git a/crates/uv-pep508/src/marker/tree.rs b/crates/uv-pep508/src/marker/tree.rs index 26fbe4d36..01a811633 100644 --- a/crates/uv-pep508/src/marker/tree.rs +++ b/crates/uv-pep508/src/marker/tree.rs @@ -931,14 +931,14 @@ impl MarkerTree { MarkerWarningKind::LexicographicComparison, format!("Comparing {l_string} and {value} lexicographically"), ); - }; + } if let Bound::Included(value) | Bound::Excluded(value) = end { reporter.report( MarkerWarningKind::LexicographicComparison, format!("Comparing {l_string} and {value} lexicographically"), ); - }; + } } } diff --git a/crates/uv-pypi-types/src/metadata/metadata23.rs b/crates/uv-pypi-types/src/metadata/metadata23.rs index 3fff955e2..cd934a25d 100644 --- a/crates/uv-pypi-types/src/metadata/metadata23.rs +++ b/crates/uv-pypi-types/src/metadata/metadata23.rs @@ -1,10 +1,12 @@ //! Vendored from +use std::fmt::Display; +use std::fmt::Write; +use std::str; +use std::str::FromStr; + use crate::metadata::Headers; use crate::MetadataError; -use std::fmt::Display; -use std::str; -use std::str::FromStr; /// Code Metadata 2.3 as specified in /// . @@ -200,15 +202,15 @@ impl Metadata23 { let value = value.to_string(); let mut lines = value.lines(); if let Some(line) = lines.next() { - writer.push_str(&format!("{key}: {line}\n")); + let _ = writeln!(writer, "{key}: {line}"); } else { // The value is an empty string - writer.push_str(&format!("{key}: \n")); + let _ = writeln!(writer, "{key}: "); } for line in lines { // Python implementations vary // https://github.com/pypa/pyproject-metadata/pull/150/files#diff-7d938dbc255a08c2cfab1b4f1f8d1f6519c9312dd0a39d7793fa778474f1fbd1L135-R141 - writer.push_str(&format!("{}{}\n", " ".repeat(key.len() + 2), line)); + let _ = writeln!(writer, "{}{}", " ".repeat(key.len() + 2), line); } } fn write_opt_str(writer: &mut String, key: &str, value: Option<&impl Display>) { diff --git a/crates/uv-python/src/discovery.rs b/crates/uv-python/src/discovery.rs index c406a249e..3c301b7c7 100644 --- a/crates/uv-python/src/discovery.rs +++ b/crates/uv-python/src/discovery.rs @@ -978,7 +978,7 @@ pub fn find_python_installations<'a>( PythonRequest::Version(version) => { if let Err(err) = version.check_supported() { return Box::new(iter::once(Err(Error::InvalidVersionRequest(err)))); - }; + } Box::new({ debug!("Searching for {request} in {sources}"); python_interpreters(version, None, environments, preference, cache) @@ -1004,7 +1004,7 @@ pub fn find_python_installations<'a>( PythonRequest::ImplementationVersion(implementation, version) => { if let Err(err) = version.check_supported() { return Box::new(iter::once(Err(Error::InvalidVersionRequest(err)))); - }; + } Box::new({ debug!("Searching for {request} in {sources}"); python_interpreters( @@ -1026,8 +1026,8 @@ pub fn find_python_installations<'a>( if let Some(version) = request.version() { if let Err(err) = version.check_supported() { return Box::new(iter::once(Err(Error::InvalidVersionRequest(err)))); - }; - }; + } + } Box::new({ debug!("Searching for {request} in {sources}"); python_interpreters( diff --git a/crates/uv-python/src/downloads.rs b/crates/uv-python/src/downloads.rs index aa5ca64fd..74a2afa3a 100644 --- a/crates/uv-python/src/downloads.rs +++ b/crates/uv-python/src/downloads.rs @@ -555,7 +555,7 @@ impl ManagedPythonDownload { return Ok(DownloadResult::AlreadyAvailable(path)); } - let filename = url.path_segments().unwrap().last().unwrap(); + let filename = url.path_segments().unwrap().next_back().unwrap(); let ext = SourceDistExtension::from_path(filename) .map_err(|err| Error::MissingExtension(url.to_string(), err))?; let (reader, size) = read_url(&url, client).await?; @@ -593,7 +593,7 @@ impl ManagedPythonDownload { .await .map_err(|err| Error::ExtractError(filename.to_string(), err))?; } - }; + } hasher.finish().await.map_err(Error::HashExhaustion)?; diff --git a/crates/uv-python/src/environment.rs b/crates/uv-python/src/environment.rs index 311f0ee1a..d4e72f206 100644 --- a/crates/uv-python/src/environment.rs +++ b/crates/uv-python/src/environment.rs @@ -177,7 +177,7 @@ impl PythonEnvironment { })); } Err(err) => return Err(Error::Discovery(err.into())), - }; + } if root.as_ref().is_file() { return Err(InvalidEnvironment { @@ -211,7 +211,7 @@ impl PythonEnvironment { kind: InvalidEnvironmentKind::MissingExecutable(executable.clone()), } .into()); - }; + } let interpreter = Interpreter::query(executable, cache)?; diff --git a/crates/uv-python/src/lib.rs b/crates/uv-python/src/lib.rs index 3f4e24c7f..ca723db6d 100644 --- a/crates/uv-python/src/lib.rs +++ b/crates/uv-python/src/lib.rs @@ -162,7 +162,7 @@ mod tests { match self.search_path.as_mut() { Some(paths) => paths.push(path), None => self.search_path = Some(vec![path]), - }; + } } /// Create a new directory and add it to the search path. diff --git a/crates/uv-python/src/managed.rs b/crates/uv-python/src/managed.rs index 72b43180c..343c4ad74 100644 --- a/crates/uv-python/src/managed.rs +++ b/crates/uv-python/src/managed.rs @@ -496,7 +496,7 @@ impl ManagedPythonInstallation { err, }) } - }; + } } Ok(()) diff --git a/crates/uv-python/src/sysconfig/mod.rs b/crates/uv-python/src/sysconfig/mod.rs index 52401ed15..79f7349e6 100644 --- a/crates/uv-python/src/sysconfig/mod.rs +++ b/crates/uv-python/src/sysconfig/mod.rs @@ -224,7 +224,7 @@ fn find_sysconfigdata( let metadata = entry.metadata()?; if metadata.is_symlink() { continue; - }; + } if metadata.is_file() { return Ok(entry.path()); diff --git a/crates/uv-python/src/virtualenv.rs b/crates/uv-python/src/virtualenv.rs index 4fb989b7c..d95ee1c55 100644 --- a/crates/uv-python/src/virtualenv.rs +++ b/crates/uv-python/src/virtualenv.rs @@ -111,7 +111,7 @@ pub(crate) fn conda_environment_from_env(kind: CondaEnvironmentKind) -> Option

( .context("Failed to clear registry entries under HKCU:\\{python_entry}"), )); } - }; + } } } @@ -284,6 +284,6 @@ pub fn remove_orphan_registry_entries(installations: &[ManagedPythonInstallation if let Err(err) = CURRENT_USER.remove_tree(&python_entry) { // TODO(konsti): We don't have an installation key here. warn_user_once!("Failed to remove orphan registry key HKCU:\\{python_entry}: {err}"); - }; + } } } diff --git a/crates/uv-resolver/src/candidate_selector.rs b/crates/uv-resolver/src/candidate_selector.rs index f5104eb8e..985c2826e 100644 --- a/crates/uv-resolver/src/candidate_selector.rs +++ b/crates/uv-resolver/src/candidate_selector.rs @@ -522,7 +522,7 @@ impl CandidateSelector { } if !range.contains(version) { continue; - }; + } let Some(dist) = maybe_dist.prioritized_dist() else { continue; }; diff --git a/crates/uv-resolver/src/lock/mod.rs b/crates/uv-resolver/src/lock/mod.rs index 1e8da1ced..13605fba3 100644 --- a/crates/uv-resolver/src/lock/mod.rs +++ b/crates/uv-resolver/src/lock/mod.rs @@ -1459,7 +1459,7 @@ impl Lock { return Ok(SatisfiesResult::MissingLocalIndex(name, version, path)); } } - }; + } } // If the package is immutable, we don't need to validate it (or its dependencies). @@ -2257,7 +2257,7 @@ impl Package { } .into()), }; - }; + } } if let Some(sdist) = self.to_source_dist(workspace_root)? { @@ -3599,8 +3599,8 @@ impl GitSource { "branch" => kind = GitSourceKind::Branch(val.into_owned()), "rev" => kind = GitSourceKind::Rev(val.into_owned()), "subdirectory" => subdirectory = Some(PortablePathBuf::from(val.as_ref()).into()), - _ => continue, - }; + _ => {} + } } let precise = GitOid::from_str(url.fragment().ok_or(GitSourceError::MissingSha)?) .map_err(|_| GitSourceError::InvalidSha)?; diff --git a/crates/uv-resolver/src/lock/tree.rs b/crates/uv-resolver/src/lock/tree.rs index 53f295576..604c1446b 100644 --- a/crates/uv-resolver/src/lock/tree.rs +++ b/crates/uv-resolver/src/lock/tree.rs @@ -1,4 +1,5 @@ use std::collections::{BTreeSet, VecDeque}; +use std::fmt::Write; use either::Either; use itertools::Itertools; @@ -431,17 +432,17 @@ impl<'env> TreeDisplay<'env> { if let Some(version) = package_id.version.as_ref() { line.push(' '); line.push('v'); - line.push_str(&format!("{version}")); + let _ = write!(line, "{version}"); } if let Some(edge) = edge { match edge { Edge::Prod(_) => {} Edge::Optional(extra, _) => { - line.push_str(&format!(" (extra: {extra})")); + let _ = write!(line, " (extra: {extra})"); } Edge::Dev(group, _) => { - line.push_str(&format!(" (group: {group})")); + let _ = write!(line, " (group: {group})"); } } } diff --git a/crates/uv-resolver/src/pubgrub/priority.rs b/crates/uv-resolver/src/pubgrub/priority.rs index 539d2c51a..c69adbae4 100644 --- a/crates/uv-resolver/src/pubgrub/priority.rs +++ b/crates/uv-resolver/src/pubgrub/priority.rs @@ -188,7 +188,7 @@ impl PubGrubPriorities { if matches!(entry.get(), PubGrubPriority::ConflictEarly(_)) { // Already in the right category return false; - }; + } let index = Self::get_index(&entry).unwrap_or(len); entry.insert(PubGrubPriority::ConflictEarly(Reverse(index))); true @@ -225,7 +225,7 @@ impl PubGrubPriorities { ) { // Already in the right category return false; - }; + } let index = Self::get_index(&entry).unwrap_or(len); entry.insert(PubGrubPriority::ConflictLate(Reverse(index))); true diff --git a/crates/uv-resolver/src/pubgrub/report.rs b/crates/uv-resolver/src/pubgrub/report.rs index 4fe68fbf0..06f3e8d4a 100644 --- a/crates/uv-resolver/src/pubgrub/report.rs +++ b/crates/uv-resolver/src/pubgrub/report.rs @@ -711,7 +711,7 @@ impl PubGrubReportFormatter<'_> { output_hints, ); } - }; + } } /// Generate a [`PubGrubHint`] for a package that doesn't have any wheels matching the current @@ -1957,7 +1957,7 @@ impl std::fmt::Display for PackageRange<'_> { (Bound::Excluded(v), Bound::Unbounded) => write!(f, "{package}>{v}")?, (Bound::Excluded(v), Bound::Included(b)) => write!(f, "{package}>{v},<={b}")?, (Bound::Excluded(v), Bound::Excluded(b)) => write!(f, "{package}>{v},<{b}")?, - }; + } } if segments.len() > 1 { writeln!(f)?; @@ -2015,7 +2015,7 @@ impl std::fmt::Display for DependsOn<'_> { write!(f, "depend on ")?; } else { write!(f, "depends on ")?; - }; + } match self.dependency2 { Some(ref dependency2) => write!( diff --git a/crates/uv-resolver/src/resolver/mod.rs b/crates/uv-resolver/src/resolver/mod.rs index 17d307228..e482b0d27 100644 --- a/crates/uv-resolver/src/resolver/mod.rs +++ b/crates/uv-resolver/src/resolver/mod.rs @@ -1363,7 +1363,7 @@ impl ResolverState { return Err(err.into()); } - }; + } return Ok(()); } diff --git a/crates/uv-workspace/src/pyproject.rs b/crates/uv-workspace/src/pyproject.rs index 875320ff6..6b2cc9930 100644 --- a/crates/uv-workspace/src/pyproject.rs +++ b/crates/uv-workspace/src/pyproject.rs @@ -830,10 +830,10 @@ impl TryFrom for Sources { for (lhs, rhs) in sources.iter().zip(sources.iter().skip(1)) { if lhs.extra() != rhs.extra() { continue; - }; + } if lhs.group() != rhs.group() { continue; - }; + } let lhs = lhs.marker(); let rhs = rhs.marker(); @@ -1070,7 +1070,7 @@ impl<'de> Deserialize<'de> for Source { "expected at most one of `rev`, `tag`, or `branch`", )); } - }; + } // If the user prefixed the URL with `git+`, strip it. let git = if let Some(git) = git.as_str().strip_prefix("git+") { diff --git a/crates/uv-workspace/src/pyproject_mut.rs b/crates/uv-workspace/src/pyproject_mut.rs index 0df74265c..f69c6c802 100644 --- a/crates/uv-workspace/src/pyproject_mut.rs +++ b/crates/uv-workspace/src/pyproject_mut.rs @@ -1121,7 +1121,7 @@ pub fn add_dependency( decor.set_prefix(targeted_decor.prefix().unwrap().clone()); targeted_decor.set_prefix(""); // Re-formatted later by `reformat_array_multiline` } - }; + } deps.insert_formatted(index, value); diff --git a/crates/uv-workspace/src/workspace.rs b/crates/uv-workspace/src/workspace.rs index 0e67add84..3428741ec 100644 --- a/crates/uv-workspace/src/workspace.rs +++ b/crates/uv-workspace/src/workspace.rs @@ -553,12 +553,12 @@ impl Workspace { if value.is_empty() { return None; - }; + } let path = PathBuf::from(value); if path.is_absolute() { return Some(path); - }; + } // Resolve the path relative to the install path. Some(workspace.install_path.join(path)) @@ -570,12 +570,12 @@ impl Workspace { if value.is_empty() { return None; - }; + } let path = PathBuf::from(value); if path.is_absolute() { return Some(path); - }; + } // Resolve the path relative to current directory. // Note this differs from `UV_PROJECT_ENVIRONMENT` diff --git a/crates/uv/src/commands/pip/tree.rs b/crates/uv/src/commands/pip/tree.rs index 418c75fb3..1776ea4b9 100644 --- a/crates/uv/src/commands/pip/tree.rs +++ b/crates/uv/src/commands/pip/tree.rs @@ -379,17 +379,23 @@ impl<'env> DisplayDependencyGraph<'env> { if self.invert { let parent = self.graph.edge_endpoints(edge).unwrap().0; let parent = &self.graph[parent].name; - let version = match source.version_or_url.as_ref() { - None => "*".to_string(), - Some(version) => version.to_string(), - }; - line.push_str(&format!("[requires: {parent} {version}]")); + match source.version_or_url.as_ref() { + None => { + let _ = write!(line, "[requires: {parent} *]"); + } + Some(version) => { + let _ = write!(line, "[requires: {parent} {version}]"); + } + } } else { - let version = match source.version_or_url.as_ref() { - None => "*".to_string(), - Some(version) => version.to_string(), - }; - line.push_str(&format!("[required: {version}]")); + match source.version_or_url.as_ref() { + None => { + let _ = write!(line, "[required: *]"); + } + Some(version) => { + let _ = write!(line, "[required: {version}]"); + } + } } } } diff --git a/crates/uv/src/commands/project/add.rs b/crates/uv/src/commands/project/add.rs index 0b515e1be..8b96364e5 100644 --- a/crates/uv/src/commands/project/add.rs +++ b/crates/uv/src/commands/project/add.rs @@ -506,7 +506,7 @@ pub(crate) async fn add( // Redact the credentials. redact_credentials(&mut git); - }; + } Some(Source::Git { git, subdirectory, diff --git a/crates/uv/src/commands/project/init.rs b/crates/uv/src/commands/project/init.rs index 44b3efabd..165fdfb2f 100644 --- a/crates/uv/src/commands/project/init.rs +++ b/crates/uv/src/commands/project/init.rs @@ -866,7 +866,7 @@ impl InitProjectKind { // Generate `src` files if !bare { generate_package_scripts(name, path, build_backend, true)?; - }; + } // Initialize the version control system. init_vcs(path, vcs)?; @@ -1136,7 +1136,7 @@ fn generate_package_scripts( let pyi_file = pkg_dir.join("_core.pyi"); if !pyi_file.try_exists()? { fs_err::write(pyi_file, pyi_contents)?; - }; + } // Return python script calling binary binary_call_script } @@ -1167,7 +1167,7 @@ fn generate_package_scripts( let pyi_file = pkg_dir.join("_core.pyi"); if !pyi_file.try_exists()? { fs_err::write(pyi_file, pyi_contents)?; - }; + } // Return python script calling binary binary_call_script } diff --git a/crates/uv/src/commands/project/mod.rs b/crates/uv/src/commands/project/mod.rs index 07af52b9c..ed562f36f 100644 --- a/crates/uv/src/commands/project/mod.rs +++ b/crates/uv/src/commands/project/mod.rs @@ -340,7 +340,11 @@ impl std::fmt::Display for ConflictError { } ConflictPackage::Group(ref group) => format!("group `{group}`"), }; - (i == 0).then(|| capitalize(&conflict)).unwrap_or(conflict) + if i == 0 { + capitalize(&conflict) + } else { + conflict + } }) .collect() ) @@ -561,12 +565,12 @@ impl ScriptInterpreter { if value.is_empty() { return None; - }; + } let path = PathBuf::from(value); if path.is_absolute() { return Some(path); - }; + } // Resolve the path relative to current directory. Some(CWD.join(path)) @@ -689,7 +693,7 @@ impl ScriptInterpreter { } Err(uv_python::Error::MissingEnvironment(_)) => {} Err(err) => warn!("Ignoring existing script environment: {err}"), - }; + } let client_builder = BaseClientBuilder::new() .connectivity(network_settings.connectivity) @@ -849,7 +853,7 @@ impl ProjectInterpreter { } // If the environment is an empty directory, it's fine to use InvalidEnvironmentKind::Empty => {} - }; + } } Err(uv_python::Error::Query(uv_python::InterpreterError::NotFound(path))) => { if path.is_symlink() { @@ -862,7 +866,7 @@ impl ProjectInterpreter { } } Err(err) => return Err(err.into()), - }; + } let client_builder = BaseClientBuilder::default() .connectivity(network_settings.connectivity) @@ -1033,7 +1037,7 @@ impl WorkspacePython { "Using Python request `{}` from {source}", python_request.to_canonical_string() ); - }; + } Ok(Self { source, @@ -1098,7 +1102,7 @@ impl ScriptPython { if let Some(python_request) = python_request.as_ref() { debug!("Using Python request {python_request} from {source}"); - }; + } Ok(Self { source, diff --git a/crates/uv/src/commands/project/run.rs b/crates/uv/src/commands/project/run.rs index ded2fc2f7..8ba505769 100644 --- a/crates/uv/src/commands/project/run.rs +++ b/crates/uv/src/commands/project/run.rs @@ -937,14 +937,14 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl // If `--system-site-packages` is enabled, add the system site packages to the ephemeral // environment. - if base_interpreter - .is_virtualenv() - .then(|| { + if if base_interpreter.is_virtualenv() { + { PyVenvConfiguration::parse(base_interpreter.sys_prefix().join("pyvenv.cfg")) .is_ok_and(|cfg| cfg.include_system_site_packages()) - }) - .unwrap_or(false) - { + } + } else { + false + } { ephemeral_env.set_system_site_packages()?; } else { ephemeral_env.clear_system_site_packages()?; @@ -1068,7 +1068,7 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl // Ensure `VIRTUAL_ENV` is set. if interpreter.is_virtualenv() { process.env(EnvVars::VIRTUAL_ENV, interpreter.sys_prefix().as_os_str()); - }; + } // Spawn and wait for completion // Standard input, output, and error streams are all inherited diff --git a/crates/uv/src/commands/python/find.rs b/crates/uv/src/commands/python/find.rs index ce853c701..0ad4a6a0b 100644 --- a/crates/uv/src/commands/python/find.rs +++ b/crates/uv/src/commands/python/find.rs @@ -88,7 +88,7 @@ pub(crate) async fn find( warn_user!("{err}"); } } - }; + } if show_version { writeln!( diff --git a/crates/uv/src/commands/python/install.rs b/crates/uv/src/commands/python/install.rs index 477f38d7d..a5c3b9555 100644 --- a/crates/uv/src/commands/python/install.rs +++ b/crates/uv/src/commands/python/install.rs @@ -463,7 +463,7 @@ pub(crate) async fn install( event.key.bold(), )?; } - }; + } } if preview.is_enabled() { diff --git a/crates/uv/src/commands/python/list.rs b/crates/uv/src/commands/python/list.rs index 3e604ee8d..e6323a665 100644 --- a/crates/uv/src/commands/python/list.rs +++ b/crates/uv/src/commands/python/list.rs @@ -112,7 +112,7 @@ pub(crate) async fn list( Either::Right(download.url()), )); } - }; + } let installed = match kinds { @@ -223,7 +223,7 @@ pub(crate) async fn list( Either::Right(url) => { url_or_none = Some((*url).to_string()); } - }; + } let version = key.version(); let release = version.release(); diff --git a/crates/uv/src/commands/python/pin.rs b/crates/uv/src/commands/python/pin.rs index effbb0e26..a07b07a96 100644 --- a/crates/uv/src/commands/python/pin.rs +++ b/crates/uv/src/commands/python/pin.rs @@ -116,11 +116,11 @@ pub(crate) async fn pin( ) { if resolved { return Err(err); - }; + } warn_user_once!("{err}"); } } - }; + } } let request = if resolved { diff --git a/crates/uv/src/commands/venv.rs b/crates/uv/src/commands/venv.rs index bec84418d..2580d99e1 100644 --- a/crates/uv/src/commands/venv.rs +++ b/crates/uv/src/commands/venv.rs @@ -254,7 +254,7 @@ async fn venv_impl( warn_user!("{err}"); } } - }; + } writeln!( printer.stderr(), diff --git a/crates/uv/src/commands/version.rs b/crates/uv/src/commands/version.rs index 5c9e679fc..71da73d77 100644 --- a/crates/uv/src/commands/version.rs +++ b/crates/uv/src/commands/version.rs @@ -15,6 +15,6 @@ pub(crate) fn version(output_format: VersionFormat, buffer: &mut dyn std::io::Wr // Add a trailing newline writeln!(buffer)?; } - }; + } Ok(()) } diff --git a/crates/uv/tests/it/common/mod.rs b/crates/uv/tests/it/common/mod.rs index 6b8f1e1bb..0c6d491f2 100644 --- a/crates/uv/tests/it/common/mod.rs +++ b/crates/uv/tests/it/common/mod.rs @@ -564,7 +564,7 @@ impl TestContext { ), "[SITE_PACKAGES]/".to_string(), )); - }; + } // Filter non-deterministic temporary directory names // Note we apply this _after_ all the full paths to avoid breaking their matching diff --git a/rust-toolchain.toml b/rust-toolchain.toml index c5794a6b8..e7f22fb8b 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.85" +channel = "1.86"