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. !base.layout().is_sized() #127737

Open
matthiaskrgr opened this issue Jul 14, 2024 · 1 comment
Open

ICE. !base.layout().is_sized() #127737

matthiaskrgr opened this issue Jul 14, 2024 · 1 comment
Assignees
Labels
C-bug Category: This is a bug. 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

auto-reduced (treereduce-rust):

pub trait TestTrait {
    type MyType;
    fn func() -> Option<Self>
    where
        Self: Sized;
}

impl<T> dyn TestTrait<MyType = T>
where
    Self: Sized,
{
    pub fn other_func() -> Option<Self> {
        match Self::func() {
            Some(me) => Some(me),
            None => None,
        }
    }
}

original:

//@ compile-flags: --crate-type=lib -Zmir-opt-level=2
//@ build-pass
// ^-- Must be build-pass, because check-pass will not run const prop.

pub trait TestTrait {
    type MyType;
    fn func() -> Option<Self>
    where
        Self: Sized;
}

impl<T> dyn TestTrait<MyType = T>
where
    Self: Sized,
{
    pub fn other_func() -> Option<Self> {
        match Self::func() {
            Some(me) => Some(me),
            None => None,
        }
    }
}

Version information

rustc 1.81.0-nightly (f8e4ac076 2024-07-14)
binary: rustc
commit-hash: f8e4ac0760216724f69b1ebc369bf03da56a7520
commit-date: 2024-07-14
host: x86_64-unknown-linux-gnu
release: 1.81.0-nightly
LLVM version: 18.1.7

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zmir-opt-level=5 --crate-type=lib

Program output

thread 'rustc' panicked at /rustc/f8e4ac0760216724f69b1ebc369bf03da56a7520/compiler/rustc_const_eval/src/interpret/projection.rs:166:13:
assertion failed: !base.layout().is_sized()
stack backtrace:
   0:     0x723ebf105865 - std::backtrace_rs::backtrace::libunwind::trace::hd38d957c3cc252d2
                               at /rustc/f8e4ac0760216724f69b1ebc369bf03da56a7520/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
   1:     0x723ebf105865 - std::backtrace_rs::backtrace::trace_unsynchronized::h1872a55102afa6eb
                               at /rustc/f8e4ac0760216724f69b1ebc369bf03da56a7520/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x723ebf105865 - std::sys::backtrace::_print_fmt::h20dc7ce96546708c
                               at /rustc/f8e4ac0760216724f69b1ebc369bf03da56a7520/library/std/src/sys/backtrace.rs:65:5
   3:     0x723ebf105865 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hc05f0077a6d9d85d
                               at /rustc/f8e4ac0760216724f69b1ebc369bf03da56a7520/library/std/src/sys/backtrace.rs:40:26
   4:     0x723ebf1550eb - core::fmt::rt::Argument::fmt::hc83d8497f7eca888
                               at /rustc/f8e4ac0760216724f69b1ebc369bf03da56a7520/library/core/src/fmt/rt.rs:173:76
   5:     0x723ebf1550eb - core::fmt::write::h018b5020a31eaee4
                               at /rustc/f8e4ac0760216724f69b1ebc369bf03da56a7520/library/core/src/fmt/mod.rs:1182:21
   6:     0x723ebf0fa3cf - std::io::Write::write_fmt::ha03f1960d314b86c
                               at /rustc/f8e4ac0760216724f69b1ebc369bf03da56a7520/library/std/src/io/mod.rs:1827:15
   7:     0x723ebf108051 - std::sys::backtrace::BacktraceLock::print::hb613464fb9731709
                               at /rustc/f8e4ac0760216724f69b1ebc369bf03da56a7520/library/std/src/sys/backtrace.rs:43:9
   8:     0x723ebf108051 - std::panicking::default_hook::{{closure}}::h535fcea069b87644
                               at /rustc/f8e4ac0760216724f69b1ebc369bf03da56a7520/library/std/src/panicking.rs:269:22
   9:     0x723ebf107d2c - std::panicking::default_hook::h8a985a1bbf049349
                               at /rustc/f8e4ac0760216724f69b1ebc369bf03da56a7520/library/std/src/panicking.rs:296:9
  10:     0x723ebb5ec589 - std[7a47f84281342453]::panicking::update_hook::<alloc[b164795f67c102d1]::boxed::Box<rustc_driver_impl[a19efe568a6a6683]::install_ice_hook::{closure#0}>>::{closure#0}
  11:     0x723ebf108a1f - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h0580c9dd81c802de
                               at /rustc/f8e4ac0760216724f69b1ebc369bf03da56a7520/library/alloc/src/boxed.rs:2084:9
  12:     0x723ebf108a1f - std::panicking::rust_panic_with_hook::hdb4c410c90ba309a
                               at /rustc/f8e4ac0760216724f69b1ebc369bf03da56a7520/library/std/src/panicking.rs:808:13
  13:     0x723ebf108613 - std::panicking::begin_panic_handler::{{closure}}::hd6b26adc9172d33b
                               at /rustc/f8e4ac0760216724f69b1ebc369bf03da56a7520/library/std/src/panicking.rs:667:13
  14:     0x723ebf105d29 - std::sys::backtrace::__rust_end_short_backtrace::h3a27e3f65f32503b
                               at /rustc/f8e4ac0760216724f69b1ebc369bf03da56a7520/library/std/src/sys/backtrace.rs:168:18
  15:     0x723ebf1082d4 - rust_begin_unwind
                               at /rustc/f8e4ac0760216724f69b1ebc369bf03da56a7520/library/std/src/panicking.rs:665:5
  16:     0x723ebf1516a3 - core::panicking::panic_fmt::ha0ad70cf2f26aad8
                               at /rustc/f8e4ac0760216724f69b1ebc369bf03da56a7520/library/core/src/panicking.rs:74:14
  17:     0x723ebf15172c - core::panicking::panic::h6e669894f5b53db5
                               at /rustc/f8e4ac0760216724f69b1ebc369bf03da56a7520/library/core/src/panicking.rs:148:5
  18:     0x723ebe4411b7 - <rustc_const_eval[fd17e0cfdd0bd9e3]::interpret::eval_context::InterpCx<rustc_const_eval[fd17e0cfdd0bd9e3]::const_eval::dummy_machine::DummyMachine>>::project_field::<rustc_const_eval[fd17e0cfdd0bd9e3]::interpret::operand::OpTy>.cold
  19:     0x723ebbe1e851 - <rustc_mir_transform[a9e991cd80486376]::dataflow_const_prop::ConstAnalysis>::assign_constant::{closure#0}
  20:     0x723ebbd479eb - <rustc_mir_dataflow[538483daff6f33a9]::value_analysis::Map>::for_each_projection_value::<rustc_const_eval[fd17e0cfdd0bd9e3]::interpret::operand::OpTy, <rustc_mir_transform[a9e991cd80486376]::dataflow_const_prop::ConstAnalysis>::assign_constant::{closure#0}, <rustc_mir_transform[a9e991cd80486376]::dataflow_const_prop::ConstAnalysis>::assign_constant::{closure#1}>
  21:     0x723ebbd47a6c - <rustc_mir_dataflow[538483daff6f33a9]::value_analysis::Map>::for_each_projection_value::<rustc_const_eval[fd17e0cfdd0bd9e3]::interpret::operand::OpTy, <rustc_mir_transform[a9e991cd80486376]::dataflow_const_prop::ConstAnalysis>::assign_constant::{closure#0}, <rustc_mir_transform[a9e991cd80486376]::dataflow_const_prop::ConstAnalysis>::assign_constant::{closure#1}>
  22:     0x723ebbe1e806 - <rustc_mir_transform[a9e991cd80486376]::dataflow_const_prop::ConstAnalysis>::assign_constant
  23:     0x723ebbdd6ba0 - <rustc_mir_transform[a9e991cd80486376]::dataflow_const_prop::ConstAnalysis>::assign_operand
  24:     0x723ebbe1cc4d - <rustc_mir_transform[a9e991cd80486376]::dataflow_const_prop::DataflowConstProp as rustc_middle[b63224948423896b]::mir::MirPass>::run_pass
  25:     0x723ebcc01cbb - rustc_mir_transform[a9e991cd80486376]::pass_manager::run_passes_inner
  26:     0x723ebd15eed6 - rustc_mir_transform[a9e991cd80486376]::optimized_mir
  27:     0x723ebdaab21b - rustc_query_impl[a0d93f3a76d1e236]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a0d93f3a76d1e236]::query_impl::optimized_mir::dynamic_query::{closure#2}::{closure#0}, rustc_middle[b63224948423896b]::query::erase::Erased<[u8; 8usize]>>
  28:     0x723ebced50e3 - rustc_query_system[967e3c5480e09d8a]::query::plumbing::try_execute_query::<rustc_query_impl[a0d93f3a76d1e236]::DynamicConfig<rustc_query_system[967e3c5480e09d8a]::query::caches::DefIdCache<rustc_middle[b63224948423896b]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[a0d93f3a76d1e236]::plumbing::QueryCtxt, false>
  29:     0x723ebced48e0 - rustc_query_impl[a0d93f3a76d1e236]::query_impl::optimized_mir::get_query_non_incr::__rust_end_short_backtrace
  30:     0x723ebd3f4023 - rustc_middle[b63224948423896b]::query::plumbing::query_get_at::<rustc_query_system[967e3c5480e09d8a]::query::caches::DefIdCache<rustc_middle[b63224948423896b]::query::erase::Erased<[u8; 8usize]>>>
  31:     0x723ebd3f9aa1 - <rustc_metadata[e0a5a3ee2c4f394f]::rmeta::encoder::EncodeContext>::encode_crate_root
  32:     0x723ebdc7e31e - rustc_metadata[e0a5a3ee2c4f394f]::rmeta::encoder::encode_metadata
  33:     0x723ebdc7c3f4 - rustc_metadata[e0a5a3ee2c4f394f]::fs::encode_and_write_metadata
  34:     0x723ebdc7b083 - <rustc_interface[f891d35c33df0120]::queries::Linker>::codegen_and_build_linker
  35:     0x723ebd9c0676 - rustc_interface[f891d35c33df0120]::interface::run_compiler::<core[5c27b473aec29ed1]::result::Result<(), rustc_span[8a5224f023f17529]::ErrorGuaranteed>, rustc_driver_impl[a19efe568a6a6683]::run_compiler::{closure#0}>::{closure#1}
  36:     0x723ebd99cc09 - std[7a47f84281342453]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[f891d35c33df0120]::util::run_in_thread_with_globals<rustc_interface[f891d35c33df0120]::util::run_in_thread_pool_with_globals<rustc_interface[f891d35c33df0120]::interface::run_compiler<core[5c27b473aec29ed1]::result::Result<(), rustc_span[8a5224f023f17529]::ErrorGuaranteed>, rustc_driver_impl[a19efe568a6a6683]::run_compiler::{closure#0}>::{closure#1}, core[5c27b473aec29ed1]::result::Result<(), rustc_span[8a5224f023f17529]::ErrorGuaranteed>>::{closure#0}, core[5c27b473aec29ed1]::result::Result<(), rustc_span[8a5224f023f17529]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[5c27b473aec29ed1]::result::Result<(), rustc_span[8a5224f023f17529]::ErrorGuaranteed>>
  37:     0x723ebd99c9ba - <<std[7a47f84281342453]::thread::Builder>::spawn_unchecked_<rustc_interface[f891d35c33df0120]::util::run_in_thread_with_globals<rustc_interface[f891d35c33df0120]::util::run_in_thread_pool_with_globals<rustc_interface[f891d35c33df0120]::interface::run_compiler<core[5c27b473aec29ed1]::result::Result<(), rustc_span[8a5224f023f17529]::ErrorGuaranteed>, rustc_driver_impl[a19efe568a6a6683]::run_compiler::{closure#0}>::{closure#1}, core[5c27b473aec29ed1]::result::Result<(), rustc_span[8a5224f023f17529]::ErrorGuaranteed>>::{closure#0}, core[5c27b473aec29ed1]::result::Result<(), rustc_span[8a5224f023f17529]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[5c27b473aec29ed1]::result::Result<(), rustc_span[8a5224f023f17529]::ErrorGuaranteed>>::{closure#2} as core[5c27b473aec29ed1]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  38:     0x723ebf1128cb - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hf9b8e00cff207f55
                               at /rustc/f8e4ac0760216724f69b1ebc369bf03da56a7520/library/alloc/src/boxed.rs:2070:9
  39:     0x723ebf1128cb - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hd33bea353aae3a46
                               at /rustc/f8e4ac0760216724f69b1ebc369bf03da56a7520/library/alloc/src/boxed.rs:2070:9
  40:     0x723ebf1128cb - std::sys::pal::unix::thread::Thread::new::thread_start::hb95383f957b5020b
                               at /rustc/f8e4ac0760216724f69b1ebc369bf03da56a7520/library/std/src/sys/pal/unix/thread.rs:108:17
  41:     0x723eb80a6ded - <unknown>
  42:     0x723eb812a0dc - <unknown>
  43:                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: please make sure that you have updated to the latest nightly

note: rustc 1.81.0-nightly (f8e4ac076 2024-07-14) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z mir-opt-level=5 --crate-type lib -Z dump-mir-dir=dir

query stack during panic:
#0 [optimized_mir] optimizing MIR for `<impl at /tmp/icemaker_global_tempdir.4HXXv5pAmPjZ/rustc_testrunner_tmpdir_reporting.8X4UesCacdRf/mvce.rs:8:1: 10:17>::other_func`
end of query stack

@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 Jul 14, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 14, 2024
@matthiaskrgr
Copy link
Member Author

#127087 cc @cjgillot

@cjgillot cjgillot self-assigned this Jul 14, 2024
@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 16, 2024
@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Jul 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. 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

No branches or pull requests

4 participants