Skip to content

ICE with impl_trait #43073

@leonardo-m

Description

@leonardo-m

This little program:

#![feature(conservative_impl_trait)]

fn suffixes(txt: &str) -> impl Iterator<Item=&str> {
    txt.char_indices().skip(1).map(|&(j, _)| &txt[j ..])
}
fn main() {}

Generates:

error: internal compiler error: src\librustc_typeck\check\mod.rs:617: escaping regions in predicate Obligation(predicate=Binder(ProjectionPredicate(ProjectionTy { trait_ref: <_ as std::iter::Iterator>, item_def_id: DefId { krate: CrateNum(2), node: DefIndex(1577) => core/a635d0d::iter[0]::iterator[0]::Iterator[0]::Item[0] } }, &str)),depth=0)
 --> test.rs:3:27
  |
3 | fn suffixes(txt: &str) -> impl Iterator<Item=&str> {
  |                           ^^^^^^^^^^^^^^^^^^^^^^^^

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.20.0-nightly (2fbba5bdb 2017-07-04) running on x86_64-pc-windows-gnu

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