diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6a7545c1ace..b112907bc67 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -187,6 +187,8 @@ jobs: persist-credentials: false - uses: dtolnay/rust-toolchain@stable - uses: Swatinem/rust-cache@v2 + with: + save-if: ${{ github.ref == 'refs/heads/main' }} - name: Setup dependencies run: | sudo apt-get update @@ -209,6 +211,8 @@ jobs: persist-credentials: false - uses: dtolnay/rust-toolchain@stable - uses: Swatinem/rust-cache@v2 + with: + save-if: ${{ github.ref == 'refs/heads/main' }} - uses: extractions/setup-just@v3 - name: Run journey tests run: just ci-journey-tests @@ -235,6 +239,8 @@ jobs: persist-credentials: false - uses: dtolnay/rust-toolchain@stable - uses: Swatinem/rust-cache@v2 + with: + save-if: ${{ github.ref == 'refs/heads/main' }} - name: cargo check default features if: startsWith(matrix.os, 'windows') run: cargo check --workspace --bins --examples @@ -284,6 +290,8 @@ jobs: persist-credentials: false - uses: dtolnay/rust-toolchain@stable - uses: Swatinem/rust-cache@v2 + with: + save-if: ${{ github.ref == 'refs/heads/main' }} - uses: taiki-e/install-action@v2 with: tool: nextest @@ -363,6 +371,8 @@ jobs: - name: Add Rust tools to path run: echo "PATH=$HOME/.cargo/bin:$PATH" >> "$GITHUB_ENV" - uses: Swatinem/rust-cache@v2 + with: + save-if: ${{ github.ref == 'refs/heads/main' }} - uses: taiki-e/install-action@v2 with: tool: nextest @@ -387,6 +397,8 @@ jobs: with: targets: ${{ env.TARGET }} - uses: Swatinem/rust-cache@v2 + with: + save-if: ${{ github.ref == 'refs/heads/main' }} - uses: taiki-e/install-action@v2 with: tool: nextest @@ -473,6 +485,8 @@ jobs: rustup default stable rustup target add "$TARGET" - uses: Swatinem/rust-cache@v2 + with: + save-if: ${{ github.ref == 'refs/heads/main' }} - name: 'WASI only: crates without feature toggle' if: endsWith(matrix.target, '-wasi') run: | diff --git a/.github/workflows/cron.yml b/.github/workflows/cron.yml index 2765c016265..df43e2cbe3d 100644 --- a/.github/workflows/cron.yml +++ b/.github/workflows/cron.yml @@ -17,5 +17,7 @@ jobs: with: persist-credentials: false - uses: Swatinem/rust-cache@v2 + with: + save-if: ${{ github.ref == 'refs/heads/main' }} - name: stress run: make stress diff --git a/Cargo.lock b/Cargo.lock index c5c309b0c72..551c640d792 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1325,7 +1325,6 @@ dependencies = [ "gix", "gix-features", "is-terminal", - "once_cell", "prodash", "serde_derive", "terminal_size", @@ -1432,7 +1431,6 @@ dependencies = [ "gix-worktree-stream", "insta", "is_ci", - "once_cell", "parking_lot", "pretty_assertions", "prodash", @@ -1553,7 +1551,6 @@ dependencies = [ "gix-quote", "gix-testtools", "gix-trace", - "once_cell", "shell-words", ] @@ -1586,7 +1583,6 @@ dependencies = [ "gix-ref", "gix-sec", "memchr", - "once_cell", "serde", "smallvec", "thiserror 2.0.17", @@ -1637,7 +1633,6 @@ dependencies = [ "gix-testtools", "gix-trace", "gix-url", - "once_cell", "serde", "thiserror 2.0.17", ] @@ -1652,7 +1647,6 @@ dependencies = [ "gix-testtools", "itoa", "jiff", - "once_cell", "pretty_assertions", "serde", "smallvec", @@ -2145,7 +2139,6 @@ dependencies = [ "gix-trace", "gix-validate", "home", - "once_cell", "serial_test", "thiserror 2.0.17", "windows 0.62.1", @@ -2163,7 +2156,6 @@ dependencies = [ "gix-glob", "gix-path", "gix-testtools", - "once_cell", "serial_test", "thiserror 2.0.17", ] @@ -2412,7 +2404,6 @@ dependencies = [ "document-features", "gix-fs", "libc", - "once_cell", "parking_lot", "signal-hook", "signal-hook-registry", @@ -2435,7 +2426,6 @@ dependencies = [ "gix-worktree", "io-close", "is_ci", - "once_cell", "parking_lot", "serial_test", "tar", @@ -2603,7 +2593,6 @@ dependencies = [ "gix-odb", "gix-testtools", "gix-worktree-state", - "once_cell", "symlink", "walkdir", ] @@ -3043,7 +3032,6 @@ dependencies = [ "anyhow", "clap", "gix", - "once_cell", "regex", ] diff --git a/Cargo.toml b/Cargo.toml index 69375522afc..377edbf63b0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ authors = ["Sebastian Thiel "] edition = "2021" license = "MIT OR Apache-2.0" version = "0.45.0" -rust-version = "1.74" +rust-version = "1.82" default-run = "gix" include = ["src/**/*", "/build.rs", "LICENSE-*", "README.md"] resolver = "2" @@ -174,7 +174,6 @@ terminal_size = "0.4.2" # Avoid pre-compiled binaries, see https://github.com/serde-rs/serde/issues/2538 and https://github.com/serde-rs/serde/pull/2590 serde_derive = ">=1.0.185" -once_cell = "1.21.3" document-features = { version = "0.2.0", optional = true } [profile.dev.package] insta.opt-level = 3 diff --git a/etc/msrv-badge.svg b/etc/msrv-badge.svg index 3d42373fe68..8dc2d6fa7fe 100644 --- a/etc/msrv-badge.svg +++ b/etc/msrv-badge.svg @@ -1,5 +1,5 @@ - - rustc: 1.75.0+ + + rustc: 1.82.0+ @@ -15,7 +15,7 @@ rustc - - 1.75.0+ + + 1.82.0+ diff --git a/gix-actor/Cargo.toml b/gix-actor/Cargo.toml index a9b66cf89fe..554ff163fba 100644 --- a/gix-actor/Cargo.toml +++ b/gix-actor/Cargo.toml @@ -9,7 +9,7 @@ repository = "https://github.com/GitoxideLabs/gitoxide" license = "MIT OR Apache-2.0" edition = "2021" include = ["src/**/*", "LICENSE-*"] -rust-version = "1.70" +rust-version = "1.82" [lib] doctest = false diff --git a/gix-actor/src/signature/mod.rs b/gix-actor/src/signature/mod.rs index ecb702dbd10..6641b10de57 100644 --- a/gix-actor/src/signature/mod.rs +++ b/gix-actor/src/signature/mod.rs @@ -110,7 +110,7 @@ pub(crate) mod write { impl From for std::io::Error { fn from(err: Error) -> Self { - std::io::Error::new(std::io::ErrorKind::Other, err) + std::io::Error::other(err) } } diff --git a/gix-archive/Cargo.toml b/gix-archive/Cargo.toml index 5d17aedcd37..c9bacdd1c13 100644 --- a/gix-archive/Cargo.toml +++ b/gix-archive/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" description = "archive generation from of a worktree stream" authors = ["Sebastian Thiel "] edition = "2021" -rust-version = "1.70" +rust-version = "1.82" include = ["src/**/*", "LICENSE-*"] [lib] diff --git a/gix-archive/src/write.rs b/gix-archive/src/write.rs index bd5d4decaff..bee23c09ace 100644 --- a/gix-archive/src/write.rs +++ b/gix-archive/src/write.rs @@ -160,8 +160,7 @@ where opts.tree_prefix.as_ref(), )?; } - ar.finish() - .map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err))?; + ar.finish().map_err(std::io::Error::other)?; } Ok(()) @@ -179,25 +178,25 @@ fn append_zip_entry( let file_opts = zip::write::SimpleFileOptions::default() .compression_method(zip::CompressionMethod::Deflated) .compression_level(compression_level) - .large_file(entry.bytes_remaining().map_or(true, |len| len > u32::MAX as usize)) + .large_file(entry.bytes_remaining().is_none_or(|len| len > u32::MAX as usize)) .last_modified_time(mtime) .unix_permissions(if entry.mode.is_executable() { 0o755 } else { 0o644 }); let path = add_prefix(entry.relative_path(), tree_prefix).into_owned(); match entry.mode.kind() { gix_object::tree::EntryKind::Blob | gix_object::tree::EntryKind::BlobExecutable => { ar.start_file(path.to_string(), file_opts) - .map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err))?; + .map_err(std::io::Error::other)?; std::io::copy(&mut entry, ar)?; } gix_object::tree::EntryKind::Tree | gix_object::tree::EntryKind::Commit => { ar.add_directory(path.to_string(), file_opts) - .map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err))?; + .map_err(std::io::Error::other)?; } gix_object::tree::EntryKind::Link => { use bstr::ByteSlice; std::io::copy(&mut entry, buf)?; ar.add_symlink(path.to_string(), buf.as_bstr().to_string(), file_opts) - .map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err))?; + .map_err(std::io::Error::other)?; } } Ok(()) diff --git a/gix-attributes/Cargo.toml b/gix-attributes/Cargo.toml index 62dba14d017..65a57022c07 100644 --- a/gix-attributes/Cargo.toml +++ b/gix-attributes/Cargo.toml @@ -9,7 +9,7 @@ description = "A crate of the gitoxide project dealing .gitattributes files" authors = ["Sebastian Thiel "] edition = "2021" include = ["src/**/*", "LICENSE-*"] -rust-version = "1.70" +rust-version = "1.82" [lib] doctest = false diff --git a/gix-bitmap/Cargo.toml b/gix-bitmap/Cargo.toml index 637f9464e71..83d3658fa98 100644 --- a/gix-bitmap/Cargo.toml +++ b/gix-bitmap/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" description = "A crate of the gitoxide project dedicated implementing the standard git bitmap format" authors = ["Sebastian Thiel "] edition = "2021" -rust-version = "1.70" +rust-version = "1.82" exclude = ["CHANGELOG.md"] [lib] diff --git a/gix-blame/Cargo.toml b/gix-blame/Cargo.toml index febee0905b9..9ed505d1a03 100644 --- a/gix-blame/Cargo.toml +++ b/gix-blame/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" description = "A crate of the gitoxide project dedicated to implementing a 'blame' algorithm" authors = ["Christoph Rüßler ", "Sebastian Thiel "] edition = "2021" -rust-version = "1.70" +rust-version = "1.82" [dependencies] gix-commitgraph = { version = "^0.29.0", path = "../gix-commitgraph" } diff --git a/gix-chunk/Cargo.toml b/gix-chunk/Cargo.toml index 94c7b64820f..6a54566c61d 100644 --- a/gix-chunk/Cargo.toml +++ b/gix-chunk/Cargo.toml @@ -10,7 +10,7 @@ documentation = "https://github.com/git/git/blob/seen/Documentation/technical/ch license = "MIT OR Apache-2.0" edition = "2021" include = ["src/**/*", "LICENSE-*"] -rust-version = "1.70" +rust-version = "1.82" [lib] doctest = false diff --git a/gix-command/Cargo.toml b/gix-command/Cargo.toml index a2cf9f408c2..8a25ba5ed54 100644 --- a/gix-command/Cargo.toml +++ b/gix-command/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" description = "A crate of the gitoxide project handling internal git command execution" authors = ["Sebastian Thiel "] edition = "2021" -rust-version = "1.70" +rust-version = "1.82" include = ["src/lib.rs", "LICENSE-*"] [lib] @@ -24,4 +24,3 @@ shell-words = "1.0" [dev-dependencies] gix-testtools = { path = "../tests/tools" } -once_cell = "1.21.3" diff --git a/gix-command/src/lib.rs b/gix-command/src/lib.rs index 438e8299aea..aaed98cf321 100644 --- a/gix-command/src/lib.rs +++ b/gix-command/src/lib.rs @@ -115,9 +115,10 @@ mod prepare { /// If neither this method nor [`with_shell()`](Self::with_shell()) is called, commands are /// always executed verbatim and directly, without the use of a shell. pub fn command_may_be_shell_script(mut self) -> Self { - self.use_shell = self.command.to_str().map_or(true, |cmd| { - cmd.as_bytes().find_byteset(b"|&;<>()$`\\\"' \t\n*?[#~=%").is_some() - }); + self.use_shell = self + .command + .to_str() + .is_none_or(|cmd| cmd.as_bytes().find_byteset(b"|&;<>()$`\\\"' \t\n*?[#~=%").is_some()); self } @@ -289,7 +290,7 @@ mod prepare { let mut cmd = Command::new(shell); cmd.arg("-c"); if !prep.args.is_empty() { - if prep.command.to_str().map_or(true, |cmd| !cmd.contains("$@")) { + if prep.command.to_str().is_none_or(|cmd| !cmd.contains("$@")) { if prep.quote_command { if let Ok(command) = gix_path::os_str_into_bstr(&prep.command) { prep.command = gix_path::from_bstring(gix_quote::single(command)).into(); diff --git a/gix-command/tests/command.rs b/gix-command/tests/command.rs index 867f55694c7..a142be6c7de 100644 --- a/gix-command/tests/command.rs +++ b/gix-command/tests/command.rs @@ -224,9 +224,9 @@ mod context { } mod prepare { - use once_cell::sync::Lazy; + use std::sync::LazyLock; - static SH: Lazy<&'static str> = Lazy::new(|| { + static SH: LazyLock<&'static str> = LazyLock::new(|| { gix_path::env::shell() .to_str() .expect("`prepare` tests must be run where 'sh' path is valid Unicode") diff --git a/gix-commitgraph/Cargo.toml b/gix-commitgraph/Cargo.toml index 531857b2664..224cb08f4f1 100644 --- a/gix-commitgraph/Cargo.toml +++ b/gix-commitgraph/Cargo.toml @@ -10,7 +10,7 @@ description = "Read-only access to the git commitgraph file format" authors = ["Conor Davis ", "Sebastian Thiel "] edition = "2021" include = ["src/**/*", "LICENSE-*"] -rust-version = "1.70" +rust-version = "1.82" [lib] doctest = false diff --git a/gix-config-value/Cargo.toml b/gix-config-value/Cargo.toml index 1a505c75c7e..35cbc92c013 100644 --- a/gix-config-value/Cargo.toml +++ b/gix-config-value/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" description = "A crate of the gitoxide project providing git-config value parsing" authors = ["Sebastian Thiel "] edition = "2021" -rust-version = "1.70" +rust-version = "1.82" include = ["src/**/*", "LICENSE-*"] [lib] diff --git a/gix-config/Cargo.toml b/gix-config/Cargo.toml index c966d8170de..14a24735316 100644 --- a/gix-config/Cargo.toml +++ b/gix-config/Cargo.toml @@ -11,7 +11,7 @@ edition = "2021" keywords = ["git-config", "git", "config", "gitoxide"] categories = ["config", "parser-implementations"] include = ["src/**/*", "LICENSE-*", "README.md"] -rust-version = "1.70" +rust-version = "1.82" autotests = false [features] @@ -33,7 +33,6 @@ unicode-bom = { version = "2.0.3" } bstr = { version = "1.12.0", default-features = false, features = ["std"] } serde = { version = "1.0.114", optional = true, default-features = false, features = ["derive"] } smallvec = "1.15.1" -once_cell = "1.21.3" document-features = { version = "0.2.0", optional = true } diff --git a/gix-config/src/file/access/mutate.rs b/gix-config/src/file/access/mutate.rs index 167d7c6a2f3..665877df792 100644 --- a/gix-config/src/file/access/mutate.rs +++ b/gix-config/src/file/access/mutate.rs @@ -376,7 +376,7 @@ impl<'event> File<'event> { nl: &impl AsRef<[u8]>, ) { if !ends_with_newline(lhs.as_ref(), nl, true) - && !rhs.first().map_or(true, |e| e.to_bstr_lossy().starts_with(nl.as_ref())) + && !rhs.first().is_none_or(|e| e.to_bstr_lossy().starts_with(nl.as_ref())) { lhs.push(Event::Newline(Cow::Owned(nl.as_ref().into()))); } diff --git a/gix-config/src/file/mutable/section.rs b/gix-config/src/file/mutable/section.rs index ec38ab85e2c..3602448e45f 100644 --- a/gix-config/src/file/mutable/section.rs +++ b/gix-config/src/file/mutable/section.rs @@ -71,7 +71,7 @@ impl<'event> SectionMut<'_, 'event> { text: Cow::Owned({ let mut c = Vec::with_capacity(comment.len()); let mut bytes = comment.iter().peekable(); - if !bytes.peek().map_or(true, |b| b.is_ascii_whitespace()) { + if !bytes.peek().is_none_or(|b| b.is_ascii_whitespace()) { c.insert(0, b' '); } c.extend(bytes.map(|b| if *b == b'\n' { b' ' } else { *b })); @@ -194,7 +194,7 @@ impl<'event> SectionMut<'_, 'event> { assert!( whitespace .as_deref() - .map_or(true, |ws| ws.iter().all(u8::is_ascii_whitespace)), + .is_none_or(|ws| ws.iter().all(u8::is_ascii_whitespace)), "input whitespace must only contain whitespace characters." ); self.whitespace.pre_key = whitespace; diff --git a/gix-config/src/parse/events.rs b/gix-config/src/parse/events.rs index 2eb14d679d5..ae95b61c64c 100644 --- a/gix-config/src/parse/events.rs +++ b/gix-config/src/parse/events.rs @@ -313,7 +313,7 @@ fn from_bytes<'a, 'b>( .into(); } event => { - if filter.map_or(true, |f| f(&event)) { + if filter.is_none_or(|f| f(&event)) { events.push(convert(event)); } } diff --git a/gix-config/src/parse/nom/mod.rs b/gix-config/src/parse/nom/mod.rs index 58532baab98..c5b3c27ca9a 100644 --- a/gix-config/src/parse/nom/mod.rs +++ b/gix-config/src/parse/nom/mod.rs @@ -96,9 +96,8 @@ fn section<'i>( dispatch: &mut dyn FnMut(Event<'i>), ) -> ModalResult<(), NomError<&'i [u8]>> { let start = i.checkpoint(); - let header = section_header(i).map_err(|e| { + let header = section_header(i).inspect_err(|_err| { i.reset(&start); - e })?; dispatch(Event::SectionHeader(header)); diff --git a/gix-config/tests/Cargo.toml b/gix-config/tests/Cargo.toml index 9d9cc59c425..ae97109c6e2 100644 --- a/gix-config/tests/Cargo.toml +++ b/gix-config/tests/Cargo.toml @@ -8,7 +8,7 @@ description = "Tests for the gix-config crate" license = "MIT OR Apache-2.0" authors = ["Edward Shen "] edition = "2021" -rust-version = "1.70" +rust-version = "1.82" publish = false diff --git a/gix-credentials/Cargo.toml b/gix-credentials/Cargo.toml index 840ea963612..51aa405052f 100644 --- a/gix-credentials/Cargo.toml +++ b/gix-credentials/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" description = "A crate of the gitoxide project to interact with git credentials helpers" authors = ["Sebastian Thiel "] edition = "2021" -rust-version = "1.70" +rust-version = "1.82" include = ["src/**/*", "LICENSE-*"] [lib] @@ -39,7 +39,6 @@ document-features = { version = "0.2.1", optional = true } [dev-dependencies] gix-testtools = { path = "../tests/tools" } gix-sec = { path = "../gix-sec" } -once_cell = "1.21.3" [package.metadata.docs.rs] all-features = true diff --git a/gix-credentials/examples/custom-helper.rs b/gix-credentials/examples/custom-helper.rs index 9fc0cbf61ee..3c841e6a065 100644 --- a/gix-credentials/examples/custom-helper.rs +++ b/gix-credentials/examples/custom-helper.rs @@ -13,8 +13,7 @@ pub fn main() -> Result<(), gix_credentials::program::main::Error> { password: Some("pass".into()), ..context })), - program::main::Action::Erase => Err(std::io::Error::new( - std::io::ErrorKind::Other, + program::main::Action::Erase => Err(std::io::Error::other( "Refusing to delete credentials for demo purposes", )), program::main::Action::Store => Ok(None), diff --git a/gix-credentials/src/helper/cascade.rs b/gix-credentials/src/helper/cascade.rs index 3d5b31a5ef6..aa73a178887 100644 --- a/gix-credentials/src/helper/cascade.rs +++ b/gix-credentials/src/helper/cascade.rs @@ -73,6 +73,7 @@ impl Cascade { let mut url = action .context_mut() .map(|ctx| { + #[allow(clippy::manual_inspect)] /* false positive */ ctx.destructure_url_in_place(self.use_http_path).map(|ctx| { if self.query_user_only && ctx.password.is_none() { ctx.password = Some("".into()); diff --git a/gix-credentials/src/program/mod.rs b/gix-credentials/src/program/mod.rs index a966ca622f5..ba7be2fc609 100644 --- a/gix-credentials/src/program/mod.rs +++ b/gix-credentials/src/program/mod.rs @@ -135,10 +135,10 @@ impl Program { if status.success() { Ok(()) } else { - Err(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Credentials helper program failed with status code {:?}", status.code()), - )) + Err(std::io::Error::other(format!( + "Credentials helper program failed with status code {:?}", + status.code() + ))) } } } diff --git a/gix-credentials/src/protocol/context/serde.rs b/gix-credentials/src/protocol/context/serde.rs index a4c91b96376..83cb5dcee9e 100644 --- a/gix-credentials/src/protocol/context/serde.rs +++ b/gix-credentials/src/protocol/context/serde.rs @@ -32,8 +32,7 @@ mod write { } = self; for (key, value) in [("url", url), ("path", path)] { if let Some(value) = value { - validate(key, value.as_slice().into()) - .map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err))?; + validate(key, value.as_slice().into()).map_err(std::io::Error::other)?; write_key(&mut out, key, value.as_ref()).ok(); } } @@ -45,16 +44,14 @@ mod write { ("oauth_refresh_token", oauth_refresh_token), ] { if let Some(value) = value { - validate(key, value.as_str().into()) - .map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err))?; + validate(key, value.as_str().into()).map_err(std::io::Error::other)?; write_key(&mut out, key, value.as_bytes().as_bstr()).ok(); } } if let Some(value) = password_expiry_utc { let key = "password_expiry_utc"; let value = value.to_string(); - validate(key, value.as_str().into()) - .map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err))?; + validate(key, value.as_str().into()).map_err(std::io::Error::other)?; write_key(&mut out, key, value.as_bytes().as_bstr()).ok(); } Ok(()) diff --git a/gix-credentials/tests/program/from_custom_definition.rs b/gix-credentials/tests/program/from_custom_definition.rs index c746e0b48af..dc52bff4fa9 100644 --- a/gix-credentials/tests/program/from_custom_definition.rs +++ b/gix-credentials/tests/program/from_custom_definition.rs @@ -1,13 +1,13 @@ use gix_credentials::{helper, program::Kind, Program}; -use once_cell::sync::Lazy; +use std::sync::LazyLock; -static GIT: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| { +static GIT: std::sync::LazyLock<&'static str> = std::sync::LazyLock::new(|| { gix_path::env::exe_invocation() .to_str() .expect("some `from_custom_definition` tests must be run where 'git' path is valid Unicode") }); -static SH: Lazy<&'static str> = Lazy::new(|| { +static SH: LazyLock<&'static str> = LazyLock::new(|| { gix_path::env::shell() .to_str() .expect("some `from_custom_definition` tests must be run where 'sh' path is valid Unicode") diff --git a/gix-date/Cargo.toml b/gix-date/Cargo.toml index c4e60ab807a..7a52b96f996 100644 --- a/gix-date/Cargo.toml +++ b/gix-date/Cargo.toml @@ -9,7 +9,7 @@ description = "A crate of the gitoxide project parsing dates the way git does" authors = ["Sebastian Thiel "] edition = "2021" include = ["src/**/*", "LICENSE-*"] -rust-version = "1.70" +rust-version = "1.82" [lib] doctest = false @@ -33,7 +33,6 @@ document-features = { version = "0.2.0", optional = true } [dev-dependencies] gix-hash = { path = "../gix-hash" } gix-testtools = { path = "../tests/tools" } -once_cell = "1.21.3" pretty_assertions = "1.4.1" [package.metadata.docs.rs] diff --git a/gix-date/src/time/write.rs b/gix-date/src/time/write.rs index 0bc1c3ecc8c..fb03b903f9e 100644 --- a/gix-date/src/time/write.rs +++ b/gix-date/src/time/write.rs @@ -24,10 +24,7 @@ impl Time { let minutes = (offset - (hours * SECONDS_PER_HOUR)) / 60; if hours > 99 { - return Err(std::io::Error::new( - std::io::ErrorKind::Other, - "Cannot represent offsets larger than +-9900", - )); + return Err(std::io::Error::other("Cannot represent offsets larger than +-9900")); } let mut itoa = itoa::Buffer::new(); diff --git a/gix-date/tests/time/baseline.rs b/gix-date/tests/time/baseline.rs index 7f8c2aa01d7..4eff7cef066 100644 --- a/gix-date/tests/time/baseline.rs +++ b/gix-date/tests/time/baseline.rs @@ -5,7 +5,7 @@ use gix_date::{ SecondsSinceUnixEpoch, }; use gix_testtools::Result; -use once_cell::sync::Lazy; +use std::sync::LazyLock; struct Sample { format_name: Option, @@ -13,7 +13,7 @@ struct Sample { seconds: SecondsSinceUnixEpoch, } -static BASELINE: Lazy> = Lazy::new(|| { +static BASELINE: LazyLock> = LazyLock::new(|| { (|| -> Result<_> { let base = gix_testtools::scripted_fixture_read_only("generate_git_date_baseline.sh")?; let mut map = HashMap::new(); diff --git a/gix-diff/Cargo.toml b/gix-diff/Cargo.toml index f14a624d9a8..b19dfd69a42 100644 --- a/gix-diff/Cargo.toml +++ b/gix-diff/Cargo.toml @@ -9,7 +9,7 @@ description = "Calculate differences between various git objects" authors = ["Sebastian Thiel "] edition = "2021" include = ["src/**/*", "LICENSE-*"] -rust-version = "1.74" +rust-version = "1.82" autotests = false [features] diff --git a/gix-diff/src/blob/pipeline.rs b/gix-diff/src/blob/pipeline.rs index 12ab791dd66..8789cc670e0 100644 --- a/gix-diff/src/blob/pipeline.rs +++ b/gix-diff/src/blob/pipeline.rs @@ -498,7 +498,7 @@ impl Pipeline { } } - if driver.map_or(true, |d| d.binary_to_text_command.is_none()) + if driver.is_none_or(|d| d.binary_to_text_command.is_none()) && is_binary.unwrap_or_else(|| is_binary_buf(out)) { let size = out.len() as u64; diff --git a/gix-diff/src/rewrites/tracker.rs b/gix-diff/src/rewrites/tracker.rs index 7a8f2e43172..81dd7d4dacb 100644 --- a/gix-diff/src/rewrites/tracker.rs +++ b/gix-diff/src/rewrites/tracker.rs @@ -667,7 +667,7 @@ fn estimate_involved_items( } fn needs_exact_match(percentage: Option) -> bool { - percentage.map_or(true, |p| p >= 1.0) + percentage.is_none_or(|p| p >= 1.0) } /// <`src_idx`, src, possibly diff stat> diff --git a/gix-diff/tests/Cargo.toml b/gix-diff/tests/Cargo.toml index dd72f6dc991..15efce8b0f4 100644 --- a/gix-diff/tests/Cargo.toml +++ b/gix-diff/tests/Cargo.toml @@ -9,7 +9,7 @@ license = "MIT OR Apache-2.0" description = "Tests for the gix-diff crate" authors = ["Sebastian Thiel "] edition = "2021" -rust-version = "1.70" +rust-version = "1.82" [[test]] doctest = false diff --git a/gix-diff/tests/diff/index.rs b/gix-diff/tests/diff/index.rs index 5d08ff52866..35b2b76b4b1 100644 --- a/gix-diff/tests/diff/index.rs +++ b/gix-diff/tests/diff/index.rs @@ -52,7 +52,7 @@ fn empty_to_new_tree_without_rename_tracking() -> crate::Result { let err = gix_diff::index( &lhs, &rhs, - |_change| Err(std::io::Error::new(std::io::ErrorKind::Other, "custom error")), + |_change| Err(std::io::Error::other("custom error")), None::>, &mut pathspec, &mut |_, _, _, _| true, @@ -1340,10 +1340,7 @@ mod util { } else { let tree_id_path = root.join(tree).with_extension("tree"); let hex_id = std::fs::read_to_string(&tree_id_path).map_err(|err| { - std::io::Error::new( - std::io::ErrorKind::Other, - format!("Could not read '{}': {}", tree_id_path.display(), err), - ) + std::io::Error::other(format!("Could not read '{}': {}", tree_id_path.display(), err)) })?; let tree_id = gix_hash::ObjectId::from_hex(hex_id.trim().as_bytes())?; Ok(gix_index::State::from_tree(&tree_id, odb, Default::default())?) diff --git a/gix-diff/tests/diff/tree_with_rewrites.rs b/gix-diff/tests/diff/tree_with_rewrites.rs index af5bacf95d6..c0d811357d4 100644 --- a/gix-diff/tests/diff/tree_with_rewrites.rs +++ b/gix-diff/tests/diff/tree_with_rewrites.rs @@ -112,7 +112,7 @@ fn empty_to_new_tree_without_rename_tracking() -> crate::Result { &mut cache, &mut Default::default(), &odb, - |_change| Err(std::io::Error::new(std::io::ErrorKind::Other, "custom error")), + |_change| Err(std::io::Error::other("custom error")), Options::default(), ) .unwrap_err(); @@ -1860,12 +1860,8 @@ mod util { fn read_tree(odb: &dyn gix_object::Find, root: &Path, tree: Option<&str>) -> gix_testtools::Result> { let Some(tree) = tree else { return Ok(Vec::new()) }; let tree_id_path = root.join(tree).with_extension("tree"); - let hex_id = std::fs::read_to_string(&tree_id_path).map_err(|err| { - std::io::Error::new( - std::io::ErrorKind::Other, - format!("Could not read '{}': {}", tree_id_path.display(), err), - ) - })?; + let hex_id = std::fs::read_to_string(&tree_id_path) + .map_err(|err| std::io::Error::other(format!("Could not read '{}': {}", tree_id_path.display(), err)))?; let tree_id = gix_hash::ObjectId::from_hex(hex_id.trim().as_bytes())?; let mut buf = Vec::new(); odb.find_tree(&tree_id, &mut buf)?; diff --git a/gix-dir/Cargo.toml b/gix-dir/Cargo.toml index f7b8fba0df2..36a8321110a 100644 --- a/gix-dir/Cargo.toml +++ b/gix-dir/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" description = "A crate of the gitoxide project dealing with directory walks" authors = ["Sebastian Thiel "] edition = "2021" -rust-version = "1.70" +rust-version = "1.82" [lib] doctest = false diff --git a/gix-dir/src/walk/function.rs b/gix-dir/src/walk/function.rs index 9cbda0965ad..5addf0cc710 100644 --- a/gix-dir/src/walk/function.rs +++ b/gix-dir/src/walk/function.rs @@ -197,10 +197,7 @@ pub(super) fn emit_entry( || !emit_tracked && info.status == entry::Status::Tracked) || emit_ignored.is_none() && matches!(info.status, entry::Status::Ignored(_)) || !emit_pruned - && (info.status.is_pruned() - || info - .pathspec_match - .map_or(true, |m| m == entry::PathspecMatch::Excluded)) + && (info.status.is_pruned() || info.pathspec_match.is_none_or(|m| m == entry::PathspecMatch::Excluded)) { return Action::Continue; } diff --git a/gix-dir/src/walk/readdir.rs b/gix-dir/src/walk/readdir.rs index 1d4f04e09f9..9f0bf17c4c0 100644 --- a/gix-dir/src/walk/readdir.rs +++ b/gix-dir/src/walk/readdir.rs @@ -189,7 +189,7 @@ impl State { pub(super) fn may_collapse(&self, directory_to_traverse: &Path) -> bool { self.worktree_relative_current_dir .as_ref() - .map_or(true, |cwd| cwd != directory_to_traverse) + .is_none_or(|cwd| cwd != directory_to_traverse) } pub(super) fn emit_remaining( diff --git a/gix-discover/Cargo.toml b/gix-discover/Cargo.toml index 0877536026e..d5966252851 100644 --- a/gix-discover/Cargo.toml +++ b/gix-discover/Cargo.toml @@ -9,7 +9,7 @@ description = "Discover git repositories and check if a directory is a git repos authors = ["Sebastian Thiel "] edition = "2021" include = ["src/**/*", "LICENSE-*"] -rust-version = "1.70" +rust-version = "1.82" [lib] doctest = false diff --git a/gix-discover/src/path.rs b/gix-discover/src/path.rs index f1e446f15d2..d59eef86ab7 100644 --- a/gix-discover/src/path.rs +++ b/gix-discover/src/path.rs @@ -20,15 +20,12 @@ fn read_regular_file_content_with_size_limit(path: &std::path::Path) -> std::io: let max_file_size = 1024 * 64; // NOTE: git allows 1MB here let file_size = file.metadata()?.len(); if file_size > max_file_size { - return Err(std::io::Error::new( - std::io::ErrorKind::Other, - format!( - "Refusing to open files larger than {} bytes, '{}' was {} bytes large", - max_file_size, - path.display(), - file_size - ), - )); + return Err(std::io::Error::other(format!( + "Refusing to open files larger than {} bytes, '{}' was {} bytes large", + max_file_size, + path.display(), + file_size + ))); } let mut buf = Vec::with_capacity(512); file.read_to_end(&mut buf)?; diff --git a/gix-discover/src/upwards/util.rs b/gix-discover/src/upwards/util.rs index 20244d8a0d3..9b42289a549 100644 --- a/gix-discover/src/upwards/util.rs +++ b/gix-discover/src/upwards/util.rs @@ -22,8 +22,7 @@ pub(crate) fn shorten_path_with_cwd(cursor: PathBuf, cwd: &Path) -> PathBuf { let relative_path_components = path_relative_to_cwd.components().count(); let current_component_len = cursor.components().map(comp_len).sum::(); (relative_path_components * "..".len() < current_component_len).then(|| { - std::iter::repeat("..") - .take(relative_path_components) + std::iter::repeat_n("..", relative_path_components) .chain(Some(DOT_GIT_DIR)) .collect() }) diff --git a/gix-features/Cargo.toml b/gix-features/Cargo.toml index 0573440501d..79a8615e996 100644 --- a/gix-features/Cargo.toml +++ b/gix-features/Cargo.toml @@ -8,7 +8,7 @@ version = "0.43.1" authors = ["Sebastian Thiel "] license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.70" +rust-version = "1.82" include = ["src/**/*", "LICENSE-*"] [lib] @@ -45,6 +45,7 @@ tracing-detail = ["gix-trace/tracing-detail"] ## This way, single-threaded applications don't have to pay for threaded primitives. parallel = ["dep:crossbeam-channel", "dep:parking_lot"] ## If enabled, OnceCell will be made available for interior mutability either in sync or unsync forms. +## Note: This still uses once_cell because std::sync::OnceLock::get_or_try_init() is not yet stable. once_cell = ["dep:once_cell"] ## Makes facilities of the `walkdir` crate partially available. ## In conjunction with the **parallel** feature, directory walking will be parallel instead behind a compatible interface. @@ -110,6 +111,8 @@ bytes = { version = "1.0.0", optional = true } libz-rs-sys = { version = "0.5.2", optional = true } thiserror = { version = "2.0.17", optional = true } +# Note: once_cell is kept for OnceCell type because std::sync::OnceLock::get_or_try_init() is not yet stable. +# Once it's stabilized (tracking issue #109737), we can remove this dependency. once_cell = { version = "1.21.3", optional = true } document-features = { version = "0.2.0", optional = true } diff --git a/gix-features/src/interrupt.rs b/gix-features/src/interrupt.rs index 187dcde7425..383f6c84dc5 100644 --- a/gix-features/src/interrupt.rs +++ b/gix-features/src/interrupt.rs @@ -105,7 +105,7 @@ where { fn read(&mut self, buf: &mut [u8]) -> io::Result { if self.should_interrupt.load(Ordering::Relaxed) { - return Err(std::io::Error::new(std::io::ErrorKind::Other, "Interrupted")); + return Err(std::io::Error::other("Interrupted")); } self.inner.read(buf) } @@ -140,7 +140,7 @@ where { fn write(&mut self, buf: &[u8]) -> io::Result { if self.should_interrupt.load(Ordering::Relaxed) { - return Err(std::io::Error::new(std::io::ErrorKind::Other, "Interrupted")); + return Err(std::io::Error::other("Interrupted")); } self.inner.write(buf) } diff --git a/gix-features/src/threading.rs b/gix-features/src/threading.rs index 5f92ba2a892..e5d47ca3623 100644 --- a/gix-features/src/threading.rs +++ b/gix-features/src/threading.rs @@ -7,6 +7,9 @@ mod _impl { use std::sync::Arc; /// A thread-safe cell which can be written to only once. + /// + /// Note: We use `once_cell` here because `std::sync::OnceLock::get_or_try_init()` is not yet stable. + /// Once it's stabilized, we can switch to `std::sync::OnceLock`. #[cfg(feature = "once_cell")] pub type OnceCell = once_cell::sync::OnceCell; /// A reference counted pointer type for shared ownership. @@ -62,6 +65,9 @@ mod _impl { }; /// A thread-safe cell which can be written to only once. + /// + /// Note: We use `once_cell` here because `std::cell::OnceCell::get_or_try_init()` is not yet stable. + /// Once it's stabilized, we can switch to `std::cell::OnceCell`. #[cfg(feature = "once_cell")] pub type OnceCell = once_cell::unsync::OnceCell; /// A reference counted pointer type for shared ownership. diff --git a/gix-features/src/zlib/stream/deflate/mod.rs b/gix-features/src/zlib/stream/deflate/mod.rs index d0c40399ad9..9945288977a 100644 --- a/gix-features/src/zlib/stream/deflate/mod.rs +++ b/gix-features/src/zlib/stream/deflate/mod.rs @@ -196,7 +196,7 @@ mod impls { let status = self .compressor .compress(buf, &mut self.buf, flush) - .map_err(|err| io::Error::new(io::ErrorKind::Other, err))?; + .map_err(io::Error::other)?; let written = self.compressor.total_out() - last_total_out; if written > 0 { diff --git a/gix-features/tests/parallel/mod.rs b/gix-features/tests/parallel/mod.rs index cc824332dcc..cf813c1a223 100644 --- a/gix-features/tests/parallel/mod.rs +++ b/gix-features/tests/parallel/mod.rs @@ -40,7 +40,7 @@ fn in_parallel() { #[test] fn in_parallel_with_mut_slice_in_chunks() { let num_items = 33; - let mut input: Vec<_> = std::iter::repeat(1).take(num_items).collect(); + let mut input: Vec<_> = std::iter::repeat_n(1, num_items).collect(); let counts = parallel::in_parallel_with_slice( &mut input, None, @@ -54,7 +54,7 @@ fn in_parallel_with_mut_slice_in_chunks() { std::convert::identity, ) .unwrap(); - let expected = std::iter::repeat(1).take(num_items).sum::(); + let expected = std::iter::repeat_n(1, num_items).sum::(); assert_eq!(counts.iter().sum::(), expected); assert_eq!(input.iter().sum::(), expected * 2, "we increment each entry"); } diff --git a/gix-features/tests/pipe.rs b/gix-features/tests/pipe.rs index cae6b256864..8027a234c91 100644 --- a/gix-features/tests/pipe.rs +++ b/gix-features/tests/pipe.rs @@ -59,7 +59,7 @@ mod io { let (writer, mut reader) = io::pipe::unidirectional(1); writer .channel - .send(Err(std::io::Error::new(std::io::ErrorKind::Other, "the error"))) + .send(Err(std::io::Error::other("the error"))) .expect("send success"); let mut buf = [0]; assert_eq!( @@ -70,7 +70,7 @@ mod io { writer .channel - .send(Err(std::io::Error::new(std::io::ErrorKind::Other, "the error"))) + .send(Err(std::io::Error::other("the error"))) .expect("send success"); assert_eq!( reader.fill_buf().unwrap_err().to_string(), diff --git a/gix-fetchhead/Cargo.toml b/gix-fetchhead/Cargo.toml index 93a574e2d38..5f62ef37fad 100644 --- a/gix-fetchhead/Cargo.toml +++ b/gix-fetchhead/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" description = "A crate of the gitoxide project to read and write .git/FETCH_HEAD" authors = ["Sebastian Thiel "] edition = "2021" -rust-version = "1.70" +rust-version = "1.82" [lib] doctest = false diff --git a/gix-filter/Cargo.toml b/gix-filter/Cargo.toml index eda2f3690f2..754823f609f 100644 --- a/gix-filter/Cargo.toml +++ b/gix-filter/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" description = "A crate of the gitoxide project implementing git filters" authors = ["Sebastian Thiel "] edition = "2021" -rust-version = "1.70" +rust-version = "1.82" include = ["src/**/*", "LICENSE-*"] [lib] diff --git a/gix-filter/src/driver/apply.rs b/gix-filter/src/driver/apply.rs index 0a530e39c55..cde092a49c4 100644 --- a/gix-filter/src/driver/apply.rs +++ b/gix-filter/src/driver/apply.rs @@ -228,10 +228,7 @@ impl std::io::Read for ReadFilterOutput { if let Some((mut child, cmd)) = self.child.take() { let status = child.wait()?; if !status.success() { - return Err(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Driver process {cmd:?} failed"), - )); + return Err(std::io::Error::other(format!("Driver process {cmd:?} failed"))); } } } diff --git a/gix-filter/src/driver/process/client.rs b/gix-filter/src/driver/process/client.rs index 312b0600d4e..f2f2d8a8072 100644 --- a/gix-filter/src/driver/process/client.rs +++ b/gix-filter/src/driver/process/client.rs @@ -84,7 +84,7 @@ impl Client { read.read_line_to_string(&mut buf)?; if buf .strip_prefix(welcome_prefix) - .map_or(true, |rest| rest.trim_end() != "-server") + .is_none_or(|rest| rest.trim_end() != "-server") { return Err(handshake::Error::Protocol { msg: format!("Wanted '{welcome_prefix}-server, got "), @@ -266,13 +266,10 @@ impl std::io::Read for ReadProcessOutputAndStatus<'_> { if status.is_success() { Ok(0) } else { - Err(std::io::Error::new( - std::io::ErrorKind::Other, - format!( - "Process indicated error after reading: {}", - status.message().unwrap_or_default() - ), - )) + Err(std::io::Error::other(format!( + "Process indicated error after reading: {}", + status.message().unwrap_or_default() + ))) } } else { Ok(num_read) diff --git a/gix-filter/src/driver/process/server.rs b/gix-filter/src/driver/process/server.rs index 971b5393bb2..76a7f76686c 100644 --- a/gix-filter/src/driver/process/server.rs +++ b/gix-filter/src/driver/process/server.rs @@ -73,7 +73,7 @@ impl Server { read.read_line_to_string(&mut buf)?; if buf .strip_prefix(welcome_prefix) - .map_or(true, |rest| rest.trim_end() != "-client") + .is_none_or(|rest| rest.trim_end() != "-client") { return Err(handshake::Error::Protocol { msg: format!("Expected '{welcome_prefix}-client, got"), diff --git a/gix-fs/Cargo.toml b/gix-fs/Cargo.toml index 0bd77641cf0..b5fb5c6284c 100644 --- a/gix-fs/Cargo.toml +++ b/gix-fs/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" description = "A crate providing file system specific utilities to `gitoxide`" authors = ["Sebastian Thiel "] edition = "2021" -rust-version = "1.75" +rust-version = "1.82" include = ["src/**/*", "LICENSE-*"] [lib] diff --git a/gix-fsck/Cargo.toml b/gix-fsck/Cargo.toml index e5996cac6e5..7abfe5e3331 100644 --- a/gix-fsck/Cargo.toml +++ b/gix-fsck/Cargo.toml @@ -9,7 +9,7 @@ license = "MIT OR Apache-2.0" description = "Verifies the connectivity and validity of objects in the database" edition = "2021" include = ["src/**/*", "LICENSE-*"] -rust-version = "1.70" +rust-version = "1.82" [lib] doctest = false diff --git a/gix-fsck/tests/connectivity/mod.rs b/gix-fsck/tests/connectivity/mod.rs index 10c5ea92a78..1a94ed34736 100644 --- a/gix-fsck/tests/connectivity/mod.rs +++ b/gix-fsck/tests/connectivity/mod.rs @@ -2,7 +2,7 @@ use gix_fsck::Connectivity; use gix_hash::ObjectId; use gix_hashtable::HashMap; use gix_object::Kind; -use gix_testtools::once_cell::sync::Lazy; +use std::sync::LazyLock; use crate::hex_to_id; @@ -40,7 +40,7 @@ fn hex_to_objects<'a>(hex_ids: impl IntoIterator, kind: Kind) -> // Get a `&Vec &'static [ObjectId] { - static ALL_COMMITS: Lazy> = Lazy::new(|| { + static ALL_COMMITS: LazyLock> = LazyLock::new(|| { hex_to_ids([ "ebed23648b19484cb1f340c4ee04dda08479188a", "8ff6d0f8891c3cb22827be142cc64606121d47b3", diff --git a/gix-glob/Cargo.toml b/gix-glob/Cargo.toml index 187d8985f06..2bbdf54077f 100644 --- a/gix-glob/Cargo.toml +++ b/gix-glob/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" description = "A crate of the gitoxide project dealing with pattern matching" authors = ["Sebastian Thiel "] edition = "2021" -rust-version = "1.70" +rust-version = "1.82" include = ["src/**/*", "LICENSE-*"] [lib] diff --git a/gix-glob/src/wildmatch.rs b/gix-glob/src/wildmatch.rs index 6bb16cf7110..9c91f4e27ce 100644 --- a/gix-glob/src/wildmatch.rs +++ b/gix-glob/src/wildmatch.rs @@ -89,8 +89,8 @@ pub(crate) mod function { next = p.next(); if !mode.contains(Mode::NO_MATCH_SLASH_LITERAL) { match_slash = true; - } else if leading_slash_idx.map_or(true, |idx| pattern[idx] == SLASH) - && next.map_or(true, |(_, c)| { + } else if leading_slash_idx.is_none_or(|idx| pattern[idx] == SLASH) + && next.is_none_or(|(_, c)| { c == SLASH || (c == BACKSLASH && p.peek().map(|t| t.1) == Some(SLASH)) }) { diff --git a/gix-hash/Cargo.toml b/gix-hash/Cargo.toml index c56eccaed2a..291277b3522 100644 --- a/gix-hash/Cargo.toml +++ b/gix-hash/Cargo.toml @@ -9,7 +9,7 @@ repository = "https://github.com/GitoxideLabs/gitoxide" license = "MIT OR Apache-2.0" edition = "2021" include = ["src/**/*", "LICENSE-*"] -rust-version = "1.70" +rust-version = "1.82" [lib] doctest = false diff --git a/gix-hash/src/io.rs b/gix-hash/src/io.rs index 13abc42f23f..19e981453dc 100644 --- a/gix-hash/src/io.rs +++ b/gix-hash/src/io.rs @@ -75,7 +75,7 @@ pub(super) mod _impl { progress.inc_by(out.len()); hasher.update(out); if should_interrupt.load(std::sync::atomic::Ordering::SeqCst) { - return Err(std::io::Error::new(std::io::ErrorKind::Other, "Interrupted").into()); + return Err(std::io::Error::other("Interrupted").into()); } } diff --git a/gix-hash/src/oid.rs b/gix-hash/src/oid.rs index 1cde8755eb2..0d952b219b0 100644 --- a/gix-hash/src/oid.rs +++ b/gix-hash/src/oid.rs @@ -80,7 +80,7 @@ impl oid { 20 => Ok( #[allow(unsafe_code)] unsafe { - &*(digest as *const [u8] as *const oid) + &*(std::ptr::from_ref::<[u8]>(digest) as *const oid) }, ), len => Err(Error::InvalidByteSliceLength(len)), @@ -97,7 +97,7 @@ impl oid { pub(crate) fn from_bytes(value: &[u8]) -> &Self { #[allow(unsafe_code)] unsafe { - &*(value as *const [u8] as *const oid) + &*(std::ptr::from_ref::<[u8]>(value) as *const oid) } } } diff --git a/gix-hash/src/prefix.rs b/gix-hash/src/prefix.rs index 5da49c03000..86e7c8e30a1 100644 --- a/gix-hash/src/prefix.rs +++ b/gix-hash/src/prefix.rs @@ -52,7 +52,7 @@ impl Prefix { } else { let mut prefix = ObjectId::null(id.kind()); let b = prefix.as_mut_slice(); - let copy_len = (hex_len + 1) / 2; + let copy_len = hex_len.div_ceil(2); b[..copy_len].copy_from_slice(&id.as_bytes()[..copy_len]); if hex_len % 2 == 1 { b[hex_len / 2] &= 0xf0; @@ -103,7 +103,7 @@ impl Prefix { } let src = if value.len() % 2 == 0 { - let mut out = Vec::from_iter(std::iter::repeat(0).take(value.len() / 2)); + let mut out = Vec::from_iter(std::iter::repeat_n(0, value.len() / 2)); faster_hex::hex_decode(value.as_bytes(), &mut out).map(move |_| out) } else { // TODO(perf): do without heap allocation here. @@ -111,7 +111,7 @@ impl Prefix { buf[..value.len()].copy_from_slice(value.as_bytes()); buf[value.len()] = b'0'; let src = &buf[..=value.len()]; - let mut out = Vec::from_iter(std::iter::repeat(0).take(src.len() / 2)); + let mut out = Vec::from_iter(std::iter::repeat_n(0, src.len() / 2)); faster_hex::hex_decode(src, &mut out).map(move |_| out) } .map_err(|e| match e { diff --git a/gix-hash/tests/hash/prefix.rs b/gix-hash/tests/hash/prefix.rs index 357a18869a7..4959fd7149f 100644 --- a/gix-hash/tests/hash/prefix.rs +++ b/gix-hash/tests/hash/prefix.rs @@ -45,7 +45,7 @@ mod new { for hex_len in 4..oid.kind().len_in_hex() { let mut expected = String::from(&oid_hex[..hex_len]); let num_of_zeros = oid.kind().len_in_hex() - hex_len; - expected.extend(std::iter::repeat('0').take(num_of_zeros)); + expected.extend(std::iter::repeat_n('0', num_of_zeros)); let prefix = gix_hash::Prefix::new(&oid, hex_len).unwrap(); assert_eq!(prefix.as_oid().to_hex().to_string(), expected, "{hex_len}"); assert_eq!(prefix.hex_len(), hex_len); diff --git a/gix-hashtable/Cargo.toml b/gix-hashtable/Cargo.toml index 80502bfd6ef..1f3acda562c 100644 --- a/gix-hashtable/Cargo.toml +++ b/gix-hashtable/Cargo.toml @@ -9,7 +9,7 @@ description = "A crate that provides hashtable based data structures optimized t authors = ["Pascal Kuthe "] edition = "2021" include = ["src/**/*", "LICENSE-*"] -rust-version = "1.70" +rust-version = "1.82" [lib] doctest = false diff --git a/gix-ignore/Cargo.toml b/gix-ignore/Cargo.toml index 941808691fc..793075d52d3 100644 --- a/gix-ignore/Cargo.toml +++ b/gix-ignore/Cargo.toml @@ -9,7 +9,7 @@ description = "A crate of the gitoxide project dealing .gitignore files" authors = ["Sebastian Thiel "] edition = "2021" include = ["src/**/*", "LICENSE-*"] -rust-version = "1.70" +rust-version = "1.82" [lib] doctest = false diff --git a/gix-index/Cargo.toml b/gix-index/Cargo.toml index 0bd4a578f7e..0ca772a7a51 100644 --- a/gix-index/Cargo.toml +++ b/gix-index/Cargo.toml @@ -9,7 +9,7 @@ description = "A work-in-progress crate of the gitoxide project dedicated implem authors = ["Sebastian Thiel "] edition = "2021" include = ["src/**/*", "LICENSE-*", "README.md"] -rust-version = "1.70" +rust-version = "1.82" autotests = false diff --git a/gix-index/src/extension/end_of_index_entry/decode.rs b/gix-index/src/extension/end_of_index_entry/decode.rs index e284a8a99d0..a827388f191 100644 --- a/gix-index/src/extension/end_of_index_entry/decode.rs +++ b/gix-index/src/extension/end_of_index_entry/decode.rs @@ -48,7 +48,7 @@ pub fn decode(data: &[u8], object_hash: gix_hash::Kind) -> Result, return Ok(None); } // The last-to-this chunk ends where ours starts - if last_chunk.map_or(true, |s| !std::ptr::eq(s.as_ptr_range().end, &data[start_of_eoie])) { + if last_chunk.is_none_or(|s| !std::ptr::eq(s.as_ptr_range().end, &data[start_of_eoie])) { return Ok(None); } diff --git a/gix-index/src/extension/untracked_cache.rs b/gix-index/src/extension/untracked_cache.rs index 8f7e88124e5..5a875657ba8 100644 --- a/gix-index/src/extension/untracked_cache.rs +++ b/gix-index/src/extension/untracked_cache.rs @@ -40,7 +40,7 @@ pub const SIGNATURE: Signature = *b"UNTR"; // #[allow(unused)] /// Decode an untracked cache extension from `data`, assuming object hashes are of type `object_hash`. pub fn decode(data: &[u8], object_hash: gix_hash::Kind) -> Option { - if !data.last().is_some_and(|b| *b == 0) { + if data.last().is_none_or(|b| *b != 0) { return None; } let (identifier_len, data) = var_int(data)?; diff --git a/gix-index/src/write.rs b/gix-index/src/write.rs index e0edbb0eb89..1226c089d30 100644 --- a/gix-index/src/write.rs +++ b/gix-index/src/write.rs @@ -206,12 +206,7 @@ mod util { self.count = self .count .checked_add(u32::try_from(written).expect("we don't write 4GB buffers")) - .ok_or_else(|| { - std::io::Error::new( - std::io::ErrorKind::Other, - "Cannot write indices larger than 4 gigabytes", - ) - })?; + .ok_or_else(|| std::io::Error::other("Cannot write indices larger than 4 gigabytes"))?; Ok(written) } diff --git a/gix-index/tests/Cargo.toml b/gix-index/tests/Cargo.toml index 519ecd41df4..78049304bb5 100644 --- a/gix-index/tests/Cargo.toml +++ b/gix-index/tests/Cargo.toml @@ -9,7 +9,7 @@ license = "MIT OR Apache-2.0" description = "Integration tests for gix-index" authors = ["Sebastian Thiel "] edition = "2021" -rust-version = "1.70" +rust-version = "1.82" [[test]] name = "integrate" diff --git a/gix-index/tests/index/file/read.rs b/gix-index/tests/index/file/read.rs index df85fbff492..a66a052c4a5 100644 --- a/gix-index/tests/index/file/read.rs +++ b/gix-index/tests/index/file/read.rs @@ -160,8 +160,7 @@ fn v2_very_long_path() { assert_eq!(file.entries().len(), 9); assert_eq!( file.entries()[0].path(&file), - std::iter::repeat('a') - .take(4096) + std::iter::repeat_n('a', 4096) .chain(std::iter::once('q')) .collect::() ); diff --git a/gix-lfs/Cargo.toml b/gix-lfs/Cargo.toml index 5708dd95f51..e0c0f65ffdd 100644 --- a/gix-lfs/Cargo.toml +++ b/gix-lfs/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" description = "A crate of the gitoxide project dealing with handling git large file support" authors = ["Sebastian Thiel "] edition = "2021" -rust-version = "1.70" +rust-version = "1.82" [lib] doctest = false diff --git a/gix-lock/Cargo.toml b/gix-lock/Cargo.toml index 43450495bc1..8fbc547ec86 100644 --- a/gix-lock/Cargo.toml +++ b/gix-lock/Cargo.toml @@ -9,7 +9,7 @@ description = "A git-style lock-file implementation" authors = ["Sebastian Thiel "] edition = "2021" include = ["src/**/*", "LICENSE-*", "README.md"] -rust-version = "1.70" +rust-version = "1.82" [lib] doctest = false diff --git a/gix-lock/src/commit.rs b/gix-lock/src/commit.rs index 49b2595b24d..ddcb305dba4 100644 --- a/gix-lock/src/commit.rs +++ b/gix-lock/src/commit.rs @@ -39,10 +39,7 @@ impl Marker { pub fn commit(mut self) -> Result> { if !self.created_from_file { return Err(Error { - error: std::io::Error::new( - std::io::ErrorKind::Other, - "refusing to commit marker that was never opened", - ), + error: std::io::Error::other("refusing to commit marker that was never opened"), instance: self, }); } diff --git a/gix-macros/Cargo.toml b/gix-macros/Cargo.toml index 4522da72623..c8a02f26091 100644 --- a/gix-macros/Cargo.toml +++ b/gix-macros/Cargo.toml @@ -13,7 +13,7 @@ authors = [ repository = "https://github.com/GitoxideLabs/gitoxide" license = "MIT OR Apache-2.0" include = ["src/**/*", "LICENSE-*"] -rust-version = "1.70" +rust-version = "1.82" [lib] proc-macro = true diff --git a/gix-mailmap/Cargo.toml b/gix-mailmap/Cargo.toml index d3acaf84adf..90232cd1e7f 100644 --- a/gix-mailmap/Cargo.toml +++ b/gix-mailmap/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" description = "A crate of the gitoxide project for parsing mailmap files" authors = ["Sebastian Thiel "] edition = "2021" -rust-version = "1.70" +rust-version = "1.82" include = ["src/**/*", "LICENSE-*"] [lib] diff --git a/gix-merge/Cargo.toml b/gix-merge/Cargo.toml index 00baf9c2883..e6049dc0e6d 100644 --- a/gix-merge/Cargo.toml +++ b/gix-merge/Cargo.toml @@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0" description = "A crate of the gitoxide project implementing merge algorithms" authors = ["Sebastian Thiel "] edition = "2021" -rust-version = "1.70" +rust-version = "1.82" [lints] workspace = true diff --git a/gix-merge/src/blob/builtin_driver/text/utils.rs b/gix-merge/src/blob/builtin_driver/text/utils.rs index 0b1aa7e1dfa..a98580a435e 100644 --- a/gix-merge/src/blob/builtin_driver/text/utils.rs +++ b/gix-merge/src/blob/builtin_driver/text/utils.rs @@ -97,7 +97,7 @@ pub fn assure_ends_with_nl(out: &mut Vec, nl: &BStr) { pub fn write_conflict_marker(out: &mut Vec, marker: u8, label: Option<&BStr>, marker_size: u8, nl: &BStr) { assure_ends_with_nl(out, nl); - out.extend(std::iter::repeat(marker).take(marker_size as usize)); + out.extend(std::iter::repeat_n(marker, marker_size as usize)); if let Some(label) = label { out.push(b' '); out.extend_from_slice(label); diff --git a/gix-merge/src/tree/function.rs b/gix-merge/src/tree/function.rs index 9fadae7f4da..29f6fce5791 100644 --- a/gix-merge/src/tree/function.rs +++ b/gix-merge/src/tree/function.rs @@ -197,7 +197,7 @@ where .filter(|ours| { ours.change_idx() .zip(needs_tree_insertion.flatten()) - .map_or(true, |(ours_idx, ignore_idx)| ours_idx != ignore_idx) + .is_none_or(|(ours_idx, ignore_idx)| ours_idx != ignore_idx) && our_tree.is_not_same_change_in_possible_conflict(theirs, ours, our_changes) }) { None => { diff --git a/gix-merge/src/tree/utils.rs b/gix-merge/src/tree/utils.rs index 9b21c9b69d4..d38ce4e83bc 100644 --- a/gix-merge/src/tree/utils.rs +++ b/gix-merge/src/tree/utils.rs @@ -484,7 +484,7 @@ impl TreeNodes { ) -> bool { conflict .change_idx() - .map_or(true, |idx| our_changes[idx].inner != *theirs) + .is_none_or(|idx| our_changes[idx].inner != *theirs) } pub fn remove_existing_leaf(&mut self, location: &BStr) { diff --git a/gix-merge/tests/merge/tree/mod.rs b/gix-merge/tests/merge/tree/mod.rs index 0a328bc0f23..31612a4d78a 100644 --- a/gix-merge/tests/merge/tree/mod.rs +++ b/gix-merge/tests/merge/tree/mod.rs @@ -40,7 +40,7 @@ fn run_baseline() -> crate::Result { case_name, deviation, } in baseline::Expectations::new(&root, &cases) - .filter(|case| new_test.map_or(true, |prefix: &str| case.case_name.starts_with(prefix))) + .filter(|case| new_test.is_none_or(|prefix: &str| case.case_name.starts_with(prefix))) { actual_cases += 1; let mut graph = gix_revwalk::Graph::new(&odb, None); diff --git a/gix-negotiate/Cargo.toml b/gix-negotiate/Cargo.toml index 32c53679f5d..6ba7101fb02 100644 --- a/gix-negotiate/Cargo.toml +++ b/gix-negotiate/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" description = "A crate of the gitoxide project implementing negotiation algorithms" authors = ["Sebastian Thiel "] edition = "2021" -rust-version = "1.70" +rust-version = "1.82" include = ["src/**/*", "LICENSE-*"] [lib] diff --git a/gix-negotiate/src/consecutive.rs b/gix-negotiate/src/consecutive.rs index cc924f0a46d..adf157206f2 100644 --- a/gix-negotiate/src/consecutive.rs +++ b/gix-negotiate/src/consecutive.rs @@ -60,7 +60,7 @@ impl Algorithm { while let Some((id, generation)) = queue.pop_value() { if graph .get(&id) - .map_or(true, |commit| !commit.data.flags.contains(Flags::SEEN)) + .is_none_or(|commit| !commit.data.flags.contains(Flags::SEEN)) { self.add_to_queue(id, Flags::SEEN, graph)?; } else if matches!(ancestors, Ancestors::AllUnseen) || generation < 2 { @@ -92,7 +92,7 @@ impl Negotiator for Algorithm { fn known_common(&mut self, id: ObjectId, graph: &mut crate::Graph<'_, '_>) -> Result<(), Error> { if graph .get(&id) - .map_or(true, |commit| !commit.data.flags.contains(Flags::SEEN)) + .is_none_or(|commit| !commit.data.flags.contains(Flags::SEEN)) { self.add_to_queue(id, Flags::COMMON_REF | Flags::SEEN, graph)?; self.mark_common(id, Mark::AncestorsOnly, Ancestors::DirectUnseen, graph)?; @@ -126,7 +126,7 @@ impl Negotiator for Algorithm { for parent_id in commit.parents.clone() { if graph .get(&parent_id) - .map_or(true, |commit| !commit.data.flags.contains(Flags::SEEN)) + .is_none_or(|commit| !commit.data.flags.contains(Flags::SEEN)) { if let Err(err) = self.add_to_queue(parent_id, mark, graph) { return Some(Err(err)); diff --git a/gix-negotiate/src/skipping.rs b/gix-negotiate/src/skipping.rs index 9db90db6cfa..91e1c3dffb1 100644 --- a/gix-negotiate/src/skipping.rs +++ b/gix-negotiate/src/skipping.rs @@ -81,9 +81,8 @@ impl Algorithm { let mut was_seen = false; if let Some(parent) = graph .get(&parent_id) - .map(|parent| { + .inspect(|parent| { was_seen = parent.data.flags.contains(Flags::SEEN); - parent }) .filter(|_| was_seen) { diff --git a/gix-note/Cargo.toml b/gix-note/Cargo.toml index c19a809fb58..bc90073bad6 100644 --- a/gix-note/Cargo.toml +++ b/gix-note/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" description = "A crate of the gitoxide project dealing with git notes" authors = ["Sebastian Thiel "] edition = "2021" -rust-version = "1.70" +rust-version = "1.82" [lib] doctest = false diff --git a/gix-object/Cargo.toml b/gix-object/Cargo.toml index ed27051c345..6376c647867 100644 --- a/gix-object/Cargo.toml +++ b/gix-object/Cargo.toml @@ -9,7 +9,7 @@ repository = "https://github.com/GitoxideLabs/gitoxide" license = "MIT OR Apache-2.0" edition = "2021" include = ["src/**/*", "LICENSE-*"] -rust-version = "1.70" +rust-version = "1.82" [lib] doctest = false diff --git a/gix-object/src/encode.rs b/gix-object/src/encode.rs index e2ce0addf69..0a53502dda9 100644 --- a/gix-object/src/encode.rs +++ b/gix-object/src/encode.rs @@ -30,7 +30,7 @@ pub fn loose_header(kind: crate::Kind, size: u64) -> smallvec::SmallVec<[u8; 28] impl From for io::Error { fn from(other: Error) -> io::Error { - io::Error::new(io::ErrorKind::Other, other) + io::Error::other(other) } } diff --git a/gix-object/src/tag/write.rs b/gix-object/src/tag/write.rs index 7bde5a89688..48df16b8e5a 100644 --- a/gix-object/src/tag/write.rs +++ b/gix-object/src/tag/write.rs @@ -17,7 +17,7 @@ pub enum Error { impl From for io::Error { fn from(err: Error) -> Self { - io::Error::new(io::ErrorKind::Other, err) + io::Error::other(err) } } diff --git a/gix-object/src/tree/write.rs b/gix-object/src/tree/write.rs index 929620f0e04..ade6dc6e30e 100644 --- a/gix-object/src/tree/write.rs +++ b/gix-object/src/tree/write.rs @@ -18,7 +18,7 @@ pub enum Error { impl From for io::Error { fn from(err: Error) -> Self { - io::Error::new(io::ErrorKind::Other, err) + io::Error::other(err) } } diff --git a/gix-odb/Cargo.toml b/gix-odb/Cargo.toml index b797de78184..f0a0dda63e4 100644 --- a/gix-odb/Cargo.toml +++ b/gix-odb/Cargo.toml @@ -9,7 +9,7 @@ license = "MIT OR Apache-2.0" description = "Implements various git object databases" edition = "2021" include = ["src/**/*", "LICENSE-*"] -rust-version = "1.70" +rust-version = "1.82" autotests = false [lib] diff --git a/gix-odb/src/store_impls/dynamic/init.rs b/gix-odb/src/store_impls/dynamic/init.rs index 8f62ca34e58..a2858743ddf 100644 --- a/gix-odb/src/store_impls/dynamic/init.rs +++ b/gix-odb/src/store_impls/dynamic/init.rs @@ -88,19 +88,19 @@ impl Store { Ok, )?; if !objects_dir.is_dir() { - return Err(std::io::Error::new( - std::io::ErrorKind::Other, // TODO: use NotADirectory when stabilized - format!("'{}' wasn't a directory", objects_dir.display()), - )); + return Err(std::io::Error::other(format!( + "'{}' wasn't a directory", + objects_dir.display() + ))); } let slot_count = match slots { Slots::Given(n) => n as usize, Slots::AsNeededByDiskState { multiplier, minimum } => { - let mut db_paths = crate::alternate::resolve(objects_dir.clone(), ¤t_dir) - .map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err))?; + let mut db_paths = + crate::alternate::resolve(objects_dir.clone(), ¤t_dir).map_err(std::io::Error::other)?; db_paths.insert(0, objects_dir.clone()); let num_slots = Store::collect_indices_and_mtime_sorted_by_size(db_paths, None, None) - .map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err))? + .map_err(std::io::Error::other)? .len(); let candidate = ((num_slots as f32 * multiplier) as usize).max(minimum); @@ -114,10 +114,9 @@ impl Store { } }; if slot_count > crate::store::types::PackId::max_indices() { - return Err(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Cannot use more than 2^15-1 slots, got {slot_count}"), - )); + return Err(std::io::Error::other(format!( + "Cannot use more than 2^15-1 slots, got {slot_count}" + ))); } let mut replacements: Vec<_> = replacements.collect(); replacements.sort_by(|a, b| a.0.cmp(&b.0)); diff --git a/gix-odb/src/store_impls/dynamic/load_one.rs b/gix-odb/src/store_impls/dynamic/load_one.rs index 9961532c688..36e3ceab69e 100644 --- a/gix-odb/src/store_impls/dynamic/load_one.rs +++ b/gix-odb/src/store_impls/dynamic/load_one.rs @@ -32,7 +32,7 @@ impl super::Store { }) .map_err(|err| match err { gix_pack::data::header::decode::Error::Io { source, .. } => source, - other => std::io::Error::new(std::io::ErrorKind::Other, other), + other => std::io::Error::other(other), }) } diff --git a/gix-odb/src/store_impls/dynamic/types.rs b/gix-odb/src/store_impls/dynamic/types.rs index 7627001559b..bcec419713f 100644 --- a/gix-odb/src/store_impls/dynamic/types.rs +++ b/gix-odb/src/store_impls/dynamic/types.rs @@ -318,7 +318,7 @@ impl IndexAndPacks { .map(Arc::new) .map_err(|err| match err { gix_pack::index::init::Error::Io { source, .. } => source, - err => std::io::Error::new(std::io::ErrorKind::Other, err), + err => std::io::Error::other(err), }) }), IndexAndPacks::MultiIndex(bundle) => { @@ -327,7 +327,7 @@ impl IndexAndPacks { .map(Arc::new) .map_err(|err| match err { gix_pack::multi_index::init::Error::Io { source, .. } => source, - err => std::io::Error::new(std::io::ErrorKind::Other, err), + err => std::io::Error::other(err), }) })?; if let Some(multi_index) = bundle.multi_index.loaded() { diff --git a/gix-odb/tests/Cargo.toml b/gix-odb/tests/Cargo.toml index 770f751a728..35012fe059b 100644 --- a/gix-odb/tests/Cargo.toml +++ b/gix-odb/tests/Cargo.toml @@ -8,7 +8,7 @@ authors = ["Sebastian Thiel "] license = "MIT OR Apache-2.0" description = "Tests for gix-odb with feature-toggle support" edition = "2021" -rust-version = "1.70" +rust-version = "1.82" publish = false [features] diff --git a/gix-pack/Cargo.toml b/gix-pack/Cargo.toml index ad86e23c20b..251f490fc70 100644 --- a/gix-pack/Cargo.toml +++ b/gix-pack/Cargo.toml @@ -9,7 +9,7 @@ license = "MIT OR Apache-2.0" description = "Implements git packs and related data structures" edition = "2021" include = ["src/**/*", "LICENSE-*"] -rust-version = "1.70" +rust-version = "1.82" autotests = false [lib] diff --git a/gix-pack/src/bundle/write/mod.rs b/gix-pack/src/bundle/write/mod.rs index a50c3a83287..0129d890038 100644 --- a/gix-pack/src/bundle/write/mod.rs +++ b/gix-pack/src/bundle/write/mod.rs @@ -329,9 +329,8 @@ impl crate::Bundle { if !index_path.is_file() { index_file .persist(&index_path) - .map_err(|err| { + .inspect_err(|_err| { gix_features::trace::warn!("pack file at \"{}\" is retained despite failing to move the index file into place. You can use plumbing to make it usable.",data_path.display()); - err })?; } WriteOutcome { diff --git a/gix-pack/src/cache/delta/from_offsets.rs b/gix-pack/src/cache/delta/from_offsets.rs index c9c968d2287..ef6679ec1a9 100644 --- a/gix-pack/src/cache/delta/from_offsets.rs +++ b/gix-pack/src/cache/delta/from_offsets.rs @@ -60,9 +60,8 @@ impl Tree { let anticipated_num_objects = data_sorted_by_offsets .size_hint() .1 - .map(|num_objects| { + .inspect(|&num_objects| { progress.init(Some(num_objects), progress::count("objects")); - num_objects }) .unwrap_or_default(); let mut tree = Tree::with_capacity(anticipated_num_objects)?; diff --git a/gix-pack/src/data/entry/decode.rs b/gix-pack/src/data/entry/decode.rs index 14dfd43559e..84faed44fb9 100644 --- a/gix-pack/src/data/entry/decode.rs +++ b/gix-pack/src/data/entry/decode.rs @@ -82,12 +82,7 @@ impl data::Entry { TREE => Tree, COMMIT => Commit, TAG => Tag, - other => { - return Err(io::Error::new( - io::ErrorKind::Other, - format!("Object type {other} is unsupported"), - )) - } + other => return Err(io::Error::other(format!("Object type {other} is unsupported"))), }; Ok(data::Entry { header: object, diff --git a/gix-pack/tests/Cargo.toml b/gix-pack/tests/Cargo.toml index 5a8f4ec35d9..82725f7ae79 100644 --- a/gix-pack/tests/Cargo.toml +++ b/gix-pack/tests/Cargo.toml @@ -8,7 +8,7 @@ authors = ["Sebastian Thiel "] license = "MIT OR Apache-2.0" description = "Please use `gix-` instead ('git' -> 'gix')" edition = "2021" -rust-version = "1.70" +rust-version = "1.82" [features] gix-features-parallel = ["gix-features/parallel"] diff --git a/gix-packetline-blocking/Cargo.toml b/gix-packetline-blocking/Cargo.toml index e7a0b2df74f..3f386f663e2 100644 --- a/gix-packetline-blocking/Cargo.toml +++ b/gix-packetline-blocking/Cargo.toml @@ -9,7 +9,7 @@ description = "A duplicate of `gix-packetline` with the `blocking-io` feature pr authors = ["Sebastian Thiel "] edition = "2021" include = ["src/**/*", "LICENSE-*"] -rust-version = "1.70" +rust-version = "1.82" [lib] doctest = false diff --git a/gix-packetline-blocking/src/encode/async_io.rs b/gix-packetline-blocking/src/encode/async_io.rs index 6532b84c9fa..7e580e4d14f 100644 --- a/gix-packetline-blocking/src/encode/async_io.rs +++ b/gix-packetline-blocking/src/encode/async_io.rs @@ -50,10 +50,6 @@ impl<'a, W: AsyncWrite + Unpin> LineWriter<'a, W> { } } -fn into_io_err(err: Error) -> io::Error { - io::Error::new(io::ErrorKind::Other, err) -} - impl AsyncWrite for LineWriter<'_, W> { fn poll_write(self: Pin<&mut Self>, cx: &mut Context<'_>, data: &[u8]) -> Poll> { let mut this = self.project(); @@ -62,12 +58,14 @@ impl AsyncWrite for LineWriter<'_, W> { State::Idle => { let data_len = this.prefix.len() + data.len() + this.suffix.len(); if data_len > MAX_DATA_LEN { - return Poll::Ready(Err(into_io_err(Error::DataLengthLimitExceeded { + let err = Error::DataLengthLimitExceeded { length_in_bytes: data_len, - }))); + }; + return Poll::Ready(Err(io::Error::other(err))); } if data.is_empty() { - return Poll::Ready(Err(into_io_err(Error::DataIsEmpty))); + let err = Error::DataIsEmpty; + return Poll::Ready(Err(io::Error::other(err))); } let data_len = data_len + 4; let len_buf = u16_to_hex(data_len as u16); @@ -149,12 +147,14 @@ async fn prefixed_and_suffixed_data_to_write( ) -> io::Result { let data_len = prefix.len() + data.len() + suffix.len(); if data_len > MAX_DATA_LEN { - return Err(into_io_err(Error::DataLengthLimitExceeded { + let err = Error::DataLengthLimitExceeded { length_in_bytes: data_len, - })); + }; + return Err(io::Error::other(err)); } if data.is_empty() { - return Err(into_io_err(Error::DataIsEmpty)); + let err = Error::DataIsEmpty; + return Err(io::Error::other(err)); } let data_len = data_len + 4; diff --git a/gix-packetline-blocking/src/encode/blocking_io.rs b/gix-packetline-blocking/src/encode/blocking_io.rs index 56e47ef0579..598b46e2661 100644 --- a/gix-packetline-blocking/src/encode/blocking_io.rs +++ b/gix-packetline-blocking/src/encode/blocking_io.rs @@ -52,15 +52,12 @@ fn prefixed_and_suffixed_data_to_write( ) -> io::Result { let data_len = prefix.len() + data.len() + suffix.len(); if data_len > MAX_DATA_LEN { - return Err(io::Error::new( - io::ErrorKind::Other, - Error::DataLengthLimitExceeded { - length_in_bytes: data_len, - }, - )); + return Err(io::Error::other(Error::DataLengthLimitExceeded { + length_in_bytes: data_len, + })); } if data.is_empty() { - return Err(io::Error::new(io::ErrorKind::Other, Error::DataIsEmpty)); + return Err(io::Error::other(Error::DataIsEmpty)); } let data_len = data_len + 4; diff --git a/gix-packetline-blocking/src/read/async_io.rs b/gix-packetline-blocking/src/read/async_io.rs index a0d347d84c7..1b723ca13a5 100644 --- a/gix-packetline-blocking/src/read/async_io.rs +++ b/gix-packetline-blocking/src/read/async_io.rs @@ -81,10 +81,7 @@ where return ( true, None, - Some(Err(io::Error::new( - io::ErrorKind::Other, - crate::read::Error { message: err }, - ))), + Some(Err(io::Error::other(crate::read::Error { message: err }))), ); } } diff --git a/gix-packetline-blocking/src/read/blocking_io.rs b/gix-packetline-blocking/src/read/blocking_io.rs index ce2035a1a3e..c81e7ee11d0 100644 --- a/gix-packetline-blocking/src/read/blocking_io.rs +++ b/gix-packetline-blocking/src/read/blocking_io.rs @@ -75,10 +75,7 @@ where return ( true, None, - Some(Err(io::Error::new( - io::ErrorKind::Other, - crate::read::Error { message: err }, - ))), + Some(Err(io::Error::other(crate::read::Error { message: err }))), ); } } diff --git a/gix-packetline-blocking/src/read/sidebands/async_io.rs b/gix-packetline-blocking/src/read/sidebands/async_io.rs index c17a55d6c1f..2d86567a87b 100644 --- a/gix-packetline-blocking/src/read/sidebands/async_io.rs +++ b/gix-packetline-blocking/src/read/sidebands/async_io.rs @@ -222,8 +222,7 @@ where "we don't support partial buffers right now - read-line must be used consistently" ); let Self { buf, parent } = &mut *self; - let line = std::str::from_utf8(ready!(Pin::new(parent).poll_fill_buf(cx))?) - .map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err))?; + let line = std::str::from_utf8(ready!(Pin::new(parent).poll_fill_buf(cx))?).map_err(std::io::Error::other)?; buf.clear(); buf.push_str(line); let bytes = line.len(); @@ -275,15 +274,13 @@ where }; let line = match line { - Some(line) => line?.map_err(|err| io::Error::new(io::ErrorKind::Other, err))?, + Some(line) => line?.map_err(io::Error::other)?, None => break (0, 0), }; match this.handle_progress.as_mut() { Some(handle_progress) => { - let band = line - .decode_band() - .map_err(|err| io::Error::new(io::ErrorKind::Other, err))?; + let band = line.decode_band().map_err(io::Error::other)?; const ENCODED_BAND: usize = 1; match band { BandRef::Data(d) => { @@ -297,10 +294,7 @@ where match handle_progress(false, text) { ProgressAction::Continue => {} ProgressAction::Interrupt => { - return Poll::Ready(Err(io::Error::new( - std::io::ErrorKind::Other, - "interrupted by user", - ))) + return Poll::Ready(Err(io::Error::other("interrupted by user"))) } } } @@ -309,10 +303,7 @@ where match handle_progress(true, text) { ProgressAction::Continue => {} ProgressAction::Interrupt => { - return Poll::Ready(Err(io::Error::new( - io::ErrorKind::Other, - "interrupted by user", - ))) + return Poll::Ready(Err(io::Error::other("interrupted by user"))) } } } @@ -322,8 +313,7 @@ where break match line.as_slice() { Some(d) => (U16_HEX_BYTES, d.len()), None => { - return Poll::Ready(Err(io::Error::new( - io::ErrorKind::UnexpectedEof, + return Poll::Ready(Err(io::Error::other( "encountered non-data line in a data-line only context", ))) } diff --git a/gix-packetline-blocking/src/read/sidebands/blocking_io.rs b/gix-packetline-blocking/src/read/sidebands/blocking_io.rs index 9b09baed10d..9fb95a43c4b 100644 --- a/gix-packetline-blocking/src/read/sidebands/blocking_io.rs +++ b/gix-packetline-blocking/src/read/sidebands/blocking_io.rs @@ -121,7 +121,7 @@ where self.cap, 0, "we don't support partial buffers right now - read-line must be used consistently" ); - let line = std::str::from_utf8(self.fill_buf()?).map_err(|err| io::Error::new(io::ErrorKind::Other, err))?; + let line = std::str::from_utf8(self.fill_buf()?).map_err(io::Error::other)?; buf.push_str(line); let bytes = line.len(); self.cap = 0; @@ -138,14 +138,12 @@ where if self.pos >= self.cap { let (ofs, cap) = loop { let line = match self.parent.read_line() { - Some(line) => line?.map_err(|err| io::Error::new(io::ErrorKind::Other, err))?, + Some(line) => line?.map_err(io::Error::other)?, None => break (0, 0), }; match self.handle_progress.as_mut() { Some(handle_progress) => { - let band = line - .decode_band() - .map_err(|err| io::Error::new(io::ErrorKind::Other, err))?; + let band = line.decode_band().map_err(io::Error::other)?; const ENCODED_BAND: usize = 1; match band { BandRef::Data(d) => { @@ -159,10 +157,7 @@ where match handle_progress(false, text) { ProgressAction::Continue => {} ProgressAction::Interrupt => { - return Err(std::io::Error::new( - std::io::ErrorKind::Other, - "interrupted by user", - )) + return Err(std::io::Error::other("interrupted by user")) } } } @@ -171,10 +166,7 @@ where match handle_progress(true, text) { ProgressAction::Continue => {} ProgressAction::Interrupt => { - return Err(std::io::Error::new( - std::io::ErrorKind::Other, - "interrupted by user", - )) + return Err(std::io::Error::other("interrupted by user")) } } } diff --git a/gix-packetline-blocking/src/write/async_io.rs b/gix-packetline-blocking/src/write/async_io.rs index a5813e1ede8..0c5a7ae8143 100644 --- a/gix-packetline-blocking/src/write/async_io.rs +++ b/gix-packetline-blocking/src/write/async_io.rs @@ -65,8 +65,7 @@ impl AsyncWrite for Writer { match this.state { State::Idle => { if buf.is_empty() { - return Poll::Ready(Err(io::Error::new( - io::ErrorKind::Other, + return Poll::Ready(Err(io::Error::other( "empty packet lines are not permitted as '0004' is invalid", ))); } diff --git a/gix-packetline-blocking/src/write/blocking_io.rs b/gix-packetline-blocking/src/write/blocking_io.rs index 6a302ea6de7..99201a13f42 100644 --- a/gix-packetline-blocking/src/write/blocking_io.rs +++ b/gix-packetline-blocking/src/write/blocking_io.rs @@ -46,8 +46,7 @@ impl Writer { impl io::Write for Writer { fn write(&mut self, mut buf: &[u8]) -> io::Result { if buf.is_empty() { - return Err(io::Error::new( - io::ErrorKind::Other, + return Err(io::Error::other( "empty packet lines are not permitted as '0004' is invalid", )); } diff --git a/gix-packetline/Cargo.toml b/gix-packetline/Cargo.toml index b428a978505..618b15a66f5 100644 --- a/gix-packetline/Cargo.toml +++ b/gix-packetline/Cargo.toml @@ -9,7 +9,7 @@ description = "A crate of the gitoxide project implementing the pkt-line seriali authors = ["Sebastian Thiel "] edition = "2021" include = ["src/**/*", "LICENSE-*"] -rust-version = "1.70" +rust-version = "1.82" [lib] doctest = false diff --git a/gix-packetline/src/encode/async_io.rs b/gix-packetline/src/encode/async_io.rs index 9add6f27a41..c2b10bc4775 100644 --- a/gix-packetline/src/encode/async_io.rs +++ b/gix-packetline/src/encode/async_io.rs @@ -48,10 +48,6 @@ impl<'a, W: AsyncWrite + Unpin> LineWriter<'a, W> { } } -fn into_io_err(err: Error) -> io::Error { - io::Error::new(io::ErrorKind::Other, err) -} - impl AsyncWrite for LineWriter<'_, W> { fn poll_write(self: Pin<&mut Self>, cx: &mut Context<'_>, data: &[u8]) -> Poll> { let mut this = self.project(); @@ -60,12 +56,14 @@ impl AsyncWrite for LineWriter<'_, W> { State::Idle => { let data_len = this.prefix.len() + data.len() + this.suffix.len(); if data_len > MAX_DATA_LEN { - return Poll::Ready(Err(into_io_err(Error::DataLengthLimitExceeded { + let err = Error::DataLengthLimitExceeded { length_in_bytes: data_len, - }))); + }; + return Poll::Ready(Err(io::Error::other(err))); } if data.is_empty() { - return Poll::Ready(Err(into_io_err(Error::DataIsEmpty))); + let err = Error::DataIsEmpty; + return Poll::Ready(Err(io::Error::other(err))); } let data_len = data_len + 4; let len_buf = u16_to_hex(data_len as u16); @@ -147,12 +145,14 @@ async fn prefixed_and_suffixed_data_to_write( ) -> io::Result { let data_len = prefix.len() + data.len() + suffix.len(); if data_len > MAX_DATA_LEN { - return Err(into_io_err(Error::DataLengthLimitExceeded { + let err = Error::DataLengthLimitExceeded { length_in_bytes: data_len, - })); + }; + return Err(io::Error::other(err)); } if data.is_empty() { - return Err(into_io_err(Error::DataIsEmpty)); + let err = Error::DataIsEmpty; + return Err(io::Error::other(err)); } let data_len = data_len + 4; diff --git a/gix-packetline/src/encode/blocking_io.rs b/gix-packetline/src/encode/blocking_io.rs index 1368d96f05d..c8cbe592117 100644 --- a/gix-packetline/src/encode/blocking_io.rs +++ b/gix-packetline/src/encode/blocking_io.rs @@ -50,15 +50,12 @@ fn prefixed_and_suffixed_data_to_write( ) -> io::Result { let data_len = prefix.len() + data.len() + suffix.len(); if data_len > MAX_DATA_LEN { - return Err(io::Error::new( - io::ErrorKind::Other, - Error::DataLengthLimitExceeded { - length_in_bytes: data_len, - }, - )); + return Err(io::Error::other(Error::DataLengthLimitExceeded { + length_in_bytes: data_len, + })); } if data.is_empty() { - return Err(io::Error::new(io::ErrorKind::Other, Error::DataIsEmpty)); + return Err(io::Error::other(Error::DataIsEmpty)); } let data_len = data_len + 4; diff --git a/gix-packetline/src/read/async_io.rs b/gix-packetline/src/read/async_io.rs index daa6bf4f871..bfe780738c1 100644 --- a/gix-packetline/src/read/async_io.rs +++ b/gix-packetline/src/read/async_io.rs @@ -79,10 +79,7 @@ where return ( true, None, - Some(Err(io::Error::new( - io::ErrorKind::Other, - crate::read::Error { message: err }, - ))), + Some(Err(io::Error::other(crate::read::Error { message: err }))), ); } } diff --git a/gix-packetline/src/read/blocking_io.rs b/gix-packetline/src/read/blocking_io.rs index 3e74e47f1be..351f2cb46ea 100644 --- a/gix-packetline/src/read/blocking_io.rs +++ b/gix-packetline/src/read/blocking_io.rs @@ -73,10 +73,7 @@ where return ( true, None, - Some(Err(io::Error::new( - io::ErrorKind::Other, - crate::read::Error { message: err }, - ))), + Some(Err(io::Error::other(crate::read::Error { message: err }))), ); } } diff --git a/gix-packetline/src/read/sidebands/async_io.rs b/gix-packetline/src/read/sidebands/async_io.rs index ebb364880bb..f43d647321e 100644 --- a/gix-packetline/src/read/sidebands/async_io.rs +++ b/gix-packetline/src/read/sidebands/async_io.rs @@ -220,8 +220,7 @@ where "we don't support partial buffers right now - read-line must be used consistently" ); let Self { buf, parent } = &mut *self; - let line = std::str::from_utf8(ready!(Pin::new(parent).poll_fill_buf(cx))?) - .map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err))?; + let line = std::str::from_utf8(ready!(Pin::new(parent).poll_fill_buf(cx))?).map_err(std::io::Error::other)?; buf.clear(); buf.push_str(line); let bytes = line.len(); @@ -273,15 +272,13 @@ where }; let line = match line { - Some(line) => line?.map_err(|err| io::Error::new(io::ErrorKind::Other, err))?, + Some(line) => line?.map_err(io::Error::other)?, None => break (0, 0), }; match this.handle_progress.as_mut() { Some(handle_progress) => { - let band = line - .decode_band() - .map_err(|err| io::Error::new(io::ErrorKind::Other, err))?; + let band = line.decode_band().map_err(io::Error::other)?; const ENCODED_BAND: usize = 1; match band { BandRef::Data(d) => { @@ -295,10 +292,7 @@ where match handle_progress(false, text) { ProgressAction::Continue => {} ProgressAction::Interrupt => { - return Poll::Ready(Err(io::Error::new( - std::io::ErrorKind::Other, - "interrupted by user", - ))) + return Poll::Ready(Err(io::Error::other("interrupted by user"))) } } } @@ -307,10 +301,7 @@ where match handle_progress(true, text) { ProgressAction::Continue => {} ProgressAction::Interrupt => { - return Poll::Ready(Err(io::Error::new( - io::ErrorKind::Other, - "interrupted by user", - ))) + return Poll::Ready(Err(io::Error::other("interrupted by user"))) } } } @@ -320,8 +311,7 @@ where break match line.as_slice() { Some(d) => (U16_HEX_BYTES, d.len()), None => { - return Poll::Ready(Err(io::Error::new( - io::ErrorKind::UnexpectedEof, + return Poll::Ready(Err(io::Error::other( "encountered non-data line in a data-line only context", ))) } diff --git a/gix-packetline/src/read/sidebands/blocking_io.rs b/gix-packetline/src/read/sidebands/blocking_io.rs index 0e6cf00a793..740344411f7 100644 --- a/gix-packetline/src/read/sidebands/blocking_io.rs +++ b/gix-packetline/src/read/sidebands/blocking_io.rs @@ -119,7 +119,7 @@ where self.cap, 0, "we don't support partial buffers right now - read-line must be used consistently" ); - let line = std::str::from_utf8(self.fill_buf()?).map_err(|err| io::Error::new(io::ErrorKind::Other, err))?; + let line = std::str::from_utf8(self.fill_buf()?).map_err(io::Error::other)?; buf.push_str(line); let bytes = line.len(); self.cap = 0; @@ -136,14 +136,12 @@ where if self.pos >= self.cap { let (ofs, cap) = loop { let line = match self.parent.read_line() { - Some(line) => line?.map_err(|err| io::Error::new(io::ErrorKind::Other, err))?, + Some(line) => line?.map_err(io::Error::other)?, None => break (0, 0), }; match self.handle_progress.as_mut() { Some(handle_progress) => { - let band = line - .decode_band() - .map_err(|err| io::Error::new(io::ErrorKind::Other, err))?; + let band = line.decode_band().map_err(io::Error::other)?; const ENCODED_BAND: usize = 1; match band { BandRef::Data(d) => { @@ -157,10 +155,7 @@ where match handle_progress(false, text) { ProgressAction::Continue => {} ProgressAction::Interrupt => { - return Err(std::io::Error::new( - std::io::ErrorKind::Other, - "interrupted by user", - )) + return Err(std::io::Error::other("interrupted by user")) } } } @@ -169,10 +164,7 @@ where match handle_progress(true, text) { ProgressAction::Continue => {} ProgressAction::Interrupt => { - return Err(std::io::Error::new( - std::io::ErrorKind::Other, - "interrupted by user", - )) + return Err(std::io::Error::other("interrupted by user")) } } } diff --git a/gix-packetline/src/write/async_io.rs b/gix-packetline/src/write/async_io.rs index 4775fc06df4..7a41211658e 100644 --- a/gix-packetline/src/write/async_io.rs +++ b/gix-packetline/src/write/async_io.rs @@ -63,8 +63,7 @@ impl AsyncWrite for Writer { match this.state { State::Idle => { if buf.is_empty() { - return Poll::Ready(Err(io::Error::new( - io::ErrorKind::Other, + return Poll::Ready(Err(io::Error::other( "empty packet lines are not permitted as '0004' is invalid", ))); } diff --git a/gix-packetline/src/write/blocking_io.rs b/gix-packetline/src/write/blocking_io.rs index d537d7ddf94..96139feb2a6 100644 --- a/gix-packetline/src/write/blocking_io.rs +++ b/gix-packetline/src/write/blocking_io.rs @@ -44,8 +44,7 @@ impl Writer { impl io::Write for Writer { fn write(&mut self, mut buf: &[u8]) -> io::Result { if buf.is_empty() { - return Err(io::Error::new( - io::ErrorKind::Other, + return Err(io::Error::other( "empty packet lines are not permitted as '0004' is invalid", )); } diff --git a/gix-path/Cargo.toml b/gix-path/Cargo.toml index d3591b888c8..55859684b5f 100644 --- a/gix-path/Cargo.toml +++ b/gix-path/Cargo.toml @@ -9,7 +9,7 @@ description = "A crate of the gitoxide project dealing paths and their conversio authors = ["Sebastian Thiel "] edition = "2021" include = ["src/**/*", "LICENSE-*"] -rust-version = "1.70" +rust-version = "1.82" [lib] doctest = true @@ -19,7 +19,6 @@ gix-trace = { version = "^0.1.13", path = "../gix-trace" } gix-validate = { version = "^0.10.0", path = "../gix-validate" } bstr = { version = "1.12.0", default-features = false, features = ["std"] } thiserror = "2.0.17" -once_cell = "1.21.3" [target.'cfg(not(target_family = "wasm"))'.dependencies] home = "0.5.5" diff --git a/gix-path/src/env/auxiliary.rs b/gix-path/src/env/auxiliary.rs index 9582897abb9..a890b43fe50 100644 --- a/gix-path/src/env/auxiliary.rs +++ b/gix-path/src/env/auxiliary.rs @@ -3,7 +3,7 @@ use std::{ path::{Path, PathBuf}, }; -use once_cell::sync::Lazy; +use std::sync::LazyLock; /// `usr`-like directory component names that MSYS2 may provide, other than for `/usr` itself. /// @@ -54,7 +54,7 @@ const MSYS_USR_VARIANTS: &[&str] = &["mingw64", "mingw32", "clangarm64", "clang6 /// But it is possible that some marginal uses of `installation_config_prefix()`, if they do not /// really relate to configuration, could be replaced with `git_for_windows_root()` in the future. fn git_for_windows_root() -> Option<&'static Path> { - static GIT_ROOT: Lazy> = Lazy::new(|| { + static GIT_ROOT: LazyLock> = LazyLock::new(|| { super::core_dir() .filter(|core| { // Only use this if the directory structure resembles a Git installation. This diff --git a/gix-path/src/env/git/mod.rs b/gix-path/src/env/git/mod.rs index 03daba3c2af..63231430f94 100644 --- a/gix-path/src/env/git/mod.rs +++ b/gix-path/src/env/git/mod.rs @@ -5,14 +5,14 @@ use std::{ }; use bstr::{BStr, BString, ByteSlice}; -use once_cell::sync::Lazy; +use std::sync::LazyLock; /// Other places to find Git in. #[cfg(windows)] -pub(super) static ALTERNATIVE_LOCATIONS: Lazy> = - Lazy::new(|| locations_under_program_files(|key| std::env::var_os(key))); +pub(super) static ALTERNATIVE_LOCATIONS: LazyLock> = + LazyLock::new(|| locations_under_program_files(|key| std::env::var_os(key))); #[cfg(not(windows))] -pub(super) static ALTERNATIVE_LOCATIONS: Lazy> = Lazy::new(Vec::new); +pub(super) static ALTERNATIVE_LOCATIONS: LazyLock> = LazyLock::new(Vec::new); #[cfg(windows)] fn locations_under_program_files(var_os_func: F) -> Vec @@ -101,7 +101,7 @@ pub(super) const EXE_NAME: &str = "git"; /// Invoke the git executable to obtain the origin configuration, which is cached and returned. /// /// The git executable is the one found in `PATH` or an alternative location. -pub(super) static GIT_HIGHEST_SCOPE_CONFIG_PATH: Lazy> = Lazy::new(exe_info); +pub(super) static GIT_HIGHEST_SCOPE_CONFIG_PATH: LazyLock> = LazyLock::new(exe_info); // There are a number of ways to refer to the null device on Windows, but they are not all equally // well supported. Git for Windows rejects `\\.\NUL` and `\\.\nul`. On Windows 11 ARM64 (and maybe @@ -191,7 +191,7 @@ fn first_file_from_config_with_origin(source: &BStr) -> Option<&BStr> { /// errors during execution. pub(super) fn install_config_path() -> Option<&'static BStr> { let _span = gix_trace::detail!("gix_path::git::install_config_path()"); - static PATH: Lazy> = Lazy::new(|| { + static PATH: LazyLock> = LazyLock::new(|| { // Shortcut: Specifically in Git for Windows 'Git Bash' shells, this variable is set. It // may let us deduce the installation directory, so we can save the `git` invocation. #[cfg(windows)] diff --git a/gix-path/src/env/mod.rs b/gix-path/src/env/mod.rs index 1dea11726ec..4f2eb7e8d5e 100644 --- a/gix-path/src/env/mod.rs +++ b/gix-path/src/env/mod.rs @@ -4,7 +4,7 @@ use std::{ }; use bstr::{BString, ByteSlice}; -use once_cell::sync::Lazy; +use std::sync::LazyLock; use crate::env::git::EXE_NAME; @@ -40,7 +40,7 @@ pub fn installation_config_prefix() -> Option<&'static Path> { /// Note that the returned path might not be a path on disk, if it is a fallback path or if the /// file was moved or deleted since the first time this function is called. pub fn shell() -> &'static OsStr { - static PATH: Lazy = Lazy::new(|| { + static PATH: LazyLock = LazyLock::new(|| { if cfg!(windows) { auxiliary::find_git_associated_windows_executable_with_fallback("sh") } else { @@ -61,7 +61,7 @@ pub fn exe_invocation() -> &'static Path { /// The path to the Git executable as located in the `PATH` or in other locations that it's /// known to be installed to. It's `None` if environment variables couldn't be read or if /// no executable could be found. - static EXECUTABLE_PATH: Lazy> = Lazy::new(|| { + static EXECUTABLE_PATH: LazyLock> = LazyLock::new(|| { std::env::split_paths(&std::env::var_os("PATH")?) .chain(git::ALTERNATIVE_LOCATIONS.iter().map(Into::into)) .find_map(|prefix| { @@ -109,7 +109,7 @@ pub fn xdg_config(file: &str, env_var: &mut dyn FnMut(&str) -> Option) }) } -static GIT_CORE_DIR: Lazy> = Lazy::new(|| { +static GIT_CORE_DIR: LazyLock> = LazyLock::new(|| { let mut cmd = std::process::Command::new(exe_invocation()); #[cfg(windows)] @@ -182,7 +182,7 @@ where /// path, or if the git binary wasn't built with a well-known directory structure or environment. pub fn system_prefix() -> Option<&'static Path> { if cfg!(windows) { - static PREFIX: Lazy> = Lazy::new(|| { + static PREFIX: LazyLock> = LazyLock::new(|| { system_prefix_from_exepath_var(|key| std::env::var_os(key)) .or_else(|| system_prefix_from_core_dir(core_dir)) }); diff --git a/gix-pathspec/Cargo.toml b/gix-pathspec/Cargo.toml index 83017c52739..417bb10a356 100644 --- a/gix-pathspec/Cargo.toml +++ b/gix-pathspec/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" description = "A crate of the gitoxide project dealing magical pathspecs" authors = ["Sebastian Thiel "] edition = "2021" -rust-version = "1.70" +rust-version = "1.82" include = ["src/**/*", "LICENSE-*", "README.md"] [lib] @@ -26,5 +26,4 @@ thiserror = "2.0.17" [dev-dependencies] gix-testtools = { path = "../tests/tools" } -once_cell = "1.21.3" serial_test = "3.1.1" diff --git a/gix-pathspec/src/search/matching.rs b/gix-pathspec/src/search/matching.rs index 075055d899a..3e632bb453e 100644 --- a/gix-pathspec/src/search/matching.rs +++ b/gix-pathspec/src/search/matching.rs @@ -47,7 +47,7 @@ impl Search { let basename_not_important = None; if relative_path .get(..self.common_prefix_len) - .map_or(true, |rela_path_prefix| rela_path_prefix != self.common_prefix()) + .is_none_or(|rela_path_prefix| rela_path_prefix != self.common_prefix()) { return None; } @@ -142,9 +142,10 @@ impl Search { return true; } let common_prefix_len = self.common_prefix_len.min(relative_path.len()); - if relative_path.get(..common_prefix_len).map_or(true, |rela_path_prefix| { - rela_path_prefix != self.common_prefix()[..common_prefix_len] - }) { + if relative_path + .get(..common_prefix_len) + .is_none_or(|rela_path_prefix| rela_path_prefix != self.common_prefix()[..common_prefix_len]) + { return false; } for mapping in &self.patterns { @@ -203,9 +204,10 @@ impl Search { return true; } let common_prefix_len = self.common_prefix_len.min(relative_path.len()); - if relative_path.get(..common_prefix_len).map_or(true, |rela_path_prefix| { - rela_path_prefix != self.common_prefix()[..common_prefix_len] - }) { + if relative_path + .get(..common_prefix_len) + .is_none_or(|rela_path_prefix| rela_path_prefix != self.common_prefix()[..common_prefix_len]) + { return false; } for mapping in &self.patterns { diff --git a/gix-pathspec/tests/parse/mod.rs b/gix-pathspec/tests/parse/mod.rs index 6ee363d6b5b..3c54fa1e72b 100644 --- a/gix-pathspec/tests/parse/mod.rs +++ b/gix-pathspec/tests/parse/mod.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use bstr::{BStr, BString, ByteSlice}; use gix_attributes::State; use gix_pathspec::{MagicSignature, Pattern, SearchMode}; -use once_cell::sync::Lazy; +use std::sync::LazyLock; #[test] fn baseline() { @@ -54,7 +54,7 @@ impl From for NormalizedPattern { } } -static BASELINE: Lazy> = Lazy::new(|| { +static BASELINE: LazyLock> = LazyLock::new(|| { let base = gix_testtools::scripted_fixture_read_only("parse_baseline.sh").unwrap(); (|| -> crate::Result<_> { diff --git a/gix-prompt/Cargo.toml b/gix-prompt/Cargo.toml index 4d908686843..503b74d6d8f 100644 --- a/gix-prompt/Cargo.toml +++ b/gix-prompt/Cargo.toml @@ -9,7 +9,7 @@ description = "A crate of the gitoxide project for handling prompts in the termi authors = ["Sebastian Thiel "] edition = "2021" include = ["src/**/*", "LICENSE-*", "README.md"] -rust-version = "1.70" +rust-version = "1.82" [lib] doctest = false diff --git a/gix-protocol/Cargo.toml b/gix-protocol/Cargo.toml index 0312d6ad478..ab61f2c3a94 100644 --- a/gix-protocol/Cargo.toml +++ b/gix-protocol/Cargo.toml @@ -9,7 +9,7 @@ description = "A crate of the gitoxide project for implementing git protocols" authors = ["Sebastian Thiel "] edition = "2021" include = ["src/**/*", "LICENSE-*", "!**/tests/**/*"] -rust-version = "1.70" +rust-version = "1.82" [lib] doctest = false diff --git a/gix-protocol/src/fetch/negotiate.rs b/gix-protocol/src/fetch/negotiate.rs index 767b76e4d63..1cd8ba9c666 100644 --- a/gix-protocol/src/fetch/negotiate.rs +++ b/gix-protocol/src/fetch/negotiate.rs @@ -156,8 +156,8 @@ where // and keep the oldest one. let mut cutoff_date = None::; let mut num_mappings_with_change = 0; - let mut remote_ref_target_known: Vec = std::iter::repeat(false).take(ref_map.mappings.len()).collect(); - let mut remote_ref_included: Vec = std::iter::repeat(false).take(ref_map.mappings.len()).collect(); + let mut remote_ref_target_known: Vec = std::iter::repeat_n(false, ref_map.mappings.len()).collect(); + let mut remote_ref_included: Vec = std::iter::repeat_n(false, ref_map.mappings.len()).collect(); for (mapping_idx, mapping) in ref_map.mappings.iter().enumerate() { let want_id = mapping.remote.as_id(); @@ -171,7 +171,7 @@ where if !mapping_is_ignored(mapping) { remote_ref_included[mapping_idx] = true; // Like git, we don't let known unchanged mappings participate in the tree traversal - if want_id.zip(have_id).map_or(true, |(want, have)| want != have) { + if want_id.zip(have_id).is_none_or(|(want, have)| want != have) { num_mappings_with_change += 1; } } diff --git a/gix-protocol/src/fetch/response/mod.rs b/gix-protocol/src/fetch/response/mod.rs index 5a85fcb7c35..d5c2c0965ea 100644 --- a/gix-protocol/src/fetch/response/mod.rs +++ b/gix-protocol/src/fetch/response/mod.rs @@ -27,7 +27,7 @@ impl From for Error { match err.into_inner() { Some(err) => match err.downcast::() { Ok(err) => Error::UploadPack(*err), - Err(err) => Error::Io(std::io::Error::new(std::io::ErrorKind::Other, err)), + Err(err) => Error::Io(std::io::Error::other(err)), }, None => Error::Io(std::io::ErrorKind::Other.into()), } diff --git a/gix-protocol/tests/protocol/fetch/v2.rs b/gix-protocol/tests/protocol/fetch/v2.rs index 9e0bfecc2fe..58ba0fe0d97 100644 --- a/gix-protocol/tests/protocol/fetch/v2.rs +++ b/gix-protocol/tests/protocol/fetch/v2.rs @@ -12,7 +12,7 @@ use crate::fetch::{ async fn clone_abort_prep() -> crate::Result { let out = Vec::new(); let mut dlg = CloneDelegate { - abort_with: Some(std::io::Error::new(std::io::ErrorKind::Other, "hello world")), + abort_with: Some(std::io::Error::other("hello world")), ..Default::default() }; let mut transport = transport( @@ -116,7 +116,7 @@ async fn ls_remote() -> crate::Result { async fn ls_remote_abort_in_prep_ls_refs() -> crate::Result { let out = Vec::new(); let mut delegate = LsRemoteDelegate { - abort_with: Some(std::io::Error::new(std::io::ErrorKind::Other, "hello world")), + abort_with: Some(std::io::Error::other("hello world")), ..Default::default() }; let mut transport = transport( diff --git a/gix-quote/Cargo.toml b/gix-quote/Cargo.toml index 8dd20028cec..59e0972229a 100644 --- a/gix-quote/Cargo.toml +++ b/gix-quote/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" description = "A crate of the gitoxide project dealing with various quotations used by git" authors = ["Sebastian Thiel "] edition = "2021" -rust-version = "1.70" +rust-version = "1.82" include = ["src/**/*", "LICENSE-*"] [lib] diff --git a/gix-rebase/Cargo.toml b/gix-rebase/Cargo.toml index 14b5e1a8556..1fbdfe26dff 100644 --- a/gix-rebase/Cargo.toml +++ b/gix-rebase/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" description = "A crate of the gitoxide project dealing rebases" authors = ["Sebastian Thiel "] edition = "2021" -rust-version = "1.70" +rust-version = "1.82" [lib] doctest = false diff --git a/gix-ref/Cargo.toml b/gix-ref/Cargo.toml index 5c5f5c41fb5..050ef55ddd1 100644 --- a/gix-ref/Cargo.toml +++ b/gix-ref/Cargo.toml @@ -9,7 +9,7 @@ description = "A crate to handle git references" authors = ["Sebastian Thiel "] edition = "2021" include = ["src/**/*", "LICENSE-*"] -rust-version = "1.74" +rust-version = "1.82" autotests = false [lib] diff --git a/gix-ref/src/store/packed/find.rs b/gix-ref/src/store/packed/find.rs index a172ab61032..28c41a7eb8d 100644 --- a/gix-ref/src/store/packed/find.rs +++ b/gix-ref/src/store/packed/find.rs @@ -91,14 +91,13 @@ impl packed::Buffer { }; let mut encountered_parse_failure = false; a.binary_search_by_key(&full_name.as_ref(), |b: &u8| { - let ofs = b as *const u8 as usize - a.as_ptr() as usize; + let ofs = std::ptr::from_ref::(b) as usize - a.as_ptr() as usize; let mut line = &a[search_start_of_record(ofs)..]; packed::decode::reference::<()> .parse_next(&mut line) .map(|r| r.name.as_bstr().as_bytes()) - .map_err(|err| { + .inspect_err(|_err| { encountered_parse_failure = true; - err }) .unwrap_or(&[]) }) diff --git a/gix-ref/src/store/packed/transaction.rs b/gix-ref/src/store/packed/transaction.rs index 847466b0c46..e9990ce90f1 100644 --- a/gix-ref/src/store/packed/transaction.rs +++ b/gix-ref/src/store/packed/transaction.rs @@ -87,7 +87,7 @@ impl packed::Transaction { }) .filter(|edit| { if let Change::Delete { .. } = edit.change { - buffer.as_ref().map_or(true, |b| b.find(edit.name.as_ref()).is_ok()) + buffer.as_ref().is_none_or(|b| b.find(edit.name.as_ref()).is_ok()) } else { true } diff --git a/gix-ref/tests/Cargo.toml b/gix-ref/tests/Cargo.toml index 9c0d06e2eaa..2d77c58d5fe 100644 --- a/gix-ref/tests/Cargo.toml +++ b/gix-ref/tests/Cargo.toml @@ -9,7 +9,7 @@ license = "MIT OR Apache-2.0" description = "Test the gix-ref crate with feature toggles" authors = ["Sebastian Thiel "] edition = "2021" -rust-version = "1.74" +rust-version = "1.82" [features] gix-features-parallel = ["gix-features/parallel"] # test sorted parallel loose file traversal diff --git a/gix-refspec/Cargo.toml b/gix-refspec/Cargo.toml index 1e4b363b479..5cd527fcb95 100644 --- a/gix-refspec/Cargo.toml +++ b/gix-refspec/Cargo.toml @@ -9,7 +9,7 @@ description = "A crate of the gitoxide project for parsing and representing refs authors = ["Sebastian Thiel "] edition = "2021" include = ["src/**/*", "LICENSE-*", "README.md"] -rust-version = "1.70" +rust-version = "1.82" [lib] doctest = false diff --git a/gix-refspec/tests/refspec/matching.rs b/gix-refspec/tests/refspec/matching.rs index 5f5383c5855..bbe305c09d9 100644 --- a/gix-refspec/tests/refspec/matching.rs +++ b/gix-refspec/tests/refspec/matching.rs @@ -1,6 +1,6 @@ -use gix_testtools::once_cell::sync::Lazy; +use std::sync::LazyLock; -static BASELINE: Lazy = Lazy::new(|| baseline::parse().unwrap()); +static BASELINE: LazyLock = LazyLock::new(|| baseline::parse().unwrap()); pub mod baseline { use std::{borrow::Borrow, collections::HashMap}; @@ -12,7 +12,7 @@ pub mod baseline { parse::Operation, MatchGroup, }; - use gix_testtools::once_cell::sync::Lazy; + use std::sync::LazyLock; use crate::matching::BASELINE; @@ -34,7 +34,7 @@ pub mod baseline { } } - static INPUT: Lazy> = Lazy::new(|| parse_input().unwrap()); + static INPUT: LazyLock> = LazyLock::new(|| parse_input().unwrap()); pub type Baseline = HashMap, Result, BString>>; diff --git a/gix-revision/Cargo.toml b/gix-revision/Cargo.toml index 5ef4fd06052..11353a0ef5d 100644 --- a/gix-revision/Cargo.toml +++ b/gix-revision/Cargo.toml @@ -9,7 +9,7 @@ description = "A crate of the gitoxide project dealing with finding names for re authors = ["Sebastian Thiel "] edition = "2021" include = ["src/**/*", "LICENSE-*", "README.md"] -rust-version = "1.70" +rust-version = "1.82" [lib] doctest = false diff --git a/gix-revwalk/Cargo.toml b/gix-revwalk/Cargo.toml index 9bc473712bd..2b9bac427f6 100644 --- a/gix-revwalk/Cargo.toml +++ b/gix-revwalk/Cargo.toml @@ -9,7 +9,7 @@ description = "A crate providing utilities for walking the revision graph" authors = ["Sebastian Thiel "] edition = "2021" include = ["src/**/*", "LICENSE-*"] -rust-version = "1.70" +rust-version = "1.82" [lib] doctest = false diff --git a/gix-revwalk/src/graph/mod.rs b/gix-revwalk/src/graph/mod.rs index 8f064e0c2a9..a896034c467 100644 --- a/gix-revwalk/src/graph/mod.rs +++ b/gix-revwalk/src/graph/mod.rs @@ -327,18 +327,15 @@ impl<'cache, T> Graph<'_, 'cache, T> { update_data: impl FnOnce(&mut T), ) -> Result>, get_or_insert_default::Error> { let res = try_lookup(&id, &*self.find, self.cache, &mut self.buf)?; - Ok(res.map(|commit| { - match self.map.entry(id) { - gix_hashtable::hash_map::Entry::Vacant(entry) => { - let mut data = default(); - update_data(&mut data); - entry.insert(data); - } - gix_hashtable::hash_map::Entry::Occupied(mut entry) => { - update_data(entry.get_mut()); - } + Ok(res.inspect(|_commit| match self.map.entry(id) { + gix_hashtable::hash_map::Entry::Vacant(entry) => { + let mut data = default(); + update_data(&mut data); + entry.insert(data); + } + gix_hashtable::hash_map::Entry::Occupied(mut entry) => { + update_data(entry.get_mut()); } - commit })) } diff --git a/gix-sec/Cargo.toml b/gix-sec/Cargo.toml index 2870270b110..e43022667ba 100644 --- a/gix-sec/Cargo.toml +++ b/gix-sec/Cargo.toml @@ -9,7 +9,7 @@ description = "A crate of the gitoxide project providing a shared trust model" authors = ["Sebastian Thiel "] edition = "2021" include = ["src/**/*", "LICENSE-*"] -rust-version = "1.70" +rust-version = "1.82" [lib] doctest = false diff --git a/gix-sequencer/Cargo.toml b/gix-sequencer/Cargo.toml index aaf9515dfa9..060a2a243fa 100644 --- a/gix-sequencer/Cargo.toml +++ b/gix-sequencer/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" description = "A crate of the gitoxide project handling sequences of human-aided operations" authors = ["Sebastian Thiel "] edition = "2021" -rust-version = "1.70" +rust-version = "1.82" [lib] doctest = false diff --git a/gix-shallow/Cargo.toml b/gix-shallow/Cargo.toml index 9209db86c2f..39b2876eb62 100644 --- a/gix-shallow/Cargo.toml +++ b/gix-shallow/Cargo.toml @@ -9,7 +9,7 @@ license = "MIT OR Apache-2.0" description = "Handle files specifying the shallow boundary" edition = "2021" include = ["src/**/*", "LICENSE-*"] -rust-version = "1.70" +rust-version = "1.82" [lib] doctest = false diff --git a/gix-status/Cargo.toml b/gix-status/Cargo.toml index c9b27ce522e..1c72d5d743b 100644 --- a/gix-status/Cargo.toml +++ b/gix-status/Cargo.toml @@ -9,7 +9,7 @@ description = "A crate of the gitoxide project dealing with 'git status'-like fu authors = ["Sebastian Thiel ", "Pascal Kuthe "] edition = "2021" include = ["src/**/*", "LICENSE-*"] -rust-version = "1.74" +rust-version = "1.82" autotests = false [lib] diff --git a/gix-status/src/index_as_worktree/function.rs b/gix-status/src/index_as_worktree/function.rs index 6000dd12d2f..da6bfc80144 100644 --- a/gix-status/src/index_as_worktree/function.rs +++ b/gix-status/src/index_as_worktree/function.rs @@ -280,7 +280,7 @@ impl<'index> State<'_, 'index> { .is_ok_and(|platform| platform.matching_attributes(out)) }, ) - .map_or(true, |m| m.is_excluded()); + .is_none_or(|m| m.is_excluded()); if is_excluded { self.skipped_by_pathspec.fetch_add(1, Ordering::Relaxed); diff --git a/gix-status/src/index_as_worktree/traits.rs b/gix-status/src/index_as_worktree/traits.rs index 854cedf31f1..1d5f2d68945 100644 --- a/gix-status/src/index_as_worktree/traits.rs +++ b/gix-status/src/index_as_worktree/traits.rs @@ -70,11 +70,10 @@ pub mod read_data { /// If `None`, read from this instance like a stream. /// Note that this method should only be called once to assure proper accounting of the amount of bytes read. pub fn as_bytes(&self) -> Option<&'a [u8]> { - self.inner.as_bytes().map(|v| { + self.inner.as_bytes().inspect(|v| { if let Some(bytes) = self.bytes { bytes.fetch_add(v.len() as u64, Ordering::Relaxed); } - v }) } diff --git a/gix-status/tests/Cargo.toml b/gix-status/tests/Cargo.toml index c7e06202f6c..7a0e8906f3e 100644 --- a/gix-status/tests/Cargo.toml +++ b/gix-status/tests/Cargo.toml @@ -9,7 +9,7 @@ description = "A crate to drive gix-status tests with different features" authors = ["Sebastian Thiel ", "Pascal Kuthe "] edition = "2021" publish = false -rust-version = "1.70" +rust-version = "1.82" [[test]] name = "status" diff --git a/gix-submodule/Cargo.toml b/gix-submodule/Cargo.toml index 8b4ffd4ddcc..b54b1eed9e4 100644 --- a/gix-submodule/Cargo.toml +++ b/gix-submodule/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" description = "A crate of the gitoxide project dealing git submodules" authors = ["Sebastian Thiel "] edition = "2021" -rust-version = "1.70" +rust-version = "1.82" include = ["src/**/*", "LICENSE-*"] [lib] diff --git a/gix-tempfile/Cargo.toml b/gix-tempfile/Cargo.toml index 3b8d80fcbc9..3b14d47d46a 100644 --- a/gix-tempfile/Cargo.toml +++ b/gix-tempfile/Cargo.toml @@ -9,7 +9,7 @@ description = "A tempfile implementation with a global registry to assure cleanu authors = ["Sebastian Thiel "] edition = "2021" include = ["src/**/*", "LICENSE-*", "README.md"] -rust-version = "1.70" +rust-version = "1.82" [[example]] name = "delete-tempfiles-on-sigterm" @@ -34,7 +34,6 @@ test = true gix-fs = { version = "^0.16.0", path = "../gix-fs" } parking_lot = "0.12.4" dashmap = { version = "6.0.1", optional = true } -once_cell = { version = "1.21.3", default-features = false, features = ["race", "std"] } tempfile = "3.23.0" signal-hook = { version = "0.3.18", default-features = false, optional = true } diff --git a/gix-tempfile/src/lib.rs b/gix-tempfile/src/lib.rs index ee87b5825f4..d1b757479ff 100644 --- a/gix-tempfile/src/lib.rs +++ b/gix-tempfile/src/lib.rs @@ -41,7 +41,7 @@ use std::{ sync::atomic::AtomicUsize, }; -use once_cell::sync::Lazy; +use std::sync::LazyLock; #[cfg(feature = "hp-hashmap")] type HashMap = dashmap::DashMap; @@ -111,7 +111,7 @@ use crate::handle::{Closed, Writable}; pub mod registry; static NEXT_MAP_INDEX: AtomicUsize = AtomicUsize::new(0); -static REGISTRY: Lazy>> = Lazy::new(|| { +static REGISTRY: LazyLock>> = LazyLock::new(|| { #[cfg(feature = "signals")] if signal::handler::MODE.load(std::sync::atomic::Ordering::SeqCst) != signal::handler::Mode::None as usize { for sig in signal_hook::consts::TERM_SIGNALS { diff --git a/gix-tempfile/src/signal.rs b/gix-tempfile/src/signal.rs index d7c0f83684b..d55844973aa 100644 --- a/gix-tempfile/src/signal.rs +++ b/gix-tempfile/src/signal.rs @@ -1,4 +1,4 @@ -use once_cell::sync::Lazy; +use std::sync::LazyLock; use crate::REGISTRY; @@ -12,7 +12,7 @@ use crate::REGISTRY; /// from a signal handler under the application's control. pub fn setup(mode: handler::Mode) { handler::MODE.store(mode as usize, std::sync::atomic::Ordering::SeqCst); - Lazy::force(®ISTRY); + LazyLock::force(®ISTRY); } /// diff --git a/gix-tix/Cargo.toml b/gix-tix/Cargo.toml index 6bd8b114141..ee794b3d0cc 100644 --- a/gix-tix/Cargo.toml +++ b/gix-tix/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" description = "A tool like `tig`, but minimal, fast and efficient" authors = ["Sebastian Thiel "] edition = "2021" -rust-version = "1.70" +rust-version = "1.82" [lib] doctest = false diff --git a/gix-trace/Cargo.toml b/gix-trace/Cargo.toml index e956b5ec20b..035210666af 100644 --- a/gix-trace/Cargo.toml +++ b/gix-trace/Cargo.toml @@ -8,7 +8,7 @@ version = "0.1.13" authors = ["Sebastian Thiel "] license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.70" +rust-version = "1.82" include = ["src/**/*", "LICENSE-*"] [lib] diff --git a/gix-transport/Cargo.toml b/gix-transport/Cargo.toml index 3b0e8024ed4..63d5bf96446 100644 --- a/gix-transport/Cargo.toml +++ b/gix-transport/Cargo.toml @@ -9,7 +9,7 @@ description = "A crate of the gitoxide project dedicated to implementing the git authors = ["Sebastian Thiel "] edition = "2021" include = ["src/**/*", "LICENSE-*"] -rust-version = "1.70" +rust-version = "1.82" [lib] doctest = false diff --git a/gix-transport/src/client/blocking_io/http/mod.rs b/gix-transport/src/client/blocking_io/http/mod.rs index 6605b7bcab0..bfbcb9bf943 100644 --- a/gix-transport/src/client/blocking_io/http/mod.rs +++ b/gix-transport/src/client/blocking_io/http/mod.rs @@ -483,8 +483,7 @@ struct HeadersThenBody { impl HeadersThenBody { fn handle_headers(&mut self) -> std::io::Result<()> { if let Some(headers) = self.headers.take() { - >::check_content_type(self.service, "result", headers) - .map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err))?; + >::check_content_type(self.service, "result", headers).map_err(std::io::Error::other)?; } Ok(()) } diff --git a/gix-traverse/Cargo.toml b/gix-traverse/Cargo.toml index d8c1a14e8ce..4a6eb9ed443 100644 --- a/gix-traverse/Cargo.toml +++ b/gix-traverse/Cargo.toml @@ -9,7 +9,7 @@ description = "A crate of the gitoxide project" authors = ["Sebastian Thiel "] edition = "2021" include = ["src/**/*", "LICENSE-*"] -rust-version = "1.70" +rust-version = "1.82" autotests = false [lib] diff --git a/gix-traverse/tests/Cargo.toml b/gix-traverse/tests/Cargo.toml index 91283c2d98a..8c2b8f69cd6 100644 --- a/gix-traverse/tests/Cargo.toml +++ b/gix-traverse/tests/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" description = "Integration tests for the gix-traverse crate" authors = ["Sebastian Thiel "] edition = "2021" -rust-version = "1.70" +rust-version = "1.82" [[test]] name = "traverse" diff --git a/gix-tui/Cargo.toml b/gix-tui/Cargo.toml index b0bcabbe694..3dd04d07a15 100644 --- a/gix-tui/Cargo.toml +++ b/gix-tui/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" description = "A crate of the gitoxide project dedicated to a terminal user interface to interact with git repositories" authors = ["Sebastian Thiel "] edition = "2021" -rust-version = "1.70" +rust-version = "1.82" [[bin]] name = "gixi" diff --git a/gix-url/Cargo.toml b/gix-url/Cargo.toml index 328d9aaff22..160b6e0aca7 100644 --- a/gix-url/Cargo.toml +++ b/gix-url/Cargo.toml @@ -9,7 +9,7 @@ description = "A crate of the gitoxide project implementing parsing and serializ authors = ["Sebastian Thiel "] edition = "2021" include = ["src/**/*", "LICENSE-*", "tests/baseline/**/*"] -rust-version = "1.74" +rust-version = "1.82" [lib] doctest = false diff --git a/gix-url/tests/url/baseline.rs b/gix-url/tests/url/baseline.rs index 60e6c09b386..912e4e103bd 100644 --- a/gix-url/tests/url/baseline.rs +++ b/gix-url/tests/url/baseline.rs @@ -1,7 +1,7 @@ use std::any::Any; use bstr::ByteSlice; -use gix_testtools::once_cell::sync::Lazy; +use std::sync::LazyLock; /// To see all current failures run the following command or execute cargo-nextest directly with /// the below shown arguments. @@ -13,7 +13,7 @@ use gix_testtools::once_cell::sync::Lazy; fn run() { // ensure the baseline is evaluated before we disable the panic hook, otherwise we swallow // errors inside the baseline generation - Lazy::force(&baseline::URLS); + LazyLock::force(&baseline::URLS); let panic_hook = std::panic::take_hook(); std::panic::set_hook(Box::new(|_| {})); @@ -167,7 +167,7 @@ fn assert_urls_equal(expected: &baseline::GitDiagUrl<'_>, actual: &gix_url::Url) #[allow(clippy::module_inception)] mod baseline { use bstr::{BStr, BString, ByteSlice}; - use gix_testtools::once_cell::sync::Lazy; + use std::sync::LazyLock; pub enum Kind { Unix, @@ -198,14 +198,14 @@ mod baseline { } } - static BASELINE: Lazy = Lazy::new(|| { + static BASELINE: LazyLock = LazyLock::new(|| { let base = gix_testtools::scripted_fixture_read_only("make_baseline.sh").unwrap(); std::fs::read(base.join(format!("git-baseline.{}", Kind::new().extension()))) .expect("fixture file exists") .into() }); - pub static URLS: Lazy)>> = Lazy::new(|| { + pub static URLS: LazyLock)>> = LazyLock::new(|| { let mut out = Vec::new(); let blocks = BASELINE diff --git a/gix-utils/Cargo.toml b/gix-utils/Cargo.toml index 7a4411f2b55..1dc51542619 100644 --- a/gix-utils/Cargo.toml +++ b/gix-utils/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" description = "A crate with `gitoxide` utilities that don't need feature toggles" authors = ["Sebastian Thiel "] edition = "2021" -rust-version = "1.70" +rust-version = "1.82" include = ["src/**/*", "LICENSE-*"] [lib] diff --git a/gix-validate/Cargo.toml b/gix-validate/Cargo.toml index 87460dadd5f..4a5dd1c345c 100644 --- a/gix-validate/Cargo.toml +++ b/gix-validate/Cargo.toml @@ -9,7 +9,7 @@ description = "Validation functions for various kinds of names in git" authors = ["Sebastian Thiel "] edition = "2021" include = ["src/**/*", "LICENSE-*"] -rust-version = "1.70" +rust-version = "1.82" [lib] doctest = false diff --git a/gix-validate/src/path.rs b/gix-validate/src/path.rs index e924b5b452e..394569415db 100644 --- a/gix-validate/src/path.rs +++ b/gix-validate/src/path.rs @@ -300,7 +300,7 @@ fn is_dot_ntfs(input: &BStr, search_case_insensitive: &str, ntfs_shortname_prefi || b & 0x80 == 0x80 || ntfs_shortname_prefix .get(pos) - .map_or(true, |ob| !b.eq_ignore_ascii_case(ob)) + .is_none_or(|ob| !b.eq_ignore_ascii_case(ob)) { return false; } diff --git a/gix-worktree-state/Cargo.toml b/gix-worktree-state/Cargo.toml index a4029620e6a..65599a759cb 100644 --- a/gix-worktree-state/Cargo.toml +++ b/gix-worktree-state/Cargo.toml @@ -9,7 +9,7 @@ description = "A crate of the gitoxide project implementing setting the worktree authors = ["Sebastian Thiel "] edition = "2021" include = ["src/**/*", "LICENSE-*"] -rust-version = "1.70" +rust-version = "1.82" autotests = false [lib] diff --git a/gix-worktree-state/tests/Cargo.toml b/gix-worktree-state/tests/Cargo.toml index 7f41c26467b..b9790e00142 100644 --- a/gix-worktree-state/tests/Cargo.toml +++ b/gix-worktree-state/tests/Cargo.toml @@ -9,7 +9,7 @@ description = "A crate for running tests with feature toggles on gix-worktree-st authors = ["Sebastian Thiel "] edition = "2021" publish = false -rust-version = "1.70" +rust-version = "1.82" [[test]] name = "worktree" @@ -30,6 +30,5 @@ gix-features = { path = "../../gix-features" } gix-testtools = { path = "../../tests/tools" } gix-odb = { path = "../../gix-odb" } symlink = "0.1.0" -once_cell = "1.21.3" walkdir = "2.3.2" diff --git a/gix-worktree-state/tests/state/checkout.rs b/gix-worktree-state/tests/state/checkout.rs index 764b52020d3..f30f8ac03d0 100644 --- a/gix-worktree-state/tests/state/checkout.rs +++ b/gix-worktree-state/tests/state/checkout.rs @@ -11,11 +11,11 @@ use gix_features::progress; use gix_object::{bstr::ByteSlice, Data}; use gix_testtools::tempfile::TempDir; use gix_worktree_state::checkout::Collision; -use once_cell::sync::Lazy; +use std::sync::LazyLock; use crate::fixture_path; -static DRIVER: Lazy = Lazy::new(|| { +static DRIVER: LazyLock = LazyLock::new(|| { let mut cargo = std::process::Command::new(env!("CARGO")); let res = cargo .args(["build", "-p=gix-filter", "--example", "arrow"]) @@ -686,7 +686,7 @@ fn probe_gitoxide_dir() -> crate::Result { } fn opts_from_probe() -> gix_worktree_state::checkout::Options { - static CAPABILITIES: Lazy = Lazy::new(|| probe_gitoxide_dir().unwrap()); + static CAPABILITIES: LazyLock = LazyLock::new(|| probe_gitoxide_dir().unwrap()); gix_worktree_state::checkout::Options { fs: *CAPABILITIES, diff --git a/gix-worktree-stream/Cargo.toml b/gix-worktree-stream/Cargo.toml index d65b3349722..291ea2708cd 100644 --- a/gix-worktree-stream/Cargo.toml +++ b/gix-worktree-stream/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" description = "generate a byte-stream from a git-tree" authors = ["Sebastian Thiel "] edition = "2021" -rust-version = "1.70" +rust-version = "1.82" include = ["src/**/*", "LICENSE-*"] [lib] diff --git a/gix-worktree-stream/src/entry.rs b/gix-worktree-stream/src/entry.rs index c6c8aeb4029..f5804bd7f53 100644 --- a/gix-worktree-stream/src/entry.rs +++ b/gix-worktree-stream/src/entry.rs @@ -141,7 +141,7 @@ impl std::io::Read for Entry<'_> { fn read(&mut self, buf: &mut [u8]) -> std::io::Result { let buf_len = buf.len(); if let Some(err) = self.parent.err.lock().take() { - return Err(std::io::Error::new(ErrorKind::Other, err)); + return Err(std::io::Error::other(err)); } let bytes_read = match self.remaining.as_mut() { None => { diff --git a/gix-worktree-stream/src/from_tree/mod.rs b/gix-worktree-stream/src/from_tree/mod.rs index a5017853766..d27cf86b746 100644 --- a/gix-worktree-stream/src/from_tree/mod.rs +++ b/gix-worktree-stream/src/from_tree/mod.rs @@ -63,10 +63,7 @@ where *slot = Some(err); } else { drop(slot); - write - .channel - .send(Err(std::io::Error::new(std::io::ErrorKind::Other, err))) - .ok(); + write.channel.send(Err(std::io::Error::other(err))).ok(); } } } diff --git a/gix-worktree-stream/src/lib.rs b/gix-worktree-stream/src/lib.rs index 8169f888d46..743df783e9d 100644 --- a/gix-worktree-stream/src/lib.rs +++ b/gix-worktree-stream/src/lib.rs @@ -98,7 +98,7 @@ impl Stream { extra_entries: None, path_buf: Some(Vec::with_capacity(1024).into()), err: Default::default(), - buf: std::iter::repeat(0).take(u16::MAX as usize).collect(), + buf: std::iter::repeat_n(0, u16::MAX as usize).collect(), pos: 0, filled: 0, } @@ -126,9 +126,7 @@ impl Stream { /// Note that the created entries will always have a null SHA1, and that we access this path /// to determine its type, and will access it again when it is requested. pub fn add_entry_from_path(&mut self, root: &Path, path: &Path) -> std::io::Result<&mut Self> { - let rela_path = path - .strip_prefix(root) - .map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err))?; + let rela_path = path.strip_prefix(root).map_err(std::io::Error::other)?; let meta = path.symlink_metadata()?; let relative_path = gix_path::to_unix_separators_on_windows(gix_path::into_bstr(rela_path)).into_owned(); let id = gix_hash::ObjectId::null(gix_hash::Kind::Sha1); @@ -185,7 +183,7 @@ impl Stream { extra_entries: Some(tx_entries), path_buf: Some(Vec::with_capacity(1024).into()), err: Default::default(), - buf: std::iter::repeat(0).take(u16::MAX as usize).collect(), + buf: std::iter::repeat_n(0, u16::MAX as usize).collect(), pos: 0, filled: 0, }, diff --git a/gix-worktree-stream/tests/stream.rs b/gix-worktree-stream/tests/stream.rs index 15858750aed..5f21584e248 100644 --- a/gix-worktree-stream/tests/stream.rs +++ b/gix-worktree-stream/tests/stream.rs @@ -6,7 +6,7 @@ fn hex_to_id(hex: &str) -> gix_hash::ObjectId { mod from_tree { use std::{ convert::Infallible, - io::{Error, ErrorKind, Read, Write}, + io::{Error, Read, Write}, path::PathBuf, sync::Arc, }; @@ -14,8 +14,8 @@ mod from_tree { use gix_attributes::glob::pattern::Case; use gix_hash::oid; use gix_object::{bstr::ByteSlice, tree::EntryKind, Data}; - use gix_testtools::once_cell::sync::Lazy; use gix_worktree::stack::state::attributes::Source; + use std::sync::LazyLock; use crate::hex_to_id; @@ -28,7 +28,7 @@ mod from_tree { _id: &oid, _buffer: &'a mut Vec, ) -> Result>, gix_object::find::Error> { - Err(Box::new(Error::new(ErrorKind::Other, "object retrieval failed"))) + Err(Box::new(Error::other("object retrieval failed"))) } } @@ -48,7 +48,7 @@ mod from_tree { fn can_receive_err_if_attribute_not_found() -> gix_testtools::Result { let (_dir, head_tree, odb, _cache) = basic()?; let mut stream = gix_worktree_stream::from_tree(head_tree, odb, mutating_pipeline(false), |_, _, _| { - Err(Error::new(ErrorKind::Other, "attribute retrieval failed")) + Err(Error::other("attribute retrieval failed")) }); let err = stream.next_entry().unwrap_err(); assert_eq!( @@ -280,7 +280,7 @@ mod from_tree { } } - static DRIVER: Lazy = Lazy::new(|| { + static DRIVER: LazyLock = LazyLock::new(|| { let mut cargo = std::process::Command::new(env!("CARGO")); let res = cargo .args(["build", "-p=gix-filter", "--example", "arrow"]) diff --git a/gix-worktree/Cargo.toml b/gix-worktree/Cargo.toml index 552d21124c4..e4e8654339c 100644 --- a/gix-worktree/Cargo.toml +++ b/gix-worktree/Cargo.toml @@ -9,7 +9,7 @@ description = "A crate of the gitoxide project for shared worktree related types authors = ["Sebastian Thiel "] edition = "2021" include = ["src/**/*", "LICENSE-*"] -rust-version = "1.74" +rust-version = "1.82" autotests = false [lib] diff --git a/gix-worktree/tests/Cargo.toml b/gix-worktree/tests/Cargo.toml index 2028cc98d8c..fb8bd2a2920 100644 --- a/gix-worktree/tests/Cargo.toml +++ b/gix-worktree/tests/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" description = "A crate for testing the gix-worktree crate with feature toggles" authors = ["Sebastian Thiel "] edition = "2021" -rust-version = "1.70" +rust-version = "1.82" publish = false [[test]] diff --git a/gix-worktree/tests/worktree/stack/ignore.rs b/gix-worktree/tests/worktree/stack/ignore.rs index 06d73402318..3d4b57ac238 100644 --- a/gix-worktree/tests/worktree/stack/ignore.rs +++ b/gix-worktree/tests/worktree/stack/ignore.rs @@ -61,7 +61,7 @@ fn exclude_by_dir_is_handled_just_like_git() { _id: &gix_hash::oid, _buffer: &'a mut Vec, ) -> Result>, gix_object::find::Error> { - Err(std::io::Error::new(std::io::ErrorKind::Other, "unreachable").into()) + Err(std::io::Error::other("unreachable").into()) } } for (relative_entry, source_and_line) in expectations { diff --git a/gix/Cargo.toml b/gix/Cargo.toml index 61a82ce4b30..015fe03dcb2 100644 --- a/gix/Cargo.toml +++ b/gix/Cargo.toml @@ -11,7 +11,7 @@ edition = "2021" include = ["src/**/*", "LICENSE-*"] # This MSRV is dictated by `firefox` to support the `helix` editor, but is now probably # effectively controlled by `jiff`, which also aligns with `regex`. -rust-version = "1.75" +rust-version = "1.82" [lib] doctest = false @@ -372,7 +372,6 @@ gix-transport = { version = "^0.48.0", path = "../gix-transport", optional = tru # Just to get the progress-tree feature prodash = { version = "30.0.1", optional = true, features = ["progress-tree"] } -once_cell = "1.21.3" signal-hook = { version = "0.3.18", default-features = false, optional = true } thiserror = "2.0.17" serde = { version = "1.0.114", optional = true, default-features = false, features = [ diff --git a/gix/src/config/snapshot/credential_helpers.rs b/gix/src/config/snapshot/credential_helpers.rs index cea7042f639..0899682c5e9 100644 --- a/gix/src/config/snapshot/credential_helpers.rs +++ b/gix/src/config/snapshot/credential_helpers.rs @@ -124,7 +124,7 @@ pub(super) mod function { }; let path = (!(is_http && pattern.path_is_root())).then_some(&pattern.path); - if !path.map_or(true, |path| path == &url.path) { + if path.is_some_and(|path| path != &url.path) { return None; } if pattern.user().is_some() && pattern.user() != url.user() { diff --git a/gix/src/interrupt.rs b/gix/src/interrupt.rs index 057d40a593b..223eed0add9 100644 --- a/gix/src/interrupt.rs +++ b/gix/src/interrupt.rs @@ -13,10 +13,10 @@ mod init { }; static DEREGISTER_COUNT: AtomicUsize = AtomicUsize::new(0); - static REGISTERED_HOOKS: once_cell::sync::Lazy>> = - once_cell::sync::Lazy::new(Default::default); - static DEFAULT_BEHAVIOUR_HOOKS: once_cell::sync::Lazy>> = - once_cell::sync::Lazy::new(Default::default); + static REGISTERED_HOOKS: std::sync::LazyLock>> = + std::sync::LazyLock::new(Default::default); + static DEFAULT_BEHAVIOUR_HOOKS: std::sync::LazyLock>> = + std::sync::LazyLock::new(Default::default); /// A type to help deregistering hooks registered with [`init_handler`](super::init_handler()); #[derive(Default)] diff --git a/gix/src/remote/connection/fetch/update_refs/mod.rs b/gix/src/remote/connection/fetch/update_refs/mod.rs index 4d3fd7c2906..e33cfe2151a 100644 --- a/gix/src/remote/connection/fetch/update_refs/mod.rs +++ b/gix/src/remote/connection/fetch/update_refs/mod.rs @@ -97,7 +97,7 @@ pub(crate) fn update( ) { // `None` only if unborn. let remote_id = remote.as_id(); - if matches!(dry_run, fetch::DryRun::No) && !remote_id.map_or(true, |id| repo.objects.exists(id)) { + if matches!(dry_run, fetch::DryRun::No) && !remote_id.is_none_or(|id| repo.objects.exists(id)) { if let Some(remote_id) = remote_id.filter(|id| !repo.objects.exists(id)) { let update = if is_implicit_tag { Mode::ImplicitTagNotSentByRemote.into() diff --git a/gix/src/remote/url/scheme_permission.rs b/gix/src/remote/url/scheme_permission.rs index 936c2ddd0a7..a3550e38925 100644 --- a/gix/src/remote/url/scheme_permission.rs +++ b/gix/src/remote/url/scheme_permission.rs @@ -92,7 +92,7 @@ impl SchemePermission { let user_allowed = saw_user.then(|| { config .string_filter(gitoxide::Allow::PROTOCOL_FROM_USER, &mut filter) - .map_or(true, |val| val.as_ref() == "1") + .is_none_or(|val| val.as_ref() == "1") }); Ok(SchemePermission { allow, diff --git a/gix/tests/gix/repository/config/config_snapshot/credential_helpers.rs b/gix/tests/gix/repository/config/config_snapshot/credential_helpers.rs index c7c307e0bbd..414d563b909 100644 --- a/gix/tests/gix/repository/config/config_snapshot/credential_helpers.rs +++ b/gix/tests/gix/repository/config/config_snapshot/credential_helpers.rs @@ -6,7 +6,7 @@ mod baseline { use std::collections::HashMap; use gix_object::bstr::BString; - use gix_testtools::once_cell::sync::Lazy; + use std::sync::LazyLock; use crate::remote; @@ -16,7 +16,7 @@ mod baseline { pub helpers: Vec, } - static BASELINE: Lazy> = Lazy::new(|| { + static BASELINE: LazyLock> = LazyLock::new(|| { let base = remote::repo_path("credential-helpers"); (|| -> crate::Result<_> { diff --git a/gix/tests/gix/revision/spec/from_bytes/util.rs b/gix/tests/gix/revision/spec/from_bytes/util.rs index 76dfaee7b98..934df1f20f4 100644 --- a/gix/tests/gix/revision/spec/from_bytes/util.rs +++ b/gix/tests/gix/revision/spec/from_bytes/util.rs @@ -4,10 +4,10 @@ use std::{collections::HashMap, path::PathBuf, str::FromStr}; use gix_object::{bstr, bstr::BStr}; use gix_ref::bstr::{BString, ByteSlice}; use gix_revision::spec::Kind; -use gix_testtools::once_cell::sync::Lazy; +use std::sync::LazyLock; const FIXTURE_NAME: &str = "make_rev_spec_parse_repos.sh"; -static BASELINE: Lazy>>> = Lazy::new(|| { +static BASELINE: LazyLock>>> = LazyLock::new(|| { fn kind_of(spec: &BStr) -> gix_revision::spec::Kind { if spec.starts_with(b"^") { gix_revision::spec::Kind::IncludeReachable diff --git a/src/shared.rs b/src/shared.rs index 9dbbfc77790..b38f9248aa4 100644 --- a/src/shared.rs +++ b/src/shared.rs @@ -327,7 +327,7 @@ mod clap { #[derive(Clone)] pub struct AsPathSpec; - static PATHSPEC_DEFAULTS: once_cell::sync::Lazy = once_cell::sync::Lazy::new(|| { + static PATHSPEC_DEFAULTS: std::sync::LazyLock = std::sync::LazyLock::new(|| { gix::pathspec::Defaults::from_environment(&mut |n| std::env::var_os(n)).unwrap_or_default() }); diff --git a/tests/it/Cargo.toml b/tests/it/Cargo.toml index 75a4d4934e8..3cde63c17cd 100644 --- a/tests/it/Cargo.toml +++ b/tests/it/Cargo.toml @@ -8,7 +8,7 @@ authors = ["Sebastian Thiel "] edition = "2021" license = "MIT OR Apache-2.0" publish = false -rust-version = "1.74.0" +rust-version = "1.82" [[bin]] name = "it" @@ -18,5 +18,4 @@ path = "src/main.rs" anyhow = "1.0.100" clap = { version = "4.5.48", features = ["derive"] } gix = { version = "^0.73.0", path = "../../gix", default-features = false, features = ["attributes", "blame", "blob-diff", "revision"] } -once_cell = "1.21.3" regex = { version = "1.11.3", default-features = false, features = ["std"] } diff --git a/tests/it/src/commands/check_mode.rs b/tests/it/src/commands/check_mode.rs index 3a3e4afee1a..cfd0002b7fb 100644 --- a/tests/it/src/commands/check_mode.rs +++ b/tests/it/src/commands/check_mode.rs @@ -7,8 +7,8 @@ pub(super) mod function { use anyhow::{bail, Context}; use gix::bstr::ByteSlice; - use once_cell::sync::Lazy; use regex::bytes::Regex; + use std::sync::LazyLock; pub fn check_mode() -> anyhow::Result<()> { let root = find_root()?; @@ -69,7 +69,7 @@ pub(super) mod function { /// On mismatch, report it and return `Some(true)`. fn check_for_mismatch(root: &OsStr, record: &[u8]) -> anyhow::Result { - static RECORD_REGEX: Lazy = Lazy::new(|| { + static RECORD_REGEX: LazyLock = LazyLock::new(|| { let pattern = r"(?-u)\A([0-7]+) ([[:xdigit:]]+) [[:digit:]]+\t(.+)\z"; Regex::new(pattern).expect("regex should be valid") }); diff --git a/tests/tools/Cargo.toml b/tests/tools/Cargo.toml index 190ba05c9af..75695e5310c 100644 --- a/tests/tools/Cargo.toml +++ b/tests/tools/Cargo.toml @@ -8,7 +8,7 @@ authors = ["Sebastian Thiel "] edition = "2021" license = "MIT OR Apache-2.0" include = ["/src/**/*", "/LICENSE-*"] -rust-version = "1.76" +rust-version = "1.82" [[bin]] name = "jtt" @@ -35,7 +35,6 @@ winnow = { version = "0.7.12", features = ["simd"] } fastrand = "2.0.0" bstr = { version = "1.12.0", default-features = false } crc = "3.3.0" -once_cell = "1.21.3" tempfile = "3.23.0" fs_extra = "1.2.0" parking_lot = { version = "0.12.4" } diff --git a/tests/tools/src/lib.rs b/tests/tools/src/lib.rs index e2a8febf205..932ba0c8bdc 100644 --- a/tests/tools/src/lib.rs +++ b/tests/tools/src/lib.rs @@ -22,9 +22,8 @@ pub use bstr; use bstr::ByteSlice; use io_close::Close; pub use is_ci; -pub use once_cell; -use once_cell::sync::Lazy; use parking_lot::Mutex; +use std::sync::LazyLock; pub use tempfile; /// A result type to allow using the try operator `?` in unit tests. @@ -58,9 +57,9 @@ impl Drop for GitDaemon { } } -static SCRIPT_IDENTITY: Lazy>> = Lazy::new(|| Mutex::new(BTreeMap::new())); +static SCRIPT_IDENTITY: LazyLock>> = LazyLock::new(|| Mutex::new(BTreeMap::new())); -static EXCLUDE_LUT: Lazy>> = Lazy::new(|| { +static EXCLUDE_LUT: LazyLock>> = LazyLock::new(|| { let cache = (|| { let (repo_path, _) = gix_discover::upwards(Path::new(".")).ok()?; let (gix_dir, work_tree) = repo_path.into_repository_and_work_tree_directories(); @@ -103,7 +102,7 @@ const GIT_PROGRAM: &str = "git.exe"; #[cfg(not(windows))] const GIT_PROGRAM: &str = "git"; -static GIT_CORE_DIR: Lazy = Lazy::new(|| { +static GIT_CORE_DIR: LazyLock = LazyLock::new(|| { let output = std::process::Command::new(GIT_PROGRAM) .arg("--exec-path") .output() @@ -121,7 +120,8 @@ static GIT_CORE_DIR: Lazy = Lazy::new(|| { }); /// The major, minor and patch level of the git version on the system. -pub static GIT_VERSION: Lazy<(u8, u8, u8)> = Lazy::new(|| parse_git_version().expect("git version to be parsable")); +pub static GIT_VERSION: LazyLock<(u8, u8, u8)> = + LazyLock::new(|| parse_git_version().expect("git version to be parsable")); /// Define how [`scripted_fixture_writable_with_args()`] uses produces the writable copy. pub enum Creation { @@ -697,7 +697,7 @@ fn configure_command<'a, I: IntoIterator, S: AsRef>( pub fn bash_program() -> &'static Path { // TODO(deps): Unify with `gix_path::env::shell()` by having both call a more general function // in `gix-path`. See https://github.com/GitoxideLabs/gitoxide/issues/1886. - static GIT_BASH: Lazy = Lazy::new(|| { + static GIT_BASH: LazyLock = LazyLock::new(|| { if cfg!(windows) { GIT_CORE_DIR .ancestors()