Skip to content

ICE with opaque type #85113

Closed
Closed
@alexkirsz

Description

@alexkirsz

I was playing around with existential types in nightly, forgot to update some code, and hit this ICE.

Code

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=3794cac3bdc24912ee114d8991502058

#![feature(min_type_alias_impl_trait)]
#![feature(impl_trait_in_bindings)]

type OpaqueOutputImpl<'a> = impl Output<'a> + 'a;

trait Output<'a> {}

impl<'a> Output<'a> for &'a str {}

fn cool_fn<'a>(arg: &'a str) -> OpaqueOutputImpl<'a> {
    let out: OpaqueOutputImpl<'a> = arg;
    arg // This was supposed to be `out`
}

fn main() {
    let s = String::from("wassup");
    cool_fn(&s);
}

Meta

rustc --version --verbose:

rustc 1.54.0-nightly (881c1ac40 2021-05-08) running on x86_64-unknown-linux-gnu

Error output

error: internal compiler error: member constraint for `DefId(0:5 ~ playground[b426]::OpaqueOutputImpl::{opaque#0})` has an option region `'_#7r` that is not a universal region
  --> src/main.rs:11:37
   |
11 |     let out: OpaqueOutputImpl<'a> = arg;
   |                                     ^^^
   |
   = note: delayed at compiler/rustc_mir/src/borrow_check/region_infer/mod.rs:697:22

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1019:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

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

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.54.0-nightly (881c1ac40 2021-05-08) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2 --crate-type bin

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: could not compile `playground`

To learn more, run the command again with --verbose.
Backtrace

error: internal compiler error: member constraint for `DefId(0:5 ~ playground[b426]::OpaqueOutputImpl::{opaque#0})` has an option region `'_#7r` that is not a universal region
  --> src/main.rs:11:37
   |
11 |     let out: OpaqueOutputImpl<'a> = arg;
   |                                     ^^^
   |
   = note: delayed at compiler/rustc_mir/src/borrow_check/region_infer/mod.rs:697:22

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1019:13
stack backtrace:
   0: rust_begin_unwind
             at /rustc/881c1ac408d93bb7adaa3a51dabab9266e82eee8/library/std/src/panicking.rs:493:5
   1: std::panicking::begin_panic_fmt
             at /rustc/881c1ac408d93bb7adaa3a51dabab9266e82eee8/library/std/src/panicking.rs:435:5
   2: rustc_errors::HandlerInner::flush_delayed
   3: <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop
   4: core::ptr::drop_in_place<rustc_session::parse::ParseSess>
   5: <alloc::rc::Rc<T> as core::ops::drop::Drop>::drop
   6: core::ptr::drop_in_place<rustc_interface::interface::Compiler>
   7: rustc_span::with_source_map
   8: rustc_interface::interface::create_compiler_and_run
   9: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.F-impl_trait_in_bindings`#![feature(impl_trait_in_bindings)]`F-type_alias_impl_trait`#[feature(type_alias_impl_trait)]`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.glacierICE tracked in rust-lang/glacier.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions