Skip to content

ICE: Fields cannot be extern types, unless they are at offset 0 #91827

Closed
@tmiasko

Description

@tmiasko

Code

#![feature(extern_types)]

extern "C" {
    type Content;
}

pub struct List {
    len: usize,
    _opaque: Content,
}

pub fn main() {
    let _len = match Option::<&List>::None {
        Some(a) => a.len,
        None => 0,
    };
}

Meta

rustc 1.59.0-nightly (928783de6 2021-12-11)

Error output

error: internal compiler error: /rustc/928783de663bd855a96f14b2d38c1061603587c6/compiler/rustc_const_eval/src/interpret/eval_context.rs:627:33: Fields cannot be extern types, unless they are at offset 0
  --> a.rs:13:22
   |
13 |     let _len = match Option::<&List>::None {
   |                      ^^^^^^^^^^^^^^^^^^^^^

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/928783de663bd855a96f14b2d38c1061603587c6/compiler/rustc_errors/src/lib.rs:1116:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

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.59.0-nightly (928783de6 2021-12-11) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [optimized_mir] optimizing MIR for `main`
#1 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
error: aborting due to previous error

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)C-bugCategory: This is a bug.F-extern_types`#![feature(extern_types)]`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

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions