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

ServiceBuilderExt may not extend ServiceBuilder #515

Closed
mozzenior opened this issue Sep 10, 2024 · 4 comments
Closed

ServiceBuilderExt may not extend ServiceBuilder #515

mozzenior opened this issue Sep 10, 2024 · 4 comments

Comments

@mozzenior
Copy link

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

Bug Report

ServiceBuilderExt may not extend ServiceBuilder

Version

tower = "0.5.1"
tower-http = { version = "0.5.2", features = ["util", "trace"] }

Platform

Linux laptop 6.1.0-25-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.106-3 (2024-08-26) x86_64 GNU/Linux

Description

I tried this code:

use tower::ServiceBuilder;
use tower_http::ServiceBuilderExt;

fn main() {
    ServiceBuilder::new().trace_for_http();
}

I expected to see this happen: Compile succeeds

Instead, this happened:

$ cargo build
   Compiling mytest v0.1.0 (/srv/home/user/temp/mytest)
error[E0599]: no method named `trace_for_http` found for struct `ServiceBuilder` in the current scope
 --> src/main.rs:5:27
  |
5 |     ServiceBuilder::new().trace_for_http();
  |                           ^^^^^^^^^^^^^^ method not found in `ServiceBuilder<Identity>`

warning: unused import: `tower_http::ServiceBuilderExt`
 --> src/main.rs:2:5
  |
2 | use tower_http::ServiceBuilderExt;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

For more information about this error, try `rustc --explain E0599`.
warning: `mytest` (bin "mytest") generated 1 warning
error: could not compile `mytest` (bin "mytest") due to 1 previous error; 1 warning emitted

If tower is manually pinned to 0.4.13 in Cargo.toml, then compile works fine.

I also found ServiceBuilder in tower 0.5.1 removes many cfg_attr from 0.4.13 (source), perhaps Rust considers that a major change so it only applies ServiceBuilderExt to ServiceBuilder in 0.4.x?

@jplatte
Copy link
Collaborator

jplatte commented Sep 10, 2024

Yes, we need to do a new release upgrading tower to 0.5. I'm pretty sure we already have an issue for it.

@mozzenior
Copy link
Author

Oh! I see #503 upgrades tower to 0.5 and the patch is available in the main branch. Thanks for taking a look!

@snaeil
Copy link

snaeil commented Sep 11, 2024

With tower version 0.5.1 and tower_http version 0.5.2 I am also experiencing that ServiceBuilderExt is an unused import.

Later it complains, that there's
no method named set_x_request_id found for struct Service_Builder.

Update: It seems, using the main does not solve the problem for me. ServiceBuilderExt is still an unused import.

@snaeil
Copy link

snaeil commented Sep 29, 2024

I don't have this problem anymore with tower-http 0.6.1 and tower 0.5.1 👍

@jplatte jplatte closed this as completed Sep 29, 2024
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

3 participants