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

[ICE] with underscore_lifetimes #46468

Closed
leonardo-m opened this issue Dec 3, 2017 · 3 comments
Closed

[ICE] with underscore_lifetimes #46468

leonardo-m opened this issue Dec 3, 2017 · 3 comments
Labels
A-impl-trait Area: impl Trait. Universally / existentially quantified anonymous types with static dispatch. C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@leonardo-m
Copy link

This compiles with no errors:

#![feature(conservative_impl_trait, in_band_lifetimes, underscore_lifetimes)]
fn foo<T>(items: &'a [T]) -> impl Iterator<Item=(&'a T, &'a T)> + 'a {
    items
    .iter()
    .enumerate()
    .flat_map(move |(i, x1)| items[i ..].iter().map(move |x2| (x1, x2)))
}
fn main() {}

If I replace 'a with '_:

#![feature(conservative_impl_trait, underscore_lifetimes)]
fn foo<T>(items: &'_ [T]) -> impl Iterator<Item=(&'_ T, &'_ T)> + '_ {
    items
    .iter()
    .enumerate()
    .flat_map(move |(i, x1)| items[i ..].iter().map(move |x2| (x1, x2)))
}
fn main() {}

The last Nightly ICEs:

error: internal compiler error: src\librustc_typeck\check\mod.rs:671: escaping regions in predicate Obligation(predicate=Binder(OutlivesPredicate(_, ReLateBound(DebruijnIndex { depth: 3 }, BrAnon(0)))),depth=0)
 --> ...\test.rs:2:30
  |
2 | fn foo<T>(items: &'_ [T]) -> impl Iterator<Item=(&'_ T, &'_ T)> + '_ {
  |                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

note: rustc 1.24.0-nightly (f9b0897c5 2017-12-02) running on x86_64-pc-windows-gnu

thread 'rustc' panicked at 'Box<Any>', src\librustc_errors\lib.rs:448:8
stack backtrace:
   0: mingw_set_invalid_parameter_handler
   ...

@cramertj
Copy link
Member

cramertj commented Dec 3, 2017

This isn't an issue with underscore lifetimes-- it's still the same issue with elided lifetimes not being supported in impl Trait return types.

@TimNN TimNN added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-impl-trait Area: impl Trait. Universally / existentially quantified anonymous types with static dispatch. labels Dec 5, 2017
@cramertj
Copy link
Member

cramertj commented Dec 14, 2017

This was fixed in #46616 and now compiles on nightly.

@cramertj
Copy link
Member

The version using implicit elision also compiles:

fn foo<T>(items: &[T]) -> impl Iterator<Item=(&T, &T)> {
    items
    .iter()
    .enumerate()
    .flat_map(move |(i, x1)| items[i ..].iter().map(move |x2| (x1, x2)))
}

@arielb1 arielb1 closed this as completed Dec 15, 2017
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. 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

4 participants