Skip to content

Commit 148393c

Browse files
authored
chore: bump rust edition, version, cargo resolver, and update lockfile (#300)
* update lockfile * fix compilation errors after bumping rust edition to 2024 * fix lints * run fmt * deny fixes
1 parent f4b2a50 commit 148393c

File tree

66 files changed

+692
-1422
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+692
-1422
lines changed

Cargo.lock

Lines changed: 507 additions & 519 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[workspace]
2-
resolver = "2"
2+
resolver = "3"
33
members = [
44
"crates/*",
55
"crates/fig_desktop/fuzz",
@@ -16,7 +16,7 @@ authors = [
1616
"Chay Nabors ([email protected])",
1717
"Brandon Kiser ([email protected])",
1818
]
19-
edition = "2021"
19+
edition = "2024"
2020
homepage = "https://aws.amazon.com/q/"
2121
publish = false
2222
version = "1.12.1"
@@ -128,7 +128,7 @@ reqwest = { version = "0.12.14", default-features = false, features = [
128128
ring = "0.17.14"
129129
rusqlite = { version = "0.32.1", features = ["bundled", "serde_json"] }
130130
shellexpand = "3.0.0"
131-
shell-color = { path = "crates/shell-color" }
131+
shell-color = "1.0.0"
132132
semver = { version = "1.0.26", features = ["serde"] }
133133
serde = { version = "1.0.219", features = ["derive", "rc"] }
134134
serde_json = "1.0.140"

crates/chat-cli/src/api_client/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ impl ApiClient {
432432
match event {
433433
serde_json::Value::String(assistant_text) => {
434434
stream.push(ChatResponseStream::AssistantResponseEvent {
435-
content: assistant_text.to_string(),
435+
content: assistant_text.clone(),
436436
});
437437
},
438438
serde_json::Value::Object(tool_use) => {

crates/chat-cli/src/cli/chat/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ impl ContextManager {
584584

585585
for (hook_list, is_global) in configs {
586586
hooks.extend(hook_list.iter_mut().map(|(name, h)| {
587-
h.name = name.to_string();
587+
h.name = name.clone();
588588
h.is_global = is_global;
589589
&*h
590590
}));

crates/chat-cli/src/cli/chat/conversation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ impl ConversationState {
332332

333333
// If the last message from the assistant contains tool uses AND next_message is set, we need to
334334
// ensure that next_message contains tool results.
335-
if let (Some((_, AssistantMessage::ToolUse { ref mut tool_uses, .. })), Some(user_msg)) = (
335+
if let (Some((_, AssistantMessage::ToolUse { tool_uses, .. })), Some(user_msg)) = (
336336
self.history
337337
.range_mut(self.valid_history_range.0..self.valid_history_range.1)
338338
.last(),
@@ -377,7 +377,7 @@ impl ConversationState {
377377
.collect();
378378

379379
for (_, assistant) in &mut self.history {
380-
if let AssistantMessage::ToolUse { ref mut tool_uses, .. } = assistant {
380+
if let AssistantMessage::ToolUse { tool_uses, .. } = assistant {
381381
for tool_use in tool_uses {
382382
if tool_names.contains(tool_use.name.as_str()) {
383383
continue;

crates/chat-cli/src/cli/chat/input_source.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ mod inner {
1616

1717
use super::super::prompt::ChatHelper;
1818

19+
#[allow(clippy::large_enum_variant)]
1920
#[derive(Debug)]
2021
pub enum Inner {
2122
Readline(Editor<ChatHelper, FileHistory>),

crates/chat-cli/src/cli/chat/mod.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,11 +365,11 @@ enum ToolUseStatus {
365365
#[derive(Debug, Error)]
366366
pub enum ChatError {
367367
#[error("{0}")]
368-
Client(#[from] crate::api_client::ApiClientError),
368+
Client(Box<crate::api_client::ApiClientError>),
369369
#[error("{0}")]
370370
Auth(#[from] AuthError),
371371
#[error("{0}")]
372-
ResponseStream(#[from] parser::RecvError),
372+
ResponseStream(Box<parser::RecvError>),
373373
#[error("{0}")]
374374
Std(#[from] std::io::Error),
375375
#[error("{0}")]
@@ -412,6 +412,18 @@ impl ReasonCode for ChatError {
412412
}
413413
}
414414

415+
impl From<ApiClientError> for ChatError {
416+
fn from(value: ApiClientError) -> Self {
417+
Self::Client(Box::new(value))
418+
}
419+
}
420+
421+
impl From<parser::RecvError> for ChatError {
422+
fn from(value: parser::RecvError) -> Self {
423+
Self::ResponseStream(Box::new(value))
424+
}
425+
}
426+
415427
pub struct ChatSession {
416428
/// For output read by humans and machine
417429
pub stdout: std::io::Stdout,
@@ -631,7 +643,7 @@ impl ChatSession {
631643

632644
("Tool use was interrupted", Report::from(err))
633645
},
634-
ChatError::Client(err) => match err {
646+
ChatError::Client(err) => match *err {
635647
// Errors from attempting to send too large of a conversation history. In
636648
// this case, attempt to automatically compact the history for the user.
637649
ApiClientError::ContextWindowOverflow { .. } => {
@@ -789,6 +801,7 @@ impl Drop for ChatSession {
789801
///
790802
/// Intended to provide more robust handling around state transitions while dealing with, e.g.,
791803
/// tool validation, execution, response stream handling, etc.
804+
#[allow(clippy::large_enum_variant)]
792805
#[derive(Debug)]
793806
enum ChatState {
794807
/// Prompt the user with `tool_uses`, if available.

crates/chat-cli/src/cli/chat/prompt.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,10 @@ impl PromptCompleter {
146146
let receiver = &self.receiver;
147147
sender
148148
.send(if !word.is_empty() { Some(word.to_string()) } else { None })
149-
.map_err(|e| ReadlineError::Io(std::io::Error::new(std::io::ErrorKind::Other, e.to_string())))?;
149+
.map_err(|e| ReadlineError::Io(std::io::Error::other(e.to_string())))?;
150150
let prompt_info = receiver
151151
.recv()
152-
.map_err(|e| ReadlineError::Io(std::io::Error::new(std::io::ErrorKind::Other, e.to_string())))?
152+
.map_err(|e| ReadlineError::Io(std::io::Error::other(e.to_string())))?
153153
.iter()
154154
.map(|n| format!("@{n}"))
155155
.collect::<Vec<_>>();

crates/chat-cli/src/cli/chat/tool_manager.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ impl ToolManagerBuilder {
605605
// TODO: accommodate hot reload of mcp servers
606606
if let (Some(sender), Some(receiver)) = (sender, receiver) {
607607
let clients = clients.iter().fold(HashMap::new(), |mut acc, (n, c)| {
608-
acc.insert(n.to_string(), Arc::downgrade(c));
608+
acc.insert(n.clone(), Arc::downgrade(c));
609609
acc
610610
});
611611
let prompts_clone = prompts.clone();
@@ -635,7 +635,7 @@ impl ToolManagerBuilder {
635635
return acc;
636636
};
637637
for (prompt_name, prompt_get) in prompt_gets.iter() {
638-
acc.entry(prompt_name.to_string())
638+
acc.entry(prompt_name.clone())
639639
.and_modify(|bundles| {
640640
bundles.push(PromptBundle {
641641
server_name: server_name.to_owned(),
@@ -1156,7 +1156,7 @@ impl ToolManager {
11561156
.map_err(|e| GetPromptError::Synchronization(e.to_string()))?;
11571157
for (prompt_name, prompt_get) in prompt_gets.iter() {
11581158
prompts_wl
1159-
.entry(prompt_name.to_string())
1159+
.entry(prompt_name.clone())
11601160
.and_modify(|bundles| {
11611161
let mut is_modified = false;
11621162
for bundle in &mut *bundles {
@@ -1224,7 +1224,6 @@ impl ToolManager {
12241224
has_retried = true;
12251225
self.refresh_prompts(&mut prompts_wl)?;
12261226
maybe_bundles = prompts_wl.get(&prompt_name);
1227-
continue 'blk;
12281227
},
12291228
(_, _, true) => {
12301229
break 'blk Err(GetPromptError::PromptNotFound(prompt_name));
@@ -1243,7 +1242,7 @@ impl ToolManager {
12431242
return acc;
12441243
};
12451244
for (prompt_name, prompt_get) in prompt_gets.iter() {
1246-
acc.entry(prompt_name.to_string())
1245+
acc.entry(prompt_name.clone())
12471246
.and_modify(|bundles| {
12481247
bundles.push(PromptBundle {
12491248
server_name: server_name.to_owned(),

crates/chat-cli/src/cli/chat/util/images.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ pub fn handle_images_from_paths(output: &mut impl Write, paths: &[String]) -> Ri
7777

7878
extracted_images.push((image_block, ImageMetadata {
7979
filename,
80-
filepath: path.to_string(),
80+
filepath: path.clone(),
8181
size: image_size,
8282
}));
8383
}
@@ -147,7 +147,7 @@ pub fn handle_images_from_paths(output: &mut impl Write, paths: &[String]) -> Ri
147147
/// * `false` otherwise
148148
pub fn is_supported_image_type(maybe_file_path: &str) -> bool {
149149
let supported_image_types = ["jpg", "jpeg", "png", "gif", "webp"];
150-
if let Some(extension) = maybe_file_path.split('.').last() {
150+
if let Some(extension) = maybe_file_path.split('.').next_back() {
151151
return supported_image_types.contains(&extension.trim().to_lowercase().as_str());
152152
}
153153
false

0 commit comments

Comments
 (0)