chore: 修复 release 构建的编译器警告

- 为 regex::Captures 补全显式生命周期标注
- 将仅用于 debug 日志的局部变量 (media_count/len/total) 用 cfg(debug_assertions) 条件化
- 为仅 debug 读取的 AnthropicProvider::llm_timeout_secs 字段添加 cfg_attr allow(dead_code)
This commit is contained in:
oudecheng 2026-08-07 14:36:27 +08:00
parent da62905505
commit f26ec49182
6 changed files with 8 additions and 4 deletions

2
Cargo.lock generated
View File

@ -1635,7 +1635,7 @@ dependencies = [
[[package]]
name = "picobot"
version = "0.3.2"
version = "0.3.3"
dependencies = [
"anyhow",
"async-trait",

View File

@ -1311,6 +1311,7 @@ impl FeishuChannel {
let channel = self.clone();
let bus = bus.clone();
tokio::spawn(async move {
#[cfg(debug_assertions)]
let media_count = if parsed.media.is_some() { 1 } else { 0 };
#[cfg(debug_assertions)]
tracing::debug!(open_id = %parsed.open_id, chat_id = %parsed.chat_id, content_len = %parsed.content.len(), media_count = %media_count, "Publishing message to bus");

View File

@ -1222,13 +1222,13 @@ fn resolve_env_placeholders(content: &str) -> String {
let re_braces = Regex::new(r"\$\{([A-Z_][A-Z0-9_]*)\}").expect("invalid regex");
let re_angle = Regex::new(r"<([A-Z_]+)>").expect("invalid regex");
let content = re_braces.replace_all(content, |caps: &regex::Captures| {
let content = re_braces.replace_all(content, |caps: &regex::Captures<'_>| {
let var_name = &caps[1];
env::var(var_name).unwrap_or_else(|_| caps[0].to_string())
});
re_angle
.replace_all(&content, |caps: &regex::Captures| {
.replace_all(&content, |caps: &regex::Captures<'_>| {
let var_name = &caps[1];
env::var(var_name).unwrap_or_else(|_| caps[0].to_string())
})

View File

@ -223,6 +223,7 @@ impl SessionHistory {
) -> Result<(), AgentError> {
if let Some(tid) = topic_id {
if let Some(history) = self.topic_histories.get_mut(tid) {
#[cfg(debug_assertions)]
let len = history.len();
history.clear();
#[cfg(debug_assertions)]
@ -320,6 +321,7 @@ impl SessionHistory {
/// 清空所有内存历史(主要用于测试全局重置)。
/// 不遍历清 DB生产环境如需清 DB 应由调用方显式调用。
pub(crate) fn clear_all_history(&mut self) -> Result<(), AgentError> {
#[cfg(debug_assertions)]
let total: usize = self.topic_histories.values().map(|h| h.len()).sum();
self.topic_histories.clear();
self.compression_in_flight.clear();

View File

@ -32,7 +32,7 @@ use std::process::Stdio;
/// Resolve ${ENV_VAR} placeholders in a value string
fn resolve_env_placeholders_in_value(value: &str) -> String {
let re = regex::Regex::new(r"\$\{([A-Z_][A-Z0-9_]*)\}").expect("invalid regex");
re.replace_all(value, |caps: &regex::Captures| {
re.replace_all(value, |caps: &regex::Captures<'_>| {
let var_name = &caps[1];
env::var(var_name).unwrap_or_else(|_| caps[0].to_string())
})

View File

@ -125,6 +125,7 @@ pub struct AnthropicProvider {
api_key: String,
base_url: String,
extra_headers: HashMap<String, String>,
#[cfg_attr(not(debug_assertions), allow(dead_code))]
llm_timeout_secs: u64,
model_id: String,
temperature: Option<f32>,