http-rs / http-types

Common types for HTTP operations
https://docs.rs/http-types
Apache License 2.0
200 stars 81 forks source link

backtrace problem on nightly #511

Open sassman opened 1 year ago

sassman commented 1 year ago

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:

https://github.com/http-rs/http-types/blob/6f38b3ea86602a8fa907c135373ff94400e11cd4/src/error.rs#L111-L118

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:

sassman commented 1 year ago

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<>.