dtolnay / dtolnay/anyhow

`anyhow!(e)` doesn't preserve `source` for `&Error`

Open
#341 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
6.7k
Forks
224
PR merge metrics
No merged PRs in 30d

Description

```rust
#![feature(lazy_cell)]

use std::sync::LazyLock;

static ERR: LazyLock =
LazyLock::new(|| anyhow::anyhow!("original err").context("ctx"));

fn main() {
std::env::set_var("RUST_BACKTRACE", "0");
let err = anyhow::anyhow!(&*ERR);
// ctx
println!("{:?}", err);
// source: None
println!("source: {:?}", err.source());

// However, it seems that we have "source" here?

// Error {
// context: "ctx",
// source: "original err",
// }
println!("{:#?}", err);
}

```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.