Skip to content

ICE combining universal plus existential impl Trait #46685

Closed
@nikomatsakis

Description

@nikomatsakis

The following program will ICE:

#![feature(conservative_impl_trait)]
#![feature(universal_impl_trait)]

use std::fmt::Debug;

fn foo<'a>(x: &'a impl Debug) -> impl Into<&'a impl Debug> {
    x
}

fn main() { }

The problem derives from the fact that universal impl traits, during HIR lowering, do not generate entries in the hir::Generics structure -- they are synthesized after the fact, in the ty::Generics. This interferes with the resolve_lifetime code, which expects to use the HIR generics to determine the indices of things.

I'm not sure the best fix here. The easiest fix is probably to count the number of universal impl traits and take them into account in resolve_lifetime. The best fix feels like it would be to actually insert the type parameters for universal impl trait instances into hir::Generics.

cc @cramertj @chrisvittal

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.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