Skip to content

[ICE] [conservative_impl_trait] escaping regions in predicate #41182

Closed
@crumblingstatue

Description

@crumblingstatue
#![feature(conservative_impl_trait)]

fn split_whitespace(text: &str) -> impl Iterator<Item=&str> {
    fn is_not_empty(s: &&str) -> bool {
        !s.is_empty()
    }
    let is_not_empty: fn(&&str) -> bool = is_not_empty; // coerce to fn pointer

    fn is_whitespace(c: char) -> bool {
        c.is_whitespace()
    }
    let is_whitespace: fn(char) -> bool = is_whitespace; // coerce to fn pointer

    text.split(is_whitespace).filter(is_not_empty)
}
error: internal compiler error: /checkout/src/librustc_typeck/check/mod.rs:1787: escaping regions in predicate Obligation(predicate=Binder(ProjectionPredicate(ProjectionTy { trait_ref: <_ as std::iter::Iterator>, item_name: Item(88) }, &str)),depth=0)
 --> kek.rs:3:36
  |
3 | fn split_whitespace(text: &str) -> impl Iterator<Item=&str> {
  |                                    ^^^^^^^^^^^^^^^^^^^^^^^^

Using explicit lifetimes does not trigger this ICE.

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) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions