Skip to content

ICE: type mismatch when copying! #127268

Closed
@Naserume

Description

@Naserume

Code

//@ check-pass

struct Slice(&'reborrow [&'static [u8]]);

static MAP: Slice = Slice(&[
    b"CloseEvent" as &'static [u8],
]);

fn main() {}

(original seed)

//@ check-pass
struct Slice(&'static [&'static [u8]]);
static MAP: Slice = Slice(&[
b"CloseEvent" as &'static [u8],
]);
fn main() {}

Meta

rustc --version --verbose:

rustc 1.81.0-nightly (6292b2af6 2024-07-02)
binary: rustc
commit-hash: 6292b2af620dbd771ebb687c3a93c69ba8f97268
commit-date: 2024-07-02
host: x86_64-apple-darwin
release: 1.81.0-nightly
LLVM version: 18.1.7

Error output

error[E0261]: use of undeclared lifetime name `'reborrow`
 --> ./64489B3C9F806D45C54D5CFF302A6E7678F61B90E9746D6EC53E396C5DBD906C.rs:3:15
  |
3 | struct Slice(&'reborrow [&'static [u8]]);
  |             - ^^^^^^^^^ undeclared lifetime
  |             |
  |             help: consider introducing lifetime `'reborrow` here: `<'reborrow>`
Backtrace

error: internal compiler error: compiler/rustc_const_eval/src/interpret/place.rs:852:13: type mismatch when copying!
                                src: &[&[u8]; 1],
                                dest: &[&[u8]]
 --> ./64489B3C9F806D45C54D5CFF302A6E7678F61B90E9746D6EC53E396C5DBD906C.rs:5:21
  |
5 |   static MAP: Slice = Slice(&[
  |  _____________________^
6 | |     b"CloseEvent" as &'static [u8],
7 | | ]);
  | |__^

thread 'rustc' panicked at compiler/rustc_const_eval/src/interpret/place.rs:852:13:
Box<dyn Any>
stack backtrace:
   0:        0x1100f2d93 - <std::sys::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h9393e218f71d31cf
   1:        0x11013e17b - core::fmt::write::h1271a75a7bae980c
   2:        0x1100e8c3e - std::io::Write::write_fmt::h8270e961acbabe61
   3:        0x1100f2b81 - std::sys::backtrace::print::h04e4916ebe343f6e
   4:        0x1100f5959 - std::panicking::default_hook::{{closure}}::hc9df26d29e0f9e5a
   5:        0x1100f56da - std::panicking::default_hook::h1026261fa8b9d0a8
   6:        0x1193dd0ac - std[26270defc80edaa9]::panicking::update_hook::<alloc[98df03226deedbda]::boxed::Box<rustc_driver_impl[708b2ec565622c48]::install_ice_hook::{closure#0}>>::{closure#0}
   7:        0x1100f6699 - std::panicking::rust_panic_with_hook::hf72d729757d375cc
   8:        0x119451347 - std[26270defc80edaa9]::panicking::begin_panic::<rustc_errors[d689bc684dcf46ea]::ExplicitBug>::{closure#0}
   9:        0x11943d189 - std[26270defc80edaa9]::sys::backtrace::__rust_end_short_backtrace::<std[26270defc80edaa9]::panicking::begin_panic<rustc_errors[d689bc684dcf46ea]::ExplicitBug>::{closure#0}, !>
  10:        0x11de6e199 - std[26270defc80edaa9]::panicking::begin_panic::<rustc_errors[d689bc684dcf46ea]::ExplicitBug>
  11:        0x119463486 - <rustc_errors[d689bc684dcf46ea]::diagnostic::BugAbort as rustc_errors[d689bc684dcf46ea]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:        0x1192774e1 - <rustc_errors[d689bc684dcf46ea]::DiagCtxtHandle>::span_bug::<rustc_span[2de937bbddea0bd8]::span_encoding::Span, alloc[98df03226deedbda]::string::String>
  13:        0x1192a62a8 - rustc_middle[8094f41c293b336b]::util::bug::opt_span_bug_fmt::<rustc_span[2de937bbddea0bd8]::span_encoding::Span>::{closure#0}
  14:        0x1192a72a7 - rustc_middle[8094f41c293b336b]::ty::context::tls::with_opt::<rustc_middle[8094f41c293b336b]::util::bug::opt_span_bug_fmt<rustc_span[2de937bbddea0bd8]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  15:        0x119294155 - rustc_middle[8094f41c293b336b]::ty::context::tls::with_context_opt::<rustc_middle[8094f41c293b336b]::ty::context::tls::with_opt<rustc_middle[8094f41c293b336b]::util::bug::opt_span_bug_fmt<rustc_span[2de937bbddea0bd8]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  16:        0x11de5c672 - rustc_middle[8094f41c293b336b]::util::bug::span_bug_fmt::<rustc_span[2de937bbddea0bd8]::span_encoding::Span>
  17:        0x119371d72 - <rustc_const_eval[396cbee6e07433a6]::interpret::eval_context::InterpCx<rustc_const_eval[396cbee6e07433a6]::const_eval::machine::CompileTimeMachine>>::copy_op_no_validate::<rustc_const_eval[396cbee6e07433a6]::interpret::operand::OpTy, rustc_const_eval[396cbee6e07433a6]::interpret::place::PlaceTy>
  18:        0x119347955 - <rustc_const_eval[396cbee6e07433a6]::interpret::eval_context::InterpCx<rustc_const_eval[396cbee6e07433a6]::const_eval::machine::CompileTimeMachine>>::statement
  19:        0x11936189b - rustc_const_eval[396cbee6e07433a6]::const_eval::eval_queries::eval_static_initializer_provider
  20:        0x11aa9b412 - rustc_query_impl[36fa5edae9172c7f]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[36fa5edae9172c7f]::query_impl::eval_static_initializer::dynamic_query::{closure#2}::{closure#0}, rustc_middle[8094f41c293b336b]::query::erase::Erased<[u8; 16usize]>>
  21:        0x11aa5459e - <rustc_query_impl[36fa5edae9172c7f]::query_impl::eval_static_initializer::dynamic_query::{closure#2} as core[c342ec502b95801]::ops::function::FnOnce<(rustc_middle[8094f41c293b336b]::ty::context::TyCtxt, rustc_span[2de937bbddea0bd8]::def_id::DefId)>>::call_once
  22:        0x11a858319 - rustc_query_system[16c7cab3586fd5d4]::query::plumbing::try_execute_query::<rustc_query_impl[36fa5edae9172c7f]::DynamicConfig<rustc_query_system[16c7cab3586fd5d4]::query::caches::DefIdCache<rustc_middle[8094f41c293b336b]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[36fa5edae9172c7f]::plumbing::QueryCtxt, false>
  23:        0x11aac5ded - rustc_query_impl[36fa5edae9172c7f]::query_impl::eval_static_initializer::get_query_non_incr::__rust_end_short_backtrace
  24:        0x119656cbb - <rustc_middle[8094f41c293b336b]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[af0a509199b1bc4b]::check_crate::{closure#3}>::{closure#0}
  25:        0x1197ac0ec - rustc_hir_analysis[af0a509199b1bc4b]::check_crate
  26:        0x119d53df7 - rustc_interface[eab3c32d3b591e25]::passes::run_required_analyses
  27:        0x119d563a0 - rustc_interface[eab3c32d3b591e25]::passes::analysis
  28:        0x11aa9d4ec - rustc_query_impl[36fa5edae9172c7f]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[36fa5edae9172c7f]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[8094f41c293b336b]::query::erase::Erased<[u8; 1usize]>>
  29:        0x11a87bfbe - rustc_query_system[16c7cab3586fd5d4]::query::plumbing::try_execute_query::<rustc_query_impl[36fa5edae9172c7f]::DynamicConfig<rustc_query_system[16c7cab3586fd5d4]::query::caches::SingleCache<rustc_middle[8094f41c293b336b]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[36fa5edae9172c7f]::plumbing::QueryCtxt, false>
  30:        0x11aaa7a47 - rustc_query_impl[36fa5edae9172c7f]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  31:        0x119386857 - <rustc_interface[eab3c32d3b591e25]::queries::QueryResult<&rustc_middle[8094f41c293b336b]::ty::context::GlobalCtxt>>::enter::<core[c342ec502b95801]::result::Result<(), rustc_span[2de937bbddea0bd8]::ErrorGuaranteed>, rustc_driver_impl[708b2ec565622c48]::run_compiler::{closure#0}::{closure#1}::{closure#5}>
  32:        0x1193e4465 - rustc_interface[eab3c32d3b591e25]::interface::run_compiler::<core[c342ec502b95801]::result::Result<(), rustc_span[2de937bbddea0bd8]::ErrorGuaranteed>, rustc_driver_impl[708b2ec565622c48]::run_compiler::{closure#0}>::{closure#1}
  33:        0x1193caee1 - std[26270defc80edaa9]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[eab3c32d3b591e25]::util::run_in_thread_with_globals<rustc_interface[eab3c32d3b591e25]::util::run_in_thread_pool_with_globals<rustc_interface[eab3c32d3b591e25]::interface::run_compiler<core[c342ec502b95801]::result::Result<(), rustc_span[2de937bbddea0bd8]::ErrorGuaranteed>, rustc_driver_impl[708b2ec565622c48]::run_compiler::{closure#0}>::{closure#1}, core[c342ec502b95801]::result::Result<(), rustc_span[2de937bbddea0bd8]::ErrorGuaranteed>>::{closure#0}, core[c342ec502b95801]::result::Result<(), rustc_span[2de937bbddea0bd8]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[c342ec502b95801]::result::Result<(), rustc_span[2de937bbddea0bd8]::ErrorGuaranteed>>
  34:        0x1193eaff6 - <<std[26270defc80edaa9]::thread::Builder>::spawn_unchecked_<rustc_interface[eab3c32d3b591e25]::util::run_in_thread_with_globals<rustc_interface[eab3c32d3b591e25]::util::run_in_thread_pool_with_globals<rustc_interface[eab3c32d3b591e25]::interface::run_compiler<core[c342ec502b95801]::result::Result<(), rustc_span[2de937bbddea0bd8]::ErrorGuaranteed>, rustc_driver_impl[708b2ec565622c48]::run_compiler::{closure#0}>::{closure#1}, core[c342ec502b95801]::result::Result<(), rustc_span[2de937bbddea0bd8]::ErrorGuaranteed>>::{closure#0}, core[c342ec502b95801]::result::Result<(), rustc_span[2de937bbddea0bd8]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[c342ec502b95801]::result::Result<(), rustc_span[2de937bbddea0bd8]::ErrorGuaranteed>>::{closure#2} as core[c342ec502b95801]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  35:        0x1100ff83b - std::sys::pal::unix::thread::Thread::new::thread_start::hfcd29f6cc9954faa
  36:     0x7ff801f5318b - __pthread_start

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: please make sure that you have updated to the latest nightly

note: please attach the file at `/Users/240701-nightly/rustc-ice-2024-07-03T10_34_51-69548.txt` to your bug report

query stack during panic:
#0 [eval_static_initializer] evaluating initializer of static `MAP`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0261`.

Note

Ice location:

let layout_compat =
mir_assign_valid_types(*self.tcx, self.param_env, src.layout(), dest.layout());
if !allow_transmute && !layout_compat {
span_bug!(
self.cur_span(),
"type mismatch when copying!\nsrc: {},\ndest: {}",
src.layout().ty,
dest.layout().ty,
);
}

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