Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICE 'try_get_slice_bytes' on non-slice constant #121128

Closed
matthiaskrgr opened this issue Feb 15, 2024 · 6 comments
Closed

ICE 'try_get_slice_bytes' on non-slice constant #121128

matthiaskrgr opened this issue Feb 15, 2024 · 6 comments
Labels
A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html C-bug Category: This is a bug. E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

auto-reduced (treereduce-rust):

use std::fmt::Debug;

const CONST_0: dyn Debug + Sync = *();

const CONST_FOO: str = *"foo";

static STATIC_1: dyn Debug + Sync = *();

static STATIC_BAR: str = *"bar";

fn main() {
    println!(
        "{:?} {:?} {:?} {:?}",
        &CONST_0, &CONST_FOO, &STATIC_1, &STATIC_BAR
    );
}

original:

use std::fmt::Debug;

const CONST_0: dyn Debug + Sync = *(&0 as &(dyn Debug + Sync));
//~ ERROR evaluation of `<std::string::String as Bar<std::string::String>>::F` failed
//~| ERROR the size for values of type

const CONST_FOO: str = *"foo";
//~^ ERROR the size for values of type
//~| ERROR the size for values of type

static STATIC_1: dyn Debug + Sync = *(&1 as &(dyn Debug + Sync));
//~^ ERROR the size for values of type
//~| ERROR the size for values of type

static STATIC_BAR: str = *"bar";
//~^ ERROR the size for values of type
//~| ERROR the size for values of type

fn main() {
    println!("{:?} {:?} {:?} {:?}", &CONST_0, &CONST_FOO, &STATIC_1, &STATIC_BAR);
}

Version information

rustc 1.78.0-nightly (ee9c7c940 2024-02-14)
binary: rustc
commit-hash: ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46
commit-date: 2024-02-14
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 18.1.0

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zdump-mir=all

Program output

error[E0277]: the size for values of type `(dyn Debug + Sync + 'static)` cannot be known at compilation time
 --> /tmp/icemaker_global_tempdir.oo4WJqbhBMd4/rustc_testrunner_tmpdir_reporting.ijAv6nUShzKD/mvce.rs:3:16
  |
3 | const CONST_0: dyn Debug + Sync = *();
  |                ^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
  |
  = help: the trait `Sized` is not implemented for `(dyn Debug + Sync + 'static)`

error[E0614]: type `()` cannot be dereferenced
 --> /tmp/icemaker_global_tempdir.oo4WJqbhBMd4/rustc_testrunner_tmpdir_reporting.ijAv6nUShzKD/mvce.rs:3:35
  |
3 | const CONST_0: dyn Debug + Sync = *();
  |                                   ^^^

error[E0277]: the size for values of type `(dyn Debug + Sync + 'static)` cannot be known at compilation time
 --> /tmp/icemaker_global_tempdir.oo4WJqbhBMd4/rustc_testrunner_tmpdir_reporting.ijAv6nUShzKD/mvce.rs:3:35
  |
3 | const CONST_0: dyn Debug + Sync = *();
  |                                   ^^^ doesn't have a size known at compile-time
  |
  = help: the trait `Sized` is not implemented for `(dyn Debug + Sync + 'static)`
  = note: constant expressions must have a statically known size

error[E0277]: the size for values of type `str` cannot be known at compilation time
 --> /tmp/icemaker_global_tempdir.oo4WJqbhBMd4/rustc_testrunner_tmpdir_reporting.ijAv6nUShzKD/mvce.rs:5:18
  |
5 | const CONST_FOO: str = *"foo";
  |                  ^^^ doesn't have a size known at compile-time
  |
  = help: the trait `Sized` is not implemented for `str`

error[E0277]: the size for values of type `str` cannot be known at compilation time
 --> /tmp/icemaker_global_tempdir.oo4WJqbhBMd4/rustc_testrunner_tmpdir_reporting.ijAv6nUShzKD/mvce.rs:5:24
  |
5 | const CONST_FOO: str = *"foo";
  |                        ^^^^^^ doesn't have a size known at compile-time
  |
  = help: the trait `Sized` is not implemented for `str`
  = note: constant expressions must have a statically known size

error[E0277]: the size for values of type `(dyn Debug + Sync + 'static)` cannot be known at compilation time
 --> /tmp/icemaker_global_tempdir.oo4WJqbhBMd4/rustc_testrunner_tmpdir_reporting.ijAv6nUShzKD/mvce.rs:7:18
  |
7 | static STATIC_1: dyn Debug + Sync = *();
  |                  ^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
  |
  = help: the trait `Sized` is not implemented for `(dyn Debug + Sync + 'static)`

error[E0614]: type `()` cannot be dereferenced
 --> /tmp/icemaker_global_tempdir.oo4WJqbhBMd4/rustc_testrunner_tmpdir_reporting.ijAv6nUShzKD/mvce.rs:7:37
  |
7 | static STATIC_1: dyn Debug + Sync = *();
  |                                     ^^^

error[E0277]: the size for values of type `(dyn Debug + Sync + 'static)` cannot be known at compilation time
 --> /tmp/icemaker_global_tempdir.oo4WJqbhBMd4/rustc_testrunner_tmpdir_reporting.ijAv6nUShzKD/mvce.rs:7:37
  |
7 | static STATIC_1: dyn Debug + Sync = *();
  |                                     ^^^ doesn't have a size known at compile-time
  |
  = help: the trait `Sized` is not implemented for `(dyn Debug + Sync + 'static)`
  = note: constant expressions must have a statically known size

error[E0277]: the size for values of type `str` cannot be known at compilation time
 --> /tmp/icemaker_global_tempdir.oo4WJqbhBMd4/rustc_testrunner_tmpdir_reporting.ijAv6nUShzKD/mvce.rs:9:20
  |
9 | static STATIC_BAR: str = *"bar";
  |                    ^^^ doesn't have a size known at compile-time
  |
  = help: the trait `Sized` is not implemented for `str`

error[E0277]: the size for values of type `str` cannot be known at compilation time
 --> /tmp/icemaker_global_tempdir.oo4WJqbhBMd4/rustc_testrunner_tmpdir_reporting.ijAv6nUShzKD/mvce.rs:9:26
  |
9 | static STATIC_BAR: str = *"bar";
  |                          ^^^^^^ doesn't have a size known at compile-time
  |
  = help: the trait `Sized` is not implemented for `str`
  = note: constant expressions must have a statically known size

error: internal compiler error: compiler/rustc_middle/src/mir/consts.rs:130:17: `try_get_slice_bytes` on non-slice constant

thread 'rustc' panicked at compiler/rustc_middle/src/util/bug.rs:35:44:
Box<dyn Any>
stack backtrace:
   0:     0x7f8068598e46 - std::backtrace_rs::backtrace::libunwind::trace::h5168cb64cb843b87
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7f8068598e46 - std::backtrace_rs::backtrace::trace_unsynchronized::hbbff473666b784c6
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f8068598e46 - std::sys_common::backtrace::_print_fmt::h6c61b632e6cc7949
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f8068598e46 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h974a6b559c2b8d41
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f80685e946c - core::fmt::rt::Argument::fmt::hf6a5273aff56768c
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/core/src/fmt/rt.rs:142:9
   5:     0x7f80685e946c - core::fmt::write::h1caffe3a78971207
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/core/src/fmt/mod.rs:1120:17
   6:     0x7f806858c7ef - std::io::Write::write_fmt::h2caf2bb3485e27a5
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/std/src/io/mod.rs:1854:15
   7:     0x7f8068598bf4 - std::sys_common::backtrace::_print::h0414d95b24b9ea44
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f8068598bf4 - std::sys_common::backtrace::print::hfdf60e3b3d06625d
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f806859b93b - std::panicking::default_hook::{{closure}}::h3c1109072cde0ade
  10:     0x7f806859b689 - std::panicking::default_hook::hfe3c076d4f24ecbe
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/std/src/panicking.rs:292:9
  11:     0x7f80653f563c - std[2308076c1424b998]::panicking::update_hook::<alloc[33ce0ef41c101337]::boxed::Box<rustc_driver_impl[d317596fd5f90102]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f806859c0a0 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h8a55f98e23703736
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/alloc/src/boxed.rs:2030:9
  13:     0x7f806859c0a0 - std::panicking::rust_panic_with_hook::hc147efcd5d482f2c
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/std/src/panicking.rs:785:13
  14:     0x7f8065422cf4 - std[2308076c1424b998]::panicking::begin_panic::<rustc_errors[5b15740bab0110e6]::ExplicitBug>::{closure#0}
  15:     0x7f806541f656 - std[2308076c1424b998]::sys_common::backtrace::__rust_end_short_backtrace::<std[2308076c1424b998]::panicking::begin_panic<rustc_errors[5b15740bab0110e6]::ExplicitBug>::{closure#0}, !>
  16:     0x7f806541abd6 - std[2308076c1424b998]::panicking::begin_panic::<rustc_errors[5b15740bab0110e6]::ExplicitBug>
  17:     0x7f806542e841 - <rustc_errors[5b15740bab0110e6]::diagnostic_builder::BugAbort as rustc_errors[5b15740bab0110e6]::diagnostic_builder::EmissionGuarantee>::emit_producing_guarantee
  18:     0x7f80657eed3e - <rustc_errors[5b15740bab0110e6]::DiagCtxt>::bug::<alloc[33ce0ef41c101337]::string::String>
  19:     0x7f806588b47b - rustc_middle[efc8e2d5742a68dd]::util::bug::opt_span_bug_fmt::<rustc_span[e043cedf16fd8748]::span_encoding::Span>::{closure#0}
  20:     0x7f8065870f9a - rustc_middle[efc8e2d5742a68dd]::ty::context::tls::with_opt::<rustc_middle[efc8e2d5742a68dd]::util::bug::opt_span_bug_fmt<rustc_span[e043cedf16fd8748]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7f8065870e18 - rustc_middle[efc8e2d5742a68dd]::ty::context::tls::with_context_opt::<rustc_middle[efc8e2d5742a68dd]::ty::context::tls::with_opt<rustc_middle[efc8e2d5742a68dd]::util::bug::opt_span_bug_fmt<rustc_span[e043cedf16fd8748]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7f8063ca02d0 - rustc_middle[efc8e2d5742a68dd]::util::bug::bug_fmt
  23:     0x7f8065838f1c - <rustc_middle[efc8e2d5742a68dd]::mir::consts::ConstValue>::try_get_slice_bytes_for_diagnostics
  24:     0x7f806584d756 - rustc_middle[efc8e2d5742a68dd]::mir::pretty::pretty_print_const_value_tcx
  25:     0x7f80658392f4 - <rustc_middle[efc8e2d5742a68dd]::mir::consts::Const as core[db7e23408f407db6]::fmt::Display>::fmt
  26:     0x7f80685e946c - core::fmt::rt::Argument::fmt::hf6a5273aff56768c
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/core/src/fmt/rt.rs:142:9
  27:     0x7f80685e946c - core::fmt::write::h1caffe3a78971207
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/core/src/fmt/mod.rs:1120:17
  28:     0x7f8065822aa7 - <&alloc[33ce0ef41c101337]::boxed::Box<rustc_middle[efc8e2d5742a68dd]::mir::syntax::ConstOperand> as core[db7e23408f407db6]::fmt::Debug>::fmt
  29:     0x7f80685e946c - core::fmt::rt::Argument::fmt::hf6a5273aff56768c
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/core/src/fmt/rt.rs:142:9
  30:     0x7f80685e946c - core::fmt::write::h1caffe3a78971207
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/core/src/fmt/mod.rs:1120:17
  31:     0x7f80658485eb - <rustc_middle[efc8e2d5742a68dd]::mir::syntax::Operand as core[db7e23408f407db6]::fmt::Debug>::fmt
  32:     0x7f80685e946c - core::fmt::rt::Argument::fmt::hf6a5273aff56768c
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/core/src/fmt/rt.rs:142:9
  33:     0x7f80685e946c - core::fmt::write::h1caffe3a78971207
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/core/src/fmt/mod.rs:1120:17
  34:     0x7f80658475d9 - <rustc_middle[efc8e2d5742a68dd]::mir::syntax::Rvalue as core[db7e23408f407db6]::fmt::Debug>::fmt
  35:     0x7f80685e946c - core::fmt::rt::Argument::fmt::hf6a5273aff56768c
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/core/src/fmt/rt.rs:142:9
  36:     0x7f80685e946c - core::fmt::write::h1caffe3a78971207
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/core/src/fmt/mod.rs:1120:17
  37:     0x7f8065845839 - <rustc_middle[efc8e2d5742a68dd]::mir::statement::Statement as core[db7e23408f407db6]::fmt::Debug>::fmt
  38:     0x7f80685e93f9 - core::fmt::rt::Argument::fmt::hf6a5273aff56768c
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/core/src/fmt/rt.rs:142:9
  39:     0x7f80685e93f9 - core::fmt::run::h31482ef44d21693f
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/core/src/fmt/mod.rs:1168:5
  40:     0x7f80685e93f9 - core::fmt::write::h1caffe3a78971207
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/core/src/fmt/mod.rs:1136:26
  41:     0x7f80685d7e08 - <&mut W as core::fmt::Write::write_fmt::SpecWriteFmt>::spec_write_fmt::hae1624ac05124504
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/core/src/fmt/mod.rs:211:17
  42:     0x7f80685d7e08 - core::fmt::Write::write_fmt::h99b6b0a9b31b6842
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/core/src/fmt/mod.rs:215:14
  43:     0x7f80685d7e08 - alloc::fmt::format::format_inner::h1fcd95a6a9bdbf13
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/alloc/src/fmt.rs:633:16
  44:     0x7f806599b7aa - rustc_middle[efc8e2d5742a68dd]::mir::pretty::write_mir_fn::<rustc_mir_transform[c0673d0b3c528a53]::pass_manager::dump_mir_for_phase_change::{closure#0}>
  45:     0x7f8066a2d352 - rustc_mir_transform[c0673d0b3c528a53]::mir_const
  46:     0x7f8066a2ca79 - rustc_query_impl[ecef4a4fa1cc3689]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ecef4a4fa1cc3689]::query_impl::mir_const::dynamic_query::{closure#2}::{closure#0}, rustc_middle[efc8e2d5742a68dd]::query::erase::Erased<[u8; 8usize]>>
  47:     0x7f806678cdb0 - rustc_query_system[8b26caae5283da17]::query::plumbing::try_execute_query::<rustc_query_impl[ecef4a4fa1cc3689]::DynamicConfig<rustc_query_system[8b26caae5283da17]::query::caches::VecCache<rustc_span[e043cedf16fd8748]::def_id::LocalDefId, rustc_middle[efc8e2d5742a68dd]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[ecef4a4fa1cc3689]::plumbing::QueryCtxt, false>
  48:     0x7f806678c74c - rustc_query_impl[ecef4a4fa1cc3689]::query_impl::mir_const::get_query_non_incr::__rust_end_short_backtrace
  49:     0x7f806499146e - rustc_mir_transform[c0673d0b3c528a53]::mir_promoted
  50:     0x7f8066c04692 - rustc_query_impl[ecef4a4fa1cc3689]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ecef4a4fa1cc3689]::query_impl::mir_promoted::dynamic_query::{closure#2}::{closure#0}, rustc_middle[efc8e2d5742a68dd]::query::erase::Erased<[u8; 16usize]>>
  51:     0x7f8066c04950 - rustc_query_system[8b26caae5283da17]::query::plumbing::try_execute_query::<rustc_query_impl[ecef4a4fa1cc3689]::DynamicConfig<rustc_query_system[8b26caae5283da17]::query::caches::VecCache<rustc_span[e043cedf16fd8748]::def_id::LocalDefId, rustc_middle[efc8e2d5742a68dd]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[ecef4a4fa1cc3689]::plumbing::QueryCtxt, false>
  52:     0x7f80674bd521 - rustc_query_impl[ecef4a4fa1cc3689]::query_impl::mir_promoted::get_query_non_incr::__rust_end_short_backtrace
  53:     0x7f80674bd62e - rustc_borrowck[6196199a33380a9]::mir_borrowck
  54:     0x7f80674bd565 - rustc_query_impl[ecef4a4fa1cc3689]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ecef4a4fa1cc3689]::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[efc8e2d5742a68dd]::query::erase::Erased<[u8; 8usize]>>
  55:     0x7f806678cdb0 - rustc_query_system[8b26caae5283da17]::query::plumbing::try_execute_query::<rustc_query_impl[ecef4a4fa1cc3689]::DynamicConfig<rustc_query_system[8b26caae5283da17]::query::caches::VecCache<rustc_span[e043cedf16fd8748]::def_id::LocalDefId, rustc_middle[efc8e2d5742a68dd]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[ecef4a4fa1cc3689]::plumbing::QueryCtxt, false>
  56:     0x7f806678c8cc - rustc_query_impl[ecef4a4fa1cc3689]::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace
  57:     0x7f8066ffb730 - rustc_interface[e88069c12facd435]::passes::analysis
  58:     0x7f8066ffb229 - rustc_query_impl[ecef4a4fa1cc3689]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ecef4a4fa1cc3689]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[efc8e2d5742a68dd]::query::erase::Erased<[u8; 1usize]>>
  59:     0x7f806743afe5 - rustc_query_system[8b26caae5283da17]::query::plumbing::try_execute_query::<rustc_query_impl[ecef4a4fa1cc3689]::DynamicConfig<rustc_query_system[8b26caae5283da17]::query::caches::SingleCache<rustc_middle[efc8e2d5742a68dd]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[ecef4a4fa1cc3689]::plumbing::QueryCtxt, false>
  60:     0x7f806743ad49 - rustc_query_impl[ecef4a4fa1cc3689]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  61:     0x7f8067444695 - rustc_interface[e88069c12facd435]::interface::run_compiler::<core[db7e23408f407db6]::result::Result<(), rustc_span[e043cedf16fd8748]::ErrorGuaranteed>, rustc_driver_impl[d317596fd5f90102]::run_compiler::{closure#0}>::{closure#0}
  62:     0x7f80675c5ad8 - std[2308076c1424b998]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[e88069c12facd435]::util::run_in_thread_with_globals<rustc_interface[e88069c12facd435]::util::run_in_thread_pool_with_globals<rustc_interface[e88069c12facd435]::interface::run_compiler<core[db7e23408f407db6]::result::Result<(), rustc_span[e043cedf16fd8748]::ErrorGuaranteed>, rustc_driver_impl[d317596fd5f90102]::run_compiler::{closure#0}>::{closure#0}, core[db7e23408f407db6]::result::Result<(), rustc_span[e043cedf16fd8748]::ErrorGuaranteed>>::{closure#0}, core[db7e23408f407db6]::result::Result<(), rustc_span[e043cedf16fd8748]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[db7e23408f407db6]::result::Result<(), rustc_span[e043cedf16fd8748]::ErrorGuaranteed>>
  63:     0x7f80675c5904 - <<std[2308076c1424b998]::thread::Builder>::spawn_unchecked_<rustc_interface[e88069c12facd435]::util::run_in_thread_with_globals<rustc_interface[e88069c12facd435]::util::run_in_thread_pool_with_globals<rustc_interface[e88069c12facd435]::interface::run_compiler<core[db7e23408f407db6]::result::Result<(), rustc_span[e043cedf16fd8748]::ErrorGuaranteed>, rustc_driver_impl[d317596fd5f90102]::run_compiler::{closure#0}>::{closure#0}, core[db7e23408f407db6]::result::Result<(), rustc_span[e043cedf16fd8748]::ErrorGuaranteed>>::{closure#0}, core[db7e23408f407db6]::result::Result<(), rustc_span[e043cedf16fd8748]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[db7e23408f407db6]::result::Result<(), rustc_span[e043cedf16fd8748]::ErrorGuaranteed>>::{closure#1} as core[db7e23408f407db6]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  64:     0x7f80685a51e5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hbe12538a3d7e111d
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/alloc/src/boxed.rs:2016:9
  65:     0x7f80685a51e5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h306728bac30291a0
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/alloc/src/boxed.rs:2016:9
  66:     0x7f80685a51e5 - std::sys::pal::unix::thread::Thread::new::thread_start::hec142a176366d167
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/std/src/sys/pal/unix/thread.rs:108:17
  67:     0x7f806246f9eb - <unknown>
  68:     0x7f80624f37cc - <unknown>
  69:                0x0 - <unknown>

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.78.0-nightly (ee9c7c940 2024-02-14) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z dump-mir=all -Z dump-mir-dir=dir

query stack during panic:
#0 [mir_const] preparing `main` for borrow checking
#1 [mir_promoted] promoting constants in MIR for `main`
#2 [mir_borrowck] borrow-checking `main`
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 11 previous errors

Some errors have detailed explanations: E0277, E0614.
For more information about an error, try `rustc --explain E0277`.

@matthiaskrgr matthiaskrgr added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Feb 15, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 15, 2024
@jieyouxu jieyouxu added A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) labels Feb 15, 2024
@jieyouxu
Copy link
Member

It doesn't crash for me on a slightly older nightly

rustc 1.78.0-nightly (a84bb95a1 2024-02-13)
binary: rustc
commit-hash: a84bb95a1f65bfe25038f188763a18e096a86ab2
commit-date: 2024-02-13
host: x86_64-apple-darwin
release: 1.78.0-nightly
LLVM version: 18.1.0

But it does crash with

rustc 1.78.0-nightly (ee9c7c940 2024-02-14)
binary: rustc
commit-hash: ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46
commit-date: 2024-02-14
host: x86_64-apple-darwin
release: 1.78.0-nightly
LLVM version: 18.1.0

Further reduced:

static STATIC_BAR: str = *"bar";

fn main() {
    STATIC_BAR;
}

@jieyouxu jieyouxu added E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc requires-nightly This issue requires a nightly compiler in some way. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Feb 15, 2024
@oli-obk oli-obk removed the requires-nightly This issue requires a nightly compiler in some way. label Feb 15, 2024
@lqd
Copy link
Member

lqd commented Feb 15, 2024

@oli-obk I presume the requires-nightly label was because the ICE needs -Zdump-mir=all. It bisects to #120847

@oli-obk
Copy link
Contributor

oli-obk commented Feb 15, 2024

oh whoops. In that case we can close this issue. The fix is to simply only dump mir of code that compiles 😆

@oli-obk oli-obk closed this as completed Feb 15, 2024
@matthiaskrgr
Copy link
Member Author

But this fix is not implemented yet ..?

@oli-obk
Copy link
Contributor

oli-obk commented Feb 15, 2024

no... I mean on the user side. Just don't run -Z flags on code that doesn't compile (unless they are for debugging erroneous code)

@matthiaskrgr
Copy link
Member Author

ah, heh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html C-bug Category: This is a bug. E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants