Skip to content

Panic in nightly using repr(u128) with constant higher than is representable #77457

Closed
@LFalch

Description

@LFalch

Code

#![feature(repr128, const_int_pow)]
#[repr(u128)]
#[derive(Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq)]
pub enum Prefix {
    Yobi = 1024u128.pow(8),
}

impl Prefix {
    pub fn from_str(s: &str) -> Option<Self> {
        use self::Prefix::*;
        match s {
            "Yi" => Some(Yobi),
            _ => None,
        }
    }
}
fn main() {
    println!("{:?}", Prefix::from_str("Yi"));
}

Meta

Link to playpen: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=c628f84c710d623db24c7458295437c1

rustc --version --verbose:

rustc 1.48.0-nightly (154f1f544 2020-10-02)
binary: rustc
commit-hash: 154f1f544dd68f7b53ff8d9952811e855f4c2d7c
commit-date: 2020-10-02
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: `1`,
 right: `1208925819614629174706177`', compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs:1703:33
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 (8fe73e80d 2020-10-01) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2 --crate-type bin

note: some of the compiler flags provided by cargo are hidden

error: could not compile `playground`

To learn more, run the command again with --verbose.
Backtrace

stack backtrace:
   0: rust_begin_unwind
             at /rustc/8fe73e80d762bc575040239fc05fb1c612873554/library/std/src/panicking.rs:483
   1: std::panicking::begin_panic_fmt
             at /rustc/8fe73e80d762bc575040239fc05fb1c612873554/library/std/src/panicking.rs:437
   2: <core::iter::adapters::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
   3: rustc_codegen_llvm::debuginfo::metadata::MemberDescriptionFactory::create_member_descriptions
   4: rustc_codegen_llvm::debuginfo::metadata::RecursiveTypeDescription::finalize
   5: rustc_codegen_llvm::debuginfo::metadata::type_metadata
   6: rustc_codegen_llvm::debuginfo::metadata::type_metadata::{{closure}}
   7: rustc_codegen_llvm::debuginfo::metadata::type_metadata
   8: rustc_codegen_llvm::debuginfo::<impl rustc_codegen_ssa::traits::debuginfo::DebugInfoMethods for rustc_codegen_llvm::context::CodegenCx>::create_function_debug_context::get_function_signature
   9: rustc_codegen_llvm::debuginfo::<impl rustc_codegen_ssa::traits::debuginfo::DebugInfoMethods for rustc_codegen_llvm::context::CodegenCx>::create_function_debug_context
  10: rustc_codegen_ssa::mir::codegen_mir
  11: rustc_codegen_ssa::base::codegen_instance
  12: <rustc_middle::mir::mono::MonoItem as rustc_codegen_ssa::mono_item::MonoItemExt>::define
  13: rustc_codegen_llvm::base::compile_codegen_unit::module_codegen
  14: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
  15: rustc_codegen_llvm::base::compile_codegen_unit
  16: rustc_codegen_ssa::base::codegen_crate
  17: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  18: rustc_session::utils::<impl rustc_session::session::Session>::time
  19: rustc_interface::passes::QueryContext::enter
  20: rustc_interface::queries::Queries::ongoing_codegen
  21: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  22: rustc_span::with_source_map
  23: rustc_interface::interface::create_compiler_and_run
  24: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-debuginfoArea: Debugging information in compiled programs (DWARF, PDB, etc.)C-bugCategory: This is a bug.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.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions