Skip to content

ICE: this MPlaceTy must come from try_as_mplace being used on a zst #77320

Closed
@chengniansun

Description

@chengniansun

Code

const FOO: isize = 10;
const ZST: &() = std::mem::transmute(FOO);
fn main() {
    match &() {
        ZST => 9,
    };
}

Meta

rustc --version --verbose:

rustc 1.48.0-nightly (7f7a1cbfd 2020-09-27)
binary: rustc
commit-hash: 7f7a1cbfd3b55daee191247770627afab09eece2
commit-date: 2020-09-27
host: x86_64-unknown-linux-gnu
release: 1.48.0-nightly
LLVM version: 11.0

Error output

thread 'rustc' panicked at 'assertion failed: `(left == right)`
  left: `10`,
 right: `1`: this MPlaceTy must come from `try_as_mplace` being used on a zst, so we know what
                 value this integer address must have', compiler/rustc_mir/src/const_eval/eval_queries.rs:150: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.48.0-nightly (7f7a1cbfd 2020-09-27) running on x86_64-unknown-linux-gnu
Backtrace

thread 'rustc' panicked at 'assertion failed: `(left == right)`
  left: `10`,
 right: `1`: this MPlaceTy must come from `try_as_mplace` being used on a zst, so we know what
                 value this integer address must have', compiler/rustc_mir/src/const_eval/eval_queries.rs:150:13
stack backtrace:
   0: rust_begin_unwind
             at /rustc/7f7a1cbfd3b55daee191247770627afab09eece2/library/std/src/panicking.rs:483
   1: std::panicking::begin_panic_fmt
             at /rustc/7f7a1cbfd3b55daee191247770627afab09eece2/library/std/src/panicking.rs:437
   2: rustc_mir::const_eval::eval_queries::op_to_const::{{closure}}
   3: rustc_mir::const_eval::eval_queries::op_to_const
   4: core::ops::function::FnOnce::call_once
   5: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::deref_const>::compute
   6: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
   7: rustc_middle::ty::query::plumbing::<impl rustc_query_system::query::QueryContext for rustc_middle::ty::context::TyCtxt>::start_query::{{closure}}::{{closure}}::{{closure}}
   8: rustc_query_system::query::plumbing::get_query_impl
   9: rustc_mir_build::thir::pattern::const_to_pat::ConstToPat::recur
  10: rustc_infer::infer::InferCtxtBuilder::enter
  11: rustc_mir_build::thir::pattern::PatCtxt::lower_path
  12: rustc_mir_build::thir::pattern::PatCtxt::lower_pattern
  13: rustc_mir_build::thir::pattern::check_match::MatchVisitor::lower_pattern
  14: <core::iter::adapters::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
  15: <rustc_mir_build::thir::pattern::check_match::MatchVisitor as rustc_hir::intravisit::Visitor>::visit_expr
  16: rustc_hir::intravisit::walk_expr
  17: <rustc_mir_build::thir::pattern::check_match::MatchVisitor as rustc_hir::intravisit::Visitor>::visit_expr
  18: rustc_mir_build::thir::pattern::check_match::check_match
  19: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::check_match>::compute
  20: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  21: rustc_data_structures::stack::ensure_sufficient_stack
  22: rustc_query_system::query::plumbing::get_query_impl
  23: rustc_query_system::query::plumbing::ensure_query_impl
  24: rustc_session::utils::<impl rustc_session::session::Session>::time
  25: rustc_interface::passes::analysis
  26: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
  27: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  28: rustc_data_structures::stack::ensure_sufficient_stack
  29: rustc_query_system::query::plumbing::get_query_impl
  30: rustc_interface::passes::QueryContext::enter
  31: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  32: rustc_span::with_source_map
  33: rustc_interface::interface::create_compiler_and_run
  34: scoped_tls::ScopedKey<T>::set
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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.48.0-nightly (7f7a1cbfd 2020-09-27) running on x86_64-unknown-linux-gnu

query stack during panic:

NOTE: The bug is found by our work-in-progress compiler testing tool Kira, and the test program is reduced/minimized by Perses

Metadata

Metadata

Assignees

Labels

A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)A-patternsRelating to patterns and pattern matchingC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions