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: slices are not scalars II #116721

Closed
matthiaskrgr opened this issue Oct 14, 2023 · 8 comments · Fixed by #127024
Closed

ICE: slices are not scalars II #116721

matthiaskrgr opened this issue Oct 14, 2023 · 8 comments · Fixed by #127024
Labels
A-mir-opt Area: MIR optimizations C-bug Category: This is a bug. fixed-by-next-solver Fixed by the next-generation trait solver, `-Znext-solver`. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

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


@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 Oct 14, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Oct 14, 2023
@ouz-a
Copy link
Contributor

ouz-a commented Oct 19, 2023

cc @cjgillot

@saethlin saethlin added A-mir-opt Area: MIR optimizations and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Oct 28, 2023
@Noratrieb
Copy link
Member

I cannot reproduce the original anymore, but #121357 does reproduce.
The body is impossible because of the where clauses, so no MIR opts should ever run on it...
I'll take a look.

@matthiaskrgr
Copy link
Member Author

I can still reproduce this with the original mvce when I use the flags that I listed.

@Sky9x
Copy link
Contributor

Sky9x commented Feb 20, 2024

bisected #121357 with -Zmir-opt-level=4

searched nightlies: from nightly-2023-09-01 to nightly-2023-10-01
regressed nightly: nightly-2023-09-09
searched commit range: 1e746d7...62ebe3a
regressed commit: 3cd97ed

bisected with cargo-bisect-rustc v0.6.8

cc #115612
oli was right: #116513 (comment)

@Noratrieb
Copy link
Member

The bisection here isn't useful sadly, but thank you anyways.
I took a look and yeah, the issue is what I suspected. impossible_predicates (

.filter_map(|(p, _)| if p.is_global() { Some(*p) } else { None });
) checks whether there are any impossible predicates (like Self: Sized here). It sadly has to filter out "non-global" predicates, which Self: Sized belongs to. It has to do this because of overflows as mentioned above.
@compiler-errors told me that the new trait solvers non-fatal handling of overflow will allow this to be fixed. But until then, there's nothing we can do.

As for getting the code working, the solution here so to avoid these impossible bounds wherever possible. In the example here, that's easy to do, just delete it. In #121357 that's a bit more annoying, I don't really see a solution.

We could try playing whack-a-mole by trying to make the MIR opts sorta-handle these cases that slip through, but I don't think that's very sustainable. Might work at least for the trivial cases like #121357 though, but I don't open PRs for that.

@Noratrieb Noratrieb added the fixed-by-next-solver Fixed by the next-generation trait solver, `-Znext-solver`. label Feb 20, 2024
@matthiaskrgr
Copy link
Member Author

another one

fn cast_same_meta<T: ?Sized, U: ?Sized>(ptr: *const T) -> *const U {}

fn sized_slice<T>(ptr: *const [T]) -> *const str
where
    [T]: Sized,
{
    cast_same_meta(ptr)
}

@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Apr 20, 2024
@LukasKalbertodt
Copy link
Member

I'm afraid that this has reached stable with 1.78. I couldn't reproduce it with the minimal example in the previous comment, but a crate of mine now fails on stable, but compiled fine on 1.77.2:

/tmp/ ➜  cargo new ice
    Creating binary (application) `ice` package
note: see more `Cargo.toml` keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
/tmp/ ➜  cd ice 
/tmp/ice/ (master ✔) ➜  cargo add lina
    Updating crates.io index
      Adding lina v0.2.1 to dependencies
    Updating crates.io index
/tmp/ice/ (master ✔) ➜  cargo +1.77.2 build -r
   Compiling autocfg v1.3.0
   Compiling bytemuck v1.15.0
   Compiling num-traits v0.2.19
   Compiling lina v0.2.1
   Compiling ice v0.1.0 (/tmp/ice)
    Finished release [optimized] target(s) in 0.69s
/tmp/ice/ (master ✔) ➜  cargo +1.78.0 build -r
   Compiling autocfg v1.3.0
   Compiling bytemuck v1.15.0
   Compiling num-traits v0.2.19
   Compiling lina v0.2.1
thread 'rustc' panicked at compiler/rustc_mir_dataflow/src/value_analysis.rs:849:13:
slices are not scalars
full output
stack backtrace:
   0:     0x7f1d4b78d892 - std::backtrace_rs::backtrace::libunwind::trace::he4ee80166a02c846
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5
   1:     0x7f1d4b78d892 - std::backtrace_rs::backtrace::trace_unsynchronized::h476faccf57e88641
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f1d4b78d892 - std::sys_common::backtrace::_print_fmt::h430c922a77e7a59c
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f1d4b78d892 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hffecb437d922f988
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f1d4b7dea6c - core::fmt::rt::Argument::fmt::hf3df69369399bfa9
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/fmt/rt.rs:142:9
   5:     0x7f1d4b7dea6c - core::fmt::write::hd9a8d7d029f9ea1a
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/fmt/mod.rs:1153:17
   6:     0x7f1d4b78278f - std::io::Write::write_fmt::h0e1226b2b8d973fe
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/io/mod.rs:1843:15
   7:     0x7f1d4b78d664 - std::sys_common::backtrace::_print::hd2df4a083f6e69b8
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f1d4b78d664 - std::sys_common::backtrace::print::he907f6ad7eee41cb
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f1d4b79035b - std::panicking::default_hook::{{closure}}::h3926193b61c9ca9b
  10:     0x7f1d4b7900b3 - std::panicking::default_hook::h25ba2457dea68e65
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:292:9
  11:     0x7f1d4862845d - std[e4dfbc2c3f4b09f1]::panicking::update_hook::<alloc[1adba907b9db1888]::boxed::Box<rustc_driver_impl[24a943716c49befe]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f1d4b790ac0 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h022ca2c0d8c21c9e
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/alloc/src/boxed.rs:2034:9
  13:     0x7f1d4b790ac0 - std::panicking::rust_panic_with_hook::h0ad14d90dcf5224f
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:783:13
  14:     0x7f1d4b7907c9 - std::panicking::begin_panic_handler::{{closure}}::h4a1838a06f542647
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:649:13
  15:     0x7f1d4b78dd66 - std::sys_common::backtrace::__rust_end_short_backtrace::h77cc4dc3567ca904
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7f1d4b790534 - rust_begin_unwind
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:645:5
  17:     0x7f1d4b7daf85 - core::panicking::panic_fmt::h940d4fd01a4b4fd1
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/panicking.rs:72:14
  18:     0x7f1d4a04cf9e - <rustc_mir_dataflow[7fd6167f818552b]::value_analysis::Map>::new
  19:     0x7f1d4a07c894 - <rustc_mir_transform[d35781a685dd05de]::jump_threading::JumpThreading as rustc_middle[fda44fdb505d3e7f]::mir::MirPass>::run_pass
  20:     0x7f1d4980160d - rustc_mir_transform[d35781a685dd05de]::pass_manager::run_passes_inner
  21:     0x7f1d49f064fd - rustc_mir_transform[d35781a685dd05de]::optimized_mir
  22:     0x7f1d49f03f93 - rustc_query_impl[e4152ad88c3d6c78]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e4152ad88c3d6c78]::query_impl::optimized_mir::dynamic_query::{closure#2}::{closure#0}, rustc_middle[fda44fdb505d3e7f]::query::erase::Erased<[u8; 8usize]>>
  23:     0x7f1d49908a23 - rustc_query_system[475239fef39bf53f]::query::plumbing::try_execute_query::<rustc_query_impl[e4152ad88c3d6c78]::DynamicConfig<rustc_query_system[475239fef39bf53f]::query::caches::DefIdCache<rustc_middle[fda44fdb505d3e7f]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[e4152ad88c3d6c78]::plumbing::QueryCtxt, false>
  24:     0x7f1d499080de - rustc_query_impl[e4152ad88c3d6c78]::query_impl::optimized_mir::get_query_non_incr::__rust_end_short_backtrace
  25:     0x7f1d4a7c448d - <rustc_metadata[70192afe97828208]::rmeta::encoder::EncodeContext>::encode_crate_root
  26:     0x7f1d4a7bba25 - rustc_metadata[70192afe97828208]::rmeta::encoder::encode_metadata
  27:     0x7f1d4a5b4c61 - rustc_metadata[70192afe97828208]::fs::encode_and_write_metadata
  28:     0x7f1d4a5b40ca - rustc_interface[ba2b6dc4c96cb491]::passes::start_codegen
  29:     0x7f1d4a5b39c8 - <rustc_interface[ba2b6dc4c96cb491]::queries::Queries>::codegen_and_build_linker
  30:     0x7f1d4a3fc86f - rustc_interface[ba2b6dc4c96cb491]::interface::run_compiler::<core[836963c7c1decc11]::result::Result<(), rustc_span[a4517f2b2e65298c]::ErrorGuaranteed>, rustc_driver_impl[24a943716c49befe]::run_compiler::{closure#0}>::{closure#0}
  31:     0x7f1d4a73eb6e - std[e4dfbc2c3f4b09f1]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[ba2b6dc4c96cb491]::util::run_in_thread_with_globals<rustc_interface[ba2b6dc4c96cb491]::interface::run_compiler<core[836963c7c1decc11]::result::Result<(), rustc_span[a4517f2b2e65298c]::ErrorGuaranteed>, rustc_driver_impl[24a943716c49befe]::run_compiler::{closure#0}>::{closure#0}, core[836963c7c1decc11]::result::Result<(), rustc_span[a4517f2b2e65298c]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[836963c7c1decc11]::result::Result<(), rustc_span[a4517f2b2e65298c]::ErrorGuaranteed>>
  32:     0x7f1d4a73e9ca - <<std[e4dfbc2c3f4b09f1]::thread::Builder>::spawn_unchecked_<rustc_interface[ba2b6dc4c96cb491]::util::run_in_thread_with_globals<rustc_interface[ba2b6dc4c96cb491]::interface::run_compiler<core[836963c7c1decc11]::result::Result<(), rustc_span[a4517f2b2e65298c]::ErrorGuaranteed>, rustc_driver_impl[24a943716c49befe]::run_compiler::{closure#0}>::{closure#0}, core[836963c7c1decc11]::result::Result<(), rustc_span[a4517f2b2e65298c]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[836963c7c1decc11]::result::Result<(), rustc_span[a4517f2b2e65298c]::ErrorGuaranteed>>::{closure#1} as core[836963c7c1decc11]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  33:     0x7f1d4b79a145 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h19b9e642d37e7272
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/alloc/src/boxed.rs:2020:9
  34:     0x7f1d4b79a145 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h97265befc434d3ae
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/alloc/src/boxed.rs:2020:9
  35:     0x7f1d4b79a145 - std::sys::pal::unix::thread::Thread::new::thread_start::h420dad5cf01a9f35
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/sys/pal/unix/thread.rs:108:17
  36:     0x7f1d4567455a - <unknown>
  37:     0x7f1d456f1a3c - <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.78.0 (9b00956e5 2024-04-29) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C opt-level=3 -C embed-bitcode=no -C strip=debuginfo

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [optimized_mir] optimizing MIR for `mat::hc::<impl at /home/lukas/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lina-0.2.1/src/mat/hc.rs:687:1: 689:14>::as_ref`
end of query stack
error: could not compile `lina` (lib)

The code responsible for this is fairly simple:

https://github.com/LukasKalbertodt/lina/blob/ce5fb13cd6fec882a1fdd4ec85ae8dadcad037f6/src/mat/hc.rs

Removing that impl makes the crate compile again.


Will we still just wait for the new solver, now that it's a stable-stable regression?

@LukasKalbertodt
Copy link
Member

I managed to minimize the example from lina:

use bytemuck::Pod; // 1.15.0


struct NPlusOneArray<T, const N: usize>([T; N], T);

impl<T: Pod, const N: usize> AsRef<[T]> for NPlusOneArray<T, N>
where
    [T]: Pod,
{
    fn as_ref(&self) -> &[T] {
        todo!()
    }
}

(On Playground, ICE in release mode)

bors added a commit to rust-lang-ci/rust that referenced this issue Jun 27, 2024
Avoid cloning jump threading state when possible

The current implementation of jump threading passes most of its time cloning its state. This PR attempts to avoid such clones by special-casing the last predecessor when recursing through a terminator.

This is not optimal, but a first step while I refactor the state data structure to be sparse.

The two other commits are drive-by.
Fixes rust-lang#116721

r? `@oli-obk`
bors added a commit to rust-lang-ci/rust that referenced this issue Jun 30, 2024
Avoid cloning jump threading state when possible

The current implementation of jump threading passes most of its time cloning its state. This PR attempts to avoid such clones by special-casing the last predecessor when recursing through a terminator.

This is not optimal, but a first step while I refactor the state data structure to be sparse.

The two other commits are drive-by.
Fixes rust-lang#116721

r? `@oli-obk`
bors added a commit to rust-lang-ci/rust that referenced this issue Jun 30, 2024
Avoid cloning jump threading state when possible

The current implementation of jump threading passes most of its time cloning its state. This PR attempts to avoid such clones by special-casing the last predecessor when recursing through a terminator.

This is not optimal, but a first step while I refactor the state data structure to be sparse.

The two other commits are drive-by.
Fixes rust-lang#116721

r? `@oli-obk`
@bors bors closed this as completed in 2975a21 Jun 30, 2024
RalfJung pushed a commit to RalfJung/miri that referenced this issue Jul 2, 2024
Avoid cloning jump threading state when possible

The current implementation of jump threading passes most of its time cloning its state. This PR attempts to avoid such clones by special-casing the last predecessor when recursing through a terminator.

This is not optimal, but a first step while I refactor the state data structure to be sparse.

The two other commits are drive-by.
Fixes rust-lang/rust#116721

r? `@oli-obk`
lnicola pushed a commit to lnicola/rust-analyzer that referenced this issue Jul 11, 2024
Avoid cloning jump threading state when possible

The current implementation of jump threading passes most of its time cloning its state. This PR attempts to avoid such clones by special-casing the last predecessor when recursing through a terminator.

This is not optimal, but a first step while I refactor the state data structure to be sparse.

The two other commits are drive-by.
Fixes rust-lang/rust#116721

r? `@oli-obk`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-mir-opt Area: MIR optimizations C-bug Category: This is a bug. fixed-by-next-solver Fixed by the next-generation trait solver, `-Znext-solver`. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants