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

RPITITs don't inherit outlives bounds after >1 layer of nesting #114601

Closed
compiler-errors opened this issue Aug 8, 2023 · 0 comments · Fixed by #114602
Closed

RPITITs don't inherit outlives bounds after >1 layer of nesting #114601

compiler-errors opened this issue Aug 8, 2023 · 0 comments · Fixed by #114602
Assignees
Labels
C-bug Category: This is a bug. F-return_position_impl_trait_in_trait `#![feature(return_position_impl_trait_in_trait)]`

Comments

@compiler-errors
Copy link
Member

I tried this code:

#![feature(return_position_impl_trait_in_trait)]

trait Foo {
    fn early<'a, T: 'a>(x: &'a T) -> impl Iterator<Item = impl Into<&'a T>>;

    fn late<'a, T>(x: &'a T) -> impl Iterator<Item = impl Into<&'a T>>;
}

I expected to see it compile.

Instead, this happened:

error[E0309]: the parameter type `T` may not live long enough
 --> src/lib.rs:4:64
  |
4 |     fn early<'a, T: 'a>(x: &'a T) -> impl Iterator<Item = impl Into<&'a T>>;
  |                                                                ^^^^^^^^^^^ ...so that the reference type `&'a T` does not outlive the data it points at
  |
help: consider adding an explicit lifetime bound...
  |
4 |     fn early<'a, T: 'a + 'a>(x: &'a T) -> impl Iterator<Item = impl Into<&'a T>>;
  |                        ++++

error[E0309]: the parameter type `T` may not live long enough
 --> src/lib.rs:6:59
  |
6 |     fn late<'a, T>(x: &'a T) -> impl Iterator<Item = impl Into<&'a T>>;
  |                                                           ^^^^^^^^^^^ ...so that the reference type `&'a T` does not outlive the data it points at
  |
help: consider adding an explicit lifetime bound...
  |
6 |     fn late<'a, T: 'a>(x: &'a T) -> impl Iterator<Item = impl Into<&'a T>>;
  |                  ++++

#112682 didn't install bidirectional outlives bounds 100% correctly when the lifetimes are being inherited past one layer of impl Trait.

@compiler-errors compiler-errors added C-bug Category: This is a bug. F-return_position_impl_trait_in_trait `#![feature(return_position_impl_trait_in_trait)]` labels Aug 8, 2023
@compiler-errors compiler-errors self-assigned this Aug 8, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 8, 2023
@compiler-errors compiler-errors removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 8, 2023
@bors bors closed this as completed in bf62436 Aug 8, 2023
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. F-return_position_impl_trait_in_trait `#![feature(return_position_impl_trait_in_trait)]`
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants