matze / wastebin

wastebin is a pastebin
MIT License
250 stars 25 forks source link

Compiling errors: error[E0277]: the trait bound... #40

Closed yonas closed 6 months ago

yonas commented 7 months ago
   Compiling rusqlite_migration v1.1.0 (https://github.com/cljoly/rusqlite_migration?rev=dff7b6ba305d0d5b334c40fde72a88e28984242a#dff7b6ba)
   Compiling wastebin v2.4.2 (/home/yonas/.cargo/git/checkouts/wastebin-881bf3cc3acc814d/fff2b13)
error[E0277]: the trait bound `Compression<tower_http::trace::Trace<tower_http::timeout::Timeout<Route>, SharedClassifier<ServerErrorsAsFailures>>>: Service<axum::http::Request<_>>` is not satisfied
  --> src/main.rs:44:43
   |
44 |     Router::new().merge(routes::routes()).layer(
   |                                           ^^^^^ the trait `Service<axum::http::Request<_>>` is not implemented for `Compression<tower_http::trace::Trace<tower_http::timeout::Timeout<Route>, SharedClassifier<ServerErrorsAsFailures>>>`
   |
   = help: the trait `Service<http::request::Request<ReqBody>>` is implemented for `Compression<S, P>`
   = note: required for `axum_core::extract::default_body_limit::private::DefaultBodyLimitService<Compression<tower_http::trace::Trace<tower_http::timeout::Timeout<Route>, SharedClassifier<ServerErrorsAsFailures>>>>` to implement `Service<axum::http::Request<_>>`

error[E0277]: the trait bound `Compression<tower_http::trace::Trace<tower_http::timeout::Timeout<Route>, SharedClassifier<ServerErrorsAsFailures>>>: Service<axum::http::Request<_>>` is not satisfied
   --> src/main.rs:45:9
    |
44  |       Router::new().merge(routes::routes()).layer(
    |                                             ----- required by a bound introduced by this call
45  | /         ServiceBuilder::new()
46  | |             .layer(DefaultBodyLimit::max(max_body_size))
47  | |             .layer(DefaultBodyLimit::disable())
48  | |             .layer(CompressionLayer::new())
49  | |             .layer(TraceLayer::new_for_http())
50  | |             .layer(TimeoutLayer::new(timeout)),
    | |______________________________________________^ the trait `Service<axum::http::Request<_>>` is not implemented for `Compression<tower_http::trace::Trace<tower_http::timeout::Timeout<Route>, SharedClassifier<ServerErrorsAsFailures>>>`
    |
    = help: the trait `Service<http::request::Request<ReqBody>>` is implemented for `Compression<S, P>`
    = note: required for `axum_core::extract::default_body_limit::private::DefaultBodyLimitService<Compression<tower_http::trace::Trace<tower_http::timeout::Timeout<Route>, SharedClassifier<ServerErrorsAsFailures>>>>` to implement `Service<axum::http::Request<_>>`
    = note: 1 redundant requirement hidden
    = note: required for `DefaultBodyLimitService<DefaultBodyLimitService<Compression<Trace<Timeout<Route>, SharedClassifier<ServerErrorsAsFailures>>>>>` to implement `Service<axum::http::Request<_>>`
    = note: the full type name has been written to '/tmp/cargo-installuH09C3/release/deps/wastebin-12b14d5f94a91f94.long-type-12565228264898541124.txt'
note: required by a bound in `Router::<S, B>::layer`
   --> /home/yonas/.cargo/registry/src/index.crates.io-6f17d22bba15001f/axum-0.6.20/src/routing/mod.rs:236:21
    |
233 |     pub fn layer<L, NewReqBody>(self, layer: L) -> Router<S, NewReqBody>
    |            ----- required by a bound in this associated function
...
236 |         L::Service: Service<Request<NewReqBody>> + Clone + Send + 'static,
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Router::<S, B>::layer`

For more information about this error, try `rustc --explain E0277`.

wastebin: fff2b13 FreeBSD 14.0-RELEASE

yonas commented 7 months ago

This error doesn't appear for v2.4.2:

$ git checkout tags/2.4.2
$ cargo build --release
...
   Compiling wastebin v2.4.1 (/memfs/git/wastebin)
    Finished release [optimized] target(s) in 4m 30s
matze commented 7 months ago

Strange, what's your rustc version?

yonas commented 7 months ago

@matze rustc 1.75.0-nightly (e0d7ed1f4 2023-10-01)

matze commented 7 months ago

I cannot reproduce the issue with neither rustc 1.75.0-beta.3 (b66b7951b 2023-11-20) nor rustc 1.76.0-nightly (a1a37735c 2023-11-23). Does it happen with a newer nightly or stable for you?

yonas commented 7 months ago

@matze I don't think I can get a newer version yet. Are you on FreeBSD 14.0-RELEASE as well?

matze commented 7 months ago

Nope, I am on Linux. And it's weird, I was trying to install your version but it does not seem to exist:

$ rustup install nightly-2023-10-01
info: syncing channel updates for 'nightly-2023-10-01-x86_64-unknown-linux-gnu'
info: latest update on 2023-10-01, rust version 1.74.0-nightly (ca62d2c44 2023-09-30)
matze commented 7 months ago

Could you test current master? I moved to axum 0.7 and hyper 1.0, perhaps it changes anything for you.

yonas commented 6 months ago

@matze It works, thanks! :tada: