Skip to content

Conversation

@estebank
Copy link
Contributor

@estebank estebank commented Nov 11, 2025

Given

#!/usr/bin/env -S cargo +nightly -Zscript -q
---
packag.edition = "2024"

[dependencies]
rama = "0.2.0"
---

fn main() {}

struct Foo;

impl<S, Request: 'static> rama::Service<S, Request> for Foo {
    type Response = ();
    type Error = ();

    fn serve(
        &self,
        _ctx: rama::Context<S>,
        _req: Request,
    ) -> impl Future<Output = Result<Self::Response, Self::Error>> {
        async { todo!() }
    }
}

emit

error[E0311]: the parameter type `S` may not live long enough
  --> f20.rs:20:10
   |
20 |     ) -> impl Future<Output = Result<Self::Response, Self::Error>> {
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `impl Future<Output = Result<<Foo as Service<S, Request>>::Response, <Foo as Service<S, Request>>::Error>>` will meet its required lifetime bounds...
   |
  ::: /home/gh-estebank/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rama-core-0.2.0/src/service/svc.rs:19:9
   |
19 |         &self,
   |         - the parameter type `S` must be valid for the anonymous lifetime as defined here...
   |
note: ...that is required by this bound
  --> /home/gh-estebank/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rama-core-0.2.0/src/service/svc.rs:22:77
   |
22 |     ) -> impl Future<Output = Result<Self::Response, Self::Error>> + Send + '_;
   |                                                                             ^^

without the incorrect suggestion

help: consider adding an explicit lifetime bound
   |
22 |     ) -> impl Future<Output = Result<Self::Response, Self::Error>> where S: anon {
   |                                                                    +++++++++++++

Address #142887. Needs a repro test.

Given
```rust
#!/usr/bin/env -S cargo +nightly -Zscript -q
---
packag.edition = "2024"

[dependencies]
rama = "0.2.0"
---

fn main() {}

struct Foo;

impl<S, Request: 'static> rama::Service<S, Request> for Foo {
    type Response = ();
    type Error = ();

    fn serve(
        &self,
        _ctx: rama::Context<S>,
        _req: Request,
    ) -> impl Future<Output = Result<Self::Response, Self::Error>> {
        async { todo!() }
    }
}
```
emit
```
error[E0311]: the parameter type `S` may not live long enough
  --> f20.rs:20:10
   |
20 |     ) -> impl Future<Output = Result<Self::Response, Self::Error>> {
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `impl Future<Output = Result<<Foo as Service<S, Request>>::Response, <Foo as Service<S, Request>>::Error>>` will meet its required lifetime bounds...
   |
  ::: /home/gh-estebank/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rama-core-0.2.0/src/service/svc.rs:19:9
   |
19 |         &self,
   |         - the parameter type `S` must be valid for the anonymous lifetime as defined here...
   |
note: ...that is required by this bound
  --> /home/gh-estebank/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rama-core-0.2.0/src/service/svc.rs:22:77
   |
22 |     ) -> impl Future<Output = Result<Self::Response, Self::Error>> + Send + '_;
   |                                                                             ^^
```

without the incorrect suggestion

```
help: consider adding an explicit lifetime bound
   |
22 |     ) -> impl Future<Output = Result<Self::Response, Self::Error>> where S: anon {
   |                                                                    +++++++++++++
```
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 11, 2025
@rustbot
Copy link
Collaborator

rustbot commented Nov 11, 2025

r? @nnethercote

rustbot has assigned @nnethercote.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Copy link
Contributor

@nnethercote nnethercote left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a repro test.

Yes!

View changes since this review

@nnethercote nnethercote added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants