PicoBot/src/bootstrap.rs
oudecheng cda14360af chore: 建立工程化基线(rustfmt + clippy + CI + eslint + prettier)
配置:
- rustfmt.toml: 固化 max_width=100 / 4 空格缩进,cargo fmt 全量格式化
- Cargo.toml: 配置 [lints.rust] 与 [lints.clippy] 渐进式规则
- .github/workflows/ci.yml: Rust(fmt+clippy+test) + 前端(eslint+tsc+test) 双平台 CI
- Makefile: 新增 check/fmt/fix 目标,clippy 对齐 --all-targets --all-features
- web: eslint flat config + prettier 配置 + package.json 脚本与依赖
- src/main.rs: loop→while 修复 clippy::never_loop

对抗性审查发现并修复:
- eslint 缺 caughtErrorsIgnorePattern 导致 catch(_) 误报为 error
- 前端 lint 未接入 CI,现已补上 Lint 步骤
- Makefile 与 CI 的 clippy flags 不一致,已对齐
2026-08-03 23:24:02 +08:00

27 lines
1.2 KiB
Rust

pub fn initialize_process_runtime() {
let _ = rustls::crypto::ring::default_provider().install_default();
// Install a global panic hook so that any panic in a spawned task
// is logged with a full backtrace before the process exits. Without
// this hook, panics are silent (or print a brief message to stderr)
// which makes root-causing crashes difficult.
let default_hook = std::panic::take_hook();
std::panic::set_hook(Box::new(move |info| {
// Use tracing so the panic appears in the same log stream as everything else.
tracing::error!(
panic.payload = ?info.payload(),
panic.location = ?info.location(),
"FATAL: process panicked — collecting backtrace"
);
// Print a compact backtrace to stderr as well (backtrace is not
// captured by tracing).
let backtrace = std::backtrace::Backtrace::capture();
if backtrace.status() == std::backtrace::BacktraceStatus::Captured {
eprintln!("FATAL panic backtrace:\n{}", backtrace);
}
// Delegate to the default hook which prints the panic message and
// optionally the RUST_BACKTRACE-based backtrace.
default_hook(info);
}));
}