Skip to content

Stack overflow with impl Trait and multiple lifetimes... and a closure. #92833

Closed

Description

@steffahn

Seems to stack overflow (I think it's one... on Linux it does give "segfault", technically, and on Windows it produces "thread 'rustc' has overflowed its stack").

(Current nightly behaves like current stable.)

trait Fn1<T>: Fn(T) -> <Self as Fn1<T>>::Output {
    type Output;
}
impl<F: ?Sized, T, O> Fn1<T> for F where F: Fn(T) -> O {type Output = O;}

trait Trait<'a1, 'a2> {}
impl<S: ?Sized> Trait<'_, '_> for S {}

fn foo<'a>(request: &'a str) -> impl for<'b> Fn1<&'b (), Output = impl Trait<'a, 'b>> {
    move |_: &()| ()
}

(playground)

Haven't tried much to minimize further yet, perhaps this can also be done, somehow, without using a closure? Nevermind, I removed the need for closures now

trait Fn1<T> {
    type Output;
}
impl<T, S: ?Sized> Fn1<T> for S {
    type Output = ();
}

trait Trait<'a> {}
impl<'a, S: ?Sized> Trait<'a> for S {}

fn foo() -> impl for<'b> Fn1<&'b (), Output = impl Trait<'b>> {
    ()
}

The same code used to give various ICEs in older Rust versions, stack overflow seems to be since 1.57. I don't have time to investigate further today.

@rustbot label I-crash, A-impl-trait, A-lifetimes, A-closures, T-compiler
@rustbot label -A-closures


Labeling question: is ICE -> crash a regression?

Activity

  1. added
    C-bug
    on Jan 13, 2022
  2. added
    A-closures
    A-impl-trait
    A-lifetimes
    I-crash
    T-compiler
    on Jan 13, 2022
  3. rustbot commented on Jan 13, 2022

    @rustbot
    Collaborator

    Error: Label ~~A-closures can only be set by Rust team members

    Please let @rust-lang/release know if you're having trouble with this bot.

  4. removed
    A-closures
    on Jan 13, 2022
  5. QuineDot commented on Jan 13, 2022

    @QuineDot

    More minimal:

    trait Trait<'a1, 'a2> {}
    trait WithLifetimeAndAssoc<'x> {
        type Assoc;
    }
    
    fn foo<'a>(request: &'a str) -> impl for<'b> WithLifetimeAndAssoc<'b, Assoc = impl Trait<'a, 'b>> {
        todo!()
    }
    

    Almost surely a dupe of #88236 based on the 1.56 error, and that issue also overflows now.

  6. steffahn commented on Jan 13, 2022

    @steffahn
    MemberAuthor

    Yes, that's a dupe

  7. steffahn commented on Jan 13, 2022

    @steffahn
    MemberAuthor

    I had only searched for I-crash issues :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-impl-traitA-lifetimesC-bugI-crashT-compiler

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions