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

Comments

Projects
None yet
4 participants
@leonardo-m
Copy link

leonardo-m commented Dec 3, 2017

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

This comment has been minimized.

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.

@cramertj

This comment has been minimized.

Copy link
Member

cramertj commented Dec 14, 2017

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

@cramertj

This comment has been minimized.

Copy link
Member

cramertj commented Dec 14, 2017

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 Dec 15, 2017

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