Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Rust toolchain to 1.84.0 #10533

Merged
merged 1 commit into from
Jan 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions crates/uv-auth/src/middleware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
)?;

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
)?;

Expand Down
2 changes: 1 addition & 1 deletion crates/uv-configuration/src/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ impl DevGroupsSpecification {

self.groups
.as_ref()
.map_or(false, |groups| groups.contains(group))
.is_some_and(|groups| groups.contains(group))
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/uv-dispatch/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions crates/uv-extract/src/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ pub async fn unzip<R: tokio::io::AsyncRead + Unpin>(
/// 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()?;
Expand Down
4 changes: 2 additions & 2 deletions crates/uv-fs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ pub fn is_temporary(path: impl AsRef<Path>) -> 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.
Expand Down Expand Up @@ -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(),
Expand Down
4 changes: 2 additions & 2 deletions crates/uv-install-wheel/src/wheel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ 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
from {module} import {import_name}
if __name__ == "__main__":
sys.argv[0] = re.sub(r"(-script\.pyw|\.exe)?$", "", sys.argv[0])
sys.exit({function}())
"##
"#
)
}

Expand Down
6 changes: 3 additions & 3 deletions crates/uv-pep508/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -930,12 +930,12 @@ fn parse_pep508_requirement<T: Pep508Url>(
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),
Expand Down
6 changes: 3 additions & 3 deletions crates/uv-pep508/src/unnamed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,12 @@ fn parse_unnamed_requirement<Url: UnnamedRequirementUrl>(
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),
Expand Down
2 changes: 1 addition & 1 deletion crates/uv-pep508/src/verbatim_url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion crates/uv-python/src/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions crates/uv-python/src/installation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand Down Expand Up @@ -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>,
Expand Down
8 changes: 4 additions & 4 deletions crates/uv-python/src/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -894,10 +894,10 @@ mod tests {

fs::write(
&mocked_interpreter,
formatdoc! {r##"
formatdoc! {r"
#!/bin/bash
echo '{json}'
"##},
"},
)
.unwrap();

Expand All @@ -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();
Expand Down
12 changes: 6 additions & 6 deletions crates/uv-python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))?;
Expand All @@ -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))?;
Expand Down Expand Up @@ -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)),
Expand Down
4 changes: 2 additions & 2 deletions crates/uv-resolver/src/lock/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
Expand All @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion crates/uv-resolver/src/resolver/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ impl<'a, Context: BuildContext> DefaultResolverProvider<'a, Context> {
}
}

impl<'a, Context: BuildContext> ResolverProvider for DefaultResolverProvider<'a, Context> {
impl<Context: BuildContext> 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,
Expand Down
2 changes: 1 addition & 1 deletion crates/uv-resolver/src/yanks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}
4 changes: 2 additions & 2 deletions crates/uv-scripts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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#"
Expand Down
12 changes: 6 additions & 6 deletions crates/uv-trampoline-builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
);
Expand Down Expand Up @@ -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(),
);
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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())
"##
"#
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/uv/src/commands/pip/latest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 6 additions & 6 deletions crates/uv/src/commands/project/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -1015,7 +1015,7 @@ fn pyproject_build_backend_prerequisites(

pybind11_add_module(_core MODULE src/main.cpp)
install(TARGETS _core DESTINATION ${{SKBUILD_PROJECT_NAME}})
"#},
"},
)?;
}
}
Expand Down Expand Up @@ -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
Expand Down
Loading
Loading