Skip to content

Internal compiler error due to failed typecheck (on no_core) #72099

Closed
@jaybosamiya

Description

@jaybosamiya

Bad types can lead to an internal compiler error, rather than an error message when compiling. Only affects no_core on nightly.

Code

#![feature(no_core, lang_items)]
#![no_core]

#[lang = "sized"]
trait Sized {}

fn foo() -> bool {
    ()
}

Expected

error[E0308]: mismatched types

Reality

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', src/librustc_typeck/check/demand.rs:637:35

Meta

rustc --version --verbose:

rustc 1.45.0-nightly (9912925c2 2020-05-10)
binary: rustc
commit-hash: 9912925c254589f58338cb2993163e618475ff75
commit-date: 2020-05-10
host: x86_64-unknown-linux-gnu
release: 1.45.0-nightly
LLVM version: 9.0

Backtrace:

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', src/librustc_typeck/check/demand.rs:637:35
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:78
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:59
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1069
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1537
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:62
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:198
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:218
  10: rustc_driver::report_ice
  11: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:481
  12: rust_begin_unwind
             at src/libstd/panicking.rs:385
  13: core::panicking::panic_fmt
             at src/libcore/panicking.rs:89
  14: core::panicking::panic
             at src/libcore/panicking.rs:52
  15: rustc_typeck::check::demand::<impl rustc_typeck::check::FnCtxt>::check_ref
  16: rustc_typeck::check::FnCtxt::suggest_deref_ref_or_into
  17: rustc_typeck::check::demand::<impl rustc_typeck::check::FnCtxt>::emit_coerce_suggestions
  18: rustc_typeck::check::coercion::CoerceMany<E>::coerce_inner
  19: rustc_typeck::check::FnCtxt::check_block_with_expected
  20: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
  21: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
  22: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_return_expr
  23: rustc_typeck::check::check_fn
  24: rustc_middle::ty::context::GlobalCtxt::enter_local
  25: rustc_typeck::check::typeck_tables_of
  26: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::typeck_tables_of>::compute
  27: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  28: rustc_query_system::query::plumbing::get_query_impl
  29: rustc_query_system::query::plumbing::ensure_query_impl
  30: rustc_typeck::check::typeck_item_bodies
  31: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::typeck_item_bodies>::compute
  32: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  33: rustc_query_system::query::plumbing::get_query_impl
  34: rustc_typeck::check_crate
  35: rustc_interface::passes::analysis
  36: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
  37: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  38: rustc_data_structures::stack::ensure_sufficient_stack
  39: rustc_query_system::query::plumbing::get_query_impl
  40: rustc_middle::ty::context::tls::enter_global
  41: rustc_interface::interface::run_compiler_in_existing_thread_pool
  42: scoped_tls::ScopedKey<T>::set
  43: rustc_ast::attr::with_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose 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/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.45.0-nightly (9912925c2 2020-05-10) running on x86_64-unknown-linux-gnu

note: compiler flags: -C debuginfo=1 -C llvm-args=--x86-asm-syntax=intel --crate-type rlib

query stack during panic:
#0 [typeck_tables_of] type-checking `foo`
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️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