Skip to content

maybe regression related to GATs #105878

Open
@phynalle

Description

@phynalle

Code

I tried this code:

trait Foo {
    type Gat<'a> where Self: 'a;
    fn bar(&self) -> Self::Gat<'_>;
}

impl<T: Foo> Foo for Option<T> {
    type Gat<'a> = Option<<T as Foo>::Gat<'a>> where Self: 'a;
    fn bar(&self) -> Self::Gat<'_> {
        self.as_ref().map(Foo::bar)
    }
}

Version it worked on

The code is compiled on Rust 1.65

Version with regression

The code is not compiled on current stable(1.66), beta, and nightly with error:

error: `T` does not live long enough
 --> src/lib.rs:9:9
  |
9 |         self.as_ref().map(Foo::bar)
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: could not compile `playground` due to previous error

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-GATsArea: Generic associated types (GATs)A-borrow-checkerArea: The borrow checkerC-bugCategory: This is a bug.P-highHigh priorityT-typesRelevant to the types team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions