Skip to content

NLL type-checking ICEs on closure recursing on impl Trait-returning enclosing function. #54593

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
eddyb opened this issue Sep 26, 2018 · 0 comments
Labels
A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. A-NLL Area: Non-lexical lifetimes (NLL) C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@eddyb
Copy link
Member

eddyb commented Sep 26, 2018

This compiles as expected:

#![feature(nll)]
fn foo() -> impl Copy { || bar(); }
fn bar() -> impl Copy { || foo(); }

This, however, does not, since today (suspecting it's #53542):

#![feature(nll)]
fn foo() -> impl Copy { || foo(); }
fn bar() -> impl Copy { || bar(); }

Each inner closure, because it calls its parent function, causes this ICE: "equate_inputs_and_outputs: impl std::marker::Copy==impl std::marker::Copy failed with NoSolution".
(you only need one of foo or bar, but I left both in for contrast with the first example)

I suspect each impl Copy is instantiated in two different ways, causing inconsistencies.

Originally found through a daily Travis CI build job.

@eddyb eddyb added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-NLL Area: Non-lexical lifetimes (NLL) A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. C-bug Category: This is a bug. labels Sep 26, 2018
@eddyb eddyb changed the title NLL type-checking fails on closure recursing on impl Trait-returning enclosing function. NLL type-checking ICEs on closure recursing on impl Trait-returning enclosing function. Sep 26, 2018
@nikomatsakis nikomatsakis added this to the Edition 2018 RC 2 milestone Sep 26, 2018
bors added a commit that referenced this issue Sep 29, 2018
use closure def-id in returns, but base def-id in locals

The refactorings to  handle `let x: impl Trait`  wound up breaking `impl Trait` in closure return types. I think there are some deeper problems with the code in question, but this a least should make @eddyb's example work.

Fixes #54593

r? @eddyb
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. A-NLL Area: Non-lexical lifetimes (NLL) C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

2 participants