Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[pull] main from rust-lang:main #79

Merged
merged 5 commits into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## Unreleased

### Changed

- Upgrade to Rust edition 2024
- Raise the minimum supported Rust version to `1.85`

<a name="6.4.0"></a>

## 6.4.0 (2024-11-11)
Expand Down
87 changes: 53 additions & 34 deletions Cargo.lock

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

14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ authors = [
]
repository = "https://github.com/rust-lang/rustlings"
license = "MIT"
edition = "2021" # On Update: Update the edition of the `rustfmt` command that checks the solutions.
rust-version = "1.80"
edition = "2024" # On Update: Update the edition of the `rustfmt` command that checks the solutions.
rust-version = "1.85"

[workspace.dependencies]
serde = { version = "1.0.217", features = ["derive"] }
toml_edit = { version = "0.22.22", default-features = false, features = ["parse", "serde"] }
toml_edit = { version = "0.22.24", default-features = false, features = ["parse", "serde"] }

[package]
name = "rustlings"
Expand All @@ -47,20 +47,20 @@ include = [

[dependencies]
anyhow = "1.0.95"
clap = { version = "4.5.26", features = ["derive"] }
clap = { version = "4.5.30", features = ["derive"] }
crossterm = { version = "0.28.1", default-features = false, features = ["windows", "events"] }
notify = "8.0.0"
os_pipe = "1.2.1"
rustlings-macros = { path = "rustlings-macros", version = "=6.4.0" }
serde_json = "1.0.135"
serde_json = "1.0.138"
serde.workspace = true
toml_edit.workspace = true

[target.'cfg(not(windows))'.dependencies]
rustix = { version = "0.38.43", default-features = false, features = ["std", "stdio", "termios"] }
rustix = { version = "0.38.44", default-features = false, features = ["std", "stdio", "termios"] }

[dev-dependencies]
tempfile = "3.15.0"
tempfile = "3.17.1"

[profile.release]
panic = "abort"
Expand Down
2 changes: 1 addition & 1 deletion dev/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ bin = [

[package]
name = "exercises"
edition = "2021"
edition = "2024"
# Don't publish the exercises on crates.io!
publish = false

Expand Down
2 changes: 1 addition & 1 deletion release-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ cargo test --workspace --all-targets
cargo run -- dev check --require-solutions

# MSRV
cargo +1.80 run -- dev check --require-solutions
cargo +1.85 run -- dev check --require-solutions
2 changes: 1 addition & 1 deletion solutions/13_error_handling/errors2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

use std::num::ParseIntError;

#[allow(unused_variables)]
#[allow(unused_variables, clippy::question_mark)]
fn total_cost(item_quantity: &str) -> Result<i32, ParseIntError> {
let processing_fee = 1;
let cost_per_item = 5;
Expand Down
60 changes: 31 additions & 29 deletions src/app_state.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use anyhow::{bail, Context, Error, Result};
use crossterm::{cursor, terminal, QueueableCommand};
use anyhow::{Context, Error, Result, bail};
use crossterm::{QueueableCommand, cursor, terminal};
use std::{
collections::HashSet,
env,
fs::{File, OpenOptions},
io::{Read, Seek, StdoutLock, Write},
path::{Path, MAIN_SEPARATOR_STR},
path::{MAIN_SEPARATOR_STR, Path},
process::{Command, Stdio},
sync::{
atomic::{AtomicUsize, Ordering::Relaxed},
Expand Down Expand Up @@ -427,32 +427,34 @@ impl AppState {
let next_exercise_ind = &next_exercise_ind;
let slf = &self;
thread::Builder::new()
.spawn_scoped(s, move || loop {
let exercise_ind = next_exercise_ind.fetch_add(1, Relaxed);
let Some(exercise) = slf.exercises.get(exercise_ind) else {
// No more exercises.
break;
};

if exercise_progress_sender
.send((exercise_ind, CheckProgress::Checking))
.is_err()
{
break;
};

let success = exercise.run_exercise(None, &slf.cmd_runner);
let progress = match success {
Ok(true) => CheckProgress::Done,
Ok(false) => CheckProgress::Pending,
Err(_) => CheckProgress::None,
};

if exercise_progress_sender
.send((exercise_ind, progress))
.is_err()
{
break;
.spawn_scoped(s, move || {
loop {
let exercise_ind = next_exercise_ind.fetch_add(1, Relaxed);
let Some(exercise) = slf.exercises.get(exercise_ind) else {
// No more exercises.
break;
};

if exercise_progress_sender
.send((exercise_ind, CheckProgress::Checking))
.is_err()
{
break;
};

let success = exercise.run_exercise(None, &slf.cmd_runner);
let progress = match success {
Ok(true) => CheckProgress::Done,
Ok(false) => CheckProgress::Pending,
Err(_) => CheckProgress::None,
};

if exercise_progress_sender
.send((exercise_ind, progress))
.is_err()
{
break;
}
}
})
.context("Failed to spawn a thread to check all exercises")?;
Expand Down
4 changes: 2 additions & 2 deletions src/cargo_toml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ pub fn updated_cargo_toml(
let (bins_start_ind, bins_end_ind) = bins_start_end_ind(current_cargo_toml)?;

let mut updated_cargo_toml = Vec::with_capacity(BINS_BUFFER_CAPACITY);
updated_cargo_toml.extend_from_slice(current_cargo_toml[..bins_start_ind].as_bytes());
updated_cargo_toml.extend_from_slice(&current_cargo_toml.as_bytes()[..bins_start_ind]);
append_bins(
&mut updated_cargo_toml,
exercise_infos,
exercise_path_prefix,
);
updated_cargo_toml.extend_from_slice(current_cargo_toml[bins_end_ind..].as_bytes());
updated_cargo_toml.extend_from_slice(&current_cargo_toml.as_bytes()[bins_end_ind..]);

Ok(updated_cargo_toml)
}
Expand Down
Loading
Loading