Skip to content

Commit c284566

Browse files
authored
Bump msrv to 1.63 (#1031)
* Update CI to use msrv 1.63 * Bump msrv to 1.63 * Use `Vec::retain_mut` instead of `parallel::retain_unordered_mut` * Rm `parallel::retain_unordered_mut` * Fix typo and run `cargo fmt` * Use `MaybeUninit::{assume_init_ref, write}` Signed-off-by: Jiahao XU <[email protected]>
1 parent 84d04e8 commit c284566

File tree

5 files changed

+34
-54
lines changed

5 files changed

+34
-54
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,13 @@ jobs:
201201
- uses: actions/checkout@v4
202202
- name: Install Rust
203203
run: |
204-
rustup toolchain install 1.53.0 --no-self-update --profile minimal
204+
rustup toolchain install 1.63.0 --no-self-update --profile minimal
205205
rustup toolchain install nightly --no-self-update --profile minimal
206-
rustup default 1.53.0
206+
rustup default 1.63.0
207207
shell: bash
208208
- name: Create Cargo.lock with minimal version
209209
run: cargo +nightly update -Zminimal-versions
210-
- name: Cache downloaded crates since 1.53 is really slow in fetching
210+
- name: Cache downloaded crates since 1.63 is really slow in fetching
211211
uses: Swatinem/rust-cache@v2
212212
- run: cargo check --lib -p cc --locked
213213
- run: cargo check --lib -p cc --locked --all-features

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ categories = ["development-tools::build-utils"]
1717
# The binary target is only used by tests.
1818
exclude = ["/.github", "tests", "src/bin"]
1919
edition = "2018"
20-
rust-version = "1.53"
20+
rust-version = "1.63"
2121

2222
[dependencies]
2323
jobserver = { version = "0.1.20", default-features = false, optional = true }

src/lib.rs

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1496,38 +1496,35 @@ impl Build {
14961496

14971497
cell_update(&pendings, |mut pendings| {
14981498
// Try waiting on them.
1499-
parallel::retain_unordered_mut(
1500-
&mut pendings,
1501-
|(cmd, program, child, _token)| {
1502-
match try_wait_on_child(
1503-
cmd,
1504-
program,
1505-
&mut child.0,
1506-
&mut stdout,
1507-
&mut child.1,
1508-
) {
1509-
Ok(Some(())) => {
1510-
// Task done, remove the entry
1511-
has_made_progress.set(true);
1512-
false
1513-
}
1514-
Ok(None) => true, // Task still not finished, keep the entry
1515-
Err(err) => {
1516-
// Task fail, remove the entry.
1517-
// Since we can only return one error, log the error to make
1518-
// sure users always see all the compilation failures.
1519-
has_made_progress.set(true);
1520-
1521-
if self.cargo_output.warnings {
1522-
let _ = writeln!(stdout, "cargo:warning={}", err);
1523-
}
1524-
error = Some(err);
1525-
1526-
false
1499+
pendings.retain_mut(|(cmd, program, child, _token)| {
1500+
match try_wait_on_child(
1501+
cmd,
1502+
program,
1503+
&mut child.0,
1504+
&mut stdout,
1505+
&mut child.1,
1506+
) {
1507+
Ok(Some(())) => {
1508+
// Task done, remove the entry
1509+
has_made_progress.set(true);
1510+
false
1511+
}
1512+
Ok(None) => true, // Task still not finished, keep the entry
1513+
Err(err) => {
1514+
// Task fail, remove the entry.
1515+
// Since we can only return one error, log the error to make
1516+
// sure users always see all the compilation failures.
1517+
has_made_progress.set(true);
1518+
1519+
if self.cargo_output.warnings {
1520+
let _ = writeln!(stdout, "cargo:warning={}", err);
15271521
}
1522+
error = Some(err);
1523+
1524+
false
15281525
}
1529-
},
1530-
);
1526+
}
1527+
});
15311528
pendings_is_empty = pendings.is_empty();
15321529
pendings
15331530
});

src/parallel/job_token.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ impl JobTokenServer {
3434
/// that has to be static so that it will be shared by all cc
3535
/// compilation.
3636
fn new() -> &'static Self {
37+
// TODO: Replace with a OnceLock once MSRV is 1.70
3738
static INIT: Once = Once::new();
3839
static mut JOBSERVER: MaybeUninit<JobTokenServer> = MaybeUninit::uninit();
3940

@@ -42,10 +43,9 @@ impl JobTokenServer {
4243
let server = inherited_jobserver::JobServer::from_env()
4344
.map(Self::Inherited)
4445
.unwrap_or_else(|| Self::InProcess(inprocess_jobserver::JobServer::new()));
45-
JOBSERVER = MaybeUninit::new(server);
46+
JOBSERVER.write(server);
4647
});
47-
// TODO: Poor man's assume_init_ref, as that'd require a MSRV of 1.55.
48-
&*JOBSERVER.as_ptr()
48+
JOBSERVER.assume_init_ref()
4949
}
5050
}
5151
}

src/parallel/mod.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,3 @@
11
pub(crate) mod async_executor;
22
pub(crate) mod job_token;
33
pub(crate) mod stderr;
4-
5-
/// Remove all element in `vec` which `f(element)` returns `false`.
6-
///
7-
/// TODO: Remove this once the MSRV is bumped to v1.61
8-
pub(crate) fn retain_unordered_mut<T, F>(vec: &mut Vec<T>, mut f: F)
9-
where
10-
F: FnMut(&mut T) -> bool,
11-
{
12-
let mut i = 0;
13-
while i < vec.len() {
14-
if f(&mut vec[i]) {
15-
i += 1;
16-
} else {
17-
vec.swap_remove(i);
18-
}
19-
}
20-
}

0 commit comments

Comments
 (0)