-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Rust 1.66 broke warp impl Reply on return types #107729
Comments
searched nightlies: from nightly-2022-10-01 to nightly-2023-01-01 bisected with cargo-bisect-rustc v0.6.5Host triple: x86_64-unknown-linux-gnu cargo bisect-rustc 2022-10-01 --end 2023-01-01 The lint was introduced in #102568 |
Hey, yeah so I authored that warning. Sorry that it's so vague. So the gist is that The suggestion kinda sucks, because yeah, cc @oli-obk, maybe you have additional or different thoughts about this lint. |
Hmm, why should code like this be rejected? The caller knows that the opaque type meets the bounds because the bound is on the associated type in the first place (and the function compiles, so whatever type it used there must meet the bound). If anything it's weird that the equivalent |
It makes sense from inside the body of the function, but from the outside it is a bit weird: |
WG-prioritization assigning priority (Zulip discussion). @rustbot label -I-prioritize +P-medium |
I encountered this warning. Everything seems to be working, but I want to fix the warning. Could someone explain how to fix this, as if I've only used Rust for a week and this is happening in the first real program I write in it? |
You can replace |
Indeed that gets rid of the warning. Thanks! I would not have guessed this solution. |
May I ask why this warning is desirable? Let's say I have a function like fn svc() -> impl Service<Request<Body>, Response = Response<Body>, Error = Error, Future = impl Send> {
// ...
} This warning prefers this as: fn svc() -> impl Service<Request<Body>, Response = Response<Body>, Error = Error, Future = impl Future<Output = Result<Response<Body>, Error>> + Send> {
// ...
} This feels like needless boilerplate in our application -- it's obvious that the |
Actually, what I wrote above is not correct. We are apparently unable to satisfy the proper Future bounds? See @hawkw's comment on linkerd/linkerd2-proxy#2275:
|
Currently, our nightly builds are failing due to the new warning `opaque_hidden_inferred_bound`, which triggers when an opaque type (`impl Trait`) in an associated type position does not explicitly include the associated type's trait bounds (e.g. returning a `Service<Future = impl Send, ...>`) or similar. Unfortunately, we cannot simply change our code to make the trait bound's type explicit, as changing `impl Send` to `impl Future<...> + Send` in this position results in a surprising error which I don't think is correct: ``` error[E0277]: `impl std::marker::Send` is not a future --> linkerd/app/outbound/src/http/logical.rs:97:30 | 97 | Future = impl Future<Output = Result<http::Response<http::BoxBody>, Error>> + Send, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `impl std::marker::Send` is not a future | = help: the trait `futures::Future` is not implemented for `impl std::marker::Send` = note: impl std::marker::Send must be a future or must implement `IntoFuture` to be awaited = note: required for `stack::map_err::ResponseFuture<(), impl std::marker::Send>` to implement `futures::Future` For more information about this error, try `rustc --explain E0277`. ``` See #2268 (comment) as well as the upstream Rust issue rust-lang/rust#107729, for details. This should probably be reported on the Rust issue tracker, since a warning that's (apparently) impossible to fix seems not great. However, for now, we can simply allow this warning for our nightly builds. This should fix CI.
added controllers and routers to access login and registration mocks; fixed the warn on "impl Reply" [rust-lang/rust#107729];
fixed the warn on "impl Reply" [rust-lang/rust#107729];
commit 50a2682 Author: Rogerio Oliveira <roliveira@cyclomedia.com> Date: Tue Apr 11 00:24:02 2023 +0200 removed some pub modifiers from internal functions; fixed the warn on "impl Reply" [rust-lang/rust#107729]; Changes to be committed: modified: mock-server/src/lib.rs modified: src/lib.rs modified: src/routes/authentication.rs
commit d4ffc0e Author: Rogerio Oliveira <roliveira@cyclomedia.com> Date: Tue Apr 11 12:36:06 2023 +0200 removed associated function to create an account; commit 929ece9 Author: Rogerio Oliveira <roliveira@cyclomedia.com> Date: Tue Apr 11 00:16:31 2023 +0200 added mvc structure (only controllers and routers); added controllers and routers to access login and registration mocks; fixed the warn on "impl Reply" [rust-lang/rust#107729]; Changes to be committed: modified: Cargo.lock modified: Cargo.toml new file: src/controllers/authentication/login.rs new file: src/controllers/authentication/mod.rs new file: src/controllers/authentication/registration.rs new file: src/controllers/mod.rs modified: src/lib.rs new file: src/models/account.rs new file: src/models/mod.rs new file: src/routes/authentication.rs new file: src/routes/mod.rs
commit d4ffc0e Author: Rogerio Oliveira <roliveira@cyclomedia.com> Date: Tue Apr 11 12:36:06 2023 +0200 removed associated function to create an account; commit 929ece9 Author: Rogerio Oliveira <roliveira@cyclomedia.com> Date: Tue Apr 11 00:16:31 2023 +0200 added mvc structure (only controllers and routers); added controllers and routers to access login and registration mocks; fixed the warn on "impl Reply" [rust-lang/rust#107729]; Changes to be committed: modified: Cargo.lock modified: Cargo.toml new file: src/controllers/authentication/login.rs new file: src/controllers/authentication/mod.rs new file: src/controllers/authentication/registration.rs new file: src/controllers/mod.rs modified: src/lib.rs new file: src/models/account.rs new file: src/models/mod.rs new file: src/routes/authentication.rs new file: src/routes/mod.rs
added controllers and routers to access login and registration mocks; fixed the warn on "impl Reply" [rust-lang/rust#107729];
commit 50a2682 Author: Rogerio Oliveira <roliveira@cyclomedia.com> Date: Tue Apr 11 00:24:02 2023 +0200 removed some pub modifiers from internal functions; fixed the warn on "impl Reply" [rust-lang/rust#107729]; Changes to be committed: modified: mock-server/src/lib.rs modified: src/lib.rs modified: src/routes/authentication.rs
fixed the warn on "impl Reply" [rust-lang/rust#107729];
Hi there,
we just noticed on
warp
CI that one of the examples was broken (we have#![deny(warnings)]
for the examples). The output is as follows:It seems to have been introduced with Rust version
1.66
as with1.65
the example compiles fine. I also tried with the latest nightly (cargo 1.69.0-nightly (e84a7928d 2023-01-31)
) which still reproduces the problem. This feels like a bug as it being a warning doesn't provide help, btwwarp::generic::Tuple
is private.The
todos
example should work as a MRE, but if required I can try to provide a simpler use case.Thanks!
The text was updated successfully, but these errors were encountered: