Skip to content

Commit

Permalink
Upgrade to Rust 1.80.0 (#5472)
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Jul 27, 2024
1 parent 3ea5e16 commit 24859bd
Show file tree
Hide file tree
Showing 38 changed files with 163 additions and 196 deletions.
13 changes: 0 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ resolver = "2"

[workspace.package]
edition = "2021"
rust-version = "1.77"
rust-version = "1.80"
homepage = "https://pypi.org/project/uv/"
documentation = "https://pypi.org/project/uv/"
repository = "https://github.com/astral-sh/uv"
Expand Down Expand Up @@ -102,7 +102,6 @@ md-5 = { version = "0.10.6" }
memchr = { version = "2.7.4" }
miette = { version = "7.2.0" }
nanoid = { version = "0.4.0" }
once_cell = { version = "1.19.0" }
owo-colors = { version = "4.0.0" }
path-absolutize = { version = "3.1.1" }
path-slash = { version = "0.2.1" }
Expand Down
1 change: 0 additions & 1 deletion crates/bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ anyhow = { workspace = true }
chrono = { workspace = true }
codspeed-criterion-compat = { version = "2.6.0", default-features = false, optional = true }
criterion = { version = "0.5.1", default-features = false, features = ["async_tokio"] }
once_cell = { workspace = true }
tokio = { workspace = true }

[features]
Expand Down
9 changes: 5 additions & 4 deletions crates/bench/benches/uv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@ criterion_group!(uv, resolve_warm_airflow, resolve_warm_jupyter);
criterion_main!(uv);

mod resolver {
use std::sync::LazyLock;

use anyhow::Result;
use chrono::NaiveDate;
use once_cell::sync::Lazy;

use distribution_types::IndexLocations;
use install_wheel_rs::linker::LinkMode;
Expand All @@ -94,7 +95,7 @@ mod resolver {
};
use uv_types::{BuildIsolation, EmptyInstalledPackages, HashStrategy, InFlight};

static MARKERS: Lazy<MarkerEnvironment> = Lazy::new(|| {
static MARKERS: LazyLock<MarkerEnvironment> = LazyLock::new(|| {
MarkerEnvironment::try_from(MarkerEnvironmentBuilder {
implementation_name: "cpython",
implementation_version: "3.11.5",
Expand All @@ -118,8 +119,8 @@ mod resolver {
Arch::Aarch64,
);

static TAGS: Lazy<Tags> =
Lazy::new(|| Tags::from_env(&PLATFORM, (3, 11), "cpython", (3, 11), false).unwrap());
static TAGS: LazyLock<Tags> =
LazyLock::new(|| Tags::from_env(&PLATFORM, (3, 11), "cpython", (3, 11), false).unwrap());

pub(crate) async fn resolve(
manifest: Manifest,
Expand Down
4 changes: 2 additions & 2 deletions crates/bench/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ pub mod criterion {
//! This module re-exports the criterion API but picks the right backend depending on whether
//! the benchmarks are built to run locally or with codspeed

#[cfg(not(codspeed))]
#[cfg(not(feature = "codspeed"))]
pub use criterion::*;

#[cfg(codspeed)]
#[cfg(feature = "codspeed")]
pub use codspeed_criterion_compat::*;
}
1 change: 0 additions & 1 deletion crates/distribution-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ uv-normalize = { workspace = true }
anyhow = { workspace = true }
fs-err = { workspace = true }
itertools = { workspace = true }
once_cell = { workspace = true }
rkyv = { workspace = true }
schemars = { workspace = true, optional = true }
serde = { workspace = true, features = ["derive"] }
Expand Down
11 changes: 5 additions & 6 deletions crates/distribution-types/src/index_url.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
use itertools::Either;
use std::borrow::Cow;
use std::fmt::{Display, Formatter};
use std::ops::Deref;
use std::path::Path;
use std::str::FromStr;

use itertools::Either;
use once_cell::sync::Lazy;
use std::sync::LazyLock;
use thiserror::Error;
use url::{ParseError, Url};

use pep508_rs::{VerbatimUrl, VerbatimUrlError};

use crate::Verbatim;

static PYPI_URL: Lazy<Url> = Lazy::new(|| Url::parse("https://pypi.org/simple").unwrap());
static PYPI_URL: LazyLock<Url> = LazyLock::new(|| Url::parse("https://pypi.org/simple").unwrap());

static DEFAULT_INDEX_URL: Lazy<IndexUrl> =
Lazy::new(|| IndexUrl::Pypi(VerbatimUrl::from_url(PYPI_URL.clone())));
static DEFAULT_INDEX_URL: LazyLock<IndexUrl> =
LazyLock::new(|| IndexUrl::Pypi(VerbatimUrl::from_url(PYPI_URL.clone())));

/// The URL of an index to use for fetching packages (e.g., PyPI).
#[derive(Debug, Clone, Hash, Eq, PartialEq)]
Expand Down
1 change: 0 additions & 1 deletion crates/install-wheel-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ csv = { workspace = true }
data-encoding = { workspace = true }
fs-err = { workspace = true }
mailparse = { workspace = true }
once_cell = { workspace = true }
pathdiff = { workspace = true }
platform-info = { workspace = true }
reflink-copy = { workspace = true }
Expand Down
4 changes: 2 additions & 2 deletions crates/install-wheel-rs/src/script.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use configparser::ini::Ini;
use once_cell::sync::Lazy;
use regex::Regex;
use rustc_hash::FxHashSet;
use serde::Serialize;
use std::sync::LazyLock;

use crate::{wheel, Error};

Expand Down Expand Up @@ -30,7 +30,7 @@ impl Script {
// between the object reference and the left square bracket, between the extra names and the square brackets and colons delimiting them,
// and after the right square bracket."
// – https://packaging.python.org/en/latest/specifications/entry-points/#file-format
static SCRIPT_REGEX: Lazy<Regex> = Lazy::new(|| {
static SCRIPT_REGEX: LazyLock<Regex> = LazyLock::new(|| {
Regex::new(r"^(?P<module>[\w\d_\-.]+)\s*:\s*(?P<function>[\w\d_\-.]+)(?:\s*\[\s*(?P<extras>(?:[^,]+,?\s*)+)\])?\s*$").unwrap()
});

Expand Down
5 changes: 2 additions & 3 deletions crates/install-wheel-rs/src/uninstall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ use std::collections::BTreeSet;
use std::path::{Component, Path, PathBuf};

use fs_err as fs;
use once_cell::sync::Lazy;
use std::sync::Mutex;
use std::sync::{LazyLock, Mutex};
use tracing::debug;
use uv_fs::write_atomic_sync;

Expand Down Expand Up @@ -219,7 +218,7 @@ fn normcase(s: &str) -> String {
}
}

static EASY_INSTALL_PTH: Lazy<Mutex<i32>> = Lazy::new(Mutex::default);
static EASY_INSTALL_PTH: LazyLock<Mutex<i32>> = LazyLock::new(Mutex::default);

/// Uninstall the legacy editable represented by the `.egg-link` file.
///
Expand Down
1 change: 0 additions & 1 deletion crates/pep440-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ crate-type = ["rlib", "cdylib"]
workspace = true

[dependencies]
once_cell = { workspace = true }
pyo3 = { workspace = true, optional = true, features = ["extension-module", "abi3-py37"] }
serde = { workspace = true, features = ["derive"] }
rkyv = { workspace = true }
Expand Down
40 changes: 20 additions & 20 deletions crates/pep440-rs/src/version.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
#[cfg(feature = "pyo3")]
use pyo3::{
basic::CompareOp, exceptions::PyValueError, pyclass, pymethods, FromPyObject, IntoPy, PyAny,
PyObject, PyResult, Python,
};
use serde::{de, Deserialize, Deserializer, Serialize, Serializer};
use std::sync::LazyLock;
use std::{
borrow::Borrow,
cmp::Ordering,
Expand All @@ -6,13 +13,6 @@ use std::{
sync::Arc,
};

#[cfg(feature = "pyo3")]
use pyo3::{
basic::CompareOp, exceptions::PyValueError, pyclass, pymethods, FromPyObject, IntoPy, PyAny,
PyObject, PyResult, Python,
};
use serde::{de, Deserialize, Deserializer, Serialize, Serializer};

/// One of `~=` `==` `!=` `<=` `>=` `<` `>` `===`
#[derive(
Eq,
Expand Down Expand Up @@ -821,8 +821,8 @@ impl FromStr for Version {
/// * The epoch must be `0`.
/// * The release portion must have 4 or fewer segments.
/// * All release segments, except for the first, must be representable in a
/// `u8`. The first segment must be representable in a `u16`. (This permits
/// calendar versions, like `2023.03`, to be represented.)
/// `u8`. The first segment must be representable in a `u16`. (This permits
/// calendar versions, like `2023.03`, to be represented.)
/// * There is *at most* one of the following components: pre, dev or post.
/// * If there is a pre segment, then its numeric value is less than 64.
/// * If there is a dev or post segment, then its value is less than `u8::MAX`.
Expand All @@ -843,20 +843,20 @@ impl FromStr for Version {
///
/// * Bytes 6 and 7 correspond to the first release segment as a `u16`.
/// * Bytes 5, 4 and 3 correspond to the second, third and fourth release
/// segments, respectively.
/// segments, respectively.
/// * Bytes 2, 1 and 0 represent *one* of the following:
/// `min, .devN, aN, bN, rcN, <no suffix>, .postN, max`.
/// Its representation is thus:
/// * The most significant 3 bits of Byte 2 corresponds to a value in
/// the range 0-6 inclusive, corresponding to min, dev, pre-a, pre-b, pre-rc,
/// no-suffix or post releases, respectively. `min` is a special version that
/// does not exist in PEP 440, but is used here to represent the smallest
/// possible version, preceding any `dev`, `pre`, `post` or releases. `max` is
/// an analogous concept for the largest possible version, following any `post`
/// or local releases.
/// the range 0-6 inclusive, corresponding to min, dev, pre-a, pre-b, pre-rc,
/// no-suffix or post releases, respectively. `min` is a special version that
/// does not exist in PEP 440, but is used here to represent the smallest
/// possible version, preceding any `dev`, `pre`, `post` or releases. `max` is
/// an analogous concept for the largest possible version, following any `post`
/// or local releases.
/// * The low 5 bits combined with the bits in bytes 1 and 0 correspond
/// to the release number of the suffix, if one exists. If there is no
/// suffix, then this bits are always 0.
/// to the release number of the suffix, if one exists. If there is no
/// suffix, then these bits are always 0.
///
/// The order of the encoding above is significant. For example, suffixes are
/// encoded at a less significant location than the release numbers, so that
Expand Down Expand Up @@ -2532,8 +2532,8 @@ fn parse_u64(bytes: &[u8]) -> Result<u64, VersionParseError> {
}

/// The minimum version that can be represented by a [`Version`]: `0a0.dev0`.
pub static MIN_VERSION: once_cell::sync::Lazy<Version> =
once_cell::sync::Lazy::new(|| Version::from_str("0a0.dev0").unwrap());
pub static MIN_VERSION: LazyLock<Version> =
LazyLock::new(|| Version::from_str("0a0.dev0").unwrap());

#[cfg(test)]
mod tests {
Expand Down
1 change: 0 additions & 1 deletion crates/pep508-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ workspace = true

[dependencies]
derivative = { workspace = true }
once_cell = { workspace = true }
pep440_rs = { workspace = true }
pyo3 = { workspace = true, optional = true, features = ["abi3", "extension-module"] }
pyo3-log = { workspace = true, optional = true }
Expand Down
11 changes: 5 additions & 6 deletions crates/pep508-rs/src/verbatim_url.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use regex::Regex;
use std::borrow::Cow;
use std::fmt::Debug;
use std::ops::Deref;
use std::path::{Path, PathBuf};

use once_cell::sync::Lazy;
use regex::Regex;
use std::sync::LazyLock;
use thiserror::Error;
use url::{ParseError, Url};

Expand Down Expand Up @@ -301,13 +300,13 @@ pub enum VerbatimUrlError {
pub fn expand_env_vars(s: &str) -> Cow<'_, str> {
// Generate the project root, to be used via the `${PROJECT_ROOT}`
// environment variable.
static PROJECT_ROOT_FRAGMENT: Lazy<String> = Lazy::new(|| {
static PROJECT_ROOT_FRAGMENT: LazyLock<String> = LazyLock::new(|| {
let project_root = std::env::current_dir().unwrap();
project_root.to_string_lossy().to_string()
});

static RE: Lazy<Regex> =
Lazy::new(|| Regex::new(r"(?P<var>\$\{(?P<name>[A-Z0-9_]+)})").unwrap());
static RE: LazyLock<Regex> =
LazyLock::new(|| Regex::new(r"(?P<var>\$\{(?P<name>[A-Z0-9_]+)})").unwrap());

RE.replace_all(s, |caps: &regex::Captures<'_>| {
let name = caps.name("name").unwrap().as_str();
Expand Down
1 change: 0 additions & 1 deletion crates/pypi-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ chrono = { workspace = true, features = ["serde"] }
indexmap = { workspace = true, features = ["serde"] }
itertools = { workspace = true }
mailparse = { workspace = true }
once_cell = { workspace = true }
regex = { workspace = true }
rkyv = { workspace = true }
serde = { workspace = true }
Expand Down
Loading

0 comments on commit 24859bd

Please sign in to comment.