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

New higher-ranked lifetime error #105501

Closed
khuey opened this issue Dec 9, 2022 · 1 comment · Fixed by #105915
Closed

New higher-ranked lifetime error #105501

khuey opened this issue Dec 9, 2022 · 1 comment · Fixed by #105915
Labels
C-bug Category: This is a bug. P-critical Critical priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly.

Comments

@khuey
Copy link
Contributor

khuey commented Dec 9, 2022

error: higher-ranked lifetime error
   --> lobby-server/src/auth/github.rs:340:9
    |
340 | /         Box::pin(async move {
341 | |             let gh = this
342 | |                 .http
343 | |                 .request(req)
...   |
468 | |             }
469 | |         })
    | |__________^
    |
    = note: could not prove `std::pin::Pin<Box<[async block@lobby-server/src/auth/github.rs:340:18: 469:10]>>: CoerceUnsized<std::pin::Pin<Box<(dyn futures::Future<Output = std::result::Result<(auth::AuthenticationData, http::response::Builder), http::response::Builder>> + std::marker::Send + 'c)>>>`

error: higher-ranked lifetime error
   --> lobby-server/src/lib.rs:568:33
    |
568 | ...                   tokio::spawn(f);
    |                       ^^^^^^^^^^^^^^^
    |
    = note: could not prove `futures::future::MapErr<TryForEach<impl futures::Stream<Item = std::result::Result<logger::LoggerMessage, errors::Error>>, [async block@lobby-server/src/lib.rs:562:41: 565:42], [closure@lobby-server/src/lib.rs:560:51: 560:69]>, [closure@lobby-server/src/lib.rs:567:46: 567:49]>: std::marker::Send`

The code here is part of a closed-source project unfortunately. I could share relevant bits and pieces upon request but I can't provide the whole thing for others to build.

cargo bisect-rustc blames b28d30e

@khuey
Copy link
Contributor Author

khuey commented Dec 9, 2022

Reverting #105250 on top of e10201c fixes this.

@tmandry tmandry added regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. P-critical Critical priority labels Dec 20, 2022
@bors bors closed this as completed in 575b2a2 Dec 20, 2022
Swatinem added a commit to Swatinem/rust that referenced this issue Dec 30, 2022
The test was minified from the published `msf-ice:0.2.1` crate which failed in a crater run.

A faulty compiler was triggering a `higher-ranked lifetime error`:

> could not prove `[async block@...]: Send`
bors added a commit to rust-lang-ci/rust that referenced this issue Dec 30, 2022
… r=petrochenkov

Add regression test for rust-lang#105501

The test was minified from the published crate `msf-ice:0.2.1` which failed in a crater run.

A faulty compiler was triggering a `higher-ranked lifetime error`:
> could not prove `[async block@...]: Send`

The testcase has some complexity, as it has a simplified subset of `futures::StreamExt` in it, but the error is only being triggered by a few layers of nesting. For example removing the noop `then` call would have been enough to make the error go away.
Swatinem added a commit to Swatinem/rust that referenced this issue Jan 17, 2023
- Eliminates all the `get_context` calls that async lowering created.
- Replace all `Local` `ResumeTy` types with `&mut Context<'_>`.

The `Local`s that have their types replaced are:
- The `resume` argument itself.
- The argument to `get_context`.
- The yielded value of a `yield`.

The `ResumeTy` hides a `&mut Context<'_>` behind an unsafe raw pointer, and the
`get_context` function is being used to convert that back to a `&mut Context<'_>`.

Ideally the async lowering would not use the `ResumeTy`/`get_context` indirection,
but rather directly use `&mut Context<'_>`, however that would currently
lead to higher-kinded lifetime errors.
See <rust-lang#105501>.

The async lowering step and the type / lifetime inference / checking are
still using the `ResumeTy` indirection for the time being, and that indirection
is removed here. After this transform, the generator body only knows about `&mut Context<'_>`.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 18, 2023
Transform async `ResumeTy` in generator transform

- Eliminates all the `get_context` calls that async lowering created.
- Replace all `Local` `ResumeTy` types with `&mut Context<'_>`.

The `Local`s that have their types replaced are:
- The `resume` argument itself.
- The argument to `get_context`.
- The yielded value of a `yield`.

The `ResumeTy` hides a `&mut Context<'_>` behind an unsafe raw pointer, and the `get_context` function is being used to convert that back to a `&mut Context<'_>`.

Ideally the async lowering would not use the `ResumeTy`/`get_context` indirection, but rather directly use `&mut Context<'_>`, however that would currently lead to higher-kinded lifetime errors.
See <rust-lang#105501>.

The async lowering step and the type / lifetime inference / checking are still using the `ResumeTy` indirection for the time being, and that indirection is removed here. After this transform, the generator body only knows about `&mut Context<'_>`.

---

Fixes https://github.com/bjorn3/rustc_codegen_cranelift/issues/1330 CC `@bjorn3`

r? `@compiler-errors`
Swatinem added a commit to Swatinem/rust that referenced this issue Jan 19, 2023
- Eliminates all the `get_context` calls that async lowering created.
- Replace all `Local` `ResumeTy` types with `&mut Context<'_>`.

The `Local`s that have their types replaced are:
- The `resume` argument itself.
- The argument to `get_context`.
- The yielded value of a `yield`.

The `ResumeTy` hides a `&mut Context<'_>` behind an unsafe raw pointer, and the
`get_context` function is being used to convert that back to a `&mut Context<'_>`.

Ideally the async lowering would not use the `ResumeTy`/`get_context` indirection,
but rather directly use `&mut Context<'_>`, however that would currently
lead to higher-kinded lifetime errors.
See <rust-lang#105501>.

The async lowering step and the type / lifetime inference / checking are
still using the `ResumeTy` indirection for the time being, and that indirection
is removed here. After this transform, the generator body only knows about `&mut Context<'_>`.
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Jan 19, 2023
Transform async `ResumeTy` in generator transform

- Eliminates all the `get_context` calls that async lowering created.
- Replace all `Local` `ResumeTy` types with `&mut Context<'_>`.

The `Local`s that have their types replaced are:
- The `resume` argument itself.
- The argument to `get_context`.
- The yielded value of a `yield`.

The `ResumeTy` hides a `&mut Context<'_>` behind an unsafe raw pointer, and the `get_context` function is being used to convert that back to a `&mut Context<'_>`.

Ideally the async lowering would not use the `ResumeTy`/`get_context` indirection, but rather directly use `&mut Context<'_>`, however that would currently lead to higher-kinded lifetime errors.
See <rust-lang#105501>.

The async lowering step and the type / lifetime inference / checking are still using the `ResumeTy` indirection for the time being, and that indirection is removed here. After this transform, the generator body only knows about `&mut Context<'_>`.

---

Fixes https://github.com/bjorn3/rustc_codegen_cranelift/issues/1330 CC `@bjorn3`

r? `@compiler-errors`
thomcc pushed a commit to tcdi/postgrestd that referenced this issue May 31, 2023
- Eliminates all the `get_context` calls that async lowering created.
- Replace all `Local` `ResumeTy` types with `&mut Context<'_>`.

The `Local`s that have their types replaced are:
- The `resume` argument itself.
- The argument to `get_context`.
- The yielded value of a `yield`.

The `ResumeTy` hides a `&mut Context<'_>` behind an unsafe raw pointer, and the
`get_context` function is being used to convert that back to a `&mut Context<'_>`.

Ideally the async lowering would not use the `ResumeTy`/`get_context` indirection,
but rather directly use `&mut Context<'_>`, however that would currently
lead to higher-kinded lifetime errors.
See <rust-lang/rust#105501>.

The async lowering step and the type / lifetime inference / checking are
still using the `ResumeTy` indirection for the time being, and that indirection
is removed here. After this transform, the generator body only knows about `&mut Context<'_>`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. P-critical Critical priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants