Skip to content

Conversation

dtolnay
Copy link
Owner

@dtolnay dtolnay commented Oct 20, 2022

Repro:

use anyhow::Context;

fn main() -> anyhow::Result<()> {
    let result = Err(std::fmt::Error);
    result.context("...")
}

Before:

0: <E as anyhow::context::ext::StdError>::ext_context
          at /git/anyhow/src/context.rs:27:29
1: anyhow::context::<impl anyhow::Context<T,E> for core::result::Result<T,E>>::context::{{closure}}
          at /git/anyhow/src/context.rs:50:30
2: core::result::Result<T,E>::map_err
          at /rustc/4b8f4319954ff2642690b9e5cbe4af352d095bf6/library/core/src/result.rs:861:27
3: anyhow::context::<impl anyhow::Context<T,E> for core::result::Result<T,E>>::context
          at /git/anyhow/src/context.rs:50:9
4: testing::main
          at ./src/main.rs:5:5

After:

0: <E as anyhow::context::ext::StdError>::ext_context
          at /git/anyhow/src/context.rs:27:29
1: anyhow::context::<impl anyhow::Context<T,E> for core::result::Result<T,E>>::context
          at /git/anyhow/src/context.rs:52:31
2: testing::main
          at ./src/main.rs:5:5

Repro:

    use anyhow::Context;

    fn main() -> anyhow::Result<()> {
        let result = Err(std::fmt::Error);
        result.context("...")
    }

Before:

    0: <E as anyhow::context::ext::StdError>::ext_context
              at /git/anyhow/src/context.rs:27:29
    1: anyhow::context::<impl anyhow::Context<T,E> for core::result::Result<T,E>>::context::{{closure}}
              at /git/anyhow/src/context.rs:50:30
    2: core::result::Result<T,E>::map_err
              at /rustc/4b8f4319954ff2642690b9e5cbe4af352d095bf6/library/core/src/result.rs:861:27
    3: anyhow::context::<impl anyhow::Context<T,E> for core::result::Result<T,E>>::context
              at /git/anyhow/src/context.rs:50:9
    4: testing::main
              at ./src/main.rs:5:5

After:

    0: <E as anyhow::context::ext::StdError>::ext_context
              at /git/anyhow/src/context.rs:27:29
    1: anyhow::context::<impl anyhow::Context<T,E> for core::result::Result<T,E>>::context
              at /git/anyhow/src/context.rs:52:31
    2: testing::main
              at ./src/main.rs:5:5
@dtolnay dtolnay merged commit 54fc812 into master Oct 20, 2022
@dtolnay dtolnay deleted the contextbacktrace branch October 20, 2022 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant