Skip to content

ICE: from_const: invalid ScalarPair layout: TyAndLayout #78030

@GoldsteinE

Description

@GoldsteinE

I'm doing really, really cursed things, so I'm not sure if this is a bug.

Code

#![allow(dead_code, unused_attributes)]
#![feature(no_core)]
#![feature(optin_builtin_traits)]
#![feature(lang_items)]
#![feature(rustc_attrs)]
#![no_core]

#[rustc_builtin_macro]
macro_rules! concat {
    ($($e:expr),*) => {{ /* compiler built-in */ }};
    ($($e:expr,)*) => {{ /* compiler built-in */ }};
}

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

#[lang = "copy"]
trait Copy { }

fn f(_: &'static str) { }

#[lang = "start"]
fn start(main: fn(), _argc: isize, _argv: *const *const u8) -> isize {
    main();
    0    
}

fn main() {
    f(concat!("Hello, world! %d", "\0"));
}

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

error: internal compiler error: /rustc/7f7a1cbfd3b55daee191247770627afab09eece2/compiler/rustc_codegen_ssa/src/mir/operand.rs:92:26: from_const: invalid ScalarPair layout: TyAndLayout {
    ty: &str,
    layout: Layout {
        fields: Primitive,
        variants: Single {
            index: 0,
        },
        abi: Scalar(
            Scalar {
                value: Pointer,
                valid_range: 1..=18446744073709551615,
            },
        ),
        largest_niche: Some(
            Niche {
                offset: Size {
                    raw: 0,
                },
                scalar: Scalar {
                    value: Pointer,
                    valid_range: 1..=18446744073709551615,
                },
            },
        ),
        align: AbiAndPrefAlign {
            abi: Align {
                pow2: 3,
            },
            pref: Align {
                pow2: 3,
            },
        },
        size: Size {
            raw: 8,
        },
    },
}
Backtrace

thread 'rustc' panicked at 'Box<Any>', compiler/rustc_errors/src/lib.rs:945:9
stack backtrace:
   0:     0x7f698a617680 - std::backtrace_rs::backtrace::libunwind::trace::he85dfb3ae4206056
                               at /rustc/7f7a1cbfd3b55daee191247770627afab09eece2/library/std/src/../../backtrace/src/backtrace/libunwind.rs:96
   1:     0x7f698a617680 - std::backtrace_rs::backtrace::trace_unsynchronized::h1ad28094d7b00c21
                               at /rustc/7f7a1cbfd3b55daee191247770627afab09eece2/library/std/src/../../backtrace/src/backtrace/mod.rs:66
   2:     0x7f698a617680 - std::sys_common::backtrace::_print_fmt::h901b54610713cd21
                               at /rustc/7f7a1cbfd3b55daee191247770627afab09eece2/library/std/src/sys_common/backtrace.rs:79
   3:     0x7f698a617680 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hb0ad78ee1571f7e0
                               at /rustc/7f7a1cbfd3b55daee191247770627afab09eece2/library/std/src/sys_common/backtrace.rs:58
   4:     0x7f698a6855ac - core::fmt::write::h1857a60b204f1b6a
                               at /rustc/7f7a1cbfd3b55daee191247770627afab09eece2/library/core/src/fmt/mod.rs:1080
   5:     0x7f698a6099a2 - std::io::Write::write_fmt::hf7b7d7b243f84a36
                               at /rustc/7f7a1cbfd3b55daee191247770627afab09eece2/library/std/src/io/mod.rs:1516
   6:     0x7f698a61c1ed - std::sys_common::backtrace::_print::hd093978a5287b8ff
                               at /rustc/7f7a1cbfd3b55daee191247770627afab09eece2/library/std/src/sys_common/backtrace.rs:61
   7:     0x7f698a61c1ed - std::sys_common::backtrace::print::h20f46787581d56d7
                               at /rustc/7f7a1cbfd3b55daee191247770627afab09eece2/library/std/src/sys_common/backtrace.rs:48
   8:     0x7f698a61c1ed - std::panicking::default_hook::{{closure}}::h486cbb4b82ffc357
                               at /rustc/7f7a1cbfd3b55daee191247770627afab09eece2/library/std/src/panicking.rs:208
   9:     0x7f698a61be98 - std::panicking::default_hook::h4190c9e3edd4d591
                               at /rustc/7f7a1cbfd3b55daee191247770627afab09eece2/library/std/src/panicking.rs:227
  10:     0x7f698aea3e44 - rustc_driver::report_ice::h33b98c6312de22d9
  11:     0x7f698a61ca36 - std::panicking::rust_panic_with_hook::h72e78719cdda225c
                               at /rustc/7f7a1cbfd3b55daee191247770627afab09eece2/library/std/src/panicking.rs:581
  12:     0x7f698de8809d - std::panicking::begin_panic::{{closure}}::h07c37e0eb1cdd0bd
  13:     0x7f698de87fc6 - std::sys_common::backtrace::__rust_end_short_backtrace::h0e913c6e63ac7532
  14:     0x7f698de824ff - std::panicking::begin_panic::hb4984aaf49f869f2
  15:     0x7f698debdf40 - rustc_errors::HandlerInner::bug::hba4e38a3874f5dd8
  16:     0x7f698debcaf0 - rustc_errors::Handler::bug::h9b8941b572d00bc2
  17:     0x7f698d7ffea4 - rustc_middle::util::bug::opt_span_bug_fmt::{{closure}}::ha7dea7ab2c365914
  18:     0x7f698d7f96cb - rustc_middle::ty::context::tls::with_opt::{{closure}}::hd5a48179cc9a1134
  19:     0x7f698d7f9042 - rustc_middle::ty::context::tls::with_opt::h4e42d527c5b50313
  20:     0x7f698d7ffdc9 - rustc_middle::util::bug::opt_span_bug_fmt::h41e68724f24e37b9
  21:     0x7f698d7ffd3e - rustc_middle::util::bug::bug_fmt::h38fd16a2440e0445
  22:     0x7f698b1e6975 - rustc_codegen_ssa::mir::operand::OperandRef<V>::from_const::hbc52e52c77522977
  23:     0x7f698b25b8ba - rustc_codegen_ssa::mir::operand::<impl rustc_codegen_ssa::mir::FunctionCx<Bx>>::codegen_operand::h46775bcf8465fe4f
  24:     0x7f698b254f1d - rustc_codegen_ssa::mir::block::<impl rustc_codegen_ssa::mir::FunctionCx<Bx>>::codegen_call_terminator::h6f3acf2ae2b46a89
  25:     0x7f698b24f4c6 - rustc_codegen_ssa::mir::block::<impl rustc_codegen_ssa::mir::FunctionCx<Bx>>::codegen_block::h2f244e07e56ea3d8
  26:     0x7f698b24cf9e - rustc_codegen_ssa::mir::codegen_mir::h8d642bcb147d41c1
  27:     0x7f698b35ec68 - rustc_codegen_ssa::base::codegen_instance::h894322accffbeb70
  28:     0x7f698b1bc604 - <rustc_middle::mir::mono::MonoItem as rustc_codegen_ssa::mono_item::MonoItemExt>::define::h39a2dd069eed710b
  29:     0x7f698b1ffceb - rustc_codegen_llvm::base::compile_codegen_unit::module_codegen::hb573a456da1f50eb
  30:     0x7f698b2a8e8a - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task::h9e34e57f77fd95f5
  31:     0x7f698b1ff80a - rustc_codegen_llvm::base::compile_codegen_unit::h6bde4cdd8ac24228
  32:     0x7f698b35cc60 - rustc_codegen_ssa::base::codegen_crate::h1469a17db97addb4
  33:     0x7f698b355a85 - <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate::h213008e5539f00d1
  34:     0x7f698b0f7bb1 - rustc_interface::passes::QueryContext::enter::h696fdc98b1a21464
  35:     0x7f698b13af83 - rustc_interface::queries::Queries::ongoing_codegen::h14106579db5182fd
  36:     0x7f698aeef454 - rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter::he4e35b4eaa2694c6
  37:     0x7f698ae83527 - rustc_span::with_source_map::hb500901462ee52b5
  38:     0x7f698aef1488 - rustc_interface::interface::create_compiler_and_run::heaaaf154744ddc30
  39:     0x7f698aed692a - scoped_tls::ScopedKey<T>::set::h3b254e0349c75e04
  40:     0x7f698aef3673 - std::sys_common::backtrace::__rust_begin_short_backtrace::h1aa7101e3f5fb15d
  41:     0x7f698ae6f4de - core::ops::function::FnOnce::call_once{{vtable.shim}}::h31069caa752da237
  42:     0x7f698a62b70a - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::h1080dfe0ef616bdf
                               at /rustc/7f7a1cbfd3b55daee191247770627afab09eece2/library/alloc/src/boxed.rs:1042
  43:     0x7f698a62b70a - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::hd2747e1f2d5cec32
                               at /rustc/7f7a1cbfd3b55daee191247770627afab09eece2/library/alloc/src/boxed.rs:1042
  44:     0x7f698a62b70a - std::sys::unix::thread::Thread::new::thread_start::hd0f336b4ef6808a7
                               at /rustc/7f7a1cbfd3b55daee191247770627afab09eece2/library/std/src/sys/unix/thread.rs:87
  45:     0x7f698a5313e9 - start_thread
  46:     0x7f698a459293 - __GI___clone
  47:                0x0 - <unknown>

Metadata

Metadata

Assignees

No one assigned

    Labels

    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