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

backtrace problem on nightly #511

Open
sassman opened this issue Sep 29, 2022 · 1 comment
Open

backtrace problem on nightly #511

sassman opened this issue Sep 29, 2022 · 1 comment

Comments

@sassman
Copy link

sassman commented Sep 29, 2022

In a strange constellation I'm running into the following error:

error[E0308]: mismatched types
   --> /Users/I563162/.cargo/registry/src/github.com-1ecc6299db9ec823/http-types-2.12.0/src/error.rs:114:18
    |
114 |             Some(backtrace)
    |             ---- ^^^^^^^^^ expected `&Backtrace`, found enum `std::option::Option`
    |             |
    |             arguments to this enum variant are incorrect
    |
    = note: expected reference `&Backtrace`
                    found enum `std::option::Option<&Backtrace>`

looking at the code:

http-types/src/error.rs

Lines 111 to 118 in 6f38b3e

pub fn backtrace(&self) -> Option<&std::backtrace::Backtrace> {
let backtrace = self.error.backtrace();
if let std::backtrace::BacktraceStatus::Captured = backtrace.status() {
Some(backtrace)
} else {
None
}
}

I see no change in over 2 years. Also on the anyhow crate (self.error is of type anyhow::Error) I cannot see any change on the backtrace() method.

However a fix like this would solve the problem:

- let backtrace = self.error.backtrace();
+ let backtrace = self.error.backtrace()?;

Things I've used:

  • depdency tree to http-types:
    http-types v2.12.0
    ├── async-h1 v2.3.3
    │   └── tide v0.16.0
    
  • http-types version 2.12.0
  • anyhow version 1.0.65
  • rust version
    cargo --version && rustc --version
    cargo 1.63.0-nightly (38472bc19 2022-05-31)
    rustc 1.63.0-nightly (5435ed691 2022-06-07)
@sassman
Copy link
Author

sassman commented Sep 30, 2022

it turns out that versions of anyhow < 1.0.39 don't have that problem, because there the return type is &Backtrace. Newer versions wrap this with Option<>.

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

No branches or pull requests

1 participant