Avoid incorrect lifetime suggestion involving sym::anon#148842
Open
estebank wants to merge 1 commit intorust-lang:mainfrom
Open
Avoid incorrect lifetime suggestion involving sym::anon#148842estebank wants to merge 1 commit intorust-lang:mainfrom
sym::anon#148842estebank wants to merge 1 commit intorust-lang:mainfrom
Conversation
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 {
| +++++++++++++
```
Collaborator
|
r? @nnethercote rustbot has assigned @nnethercote. Use |
Member
|
@estebank Hi Triage here, is there anything blocking this PRs implementation? Are you still working on this? |
Contributor
Author
|
@JayanAXHF I need to come up with a minimized repro case that's suitable for the test suite. I could do with an extra hand on that. |
Member
|
Ive added the |
Contributor
|
☔ The latest upstream changes (presumably #152839) made this pull request unmergeable. Please resolve the merge conflicts. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Given
emit
without the incorrect suggestion
Address #142887. Needs a repro test.