从紧急消息中删除项目信息

Shi*_*n S 5 panic rust rust-cargo

如何隐藏项目信息(如源代码路径)以防止运行发布版本时发生的紧急消息?

假设以下代码作为最小可重现示例

fn main() {
    println!("Hello!");
    let v = vec![0];
    println!("{:?}", v[1]); // panic - index out of bounds
}
Run Code Online (Sandbox Code Playgroud)

> cargo build --release
> target/release/hello-rust
得到:

Hello!
thread 'main' panicked at 'index out of bounds: the len is 1 but the index is 1', src/main.rs:5:22
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Run Code Online (Sandbox Code Playgroud)

泄露“src/main.rs:5:22”是非常不受欢迎的。我什至不想透露使用 Rust 构建的可执行文件。
我想在每种panic情况下都以“1”错误代码退出进程,例如索引越界或.unwrap()出错。

尝试过:

[profile.release]
panic = "abort"
Run Code Online (Sandbox Code Playgroud)

没有帮助。
试图查看“个人资料设置”,但没有找到有用的东西。