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

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

Closed
steffahn opened this issue Jan 13, 2022 · 4 comments
Closed
Labels
A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. A-lifetimes Area: Lifetimes / regions C-bug Category: This is a bug. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@steffahn
Copy link
Member

steffahn commented Jan 13, 2022

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?

@steffahn steffahn added the C-bug Category: This is a bug. label Jan 13, 2022
@rustbot rustbot added A-closures Area: Closures (`|…| { … }`) A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. A-lifetimes Area: Lifetimes / regions I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 13, 2022
@rustbot
Copy link
Collaborator

rustbot commented Jan 13, 2022

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.

@rustbot rustbot removed the A-closures Area: Closures (`|…| { … }`) label Jan 13, 2022
@QuineDot
Copy link

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.

@steffahn
Copy link
Member Author

Yes, that's a dupe

@steffahn
Copy link
Member Author

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
Labels
A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. A-lifetimes Area: Lifetimes / regions C-bug Category: This is a bug. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants