From 8172f0e0f19e84fdaedceb87399f3fab4a1eb563 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Thu, 17 Aug 2023 18:36:25 +0200 Subject: [PATCH] fix: Assure `gix-submodule` works with Rust 1.65. The previous version of this loop, possibly preferable, ran into a borrow-check issue that was no more from Rust 1.70 onwards. --- .github/workflows/msrv.yml | 2 +- etc/msrv-badge.svg | 2 +- gix-submodule/src/lib.rs | 22 ++++++++++------------ 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/.github/workflows/msrv.yml b/.github/workflows/msrv.yml index 8f9143e879f..26ddc0352a6 100644 --- a/.github/workflows/msrv.yml +++ b/.github/workflows/msrv.yml @@ -20,6 +20,6 @@ jobs: runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@1.65.0 # dictated by `windows` crates effectively, IMPORTANT: adjust etc/msrv-badge.svg as well + - uses: dtolnay/rust-toolchain@1.65.0 # dictated by `firefox` to support the `helix` editor, IMPORTANT: adjust etc/msrv-badge.svg as well - uses: extractions/setup-just@v1 - run: just ci-check-msrv diff --git a/etc/msrv-badge.svg b/etc/msrv-badge.svg index fa117879cf4..72186a6c94c 100644 --- a/etc/msrv-badge.svg +++ b/etc/msrv-badge.svg @@ -1 +1 @@ -rustc: 1.59.0+rustc1.64.0+ +rustc: 1.59.0+rustc1.65.0+ diff --git a/gix-submodule/src/lib.rs b/gix-submodule/src/lib.rs index 82665352849..3c77c906053 100644 --- a/gix-submodule/src/lib.rs +++ b/gix-submodule/src/lib.rs @@ -55,22 +55,20 @@ impl File { let mut config_to_append = gix_config::File::new(config.meta_owned()); let mut prev_name = None; - let mut section = None; for ((module_name, field), values) in values { if prev_name.map_or(true, |pn: &BStr| pn != module_name) { - section.take(); - section = Some( - config_to_append - .new_section("submodule", Cow::Owned(module_name.to_owned())) - .expect("all names come from valid configuration, so remain valid"), - ); + config_to_append + .new_section("submodule", Cow::Owned(module_name.to_owned())) + .expect("all names come from valid configuration, so remain valid"); prev_name = Some(module_name); } - let section = section.as_mut().expect("always set at this point"); - section.push( - field.try_into().expect("statically known key"), - Some(values.last().expect("at least one value or we wouldn't be here")), - ); + config_to_append + .section_mut("submodule", Some(module_name)) + .expect("always set at this point") + .push( + field.try_into().expect("statically known key"), + Some(values.last().expect("at least one value or we wouldn't be here")), + ); } self.config.append(config_to_append);