Skip to content

Commit 76d33fc

Browse files
committed
chore: upgrade to Rust 1.89
1 parent 1f5638b commit 76d33fc

37 files changed

+496
-513
lines changed

.github/workflows/codex.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
- name: Checkout repository
4040
uses: actions/checkout@v5
4141

42-
- uses: dtolnay/rust-toolchain@1.88
42+
- uses: dtolnay/rust-toolchain@1.89
4343
with:
4444
targets: x86_64-unknown-linux-gnu
4545
components: clippy

.github/workflows/rust-ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
working-directory: codex-rs
5858
steps:
5959
- uses: actions/checkout@v5
60-
- uses: dtolnay/rust-toolchain@1.88
60+
- uses: dtolnay/rust-toolchain@1.89
6161
with:
6262
components: rustfmt
6363
- name: cargo fmt
@@ -112,7 +112,7 @@ jobs:
112112

113113
steps:
114114
- uses: actions/checkout@v5
115-
- uses: dtolnay/rust-toolchain@1.88
115+
- uses: dtolnay/rust-toolchain@1.89
116116
with:
117117
targets: ${{ matrix.target }}
118118
components: clippy

.github/workflows/rust-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ jobs:
7575

7676
steps:
7777
- uses: actions/checkout@v5
78-
- uses: dtolnay/rust-toolchain@1.88
78+
- uses: dtolnay/rust-toolchain@1.89
7979
with:
8080
targets: ${{ matrix.target }}
8181

codex-rs/apply-patch/src/lib.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -415,12 +415,12 @@ fn apply_hunks_to_files(hunks: &[Hunk]) -> anyhow::Result<AffectedPaths> {
415415
for hunk in hunks {
416416
match hunk {
417417
Hunk::AddFile { path, contents } => {
418-
if let Some(parent) = path.parent() {
419-
if !parent.as_os_str().is_empty() {
420-
std::fs::create_dir_all(parent).with_context(|| {
421-
format!("Failed to create parent directories for {}", path.display())
422-
})?;
423-
}
418+
if let Some(parent) = path.parent()
419+
&& !parent.as_os_str().is_empty()
420+
{
421+
std::fs::create_dir_all(parent).with_context(|| {
422+
format!("Failed to create parent directories for {}", path.display())
423+
})?;
424424
}
425425
std::fs::write(path, contents)
426426
.with_context(|| format!("Failed to write file {}", path.display()))?;
@@ -439,15 +439,12 @@ fn apply_hunks_to_files(hunks: &[Hunk]) -> anyhow::Result<AffectedPaths> {
439439
let AppliedPatch { new_contents, .. } =
440440
derive_new_contents_from_chunks(path, chunks)?;
441441
if let Some(dest) = move_path {
442-
if let Some(parent) = dest.parent() {
443-
if !parent.as_os_str().is_empty() {
444-
std::fs::create_dir_all(parent).with_context(|| {
445-
format!(
446-
"Failed to create parent directories for {}",
447-
dest.display()
448-
)
449-
})?;
450-
}
442+
if let Some(parent) = dest.parent()
443+
&& !parent.as_os_str().is_empty()
444+
{
445+
std::fs::create_dir_all(parent).with_context(|| {
446+
format!("Failed to create parent directories for {}", dest.display())
447+
})?;
451448
}
452449
std::fs::write(dest, new_contents)
453450
.with_context(|| format!("Failed to write file {}", dest.display()))?;
@@ -529,9 +526,12 @@ fn compute_replacements(
529526
// If a chunk has a `change_context`, we use seek_sequence to find it, then
530527
// adjust our `line_index` to continue from there.
531528
if let Some(ctx_line) = &chunk.change_context {
532-
if let Some(idx) =
533-
seek_sequence::seek_sequence(original_lines, &[ctx_line.clone()], line_index, false)
534-
{
529+
if let Some(idx) = seek_sequence::seek_sequence(
530+
original_lines,
531+
std::slice::from_ref(ctx_line),
532+
line_index,
533+
false,
534+
) {
535535
line_index = idx + 1;
536536
} else {
537537
return Err(ApplyPatchError::ComputeReplacements(format!(

codex-rs/arg0/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ const ILLEGAL_ENV_VAR_PREFIX: &str = "CODEX_";
8989
/// Security: Do not allow `.env` files to create or modify any variables
9090
/// with names starting with `CODEX_`.
9191
fn load_dotenv() {
92-
if let Ok(codex_home) = codex_core::config::find_codex_home() {
93-
if let Ok(iter) = dotenvy::from_path_iter(codex_home.join(".env")) {
94-
set_filtered(iter);
95-
}
92+
if let Ok(codex_home) = codex_core::config::find_codex_home()
93+
&& let Ok(iter) = dotenvy::from_path_iter(codex_home.join(".env"))
94+
{
95+
set_filtered(iter);
9696
}
9797

9898
if let Ok(iter) = dotenvy::dotenv_iter() {

codex-rs/cli/src/login.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ pub async fn run_login_status(cli_config_overrides: CliConfigOverrides) -> ! {
6666
Ok(api_key) => {
6767
eprintln!("Logged in using an API key - {}", safe_format_key(&api_key));
6868

69-
if let Ok(env_api_key) = env::var(OPENAI_API_KEY_ENV_VAR) {
70-
if env_api_key == api_key {
71-
eprintln!(
72-
" API loaded from OPENAI_API_KEY environment variable or .env file"
73-
);
74-
}
69+
if let Ok(env_api_key) = env::var(OPENAI_API_KEY_ENV_VAR)
70+
&& env_api_key == api_key
71+
{
72+
eprintln!(
73+
" API loaded from OPENAI_API_KEY environment variable or .env file"
74+
);
7575
}
7676
std::process::exit(0);
7777
}

codex-rs/core/src/chat_completions.rs

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -290,13 +290,12 @@ async fn process_chat_sse<S>(
290290
.get("delta")
291291
.and_then(|d| d.get("content"))
292292
.and_then(|c| c.as_str())
293+
&& !content.is_empty()
293294
{
294-
if !content.is_empty() {
295-
assistant_text.push_str(content);
296-
let _ = tx_event
297-
.send(Ok(ResponseEvent::OutputTextDelta(content.to_string())))
298-
.await;
299-
}
295+
assistant_text.push_str(content);
296+
let _ = tx_event
297+
.send(Ok(ResponseEvent::OutputTextDelta(content.to_string())))
298+
.await;
300299
}
301300

302301
// Forward any reasoning/thinking deltas if present.
@@ -333,27 +332,25 @@ async fn process_chat_sse<S>(
333332
.get("delta")
334333
.and_then(|d| d.get("tool_calls"))
335334
.and_then(|tc| tc.as_array())
335+
&& let Some(tool_call) = tool_calls.first()
336336
{
337-
if let Some(tool_call) = tool_calls.first() {
338-
// Mark that we have an active function call in progress.
339-
fn_call_state.active = true;
337+
// Mark that we have an active function call in progress.
338+
fn_call_state.active = true;
340339

341-
// Extract call_id if present.
342-
if let Some(id) = tool_call.get("id").and_then(|v| v.as_str()) {
343-
fn_call_state.call_id.get_or_insert_with(|| id.to_string());
344-
}
340+
// Extract call_id if present.
341+
if let Some(id) = tool_call.get("id").and_then(|v| v.as_str()) {
342+
fn_call_state.call_id.get_or_insert_with(|| id.to_string());
343+
}
345344

346-
// Extract function details if present.
347-
if let Some(function) = tool_call.get("function") {
348-
if let Some(name) = function.get("name").and_then(|n| n.as_str()) {
349-
fn_call_state.name.get_or_insert_with(|| name.to_string());
350-
}
345+
// Extract function details if present.
346+
if let Some(function) = tool_call.get("function") {
347+
if let Some(name) = function.get("name").and_then(|n| n.as_str()) {
348+
fn_call_state.name.get_or_insert_with(|| name.to_string());
349+
}
351350

352-
if let Some(args_fragment) =
353-
function.get("arguments").and_then(|a| a.as_str())
354-
{
355-
fn_call_state.arguments.push_str(args_fragment);
356-
}
351+
if let Some(args_fragment) = function.get("arguments").and_then(|a| a.as_str())
352+
{
353+
fn_call_state.arguments.push_str(args_fragment);
357354
}
358355
}
359356
}
@@ -491,15 +488,14 @@ where
491488
// Only use the final assistant message if we have not
492489
// seen any deltas; otherwise, deltas already built the
493490
// cumulative text and this would duplicate it.
494-
if this.cumulative.is_empty() {
495-
if let crate::models::ResponseItem::Message { content, .. } = &item {
496-
if let Some(text) = content.iter().find_map(|c| match c {
497-
crate::models::ContentItem::OutputText { text } => Some(text),
498-
_ => None,
499-
}) {
500-
this.cumulative.push_str(text);
501-
}
502-
}
491+
if this.cumulative.is_empty()
492+
&& let crate::models::ResponseItem::Message { content, .. } = &item
493+
&& let Some(text) = content.iter().find_map(|c| match c {
494+
crate::models::ContentItem::OutputText { text } => Some(text),
495+
_ => None,
496+
})
497+
{
498+
this.cumulative.push_str(text);
503499
}
504500

505501
// Swallow assistant message here; emit on Completed.

codex-rs/core/src/codex.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -544,10 +544,10 @@ impl Session {
544544

545545
pub fn remove_task(&self, sub_id: &str) {
546546
let mut state = self.state.lock_unchecked();
547-
if let Some(task) = &state.current_task {
548-
if task.sub_id == sub_id {
549-
state.current_task.take();
550-
}
547+
if let Some(task) = &state.current_task
548+
&& task.sub_id == sub_id
549+
{
550+
state.current_task.take();
551551
}
552552
}
553553

@@ -1239,18 +1239,18 @@ async fn submission_loop(
12391239
// Gracefully flush and shutdown rollout recorder on session end so tests
12401240
// that inspect the rollout file do not race with the background writer.
12411241
let recorder_opt = sess.rollout.lock_unchecked().take();
1242-
if let Some(rec) = recorder_opt {
1243-
if let Err(e) = rec.shutdown().await {
1244-
warn!("failed to shutdown rollout recorder: {e}");
1245-
let event = Event {
1246-
id: sub.id.clone(),
1247-
msg: EventMsg::Error(ErrorEvent {
1248-
message: "Failed to shutdown rollout recorder".to_string(),
1249-
}),
1250-
};
1251-
if let Err(e) = sess.tx_event.send(event).await {
1252-
warn!("failed to send error message: {e:?}");
1253-
}
1242+
if let Some(rec) = recorder_opt
1243+
&& let Err(e) = rec.shutdown().await
1244+
{
1245+
warn!("failed to shutdown rollout recorder: {e}");
1246+
let event = Event {
1247+
id: sub.id.clone(),
1248+
msg: EventMsg::Error(ErrorEvent {
1249+
message: "Failed to shutdown rollout recorder".to_string(),
1250+
}),
1251+
};
1252+
if let Err(e) = sess.tx_event.send(event).await {
1253+
warn!("failed to send error message: {e:?}");
12541254
}
12551255
}
12561256

codex-rs/core/src/config.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -759,10 +759,10 @@ fn default_model() -> String {
759759
pub fn find_codex_home() -> std::io::Result<PathBuf> {
760760
// Honor the `CODEX_HOME` environment variable when it is set to allow users
761761
// (and tests) to override the default location.
762-
if let Ok(val) = std::env::var("CODEX_HOME") {
763-
if !val.is_empty() {
764-
return PathBuf::from(val).canonicalize();
765-
}
762+
if let Ok(val) = std::env::var("CODEX_HOME")
763+
&& !val.is_empty()
764+
{
765+
return PathBuf::from(val).canonicalize();
766766
}
767767

768768
let mut p = home_dir().ok_or_else(|| {

codex-rs/core/src/git_info.rs

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -51,33 +51,30 @@ pub async fn collect_git_info(cwd: &Path) -> Option<GitInfo> {
5151
};
5252

5353
// Process commit hash
54-
if let Some(output) = commit_result {
55-
if output.status.success() {
56-
if let Ok(hash) = String::from_utf8(output.stdout) {
57-
git_info.commit_hash = Some(hash.trim().to_string());
58-
}
59-
}
54+
if let Some(output) = commit_result
55+
&& output.status.success()
56+
&& let Ok(hash) = String::from_utf8(output.stdout)
57+
{
58+
git_info.commit_hash = Some(hash.trim().to_string());
6059
}
6160

6261
// Process branch name
63-
if let Some(output) = branch_result {
64-
if output.status.success() {
65-
if let Ok(branch) = String::from_utf8(output.stdout) {
66-
let branch = branch.trim();
67-
if branch != "HEAD" {
68-
git_info.branch = Some(branch.to_string());
69-
}
70-
}
62+
if let Some(output) = branch_result
63+
&& output.status.success()
64+
&& let Ok(branch) = String::from_utf8(output.stdout)
65+
{
66+
let branch = branch.trim();
67+
if branch != "HEAD" {
68+
git_info.branch = Some(branch.to_string());
7169
}
7270
}
7371

7472
// Process repository URL
75-
if let Some(output) = url_result {
76-
if output.status.success() {
77-
if let Ok(url) = String::from_utf8(output.stdout) {
78-
git_info.repository_url = Some(url.trim().to_string());
79-
}
80-
}
73+
if let Some(output) = url_result
74+
&& output.status.success()
75+
&& let Ok(url) = String::from_utf8(output.stdout)
76+
{
77+
git_info.repository_url = Some(url.trim().to_string());
8178
}
8279

8380
Some(git_info)

0 commit comments

Comments
 (0)