Skip to content

ICE: slices are not scalars II #116721

Closed
@matthiaskrgr

Description

@matthiaskrgr

File: /tmp/icemaker/033b7887410cef9d40e915f3b66f44d747d3e0d2.rs

#116513 season two

auto-reduced (treereduce-rust):

fn hey<T>(it: &[T])
where
    [T]: Clone,
{
}

fn main() {}

original:

// compile-flags: -Z mir-opt-level=0
// EMIT_MIR issue_91633.hey.mir_map.0.mir
fn hey<T> (it: &[T])
 where
     [T] : Clone,
 {
     let _ = {0;0};
 }

// EMIT_MIR issue_91633.bar.mir_map.0.mir
fn bar<T> (it: Box<[T]>)
 where
     [T] : std::ops::Index<usize>,
 {
     let _ = it[0];
 }

// EMIT_MIR issue_91633.fun.mir_map.0.mir
fn fun<T> (it: &[T]) -> &T
 {
     let f = &it[0];
     f
 }

// EMIT_MIR issue_91633.foo.mir_map.0.mir
fn foo<T: Clone> (it: Box<[T]>) -> T
 {
     let f = it[0].clone();
     f
 }
 fn main(){}

Version information

rustc 1.75.0-nightly (57ef88985 2023-10-13)
binary: rustc
commit-hash: 57ef8898520f7ff2c60341636bb86d94cb550e79
commit-date: 2023-10-13
host: x86_64-unknown-linux-gnu
release: 1.75.0-nightly
LLVM version: 17.0.2

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zmir-opt-level=3 --emit=mir

Program output

warning: unused variable: `it`
 --> /tmp/icemaker/033b7887410cef9d40e915f3b66f44d747d3e0d2.rs:3:12
  |
3 | fn hey<T> (it: &[T])
  |            ^^ help: if this is intentional, prefix it with an underscore: `_it`
  |
  = note: `#[warn(unused_variables)]` on by default

warning: function `hey` is never used
 --> /tmp/icemaker/033b7887410cef9d40e915f3b66f44d747d3e0d2.rs:3:4
  |
3 | fn hey<T> (it: &[T])
  |    ^^^
  |
  = note: `#[warn(dead_code)]` on by default

warning: function `bar` is never used
  --> /tmp/icemaker/033b7887410cef9d40e915f3b66f44d747d3e0d2.rs:11:4
   |
11 | fn bar<T> (it: Box<[T]>)
   |    ^^^

warning: function `fun` is never used
  --> /tmp/icemaker/033b7887410cef9d40e915f3b66f44d747d3e0d2.rs:19:4
   |
19 | fn fun<T> (it: &[T]) -> &T
   |    ^^^

warning: function `foo` is never used
  --> /tmp/icemaker/033b7887410cef9d40e915f3b66f44d747d3e0d2.rs:26:4
   |
26 | fn foo<T: Clone> (it: Box<[T]>) -> T
   |    ^^^

thread 'rustc' panicked at compiler/rustc_mir_dataflow/src/value_analysis.rs:764:13:
slices are not scalars
stack backtrace:
   0:     0x7f2ba6b628fc - std::backtrace_rs::backtrace::libunwind::trace::h03c0bf785ff8ac95
                               at /rustc/57ef8898520f7ff2c60341636bb86d94cb550e79/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f2ba6b628fc - std::backtrace_rs::backtrace::trace_unsynchronized::heb554a194a8b8d76
                               at /rustc/57ef8898520f7ff2c60341636bb86d94cb550e79/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f2ba6b628fc - std::sys_common::backtrace::_print_fmt::h5104548cf2f1d04d
                               at /rustc/57ef8898520f7ff2c60341636bb86d94cb550e79/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7f2ba6b628fc - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h60a89bd281db8532
                               at /rustc/57ef8898520f7ff2c60341636bb86d94cb550e79/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f2ba6bca350 - core::fmt::rt::Argument::fmt::h3f967ff7ed1eb864
                               at /rustc/57ef8898520f7ff2c60341636bb86d94cb550e79/library/core/src/fmt/rt.rs:142:9
   5:     0x7f2ba6bca350 - core::fmt::write::h6c7eacf90d438ccc
                               at /rustc/57ef8898520f7ff2c60341636bb86d94cb550e79/library/core/src/fmt/mod.rs:1117:17
   6:     0x7f2ba6b55c4f - std::io::Write::write_fmt::heed557ad0e7e227d
                               at /rustc/57ef8898520f7ff2c60341636bb86d94cb550e79/library/std/src/io/mod.rs:1762:15
   7:     0x7f2ba6b626e4 - std::sys_common::backtrace::_print::hc14194a28bba6478
                               at /rustc/57ef8898520f7ff2c60341636bb86d94cb550e79/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f2ba6b626e4 - std::sys_common::backtrace::print::h49644fe6309a893a
                               at /rustc/57ef8898520f7ff2c60341636bb86d94cb550e79/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f2ba6b654f7 - std::panicking::default_hook::{{closure}}::h2aa5ccff7297f9c8
  10:     0x7f2ba6b6523a - std::panicking::default_hook::h9e4bff1aa2bdf161
                               at /rustc/57ef8898520f7ff2c60341636bb86d94cb550e79/library/std/src/panicking.rs:292:9
  11:     0x7f2ba9718daa - std[5f80c380de201c9c]::panicking::update_hook::<alloc[9cbc8cef37f5f9a9]::boxed::Box<rustc_driver_impl[3ff10296a9c85239]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f2ba6b65c98 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h372bad5385f8c0c5
                               at /rustc/57ef8898520f7ff2c60341636bb86d94cb550e79/library/alloc/src/boxed.rs:2021:9
  13:     0x7f2ba6b65c98 - std::panicking::rust_panic_with_hook::h6c6741452089fc1b
                               at /rustc/57ef8898520f7ff2c60341636bb86d94cb550e79/library/std/src/panicking.rs:735:13
  14:     0x7f2ba6b659a6 - std::panicking::begin_panic_handler::{{closure}}::h281b553b64b3c920
                               at /rustc/57ef8898520f7ff2c60341636bb86d94cb550e79/library/std/src/panicking.rs:601:13
  15:     0x7f2ba6b62e16 - std::sys_common::backtrace::__rust_end_short_backtrace::h3fa2532f3895ceba
                               at /rustc/57ef8898520f7ff2c60341636bb86d94cb550e79/library/std/src/sys_common/backtrace.rs:170:18
  16:     0x7f2ba6b65722 - rust_begin_unwind
                               at /rustc/57ef8898520f7ff2c60341636bb86d94cb550e79/library/std/src/panicking.rs:597:5
  17:     0x7f2ba6bc6975 - core::panicking::panic_fmt::h7601551d8f1de7d6
                               at /rustc/57ef8898520f7ff2c60341636bb86d94cb550e79/library/core/src/panicking.rs:72:14
  18:     0x7f2ba9c2a8b7 - <rustc_mir_dataflow[68eaf0bb38c8fec3]::value_analysis::Map>::register_children
  19:     0x7f2ba9c299b8 - <rustc_mir_dataflow[68eaf0bb38c8fec3]::value_analysis::Map>::new
  20:     0x7f2ba9d0fd45 - <rustc_mir_transform[892ade550f628091]::dataflow_const_prop::DataflowConstProp as rustc_middle[48fc6e82f368dfd0]::mir::MirPass>::run_pass
  21:     0x7f2ba8560a5f - rustc_mir_transform[892ade550f628091]::pass_manager::run_passes_inner
  22:     0x7f2ba8d69a6c - rustc_mir_transform[892ade550f628091]::optimized_mir
  23:     0x7f2ba7a196dd - rustc_query_impl[d93ff4b57be0a3f9]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[d93ff4b57be0a3f9]::query_impl::optimized_mir::dynamic_query::{closure#2}::{closure#0}, rustc_middle[48fc6e82f368dfd0]::query::erase::Erased<[u8; 8usize]>>
  24:     0x7f2ba7dcf2d1 - rustc_query_system[bf593801cb8c9f4a]::query::plumbing::try_execute_query::<rustc_query_impl[d93ff4b57be0a3f9]::DynamicConfig<rustc_query_system[bf593801cb8c9f4a]::query::caches::DefaultCache<rustc_span[3385b0a88a85fcb6]::def_id::DefId, rustc_middle[48fc6e82f368dfd0]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[d93ff4b57be0a3f9]::plumbing::QueryCtxt, false>
  25:     0x7f2ba91d8a22 - rustc_query_impl[d93ff4b57be0a3f9]::query_impl::optimized_mir::get_query_non_incr::__rust_end_short_backtrace
  26:     0x7f2ba7c8bba0 - <rustc_middle[48fc6e82f368dfd0]::ty::context::TyCtxt>::instance_mir
  27:     0x7f2ba9af9e5e - rustc_middle[48fc6e82f368dfd0]::mir::pretty::write_mir_pretty
  28:     0x7f2ba9cde8e3 - rustc_mir_transform[892ade550f628091]::dump_mir::emit_mir
  29:     0x7f2ba8ef940f - rustc_interface[d1c057f52199548c]::passes::start_codegen
  30:     0x7f2ba8ef8916 - <rustc_interface[d1c057f52199548c]::queries::Queries>::ongoing_codegen
  31:     0x7f2ba8ee7552 - std[5f80c380de201c9c]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[d1c057f52199548c]::util::run_in_thread_with_globals<rustc_interface[d1c057f52199548c]::interface::run_compiler<core[5ecddd5f6ab0df47]::result::Result<(), rustc_span[3385b0a88a85fcb6]::ErrorGuaranteed>, rustc_driver_impl[3ff10296a9c85239]::run_compiler::{closure#1}>::{closure#0}, core[5ecddd5f6ab0df47]::result::Result<(), rustc_span[3385b0a88a85fcb6]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[5ecddd5f6ab0df47]::result::Result<(), rustc_span[3385b0a88a85fcb6]::ErrorGuaranteed>>
  32:     0x7f2ba8ee67d3 - <<std[5f80c380de201c9c]::thread::Builder>::spawn_unchecked_<rustc_interface[d1c057f52199548c]::util::run_in_thread_with_globals<rustc_interface[d1c057f52199548c]::interface::run_compiler<core[5ecddd5f6ab0df47]::result::Result<(), rustc_span[3385b0a88a85fcb6]::ErrorGuaranteed>, rustc_driver_impl[3ff10296a9c85239]::run_compiler::{closure#1}>::{closure#0}, core[5ecddd5f6ab0df47]::result::Result<(), rustc_span[3385b0a88a85fcb6]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[5ecddd5f6ab0df47]::result::Result<(), rustc_span[3385b0a88a85fcb6]::ErrorGuaranteed>>::{closure#1} as core[5ecddd5f6ab0df47]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  33:     0x7f2ba6b70c05 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h0018b354bb46a254
                               at /rustc/57ef8898520f7ff2c60341636bb86d94cb550e79/library/alloc/src/boxed.rs:2007:9
  34:     0x7f2ba6b70c05 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hb166705f6d4a8b53
                               at /rustc/57ef8898520f7ff2c60341636bb86d94cb550e79/library/alloc/src/boxed.rs:2007:9
  35:     0x7f2ba6b70c05 - std::sys::unix::thread::Thread::new::thread_start::hdac26740529f6e03
                               at /rustc/57ef8898520f7ff2c60341636bb86d94cb550e79/library/std/src/sys/unix/thread.rs:108:17
  36:     0x7f2ba69139eb - <unknown>
  37:     0x7f2ba69977cc - <unknown>
  38:                0x0 - <unknown>

error: 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.75.0-nightly (57ef88985 2023-10-13) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z mir-opt-level=3 -Z dump-mir-dir=dir

query stack during panic:
#0 [optimized_mir] optimizing MIR for `hey`
end of query stack
warning: 5 warnings emitted


Metadata

Metadata

Assignees

No one assigned

    Labels

    A-mir-optArea: MIR optimizationsC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.fixed-by-next-solverFixed by the next-generation trait solver, `-Znext-solver`.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions