Skip to content

ICE: 'called Result::unwrap() on an Err value: "7 is not a power of 2"', compiler/rustc_mir/src/interpret/traits.rs:168:62 #86132

Closed
@Cancelll

Description

@Cancelll

Code

use std::mem;
trait Trait {}
const TRAIT_OBJ_UNALIGNED_VTABLE: &Trait =
    unsafe { mem::transmute((&92u8, &[0b_______001_11i128; 128])) };

Meta

rustc --version --verbose:

rustc 1.54.0-nightly (35fff69d0 2021-06-06)
binary: rustc
commit-hash: 35fff69d043b1c0f5c29894e7f4b0da8b039c131
commit-date: 2021-06-06
host: x86_64-unknown-linux-gnu
release: 1.54.0-nightly
LLVM version: 12.0.1

Error output

warning: trait objects without an explicit `dyn` are deprecated
 --> mutant.rs:3:36
  |
3 | const TRAIT_OBJ_UNALIGNED_VTABLE: &Trait =
  |                                    ^^^^^ help: use `dyn`: `dyn Trait`
  |
  = note: `#[warn(bare_trait_objects)]` on by default
  = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
  = note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>

warning: constant is never used: `TRAIT_OBJ_UNALIGNED_VTABLE`
 --> mutant.rs:3:1
  |
3 | / const TRAIT_OBJ_UNALIGNED_VTABLE: &Trait =
4 | |     unsafe { mem::transmute((&92u8, &[0b_______001_11i128; 128])) };
  | |____________________________________________________________________^
  |
  = note: `#[warn(dead_code)]` on by default

thread 'rustc' panicked at 'called `Result::unwrap()` on an `Err` value: "`7` is not a power of 2"', compiler/rustc_mir/src/interpret/traits.rs:168:62
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.54.0-nightly (35fff69d0 2021-06-06) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z mir-opt-level=3 -Z new-llvm-pass-manager=yes -Z unsound-mir-opts=yes -Z polonius=yes -Z polymorphize=yes -C debuginfo=2 -C opt-level=3 --crate-type staticlib

query stack during panic:
#0 [eval_to_allocation_raw] const-evaluating + checking `TRAIT_OBJ_UNALIGNED_VTABLE`
#1 [eval_to_const_value_raw] simplifying constant for the type system `TRAIT_OBJ_UNALIGNED_VTABLE`
end of query stack
warning: 2 warnings emitted
Backtrace

warning: trait objects without an explicit `dyn` are deprecated
 --> mutant.rs:3:36
  |
3 | const TRAIT_OBJ_UNALIGNED_VTABLE: &Trait =
  |                                    ^^^^^ help: use `dyn`: `dyn Trait`
  |
  = note: `#[warn(bare_trait_objects)]` on by default
  = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
  = note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>

warning: constant is never used: `TRAIT_OBJ_UNALIGNED_VTABLE`
 --> mutant.rs:3:1
  |
3 | / const TRAIT_OBJ_UNALIGNED_VTABLE: &Trait =
4 | |     unsafe { mem::transmute((&92u8, &[0b_______001_11i128; 128])) };
  | |____________________________________________________________________^
  |
  = note: `#[warn(dead_code)]` on by default

thread 'rustc' panicked at 'called `Result::unwrap()` on an `Err` value: "`7` is not a power of 2"', compiler/rustc_mir/src/interpret/traits.rs:168:62
stack backtrace:
   0: rust_begin_unwind
             at /rustc/35fff69d043b1c0f5c29894e7f4b0da8b039c131/library/std/src/panicking.rs:515:5
   1: core::panicking::panic_fmt
             at /rustc/35fff69d043b1c0f5c29894e7f4b0da8b039c131/library/core/src/panicking.rs:92:14
   2: core::result::unwrap_failed
             at /rustc/35fff69d043b1c0f5c29894e7f4b0da8b039c131/library/core/src/result.rs:1355:5
   3: rustc_mir::interpret::traits::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::read_size_and_align_from_vtable
   4: rustc_mir::interpret::eval_context::InterpCx<M>::size_and_align_of
   5: rustc_mir::interpret::place::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::deref_operand
   6: rustc_mir::interpret::place::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::eval_place
   7: rustc_mir::interpret::step::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::eval_rvalue_into_place
   8: rustc_mir::interpret::step::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::run
   9: rustc_mir::const_eval::eval_queries::eval_to_allocation_raw_provider
  10: rustc_query_impl::<impl rustc_query_system::query::config::QueryAccessors<rustc_query_impl::plumbing::QueryCtxt> for rustc_query_impl::queries::eval_to_allocation_raw>::compute
  11: rustc_query_system::query::plumbing::get_query_impl
  12: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::eval_to_allocation_raw
  13: rustc_mir::const_eval::eval_queries::eval_to_const_value_raw_provider
  14: rustc_query_impl::<impl rustc_query_system::query::config::QueryAccessors<rustc_query_impl::plumbing::QueryCtxt> for rustc_query_impl::queries::eval_to_const_value_raw>::compute
  15: rustc_query_system::query::plumbing::get_query_impl
  16: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::eval_to_const_value_raw
  17: rustc_mir::const_eval::eval_queries::eval_to_const_value_raw_provider
  18: rustc_query_impl::<impl rustc_query_system::query::config::QueryAccessors<rustc_query_impl::plumbing::QueryCtxt> for rustc_query_impl::queries::eval_to_const_value_raw>::compute
  19: rustc_query_system::query::plumbing::get_query_impl
  20: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::eval_to_const_value_raw
  21: rustc_middle::mir::interpret::queries::<impl rustc_middle::ty::context::TyCtxt>::const_eval_global_id
  22: rustc_middle::mir::interpret::queries::<impl rustc_middle::ty::context::TyCtxt>::const_eval_poly
  23: <rustc_lint::BuiltinCombinedLateLintPass as rustc_lint::passes::LateLintPass>::check_item
  24: rustc_hir::intravisit::Visitor::visit_nested_item
  25: rustc_hir::intravisit::walk_crate
  26: rustc_lint::late::late_lint_crate
  27: rustc_data_structures::sync::join
  28: std::panic::catch_unwind
  29: rustc_interface::passes::analysis
  30: rustc_query_system::query::plumbing::get_query_impl
  31: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
  32: rustc_interface::passes::QueryContext::enter
  33: rustc_span::with_session_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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.54.0-nightly (35fff69d0 2021-06-06) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z mir-opt-level=3 -Z new-llvm-pass-manager=yes -Z unsound-mir-opts=yes -Z polonius=yes -Z polymorphize=yes -C debuginfo=2 -C opt-level=3 --crate-type staticlib

query stack during panic:
#0 [eval_to_allocation_raw] const-evaluating + checking `TRAIT_OBJ_UNALIGNED_VTABLE`
#1 [eval_to_const_value_raw] simplifying constant for the type system `TRAIT_OBJ_UNALIGNED_VTABLE`
#2 [eval_to_const_value_raw] simplifying constant for the type system `TRAIT_OBJ_UNALIGNED_VTABLE`
#3 [analysis] running analysis passes on this crate
end of query stack
warning: 2 warnings emitted

Metadata

Metadata

Assignees

Labels

A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)C-bugCategory: This is a bug.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-lowLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions