Skip to content

ICE: opaque type with non-universal region args #111906

Closed
@lcnr

Description

@lcnr

all of the following examples result in the same ICE and should imo all be added as test cases once this is fixed:

this one should pass

fn foo<'a: 'a>() -> impl Sized {
    let _: () = foo::<'a>();
    loop {}
}

this one should error afaik

fn foo<'a: 'a>() -> impl Sized {
    let _: *mut &'a () = foo::<'a>();
    loop {}
}

this one should pass

fn foo<'a: 'a>() -> impl Sized + 'a {
    let _: *mut &'a () = foo::<'a>();
    loop {}
}

this one should error

trait Trait<'a, 'b> {}
impl<'a, 'b, T> Trait<'a, 'b> for T {}

fn foo<'a: 'a, 'b: 'b>() -> impl Trait<'a, 'b> {
    let _: *mut &'a () = foo::<'a, 'b>();
    let _: *mut &'b () = foo::<'a, 'b>();
    loop {}
}

they all ICE with

rror: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: opaque type with non-universal region substs
 --> src/lib.rs:2:12
  |
2 |     let _: () = foo::<'a>();
  |            ^^
  |
  = note: delayed at compiler/rustc_borrowck/src/region_infer/opaque_types.rs:94:35

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) ❄️P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions