Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove 2 frames of backtrace noise on Option's Context impl #280

Merged
merged 1 commit into from Oct 20, 2022

Conversation

dtolnay
Copy link
Owner

@dtolnay dtolnay commented Oct 20, 2022

Another instance of the same issue as #279, which I missed in that PR...

Repro:

use anyhow::Context;

fn main() -> anyhow::Result<()> {
    let result = None::<()>;
    result.context("...")
}

Before:

0: anyhow::context::<impl anyhow::Context<T,core::convert::Infallible> for core::option::Option<T>>::context::{{closure}}
          at /git/anyhow/src/context.rs:95:57
1: core::option::Option<T>::ok_or_else
          at /rustc/4b8f4319954ff2642690b9e5cbe4af352d095bf6/library/core/src/option.rs:1083:25
2: anyhow::context::<impl anyhow::Context<T,core::convert::Infallible> for core::option::Option<T>>::context
          at /git/anyhow/src/context.rs:95:9
3: testing::main
          at ./src/main.rs:5:5

After:

0: anyhow::context::<impl anyhow::Context<T,core::convert::Infallible> for core::option::Option<T>>::context
          at /git/anyhow/src/context.rs:99:54
1: testing::main
          at ./src/main.rs:5:5

Repro:

    use anyhow::Context;

    fn main() -> anyhow::Result<()> {
        let result = None::<()>;
        result.context("...")
    }

Before:

    0: anyhow::context::<impl anyhow::Context<T,core::convert::Infallible> for core::option::Option<T>>::context::{{closure}}
              at /git/anyhow/src/context.rs:95:57
    1: core::option::Option<T>::ok_or_else
              at /rustc/4b8f4319954ff2642690b9e5cbe4af352d095bf6/library/core/src/option.rs:1083:25
    2: anyhow::context::<impl anyhow::Context<T,core::convert::Infallible> for core::option::Option<T>>::context
              at /git/anyhow/src/context.rs:95:9
    3: testing::main
              at ./src/main.rs:5:5

After:

    0: anyhow::context::<impl anyhow::Context<T,core::convert::Infallible> for core::option::Option<T>>::context
              at /git/anyhow/src/context.rs:99:54
    1: testing::main
              at ./src/main.rs:5:5
@dtolnay dtolnay merged commit 47e902a into master Oct 20, 2022
@dtolnay dtolnay deleted the contextbacktrace branch October 20, 2022 22:25
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.

None yet

1 participant