From 6cc7a560f72a9e34907df5309d61980dac52a044 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Tue, 3 Dec 2024 13:21:05 -0600 Subject: [PATCH] Revert "Upgrade to Rust 1.83 (#9511)" (#9617) This reverts commit cf20673197f2073aa2ccde999423b816d3cb5ca5 (#9511) due to failure on powerpc64le in https://github.com/astral-sh/uv/pull/9612 --- Cargo.toml | 2 +- crates/uv-cache/src/wheel.rs | 2 +- crates/uv-client/src/httpcache/mod.rs | 1 - crates/uv-client/src/remote_metadata.rs | 2 +- .../uv-configuration/src/name_specifiers.rs | 2 +- crates/uv-distribution-types/src/buildable.rs | 2 +- crates/uv-distribution-types/src/hash.rs | 2 +- crates/uv-distribution-types/src/lib.rs | 4 +-- .../uv-distribution/src/metadata/lowering.rs | 4 +-- crates/uv-distribution/src/source/mod.rs | 4 +-- crates/uv-extract/src/hash.rs | 2 +- crates/uv-install-wheel/src/linker.rs | 4 +-- crates/uv-options-metadata/src/lib.rs | 2 +- crates/uv-pep440/src/version.rs | 2 +- crates/uv-pep508/src/marker/tree.rs | 4 +-- crates/uv-pypi-types/src/conflicts.rs | 6 ++-- .../uv-pypi-types/src/metadata/metadata23.rs | 36 +++++++------------ crates/uv-python/src/discovery.rs | 8 ++--- crates/uv-python/src/installation.rs | 2 +- crates/uv-resolver/src/candidate_selector.rs | 4 +-- crates/uv-resolver/src/error.rs | 2 +- crates/uv-resolver/src/lock/mod.rs | 4 +-- .../uv-resolver/src/pubgrub/dependencies.rs | 2 +- crates/uv-scripts/src/lib.rs | 2 +- crates/uv-settings/src/lib.rs | 9 ++++- crates/uv-types/src/builds.rs | 2 +- crates/uv-workspace/src/pyproject_mut.rs | 8 ++--- crates/uv-workspace/src/workspace.rs | 6 ++-- crates/uv/src/commands/build_frontend.rs | 2 +- crates/uv/src/commands/tool/uninstall.rs | 1 - rust-toolchain.toml | 2 +- 31 files changed, 64 insertions(+), 71 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3d55edafe383..33cfb890e3f3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ resolver = "2" [workspace.package] edition = "2021" -rust-version = "1.83" +rust-version = "1.81" homepage = "https://pypi.org/project/uv/" documentation = "https://pypi.org/project/uv/" repository = "https://github.com/astral-sh/uv" diff --git a/crates/uv-cache/src/wheel.rs b/crates/uv-cache/src/wheel.rs index ab074df06f25..c35183124d1d 100644 --- a/crates/uv-cache/src/wheel.rs +++ b/crates/uv-cache/src/wheel.rs @@ -23,7 +23,7 @@ pub enum WheelCache<'a> { Git(&'a Url, &'a str), } -impl WheelCache<'_> { +impl<'a> WheelCache<'a> { /// The root directory for a cache bucket. pub fn root(&self) -> PathBuf { match self { diff --git a/crates/uv-client/src/httpcache/mod.rs b/crates/uv-client/src/httpcache/mod.rs index f9f4de953908..ca99eb4d48f0 100644 --- a/crates/uv-client/src/httpcache/mod.rs +++ b/crates/uv-client/src/httpcache/mod.rs @@ -992,7 +992,6 @@ impl ArchivedCachePolicy { /// This dictates what the caller should do next by indicating whether the /// cached response is stale or not. #[derive(Debug)] -#[allow(clippy::large_enum_variant)] pub enum BeforeRequest { /// The cached response is still fresh, and the caller may return the /// cached response without issuing an HTTP requests. diff --git a/crates/uv-client/src/remote_metadata.rs b/crates/uv-client/src/remote_metadata.rs index 3a2540ba0f31..15286f9cf639 100644 --- a/crates/uv-client/src/remote_metadata.rs +++ b/crates/uv-client/src/remote_metadata.rs @@ -85,7 +85,7 @@ pub(crate) async fn wheel_metadata_from_remote_zip( // The zip archive uses as BufReader which reads in chunks of 8192. To ensure we prefetch // enough data we round the size up to the nearest multiple of the buffer size. let buffer_size = 8192; - let size = size.div_ceil(buffer_size) * buffer_size; + let size = ((size + buffer_size - 1) / buffer_size) * buffer_size; // Fetch the bytes from the zip archive that contain the requested file. reader diff --git a/crates/uv-configuration/src/name_specifiers.rs b/crates/uv-configuration/src/name_specifiers.rs index dbb36c38debb..4c36ad943c47 100644 --- a/crates/uv-configuration/src/name_specifiers.rs +++ b/crates/uv-configuration/src/name_specifiers.rs @@ -31,7 +31,7 @@ impl<'de> serde::Deserialize<'de> for PackageNameSpecifier { { struct Visitor; - impl serde::de::Visitor<'_> for Visitor { + impl<'de> serde::de::Visitor<'de> for Visitor { type Value = PackageNameSpecifier; fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { diff --git a/crates/uv-distribution-types/src/buildable.rs b/crates/uv-distribution-types/src/buildable.rs index 238d756e2b3e..ae6897b4cfb7 100644 --- a/crates/uv-distribution-types/src/buildable.rs +++ b/crates/uv-distribution-types/src/buildable.rs @@ -92,7 +92,7 @@ pub enum SourceUrl<'a> { Directory(DirectorySourceUrl<'a>), } -impl SourceUrl<'_> { +impl<'a> SourceUrl<'a> { /// Return the [`Url`] of the source. pub fn url(&self) -> &Url { match self { diff --git a/crates/uv-distribution-types/src/hash.rs b/crates/uv-distribution-types/src/hash.rs index ff668b6a1e7a..e1a8ed47235d 100644 --- a/crates/uv-distribution-types/src/hash.rs +++ b/crates/uv-distribution-types/src/hash.rs @@ -11,7 +11,7 @@ pub enum HashPolicy<'a> { Validate(&'a [HashDigest]), } -impl HashPolicy<'_> { +impl<'a> HashPolicy<'a> { /// Returns `true` if the hash policy is `None`. pub fn is_none(&self) -> bool { matches!(self, Self::None) diff --git a/crates/uv-distribution-types/src/lib.rs b/crates/uv-distribution-types/src/lib.rs index 894812d26fa8..974e77eedc29 100644 --- a/crates/uv-distribution-types/src/lib.rs +++ b/crates/uv-distribution-types/src/lib.rs @@ -101,7 +101,7 @@ pub enum VersionOrUrlRef<'a, T: Pep508Url = VerbatimUrl> { Url(&'a T), } -impl VersionOrUrlRef<'_, T> { +impl<'a, T: Pep508Url> VersionOrUrlRef<'a, T> { /// If it is a URL, return its value. pub fn url(&self) -> Option<&T> { match self { @@ -138,7 +138,7 @@ pub enum InstalledVersion<'a> { Url(&'a Url, &'a Version), } -impl InstalledVersion<'_> { +impl<'a> InstalledVersion<'a> { /// If it is a URL, return its value. pub fn url(&self) -> Option<&Url> { match self { diff --git a/crates/uv-distribution/src/metadata/lowering.rs b/crates/uv-distribution/src/metadata/lowering.rs index bedcc1e31692..7133fac80766 100644 --- a/crates/uv-distribution/src/metadata/lowering.rs +++ b/crates/uv-distribution/src/metadata/lowering.rs @@ -84,7 +84,7 @@ impl LoweredRequirement { if workspace.packages().contains_key(&requirement.name) { // And it's not a recursive self-inclusion (extras that activate other extras), e.g. // `framework[machine_learning]` depends on `framework[cuda]`. - if project_name.is_none_or(|project_name| *project_name != requirement.name) { + if !project_name.is_some_and(|project_name| *project_name == requirement.name) { // It must be declared as a workspace source. let Some(sources) = sources.as_ref() else { // No sources were declared for the workspace package. @@ -141,7 +141,7 @@ impl LoweredRequirement { // Support recursive editable inclusions. if has_sources && requirement.version_or_url.is_none() - && project_name.is_none_or(|project_name| *project_name != requirement.name) + && !project_name.is_some_and(|project_name| *project_name == requirement.name) { warn_user_once!( "Missing version constraint (e.g., a lower bound) for `{}`", diff --git a/crates/uv-distribution/src/source/mod.rs b/crates/uv-distribution/src/source/mod.rs index 08849dc170c3..c6c1337fc72e 100644 --- a/crates/uv-distribution/src/source/mod.rs +++ b/crates/uv-distribution/src/source/mod.rs @@ -1694,7 +1694,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> { .map_err(Error::CacheWrite)?; if let Err(err) = rename_with_retry(extracted, target).await { // If the directory already exists, accept it. - if err.kind() == std::io::ErrorKind::AlreadyExists { + if target.is_dir() { warn!("Directory already exists: {}", target.display()); } else { return Err(Error::CacheWrite(err)); @@ -1755,7 +1755,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> { .map_err(Error::CacheWrite)?; if let Err(err) = rename_with_retry(extracted, target).await { // If the directory already exists, accept it. - if err.kind() == std::io::ErrorKind::AlreadyExists { + if target.is_dir() { warn!("Directory already exists: {}", target.display()); } else { return Err(Error::CacheWrite(err)); diff --git a/crates/uv-extract/src/hash.rs b/crates/uv-extract/src/hash.rs index 626911c118d4..e7abdc668924 100644 --- a/crates/uv-extract/src/hash.rs +++ b/crates/uv-extract/src/hash.rs @@ -80,7 +80,7 @@ where } } -impl tokio::io::AsyncRead for HashReader<'_, R> +impl<'a, R> tokio::io::AsyncRead for HashReader<'a, R> where R: tokio::io::AsyncRead + Unpin, { diff --git a/crates/uv-install-wheel/src/linker.rs b/crates/uv-install-wheel/src/linker.rs index 3f5b696dcd76..923be5ebf58e 100644 --- a/crates/uv-install-wheel/src/linker.rs +++ b/crates/uv-install-wheel/src/linker.rs @@ -384,7 +384,7 @@ fn clone_recursive( match attempt { Attempt::Initial => { if let Err(err) = reflink::reflink(&from, &to) { - if err.kind() == std::io::ErrorKind::AlreadyExists { + if matches!(err.kind(), std::io::ErrorKind::AlreadyExists) { // If cloning/copying fails and the directory exists already, it must be merged recursively. if entry.file_type()?.is_dir() { for entry in fs::read_dir(from)? { @@ -420,7 +420,7 @@ fn clone_recursive( } Attempt::Subsequent => { if let Err(err) = reflink::reflink(&from, &to) { - if err.kind() == std::io::ErrorKind::AlreadyExists { + if matches!(err.kind(), std::io::ErrorKind::AlreadyExists) { // If cloning/copying fails and the directory exists already, it must be merged recursively. if entry.file_type()?.is_dir() { for entry in fs::read_dir(from)? { diff --git a/crates/uv-options-metadata/src/lib.rs b/crates/uv-options-metadata/src/lib.rs index 6e966cfc41a2..81f3ebafef8f 100644 --- a/crates/uv-options-metadata/src/lib.rs +++ b/crates/uv-options-metadata/src/lib.rs @@ -198,7 +198,7 @@ struct SerializeVisitor<'a> { entries: &'a mut BTreeMap, } -impl Visit for SerializeVisitor<'_> { +impl<'a> Visit for SerializeVisitor<'a> { fn record_set(&mut self, name: &str, set: OptionSet) { // Collect the entries of the set. let mut entries = BTreeMap::new(); diff --git a/crates/uv-pep440/src/version.rs b/crates/uv-pep440/src/version.rs index 1b54909b92bf..59962cbbb54e 100644 --- a/crates/uv-pep440/src/version.rs +++ b/crates/uv-pep440/src/version.rs @@ -3926,7 +3926,7 @@ mod tests { /// assertion failure messages. struct VersionBloatedDebug<'a>(&'a Version); - impl std::fmt::Debug for VersionBloatedDebug<'_> { + impl<'a> std::fmt::Debug for VersionBloatedDebug<'a> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("Version") .field("epoch", &self.0.epoch()) diff --git a/crates/uv-pep508/src/marker/tree.rs b/crates/uv-pep508/src/marker/tree.rs index f3b43aea000a..057955916b83 100644 --- a/crates/uv-pep508/src/marker/tree.rs +++ b/crates/uv-pep508/src/marker/tree.rs @@ -1276,7 +1276,7 @@ pub struct MarkerTreeDebugGraph<'a> { marker: &'a MarkerTree, } -impl fmt::Debug for MarkerTreeDebugGraph<'_> { +impl<'a> fmt::Debug for MarkerTreeDebugGraph<'a> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.marker.fmt_graph(f, 0) } @@ -1293,7 +1293,7 @@ pub struct MarkerTreeDebugRaw<'a> { marker: &'a MarkerTree, } -impl fmt::Debug for MarkerTreeDebugRaw<'_> { +impl<'a> fmt::Debug for MarkerTreeDebugRaw<'a> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let node = INTERNER.shared.node(self.marker.0); f.debug_tuple("MarkerTreeDebugRaw").field(node).finish() diff --git a/crates/uv-pypi-types/src/conflicts.rs b/crates/uv-pypi-types/src/conflicts.rs index f740f0dbe09b..57ed4851a518 100644 --- a/crates/uv-pypi-types/src/conflicts.rs +++ b/crates/uv-pypi-types/src/conflicts.rs @@ -243,7 +243,7 @@ impl<'a> From<(&'a PackageName, &'a GroupName)> for ConflictItemRef<'a> { } } -impl hashbrown::Equivalent for ConflictItemRef<'_> { +impl<'a> hashbrown::Equivalent for ConflictItemRef<'a> { fn equivalent(&self, key: &ConflictItem) -> bool { key.as_ref() == *self } @@ -335,7 +335,7 @@ impl<'a> From<&'a GroupName> for ConflictPackageRef<'a> { } } -impl PartialEq for ConflictPackageRef<'_> { +impl<'a> PartialEq for ConflictPackageRef<'a> { fn eq(&self, other: &ConflictPackage) -> bool { other.as_ref() == *self } @@ -347,7 +347,7 @@ impl<'a> PartialEq> for ConflictPackage { } } -impl hashbrown::Equivalent for ConflictPackageRef<'_> { +impl<'a> hashbrown::Equivalent for ConflictPackageRef<'a> { fn equivalent(&self, key: &ConflictPackage) -> bool { key.as_ref() == *self } diff --git a/crates/uv-pypi-types/src/metadata/metadata23.rs b/crates/uv-pypi-types/src/metadata/metadata23.rs index 3fff955e22d4..f10a73968832 100644 --- a/crates/uv-pypi-types/src/metadata/metadata23.rs +++ b/crates/uv-pypi-types/src/metadata/metadata23.rs @@ -211,7 +211,7 @@ impl Metadata23 { writer.push_str(&format!("{}{}\n", " ".repeat(key.len() + 2), line)); } } - fn write_opt_str(writer: &mut String, key: &str, value: Option<&impl Display>) { + fn write_opt_str(writer: &mut String, key: &str, value: &Option) { if let Some(value) = value { write_str(writer, key, value); } @@ -233,40 +233,28 @@ impl Metadata23 { write_all(&mut writer, "Platform", &self.platforms); write_all(&mut writer, "Supported-Platform", &self.supported_platforms); write_all(&mut writer, "Summary", &self.summary); - write_opt_str(&mut writer, "Keywords", self.keywords.as_ref()); - write_opt_str(&mut writer, "Home-Page", self.home_page.as_ref()); - write_opt_str(&mut writer, "Download-URL", self.download_url.as_ref()); - write_opt_str(&mut writer, "Author", self.author.as_ref()); - write_opt_str(&mut writer, "Author-email", self.author_email.as_ref()); - write_opt_str(&mut writer, "License", self.license.as_ref()); - write_opt_str( - &mut writer, - "License-Expression", - self.license_expression.as_ref(), - ); + write_opt_str(&mut writer, "Keywords", &self.keywords); + write_opt_str(&mut writer, "Home-Page", &self.home_page); + write_opt_str(&mut writer, "Download-URL", &self.download_url); + write_opt_str(&mut writer, "Author", &self.author); + write_opt_str(&mut writer, "Author-email", &self.author_email); + write_opt_str(&mut writer, "License", &self.license); + write_opt_str(&mut writer, "License-Expression", &self.license_expression); write_all(&mut writer, "License-File", &self.license_files); write_all(&mut writer, "Classifier", &self.classifiers); write_all(&mut writer, "Requires-Dist", &self.requires_dist); write_all(&mut writer, "Provides-Dist", &self.provides_dist); write_all(&mut writer, "Obsoletes-Dist", &self.obsoletes_dist); - write_opt_str(&mut writer, "Maintainer", self.maintainer.as_ref()); - write_opt_str( - &mut writer, - "Maintainer-email", - self.maintainer_email.as_ref(), - ); - write_opt_str( - &mut writer, - "Requires-Python", - self.requires_python.as_ref(), - ); + write_opt_str(&mut writer, "Maintainer", &self.maintainer); + write_opt_str(&mut writer, "Maintainer-email", &self.maintainer_email); + write_opt_str(&mut writer, "Requires-Python", &self.requires_python); write_all(&mut writer, "Requires-External", &self.requires_external); write_all(&mut writer, "Project-URL", &self.project_urls); write_all(&mut writer, "Provides-Extra", &self.provides_extras); write_opt_str( &mut writer, "Description-Content-Type", - self.description_content_type.as_ref(), + &self.description_content_type, ); write_all(&mut writer, "Dynamic", &self.dynamic); diff --git a/crates/uv-python/src/discovery.rs b/crates/uv-python/src/discovery.rs index 3818ea3fad36..af382a92a087 100644 --- a/crates/uv-python/src/discovery.rs +++ b/crates/uv-python/src/discovery.rs @@ -1165,17 +1165,17 @@ pub(crate) fn is_windows_store_shim(path: &Path) -> bool { } // Ex) `WindowsApps` - if components + if !components .next() - .is_none_or(|component| component.as_os_str() != "WindowsApps") + .is_some_and(|component| component.as_os_str() == "WindowsApps") { return false; } // Ex) `Microsoft` - if components + if !components .next() - .is_none_or(|component| component.as_os_str() != "Microsoft") + .is_some_and(|component| component.as_os_str() == "Microsoft") { return false; } diff --git a/crates/uv-python/src/installation.rs b/crates/uv-python/src/installation.rs index 66405e98b05e..e1a7203c3709 100644 --- a/crates/uv-python/src/installation.rs +++ b/crates/uv-python/src/installation.rs @@ -89,7 +89,7 @@ impl PythonInstallation { python_install_mirror: Option<&str>, pypy_install_mirror: Option<&str>, ) -> Result { - let request = request.unwrap_or(&PythonRequest::Default); + let request = request.unwrap_or_else(|| &PythonRequest::Default); // Search for the installation match Self::find(request, environments, preference, cache) { diff --git a/crates/uv-resolver/src/candidate_selector.rs b/crates/uv-resolver/src/candidate_selector.rs index 63b47550840e..ed6c0690602b 100644 --- a/crates/uv-resolver/src/candidate_selector.rs +++ b/crates/uv-resolver/src/candidate_selector.rs @@ -135,7 +135,7 @@ impl CandidateSelector { is_excluded: bool, index: Option<&'a IndexUrl>, env: &ResolverEnvironment, - ) -> Option> { + ) -> Option { // In the branches, we "sort" the preferences by marker-matching through an iterator that // first has the matching half and then the mismatching half. let preferences_match = preferences @@ -282,7 +282,7 @@ impl CandidateSelector { range: &Range, version_maps: &'a [VersionMap], env: &ResolverEnvironment, - ) -> Option> { + ) -> Option { trace!( "Selecting candidate for {package_name} with range {range} with {} remote versions", version_maps.iter().map(VersionMap::len).sum::(), diff --git a/crates/uv-resolver/src/error.rs b/crates/uv-resolver/src/error.rs index 6ad747e8a8b2..6aea74da4a15 100644 --- a/crates/uv-resolver/src/error.rs +++ b/crates/uv-resolver/src/error.rs @@ -808,7 +808,7 @@ impl<'range> From<&'range Range> for SentinelRange<'range> { } } -impl SentinelRange<'_> { +impl<'range> SentinelRange<'range> { /// Returns `true` if the range appears to be, e.g., `>1.0.0, <1.0.0+[max]`. pub fn is_sentinel(&self) -> bool { self.0.iter().all(|(lower, upper)| { diff --git a/crates/uv-resolver/src/lock/mod.rs b/crates/uv-resolver/src/lock/mod.rs index 49fe8596d91f..4638b3a1b784 100644 --- a/crates/uv-resolver/src/lock/mod.rs +++ b/crates/uv-resolver/src/lock/mod.rs @@ -2753,7 +2753,7 @@ impl<'de> serde::de::Deserialize<'de> for RegistrySource { { struct Visitor; - impl serde::de::Visitor<'_> for Visitor { + impl<'de> serde::de::Visitor<'de> for Visitor { type Value = RegistrySource; fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { @@ -2974,7 +2974,7 @@ impl SourceDist { ) -> Result, LockError> { // Reject distributions from registries that don't match the index URL, as can occur with // `--find-links`. - if index.is_none_or(|index| *index != reg_dist.index) { + if !index.is_some_and(|index| *index == reg_dist.index) { return Ok(None); } diff --git a/crates/uv-resolver/src/pubgrub/dependencies.rs b/crates/uv-resolver/src/pubgrub/dependencies.rs index 21a49293d50a..66252a410dd7 100644 --- a/crates/uv-resolver/src/pubgrub/dependencies.rs +++ b/crates/uv-resolver/src/pubgrub/dependencies.rs @@ -104,7 +104,7 @@ impl PubGrubDependency { // Detect self-dependencies. if dev.is_none() { debug_assert!( - source_name.is_none_or(|source_name| source_name != name), + !source_name.is_some_and(|source_name| source_name == name), "extras not flattened for {name}" ); } diff --git a/crates/uv-scripts/src/lib.rs b/crates/uv-scripts/src/lib.rs index 8b46007e0be8..1c9802dbd164 100644 --- a/crates/uv-scripts/src/lib.rs +++ b/crates/uv-scripts/src/lib.rs @@ -350,7 +350,7 @@ impl ScriptTag { let mut lines = contents.lines(); // Ensure that the first line is exactly `# /// script`. - if lines.next().is_none_or(|line| line != "# /// script") { + if !lines.next().is_some_and(|line| line == "# /// script") { return Ok(None); } diff --git a/crates/uv-settings/src/lib.rs b/crates/uv-settings/src/lib.rs index 7d655bda3cf7..0b3469d872fa 100644 --- a/crates/uv-settings/src/lib.rs +++ b/crates/uv-settings/src/lib.rs @@ -50,7 +50,14 @@ impl FilesystemOptions { Ok(Some(Self(options))) } Err(Error::Io(err)) if err.kind() == std::io::ErrorKind::NotFound => Ok(None), - Err(Error::Io(err)) if err.kind() == std::io::ErrorKind::NotADirectory => Ok(None), + Err(_) if !dir.is_dir() => { + // Ex) `XDG_CONFIG_HOME=/dev/null` + tracing::debug!( + "User configuration directory `{}` does not exist or is not a directory", + dir.display() + ); + Ok(None) + } Err(err) => Err(err), } } diff --git a/crates/uv-types/src/builds.rs b/crates/uv-types/src/builds.rs index 5f5f6b762eaa..552660e6c574 100644 --- a/crates/uv-types/src/builds.rs +++ b/crates/uv-types/src/builds.rs @@ -10,7 +10,7 @@ pub enum BuildIsolation<'a> { SharedPackage(&'a PythonEnvironment, &'a [PackageName]), } -impl BuildIsolation<'_> { +impl<'a> BuildIsolation<'a> { /// Returns `true` if build isolation is enforced for the given package name. pub fn is_isolated(&self, package: Option<&PackageName>) -> bool { match self { diff --git a/crates/uv-workspace/src/pyproject_mut.rs b/crates/uv-workspace/src/pyproject_mut.rs index 09ae5b28b362..34be572d91f4 100644 --- a/crates/uv-workspace/src/pyproject_mut.rs +++ b/crates/uv-workspace/src/pyproject_mut.rs @@ -277,10 +277,10 @@ impl PyProjectTomlMut { // If necessary, update the name. if let Some(index) = index.name.as_deref() { - if table + if !table .get("name") .and_then(|name| name.as_str()) - .is_none_or(|name| name != index) + .is_some_and(|name| name == index) { let mut formatted = Formatted::new(index.to_string()); if let Some(value) = table.get("name").and_then(Item::as_value) { @@ -296,11 +296,11 @@ impl PyProjectTomlMut { } // If necessary, update the URL. - if table + if !table .get("url") .and_then(|item| item.as_str()) .and_then(|url| Url::parse(url).ok()) - .is_none_or(|url| CanonicalUrl::new(&url) != CanonicalUrl::new(index.url.url())) + .is_some_and(|url| CanonicalUrl::new(&url) == CanonicalUrl::new(index.url.url())) { let mut formatted = Formatted::new(index.url.to_string()); if let Some(value) = table.get("url").and_then(Item::as_value) { diff --git a/crates/uv-workspace/src/workspace.rs b/crates/uv-workspace/src/workspace.rs index e7f508a107ef..bad924e66c4b 100644 --- a/crates/uv-workspace/src/workspace.rs +++ b/crates/uv-workspace/src/workspace.rs @@ -716,12 +716,12 @@ impl Workspace { member_glob.to_string(), )); } - Err(err) if err.kind() == std::io::ErrorKind::NotADirectory => { + // If the entry is _not_ a directory, skip it. + Err(_) if !member_root.is_dir() => { warn!( "Ignoring non-directory workspace member: `{}`", member_root.simplified_display() ); - continue; } Err(err) => return Err(err.into()), @@ -975,7 +975,7 @@ impl ProjectWorkspace { let project = pyproject_toml .project .clone() - .ok_or(WorkspaceError::MissingProject(pyproject_path))?; + .ok_or_else(|| WorkspaceError::MissingProject(pyproject_path))?; Self::from_project(project_root, &project, &pyproject_toml, options).await } diff --git a/crates/uv/src/commands/build_frontend.rs b/crates/uv/src/commands/build_frontend.rs index c861f52704f1..2755143cab1c 100644 --- a/crates/uv/src/commands/build_frontend.rs +++ b/crates/uv/src/commands/build_frontend.rs @@ -910,7 +910,7 @@ enum Source<'a> { Directory(Cow<'a, Path>), } -impl Source<'_> { +impl<'a> Source<'a> { fn path(&self) -> &Path { match self { Self::File(path) => path.as_ref(), diff --git a/crates/uv/src/commands/tool/uninstall.rs b/crates/uv/src/commands/tool/uninstall.rs index 4748ce1467e8..ba419898f13c 100644 --- a/crates/uv/src/commands/tool/uninstall.rs +++ b/crates/uv/src/commands/tool/uninstall.rs @@ -82,7 +82,6 @@ impl IgnoreCurrentlyBeingDeleted for Result<(), std::io::Error> { fn ignore_currently_being_deleted(self) -> Self { match self { Ok(()) => Ok(()), - Err(err) if err.kind() == std::io::ErrorKind::DirectoryNotEmpty => Ok(()), Err(err) if err.is_in_process_of_being_deleted() => Ok(()), Err(err) => Err(err), } diff --git a/rust-toolchain.toml b/rust-toolchain.toml index a718dc2fc84c..4cef0b738ff6 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.83" +channel = "1.81"