Skip to content

ICE: unhandled type: {type error} #122191

Closed
@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

type Foo = impl Send;

struct A;

const VALUE: Foo = value();

fn test() {
    match VALUE {
        0 | 0 => {}

        _ => (),
    }
}

original:

#![feature(type_alias_impl_trait)]

type Foo = impl Send;

// This is not structural-match
struct A;

const fn value() -> Foo {
    A
}
const VALUE: Foo = value();

fn test() {
    match VALUE {
        0
            | 0 => {}
        //~^ `Foo` cannot be used in patterns
        _ => (),
    }
}

fn main() { self.f() }

Version information

rustc 1.78.0-nightly (1b2c53a15 2024-03-08)
binary: rustc
commit-hash: 1b2c53a15dba7962cfc284c3b6d61a0341ffa27a
commit-date: 2024-03-08
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 18.1.0

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zvalidate-mir

Program output

error[E0658]: `impl Trait` in type aliases is unstable
 --> /tmp/icemaker_global_tempdir.P292uEtBs2RF/rustc_testrunner_tmpdir_reporting.qNCz5tflPNXt/mvce.rs:1:12
  |
1 | type Foo = impl Send;
  |            ^^^^^^^^^
  |
  = note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
  = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable
  = note: this compiler was built on 2024-03-08; consider upgrading it if it is out of date

error[E0601]: `main` function not found in crate `mvce`
  --> /tmp/icemaker_global_tempdir.P292uEtBs2RF/rustc_testrunner_tmpdir_reporting.qNCz5tflPNXt/mvce.rs:13:2
   |
13 | }
   |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.P292uEtBs2RF/rustc_testrunner_tmpdir_reporting.qNCz5tflPNXt/mvce.rs`

error[E0425]: cannot find function `value` in this scope
 --> /tmp/icemaker_global_tempdir.P292uEtBs2RF/rustc_testrunner_tmpdir_reporting.qNCz5tflPNXt/mvce.rs:5:20
  |
5 | const VALUE: Foo = value();
  |                    ^^^^^ not found in this scope

error: item constrains opaque type that is not in its signature
 --> /tmp/icemaker_global_tempdir.P292uEtBs2RF/rustc_testrunner_tmpdir_reporting.qNCz5tflPNXt/mvce.rs:9:13
  |
9 |         0 | 0 => {}
  |             ^
  |
  = note: this item must mention the opaque type in its signature in order to be able to register hidden types
note: this item must mention the opaque type in its signature in order to be able to register hidden types
 --> /tmp/icemaker_global_tempdir.P292uEtBs2RF/rustc_testrunner_tmpdir_reporting.qNCz5tflPNXt/mvce.rs:7:4
  |
7 | fn test() {
  |    ^^^^

warning: unreachable pattern
 --> /tmp/icemaker_global_tempdir.P292uEtBs2RF/rustc_testrunner_tmpdir_reporting.qNCz5tflPNXt/mvce.rs:9:13
  |
9 |         0 | 0 => {}
  |             ^
  |
  = note: `#[warn(unreachable_patterns)]` on by default

error: internal compiler error: compiler/rustc_const_eval/src/transform/validate.rs:1302:30: unhandled type: {type error}

thread 'rustc' panicked at compiler/rustc_middle/src/util/bug.rs:35:44:
Box<dyn Any>
stack backtrace:
   0:     0x7fdf7f18ca52 - std::backtrace_rs::backtrace::libunwind::trace::hb56c0f78213c8d9f
                               at /rustc/1b2c53a15dba7962cfc284c3b6d61a0341ffa27a/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7fdf7f18ca52 - std::backtrace_rs::backtrace::trace_unsynchronized::hf06d37baed012a8b
                               at /rustc/1b2c53a15dba7962cfc284c3b6d61a0341ffa27a/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fdf7f18ca52 - std::sys_common::backtrace::_print_fmt::hb3319ebb8df50ed8
                               at /rustc/1b2c53a15dba7962cfc284c3b6d61a0341ffa27a/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7fdf7f18ca52 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h803c3eeec75e4f63
                               at /rustc/1b2c53a15dba7962cfc284c3b6d61a0341ffa27a/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7fdf7f1dda5c - core::fmt::rt::Argument::fmt::h94e1da2f5ffac2b0
                               at /rustc/1b2c53a15dba7962cfc284c3b6d61a0341ffa27a/library/core/src/fmt/rt.rs:142:9
   5:     0x7fdf7f1dda5c - core::fmt::write::h187ead52a5135d3b
                               at /rustc/1b2c53a15dba7962cfc284c3b6d61a0341ffa27a/library/core/src/fmt/mod.rs:1153:17
   6:     0x7fdf7f1814cf - std::io::Write::write_fmt::h5d3f9c61f41d2590
                               at /rustc/1b2c53a15dba7962cfc284c3b6d61a0341ffa27a/library/std/src/io/mod.rs:1846:15
   7:     0x7fdf7f18c824 - std::sys_common::backtrace::_print::ha9efa2585b9464f2
                               at /rustc/1b2c53a15dba7962cfc284c3b6d61a0341ffa27a/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7fdf7f18c824 - std::sys_common::backtrace::print::h23c465429e472e6b
                               at /rustc/1b2c53a15dba7962cfc284c3b6d61a0341ffa27a/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7fdf7f18f52b - std::panicking::default_hook::{{closure}}::h984357cf4f22a420
  10:     0x7fdf7f18f287 - std::panicking::default_hook::hf3edc1c39c54e0a3
                               at /rustc/1b2c53a15dba7962cfc284c3b6d61a0341ffa27a/library/std/src/panicking.rs:292:9
  11:     0x7fdf8205c02c - std[6fed0b3d7eb5db8f]::panicking::update_hook::<alloc[c7d5fdcd1c175fc6]::boxed::Box<rustc_driver_impl[205ec082ad015eb1]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7fdf7f18fc90 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h3ef6d0b8345c8bff
                               at /rustc/1b2c53a15dba7962cfc284c3b6d61a0341ffa27a/library/alloc/src/boxed.rs:2030:9
  13:     0x7fdf7f18fc90 - std::panicking::rust_panic_with_hook::h2b299f843211a151
                               at /rustc/1b2c53a15dba7962cfc284c3b6d61a0341ffa27a/library/std/src/panicking.rs:783:13
  14:     0x7fdf82089034 - std[6fed0b3d7eb5db8f]::panicking::begin_panic::<rustc_errors[366873c695d5609e]::ExplicitBug>::{closure#0}
  15:     0x7fdf82085c86 - std[6fed0b3d7eb5db8f]::sys_common::backtrace::__rust_end_short_backtrace::<std[6fed0b3d7eb5db8f]::panicking::begin_panic<rustc_errors[366873c695d5609e]::ExplicitBug>::{closure#0}, !>
  16:     0x7fdf820811b6 - std[6fed0b3d7eb5db8f]::panicking::begin_panic::<rustc_errors[366873c695d5609e]::ExplicitBug>
  17:     0x7fdf820923d1 - <rustc_errors[366873c695d5609e]::diagnostic::BugAbort as rustc_errors[366873c695d5609e]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  18:     0x7fdf8250fb61 - rustc_middle[aecd23319abffe8]::util::bug::opt_span_bug_fmt::<rustc_span[1b87e9fe8fb1a926]::span_encoding::Span>::{closure#0}
  19:     0x7fdf824f33fa - rustc_middle[aecd23319abffe8]::ty::context::tls::with_opt::<rustc_middle[aecd23319abffe8]::util::bug::opt_span_bug_fmt<rustc_span[1b87e9fe8fb1a926]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  20:     0x7fdf824f3278 - rustc_middle[aecd23319abffe8]::ty::context::tls::with_context_opt::<rustc_middle[aecd23319abffe8]::ty::context::tls::with_opt<rustc_middle[aecd23319abffe8]::util::bug::opt_span_bug_fmt<rustc_span[1b87e9fe8fb1a926]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  21:     0x7fdf80a34120 - rustc_middle[aecd23319abffe8]::util::bug::bug_fmt
  22:     0x7fdf80c97fb9 - <rustc_const_eval[95eca17ec43bf463]::transform::validate::TypeChecker as rustc_middle[aecd23319abffe8]::mir::visit::Visitor>::visit_terminator
  23:     0x7fdf83e92847 - rustc_const_eval[95eca17ec43bf463]::transform::validate::validate_types
  24:     0x7fdf80c7c843 - <rustc_const_eval[95eca17ec43bf463]::transform::validate::Validator as rustc_middle[aecd23319abffe8]::mir::MirPass>::run_pass
  25:     0x7fdf81af65d0 - rustc_mir_transform[871016de5a10e3d3]::pass_manager::validate_body
  26:     0x7fdf8341390a - rustc_mir_transform[871016de5a10e3d3]::pass_manager::run_passes_inner
  27:     0x7fdf83b3de62 - rustc_mir_transform[871016de5a10e3d3]::mir_drops_elaborated_and_const_checked
  28:     0x7fdf83b3d721 - rustc_query_impl[6b7a6552b37014cc]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[6b7a6552b37014cc]::query_impl::mir_drops_elaborated_and_const_checked::dynamic_query::{closure#2}::{closure#0}, rustc_middle[aecd23319abffe8]::query::erase::Erased<[u8; 8usize]>>
  29:     0x7fdf83530b3b - rustc_query_system[b1c5429972f486b9]::query::plumbing::try_execute_query::<rustc_query_impl[6b7a6552b37014cc]::DynamicConfig<rustc_query_system[b1c5429972f486b9]::query::caches::VecCache<rustc_span[1b87e9fe8fb1a926]::def_id::LocalDefId, rustc_middle[aecd23319abffe8]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[6b7a6552b37014cc]::plumbing::QueryCtxt, false>
  30:     0x7fdf8353041c - rustc_query_impl[6b7a6552b37014cc]::query_impl::mir_drops_elaborated_and_const_checked::get_query_non_incr::__rust_end_short_backtrace
  31:     0x7fdf83fe8010 - rustc_interface[9dbce73f39987c61]::passes::analysis
  32:     0x7fdf83fe77d9 - rustc_query_impl[6b7a6552b37014cc]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[6b7a6552b37014cc]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[aecd23319abffe8]::query::erase::Erased<[u8; 1usize]>>
  33:     0x7fdf841499e5 - rustc_query_system[b1c5429972f486b9]::query::plumbing::try_execute_query::<rustc_query_impl[6b7a6552b37014cc]::DynamicConfig<rustc_query_system[b1c5429972f486b9]::query::caches::SingleCache<rustc_middle[aecd23319abffe8]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[6b7a6552b37014cc]::plumbing::QueryCtxt, false>
  34:     0x7fdf84149749 - rustc_query_impl[6b7a6552b37014cc]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  35:     0x7fdf8415702f - rustc_interface[9dbce73f39987c61]::interface::run_compiler::<core[b7a137df7f3ab9dc]::result::Result<(), rustc_span[1b87e9fe8fb1a926]::ErrorGuaranteed>, rustc_driver_impl[205ec082ad015eb1]::run_compiler::{closure#0}>::{closure#0}
  36:     0x7fdf843ce705 - std[6fed0b3d7eb5db8f]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[9dbce73f39987c61]::util::run_in_thread_with_globals<rustc_interface[9dbce73f39987c61]::util::run_in_thread_pool_with_globals<rustc_interface[9dbce73f39987c61]::interface::run_compiler<core[b7a137df7f3ab9dc]::result::Result<(), rustc_span[1b87e9fe8fb1a926]::ErrorGuaranteed>, rustc_driver_impl[205ec082ad015eb1]::run_compiler::{closure#0}>::{closure#0}, core[b7a137df7f3ab9dc]::result::Result<(), rustc_span[1b87e9fe8fb1a926]::ErrorGuaranteed>>::{closure#0}, core[b7a137df7f3ab9dc]::result::Result<(), rustc_span[1b87e9fe8fb1a926]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[b7a137df7f3ab9dc]::result::Result<(), rustc_span[1b87e9fe8fb1a926]::ErrorGuaranteed>>
  37:     0x7fdf843ce532 - <<std[6fed0b3d7eb5db8f]::thread::Builder>::spawn_unchecked_<rustc_interface[9dbce73f39987c61]::util::run_in_thread_with_globals<rustc_interface[9dbce73f39987c61]::util::run_in_thread_pool_with_globals<rustc_interface[9dbce73f39987c61]::interface::run_compiler<core[b7a137df7f3ab9dc]::result::Result<(), rustc_span[1b87e9fe8fb1a926]::ErrorGuaranteed>, rustc_driver_impl[205ec082ad015eb1]::run_compiler::{closure#0}>::{closure#0}, core[b7a137df7f3ab9dc]::result::Result<(), rustc_span[1b87e9fe8fb1a926]::ErrorGuaranteed>>::{closure#0}, core[b7a137df7f3ab9dc]::result::Result<(), rustc_span[1b87e9fe8fb1a926]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[b7a137df7f3ab9dc]::result::Result<(), rustc_span[1b87e9fe8fb1a926]::ErrorGuaranteed>>::{closure#1} as core[b7a137df7f3ab9dc]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  38:     0x7fdf7f199435 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h8df09d4849ce0fbf
                               at /rustc/1b2c53a15dba7962cfc284c3b6d61a0341ffa27a/library/alloc/src/boxed.rs:2016:9
  39:     0x7fdf7f199435 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h8b606ed8e7a34b19
                               at /rustc/1b2c53a15dba7962cfc284c3b6d61a0341ffa27a/library/alloc/src/boxed.rs:2016:9
  40:     0x7fdf7f199435 - std::sys::pal::unix::thread::Thread::new::thread_start::hf3f71e6bccca7599
                               at /rustc/1b2c53a15dba7962cfc284c3b6d61a0341ffa27a/library/std/src/sys/pal/unix/thread.rs:108:17
  41:     0x7fdf7ef7c55a - <unknown>
  42:     0x7fdf7eff9a3c - <unknown>
  43:                0x0 - <unknown>

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.78.0-nightly (1b2c53a15 2024-03-08) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z validate-mir -Z dump-mir-dir=dir

query stack during panic:
#0 [mir_drops_elaborated_and_const_checked] elaborating drops for `test`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 5 previous errors; 1 warning emitted

Some errors have detailed explanations: E0425, E0601, E0658.
For more information about an error, try `rustc --explain E0425`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    -Zvalidate-mirUnstable option: MIR validationA-type-systemArea: Type systemC-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.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-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