rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
97.33k stars 12.59k forks source link

ICE: `type mismatch when copying!` #127268

Closed Naserume closed 2 months ago

Naserume commented 3 months ago

Code

//@ check-pass

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

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

fn main() {}

(original seed) https://github.com/rust-lang/rust/blob/d68fe4eaa81305b53cdddc2339e8efdc2aa1e013/tests/ui/nll/issue-55288.rs#L1-L9

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 stack backtrace: 0: 0x1100f2d93 - ::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::>::{closure#0} 7: 0x1100f6699 - std::panicking::rust_panic_with_hook::hf72d729757d375cc 8: 0x119451347 - std[26270defc80edaa9]::panicking::begin_panic::::{closure#0} 9: 0x11943d189 - std[26270defc80edaa9]::sys::backtrace::__rust_end_short_backtrace::::{closure#0}, !> 10: 0x11de6e199 - std[26270defc80edaa9]::panicking::begin_panic:: 11: 0x119463486 - ::emit_producing_guarantee 12: 0x1192774e1 - ::span_bug:: 13: 0x1192a62a8 - rustc_middle[8094f41c293b336b]::util::bug::opt_span_bug_fmt::::{closure#0} 14: 0x1192a72a7 - rustc_middle[8094f41c293b336b]::ty::context::tls::with_opt::::{closure#0}, !>::{closure#0} 15: 0x119294155 - rustc_middle[8094f41c293b336b]::ty::context::tls::with_context_opt::::{closure#0}, !>::{closure#0}, !> 16: 0x11de5c672 - rustc_middle[8094f41c293b336b]::util::bug::span_bug_fmt:: 17: 0x119371d72 - >::copy_op_no_validate:: 18: 0x119347955 - >::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::> 21: 0x11aa5459e - >::call_once 22: 0x11a858319 - rustc_query_system[16c7cab3586fd5d4]::query::plumbing::try_execute_query::>, 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 - ::par_body_owners::::{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::> 29: 0x11a87bfbe - rustc_query_system[16c7cab3586fd5d4]::query::plumbing::try_execute_query::>, 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 - >::enter::, rustc_driver_impl[708b2ec565622c48]::run_compiler::{closure#0}::{closure#1}::{closure#5}> 32: 0x1193e4465 - rustc_interface[eab3c32d3b591e25]::interface::run_compiler::, rustc_driver_impl[708b2ec565622c48]::run_compiler::{closure#0}>::{closure#1} 33: 0x1193caee1 - std[26270defc80edaa9]::sys::backtrace::__rust_begin_short_backtrace::, 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 - <::spawn_unchecked_, 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: https://github.com/rust-lang/rust/blob/6292b2af620dbd771ebb687c3a93c69ba8f97268/compiler/rustc_const_eval/src/interpret/place.rs#L849-L858

lqd commented 3 months ago

This started ICEing in #126996 cc @oli-obk