hyperium / http

Rust HTTP types
Apache License 2.0
1.16k stars 291 forks source link

Update to v0.2.3 cause build error #473

Closed leric closed 3 years ago

leric commented 3 years ago

Update to v0.2.3 cause build error on macos:

error[E0277]: the trait bound `dyn Any + Send + Sync: Clone` is not satisfied
  --> /Users/Leric/.cargo/registry/src/github.com-1ecc6299db9ec823/http-0.2.3/src/extensions.rs:38:5
   |
38 |     map: Option<Box<AnyMap>>,
   |     ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `dyn Any + Send + Sync`
   |
   = note: required because of the requirements on the impl of `Clone` for `Box<dyn Any + Send + Sync>`
   = note: 3 redundant requirements hidden
   = note: required because of the requirements on the impl of `Clone` for `Option<Box<HashMap<TypeId, Box<dyn Any + Send + Sync>, BuildHasherDefault<IdHasher>>>>`
   = note: required by `clone`
   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error

Set version back to v0.2.2 in Cargo.yaml http = "=0.2.2" can fix this for now.

v0.2.3 works fine on Linux.

Env

MacOS 11.2 Rust 1.50.0 hyper 0.14.4 tungstenite 0.13

seanmonstar commented 3 years ago

The extensions were never Clone. Are you sure this problem is with http?

leric commented 3 years ago

It strange, only my local cached code somehow got modified, looks like this:

/// A type map of protocol extensions.
///
/// `Extensions` can be used by `Request` and `Response` to store
/// extra data derived from the underlying protocol.
#[derive(Default, Clone)]
pub struct Extensions {
    // If extensions are never used, no need to carry around an empty HashMap.
    // That's 3 words. Instead, this is only 1 word.
    map: Option<Box<AnyMap>>,
}

Delete the cached folder fixed the problem.

Sorry for bothering.