Skip to content

[ICE] with underscore_lifetimes #46468

Closed
Closed
@leonardo-m

Description

@leonardo-m

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
   ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions