Skip to content

generic OpaqueCast causes elaborate_drops ICE #116141

Closed
@lcnr

Description

@lcnr
#![feature(type_alias_impl_trait)]

fn foo<T>(x: T) {
    type Opaque<T> = impl Sized;
    let foo: Opaque<T> = (x,);
    let (a,): (T,) = foo;
}

fn main() {
    foo::<u32>(1);
}

this should compile, but results in

error: internal compiler error: /rustc/37390d65636dd67e263753a3c04fbc60dcc4348e/compiler/rustc_mir_dataflow/src/elaborate_drops.rs:880:18: open drop from non-ADT `Alias(Opaque, AliasTy { args: [T/#0], def_id: DefId(0:8 ~ playground[3e18]::foo::Opaque::{opaque#0}) })`
 --> src/main.rs:7:1
  |
7 | }
  | ^

thread 'rustc' panicked at /rustc/37390d65636dd67e263753a3c04fbc60dcc4348e/compiler/rustc_errors/src/lib.rs:995:33:
Box<dyn Any>
stack backtrace:
[..]
  16:     0x7f46f718daa6 - std[9ef313c09c7ea29b]::panicking::begin_panic::<rustc_errors[dd5bc5de006c082c]::ExplicitBug>
  17:     0x7f46f71294fe - <rustc_errors[dd5bc5de006c082c]::HandlerInner>::span_bug::<rustc_span[cf885d34b04bf018]::span_encoding::Span, alloc[2953c23748a9424d]::string::String>
  18:     0x7f46f712938b - <rustc_errors[dd5bc5de006c082c]::Handler>::span_bug::<rustc_span[cf885d34b04bf018]::span_encoding::Span, alloc[2953c23748a9424d]::string::String>
  19:     0x7f46f712d9db - rustc_middle[20d02980dd0ade83]::util::bug::opt_span_bug_fmt::<rustc_span[cf885d34b04bf018]::span_encoding::Span>::{closure#0}
  20:     0x7f46f712da0a - rustc_middle[20d02980dd0ade83]::ty::context::tls::with_opt::<rustc_middle[20d02980dd0ade83]::util::bug::opt_span_bug_fmt<rustc_span[cf885d34b04bf018]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7f46f712d2a8 - rustc_middle[20d02980dd0ade83]::ty::context::tls::with_context_opt::<rustc_middle[20d02980dd0ade83]::ty::context::tls::with_opt<rustc_middle[20d02980dd0ade83]::util::bug::opt_span_bug_fmt<rustc_span[cf885d34b04bf018]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7f46f5b47db4 - rustc_middle[20d02980dd0ade83]::util::bug::span_bug_fmt::<rustc_span[cf885d34b04bf018]::span_encoding::Span>
  23:     0x7f46f50ca08e - <rustc_mir_dataflow[6de55ebf20757579]::elaborate_drops::DropCtxt<rustc_mir_transform[9d1f7c219b7f440d]::elaborate_drops::Elaborator>>::elaborate_drop
  24:     0x7f46f50be1f5 - <rustc_mir_transform[9d1f7c219b7f440d]::elaborate_drops::ElaborateDrops as rustc_middle[20d02980dd0ade83]::mir::MirPass>::run_pass
  25:     0x7f46f4d3c01e - rustc_mir_transform[9d1f7c219b7f440d]::mir_drops_elaborated_and_const_checked
  26:     0x7f46f4d3b32e - rustc_query_impl[fcf800a1a0d95cd]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[fcf800a1a0d95cd]::query_impl::mir_drops_elaborated_and_const_checked::dynamic_query::{closure#2}::{closure#0}, rustc_middle[20d02980dd0ade83]::query::erase::Erased<[u8; 8usize]>>
[..]

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.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.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions