Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Breaking error when upgrading Hyper from 0.14.X to 1.X.X #2617

Closed
1 task done
CaliViking opened this issue Feb 26, 2024 · 0 comments
Closed
1 task done

Breaking error when upgrading Hyper from 0.14.X to 1.X.X #2617

CaliViking opened this issue Feb 26, 2024 · 0 comments

Comments

@CaliViking
Copy link

CaliViking commented Feb 26, 2024

  • I have looked for existing issues (including closed) about this

Bug Report

Version

├── axum v0.7.4
│   ├── axum-core v0.4.3

Platform

Linux DESKTOP-GU276AE 5.15.133.1-microsoft-standard-WSL2 #1 SMP Thu Oct 5 21:02:42 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

Crates

│ ├── hyper v1.1.0

Description

Short summary of the bug

I get a breaking error when upgrading from Hyper 0.14 to 1.X. I have followed the Hyper upgrade recommendations found here: https://hyper.rs/guides/1/upgrading/#:~:text=Prepare%20with%20Backports%20and%20Deprecations.%20Before%20upgrading%2C,enabling%20the%20backports%20and%20deprecated%20features%20of

Error message

Here is the error when using Hyper 1.0.0, I have also tried 1.1.0 with the same results:

error[E0277]: the trait bound `fn(std::option::Option<Query<Pagination>>, axum::extract::State<Arc<std::sync::Mutex<TagDictionary>>>) -> impl futures_util::Future<Output = Result<impl IntoResponse, hyper::StatusCode>> {adv::tags::get_tags}: Handler<_, _, _>` is not satisfied
   --> server/src/http_server/routes/api/v1/adv/tags/mod.rs:22:25
    |
22  |         .route("/", get(get_tags))
    |                     --- ^^^^^^^^ the trait `Handler<_, _, _>` is not implemented for fn item `fn(Option<Query<Pagination>>, State<Arc<Mutex<TagDictionary>>>) -> impl Future<Output = ...> {get_tags}`
    |                     |
    |                     required by a bound introduced by this call
    |
    = help: the following other types implement trait `Handler<T, S, B>`:
              <Layered<L, H, T, S, B, B2> as Handler<T, S, B2>>
              <MethodRouter<S, B> as Handler<(), S, B>>
note: required by a bound in `axum::routing::get`
   --> /home/niels/.cargo/registry/src/index.crates.io-6f17d22bba15001f/axum-0.6.18/src/routing/method_routing.rs:403:1
    |
403 | top_level_handler_fn!(get, GET);
    | ^^^^^^^^^^^^^^^^^^^^^^---^^^^^^
    | |                     |
    | |                     required by a bound in this function
    | required by this bound in `get`
    = note: this error originates in the macro `top_level_handler_fn` (in Nightly builds, run with -Z macro-backtrace for more info)

I tried this code:

Here is my code (it is simplified to just cause the issue to happen once):

pub fn routes(tag_dictionary_ref: Arc<Mutex<TagDictionary>>) -> Router {
    let router = Router::new()
        .route("/", get(get_tags))
        .with_state(tag_dictionary_ref);

    router
}

Here is the function that is called:

async fn get_tags(
    pagination: Option<Query<Pagination>>,
    State(tag_dictionary_ref): State<Arc<Mutex<TagDictionary>>>,
) -> Result<impl IntoResponse, StatusCode> {
    let Query(pagination) = pagination.unwrap_or_default();
    let limit = pagination.limit.unwrap_or(100);
    let offset = pagination.offset;
    let order = pagination.order;
    let after_tag_name = pagination.after_tag_name;

    let tag_definitions: Vec<TagDefinition> = utilities::get_tag_definition_list(tag_dictionary_ref, order, offset, after_tag_name, limit)?;

    Ok(Json(tag_definitions))
}

I have tried asking GitHub Copilot, but there is nothing that seems to make sense.

I have posted the question on Discord as well, but prefer this as the response channel.

This works (but it is not what I would like)

The issue disappears when using Hyper 0.14.28

What am I doing wrong?

Thanks in advance,
Niels

@tokio-rs tokio-rs locked and limited conversation to collaborators Feb 26, 2024
@jplatte jplatte converted this issue into discussion #2618 Feb 26, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant