Skip to content

ICE: library/core/src/slice/index.rs:73:5: out of range slice #96259

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

Closed
rvantonder opened this issue Apr 20, 2022 · 6 comments
Closed

ICE: library/core/src/slice/index.rs:73:5: out of range slice #96259

rvantonder opened this issue Apr 20, 2022 · 6 comments
Labels
C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. glacier ICE tracked in rust-lang/glacier. 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.

Comments

@rvantonder
Copy link

Code

Minimal "readable" code:

#[derive(Print)]
struct Foo<#[cfg] A, B> {
    third: [u8; {
        #[cfg] let a =      #[cfg] u8, #[] bool,

via comby-reducer

Truly minimized:

#[derive(P]struct o<#[cfg]B>{t:[0;{#[cfg]let 0=#[cfg]0,

via afl-tmin on the above

Meta

On nightly

rustc --version --verbose:

rustc 1.62.0-nightly (4ca19e09d 2022-04-19)
binary: rustc
commit-hash: 4ca19e09d302a4cbde14f9cb1bc109179dc824cd
commit-date: 2022-04-19
host: x86_64-unknown-linux-gnu
release: 1.62.0-nightly
LLVM version: 14.0.1

Error output

thread 'rustc' panicked at 'range end index 9 out of range for slice of length 8', library/core/src/slice/index.rs:73:5
Backtrace

stack backtrace:
   0:     0x7f8835ae385d - std::backtrace_rs::backtrace::libunwind::trace::hd79e9b51bb0b02a3
                               at /rustc/4ca19e09d302a4cbde14f9cb1bc109179dc824cd/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f8835ae385d - std::backtrace_rs::backtrace::trace_unsynchronized::hc4b2624d11f57391
                               at /rustc/4ca19e09d302a4cbde14f9cb1bc109179dc824cd/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f8835ae385d - std::sys_common::backtrace::_print_fmt::h5b920b6df28041d5
                               at /rustc/4ca19e09d302a4cbde14f9cb1bc109179dc824cd/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f8835ae385d - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h01f2db48eea34166
                               at /rustc/4ca19e09d302a4cbde14f9cb1bc109179dc824cd/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f8835b3eefc - core::fmt::write::h743b8fce003c331c
                               at /rustc/4ca19e09d302a4cbde14f9cb1bc109179dc824cd/library/core/src/fmt/mod.rs:1194:17
   5:     0x7f8835ad5041 - std::io::Write::write_fmt::h55edc38b905db9b5
                               at /rustc/4ca19e09d302a4cbde14f9cb1bc109179dc824cd/library/std/src/io/mod.rs:1655:15
   6:     0x7f8835ae6575 - std::sys_common::backtrace::_print::h72c54a6b7a86b7bf
                               at /rustc/4ca19e09d302a4cbde14f9cb1bc109179dc824cd/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f8835ae6575 - std::sys_common::backtrace::print::h8b541992f5fa33c9
                               at /rustc/4ca19e09d302a4cbde14f9cb1bc109179dc824cd/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f8835ae6575 - std::panicking::default_hook::{{closure}}::h47e8a61e5844dea4
                               at /rustc/4ca19e09d302a4cbde14f9cb1bc109179dc824cd/library/std/src/panicking.rs:295:22
   9:     0x7f8835ae61e9 - std::panicking::default_hook::h65ae1796882c178c
                               at /rustc/4ca19e09d302a4cbde14f9cb1bc109179dc824cd/library/std/src/panicking.rs:314:9
  10:     0x7f88362845a1 - rustc_driver[caca827775d68846]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f8835ae6d46 - std::panicking::rust_panic_with_hook::h1c3eee211b989bad
                               at /rustc/4ca19e09d302a4cbde14f9cb1bc109179dc824cd/library/std/src/panicking.rs:702:17
  12:     0x7f8835ae6b47 - std::panicking::begin_panic_handler::{{closure}}::h653627205f5b2cdc
                               at /rustc/4ca19e09d302a4cbde14f9cb1bc109179dc824cd/library/std/src/panicking.rs:588:13
  13:     0x7f8835ae3d14 - std::sys_common::backtrace::__rust_end_short_backtrace::h36d845a914b6aae7
                               at /rustc/4ca19e09d302a4cbde14f9cb1bc109179dc824cd/library/std/src/sys_common/backtrace.rs:138:18
  14:     0x7f8835ae6879 - rust_begin_unwind
                               at /rustc/4ca19e09d302a4cbde14f9cb1bc109179dc824cd/library/std/src/panicking.rs:584:5
  15:     0x7f8835aabbd3 - core::panicking::panic_fmt::hb6389d787a80a806
                               at /rustc/4ca19e09d302a4cbde14f9cb1bc109179dc824cd/library/core/src/panicking.rs:142:14
  16:     0x7f8835b41656 - core::slice::index::slice_end_index_len_fail_rt::he7be6edaae32d23c
                               at /rustc/4ca19e09d302a4cbde14f9cb1bc109179dc824cd/library/core/src/slice/index.rs:73:5
  17:     0x7f8835b33a37 - core::ops::function::FnOnce::call_once::h620bfc375d5c0e55
                               at /rustc/4ca19e09d302a4cbde14f9cb1bc109179dc824cd/library/core/src/ops/function.rs:248:5
  18:     0x7f8835b3a3c6 - core::intrinsics::const_eval_select::h02c57ce24d1aade4
                               at /rustc/4ca19e09d302a4cbde14f9cb1bc109179dc824cd/library/core/src/intrinsics.rs:2370:5
  19:     0x7f8835aabce6 - core::slice::index::slice_end_index_len_fail::hac0d918f9000e153
                               at /rustc/4ca19e09d302a4cbde14f9cb1bc109179dc824cd/library/core/src/slice/index.rs:67:9
  20:     0x7f8837f73328 - <rustc_parse[58f4b13f8d1bf4e]::parser::attr_wrapper::LazyTokenStreamImpl as rustc_ast[5660607621a98d76]::tokenstream::CreateTokenStream>::create_token_stream
  21:     0x7f8838978a35 - <&mut <rustc_expand[8eb2b2253b629b81]::config::StripUnconfigured>::configure_tokens::{closure#0} as core[864d7ae58f623181]::ops::function::FnOnce<(&(rustc_ast[5660607621a98d76]::tokenstream::AttrAnnotatedTokenTree, rustc_ast[5660607621a98d76]::tokenstream::Spacing),)>>::call_once
  22:     0x7f8838998d0e - <alloc[642b2cd0ec1e1a81]::vec::Vec<(rustc_ast[5660607621a98d76]::tokenstream::AttrAnnotatedTokenTree, rustc_ast[5660607621a98d76]::tokenstream::Spacing)> as alloc[642b2cd0ec1e1a81]::vec::spec_from_iter::SpecFromIter<(rustc_ast[5660607621a98d76]::tokenstream::AttrAnnotatedTokenTree, rustc_ast[5660607621a98d76]::tokenstream::Spacing), core[864d7ae58f623181]::iter::adapters::flatten::FlatMap<core[864d7ae58f623181]::slice::iter::Iter<(rustc_ast[5660607621a98d76]::tokenstream::AttrAnnotatedTokenTree, rustc_ast[5660607621a98d76]::tokenstream::Spacing)>, core[864d7ae58f623181]::option::IntoIter<(rustc_ast[5660607621a98d76]::tokenstream::AttrAnnotatedTokenTree, rustc_ast[5660607621a98d76]::tokenstream::Spacing)>, <rustc_expand[8eb2b2253b629b81]::config::StripUnconfigured>::configure_tokens::{closure#0}>>>::from_iter
  23:     0x7f8838978b39 - <&mut <rustc_expand[8eb2b2253b629b81]::config::StripUnconfigured>::configure_tokens::{closure#0} as core[864d7ae58f623181]::ops::function::FnOnce<(&(rustc_ast[5660607621a98d76]::tokenstream::AttrAnnotatedTokenTree, rustc_ast[5660607621a98d76]::tokenstream::Spacing),)>>::call_once
  24:     0x7f8838998eeb - <alloc[642b2cd0ec1e1a81]::vec::Vec<(rustc_ast[5660607621a98d76]::tokenstream::AttrAnnotatedTokenTree, rustc_ast[5660607621a98d76]::tokenstream::Spacing)> as alloc[642b2cd0ec1e1a81]::vec::spec_from_iter::SpecFromIter<(rustc_ast[5660607621a98d76]::tokenstream::AttrAnnotatedTokenTree, rustc_ast[5660607621a98d76]::tokenstream::Spacing), core[864d7ae58f623181]::iter::adapters::flatten::FlatMap<core[864d7ae58f623181]::slice::iter::Iter<(rustc_ast[5660607621a98d76]::tokenstream::AttrAnnotatedTokenTree, rustc_ast[5660607621a98d76]::tokenstream::Spacing)>, core[864d7ae58f623181]::option::IntoIter<(rustc_ast[5660607621a98d76]::tokenstream::AttrAnnotatedTokenTree, rustc_ast[5660607621a98d76]::tokenstream::Spacing)>, <rustc_expand[8eb2b2253b629b81]::config::StripUnconfigured>::configure_tokens::{closure#0}>>>::from_iter
  25:     0x7f8838978b39 - <&mut <rustc_expand[8eb2b2253b629b81]::config::StripUnconfigured>::configure_tokens::{closure#0} as core[864d7ae58f623181]::ops::function::FnOnce<(&(rustc_ast[5660607621a98d76]::tokenstream::AttrAnnotatedTokenTree, rustc_ast[5660607621a98d76]::tokenstream::Spacing),)>>::call_once
  26:     0x7f8838998eeb - <alloc[642b2cd0ec1e1a81]::vec::Vec<(rustc_ast[5660607621a98d76]::tokenstream::AttrAnnotatedTokenTree, rustc_ast[5660607621a98d76]::tokenstream::Spacing)> as alloc[642b2cd0ec1e1a81]::vec::spec_from_iter::SpecFromIter<(rustc_ast[5660607621a98d76]::tokenstream::AttrAnnotatedTokenTree, rustc_ast[5660607621a98d76]::tokenstream::Spacing), core[864d7ae58f623181]::iter::adapters::flatten::FlatMap<core[864d7ae58f623181]::slice::iter::Iter<(rustc_ast[5660607621a98d76]::tokenstream::AttrAnnotatedTokenTree, rustc_ast[5660607621a98d76]::tokenstream::Spacing)>, core[864d7ae58f623181]::option::IntoIter<(rustc_ast[5660607621a98d76]::tokenstream::AttrAnnotatedTokenTree, rustc_ast[5660607621a98d76]::tokenstream::Spacing)>, <rustc_expand[8eb2b2253b629b81]::config::StripUnconfigured>::configure_tokens::{closure#0}>>>::from_iter
  27:     0x7f8838978b39 - <&mut <rustc_expand[8eb2b2253b629b81]::config::StripUnconfigured>::configure_tokens::{closure#0} as core[864d7ae58f623181]::ops::function::FnOnce<(&(rustc_ast[5660607621a98d76]::tokenstream::AttrAnnotatedTokenTree, rustc_ast[5660607621a98d76]::tokenstream::Spacing),)>>::call_once
  28:     0x7f8838998eeb - <alloc[642b2cd0ec1e1a81]::vec::Vec<(rustc_ast[5660607621a98d76]::tokenstream::AttrAnnotatedTokenTree, rustc_ast[5660607621a98d76]::tokenstream::Spacing)> as alloc[642b2cd0ec1e1a81]::vec::spec_from_iter::SpecFromIter<(rustc_ast[5660607621a98d76]::tokenstream::AttrAnnotatedTokenTree, rustc_ast[5660607621a98d76]::tokenstream::Spacing), core[864d7ae58f623181]::iter::adapters::flatten::FlatMap<core[864d7ae58f623181]::slice::iter::Iter<(rustc_ast[5660607621a98d76]::tokenstream::AttrAnnotatedTokenTree, rustc_ast[5660607621a98d76]::tokenstream::Spacing)>, core[864d7ae58f623181]::option::IntoIter<(rustc_ast[5660607621a98d76]::tokenstream::AttrAnnotatedTokenTree, rustc_ast[5660607621a98d76]::tokenstream::Spacing)>, <rustc_expand[8eb2b2253b629b81]::config::StripUnconfigured>::configure_tokens::{closure#0}>>>::from_iter
  29:     0x7f883897c11a - <rustc_expand[8eb2b2253b629b81]::config::StripUnconfigured>::configure_tokens
  30:     0x7f88384de785 - <rustc_expand[8eb2b2253b629b81]::config::StripUnconfigured>::configure::<rustc_ast[5660607621a98d76]::ptr::P<rustc_ast[5660607621a98d76]::ast::Item>>
  31:     0x7f88384f63ae - rustc_builtin_macros[1cc46f8d8581203a]::cfg_eval::cfg_eval
  32:     0x7f88384f7751 - <rustc_builtin_macros[1cc46f8d8581203a]::derive::Expander as rustc_expand[8eb2b2253b629b81]::base::MultiItemModifier>::expand::{closure#0}
  33:     0x7f88385ec371 - <rustc_resolve[2d23a0f91d06c8ab]::Resolver as rustc_expand[8eb2b2253b629b81]::base::ResolverExpand>::resolve_derives
  34:     0x7f88384f731b - <rustc_builtin_macros[1cc46f8d8581203a]::derive::Expander as rustc_expand[8eb2b2253b629b81]::base::MultiItemModifier>::expand
  35:     0x7f8837e9b7f9 - <rustc_expand[8eb2b2253b629b81]::expand::MacroExpander>::fully_expand_fragment
  36:     0x7f88389a0c8e - <rustc_expand[8eb2b2253b629b81]::expand::MacroExpander>::expand_crate
  37:     0x7f88382d32c4 - <rustc_session[ce05394807c68a98]::session::Session>::time::<core[864d7ae58f623181]::result::Result<rustc_ast[5660607621a98d76]::ast::Crate, rustc_errors[14f27e81a88a2c7]::ErrorGuaranteed>, rustc_interface[dacacaf3651fe347]::passes::configure_and_expand::{closure#1}>
  38:     0x7f88382cdc22 - rustc_interface[dacacaf3651fe347]::passes::configure_and_expand
  39:     0x7f88382f5e17 - <rustc_interface[dacacaf3651fe347]::queries::Queries>::expansion
  40:     0x7f88382989b9 - <rustc_interface[dacacaf3651fe347]::interface::Compiler>::enter::<rustc_driver[caca827775d68846]::run_compiler::{closure#1}::{closure#2}, core[864d7ae58f623181]::result::Result<core[864d7ae58f623181]::option::Option<rustc_interface[dacacaf3651fe347]::queries::Linker>, rustc_errors[14f27e81a88a2c7]::ErrorGuaranteed>>
  41:     0x7f88382c23ff - rustc_span[ff646084812721ee]::with_source_map::<core[864d7ae58f623181]::result::Result<(), rustc_errors[14f27e81a88a2c7]::ErrorGuaranteed>, rustc_interface[dacacaf3651fe347]::interface::create_compiler_and_run<core[864d7ae58f623181]::result::Result<(), rustc_errors[14f27e81a88a2c7]::ErrorGuaranteed>, rustc_driver[caca827775d68846]::run_compiler::{closure#1}>::{closure#1}>
  42:     0x7f88382acd64 - rustc_interface[dacacaf3651fe347]::interface::create_compiler_and_run::<core[864d7ae58f623181]::result::Result<(), rustc_errors[14f27e81a88a2c7]::ErrorGuaranteed>, rustc_driver[caca827775d68846]::run_compiler::{closure#1}>
  43:     0x7f8838295fa1 - <scoped_tls[d6203f3b3010b98e]::ScopedKey<rustc_span[ff646084812721ee]::SessionGlobals>>::set::<rustc_interface[dacacaf3651fe347]::interface::run_compiler<core[864d7ae58f623181]::result::Result<(), rustc_errors[14f27e81a88a2c7]::ErrorGuaranteed>, rustc_driver[caca827775d68846]::run_compiler::{closure#1}>::{closure#0}, core[864d7ae58f623181]::result::Result<(), rustc_errors[14f27e81a88a2c7]::ErrorGuaranteed>>
  44:     0x7f88382af54f - std[fd2a1eaf3e081d4d]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[dacacaf3651fe347]::util::run_in_thread_pool_with_globals<rustc_interface[dacacaf3651fe347]::interface::run_compiler<core[864d7ae58f623181]::result::Result<(), rustc_errors[14f27e81a88a2c7]::ErrorGuaranteed>, rustc_driver[caca827775d68846]::run_compiler::{closure#1}>::{closure#0}, core[864d7ae58f623181]::result::Result<(), rustc_errors[14f27e81a88a2c7]::ErrorGuaranteed>>::{closure#0}, core[864d7ae58f623181]::result::Result<(), rustc_errors[14f27e81a88a2c7]::ErrorGuaranteed>>
  45:     0x7f88382af689 - <<std[fd2a1eaf3e081d4d]::thread::Builder>::spawn_unchecked_<rustc_interface[dacacaf3651fe347]::util::run_in_thread_pool_with_globals<rustc_interface[dacacaf3651fe347]::interface::run_compiler<core[864d7ae58f623181]::result::Result<(), rustc_errors[14f27e81a88a2c7]::ErrorGuaranteed>, rustc_driver[caca827775d68846]::run_compiler::{closure#1}>::{closure#0}, core[864d7ae58f623181]::result::Result<(), rustc_errors[14f27e81a88a2c7]::ErrorGuaranteed>>::{closure#0}, core[864d7ae58f623181]::result::Result<(), rustc_errors[14f27e81a88a2c7]::ErrorGuaranteed>>::{closure#1} as core[864d7ae58f623181]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  46:     0x7f8835af0bf3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h211dae6d8dec3611
                               at /rustc/4ca19e09d302a4cbde14f9cb1bc109179dc824cd/library/alloc/src/boxed.rs:1866:9
  47:     0x7f8835af0bf3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hb54334e8a7bb1f12
                               at /rustc/4ca19e09d302a4cbde14f9cb1bc109179dc824cd/library/alloc/src/boxed.rs:1866:9
  48:     0x7f8835af0bf3 - std::sys::unix::thread::Thread::new::thread_start::hf8b57655f2f2e68e
                               at /rustc/4ca19e09d302a4cbde14f9cb1bc109179dc824cd/library/std/src/sys/unix/thread.rs:108:17
  49:     0x7f883562a6db - start_thread
                               at /build/glibc-S9d2JN/glibc-2.27/nptl/pthread_create.c:463
  50:     0x7f883514b71f - __GI___clone
                               at /build/glibc-S9d2JN/glibc-2.27/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:95
  51:                0x0 - <unknown>

Notes

I searched through ICE issues and believe this is not a duplicate, but let me know! Found with compiler fuzzing tools comby-decomposer and afl-compiler-fuzzer

@rvantonder rvantonder added C-bug Category: This is a bug. 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. labels Apr 20, 2022
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Apr 23, 2022
@chiquidev
Copy link

Good afternoon, I'm having the same issue, any solutions?

@agroce
Copy link

agroce commented Jul 18, 2022

@chiquidev I'm afraid we discovered this using a fuzzer, so we haven't tried to find workarounds! You're running into this in real human-written code? Can you share the context, possibly? I'm always interested when a fuzzer-found bug is something that's a problem for real code!

@haibane-tenshi
Copy link

haibane-tenshi commented Oct 6, 2022

Ran into this issue while writing a hand-written parser, both on stable and nightly

compiler version

Stable:

rustc 1.64.0 (a55dd71d5 2022-09-19)
binary: rustc
commit-hash: a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52
commit-date: 2022-09-19
host: x86_64-pc-windows-msvc
release: 1.64.0
LLVM version: 14.0.6

Nightly:

rustc 1.66.0-nightly (9c56d9d6f 2022-09-29)
binary: rustc
commit-hash: 9c56d9d6fec6262bbb1549cfe466a812ae2c6523
commit-date: 2022-09-29
host: x86_64-pc-windows-msvc
release: 1.66.0-nightly
LLVM version: 15.0.0
Error + backtrace on stable
thread 'rustc' panicked at 'range end index 3 out of range for slice of length 2', library\core\src\slice\index.rs:73:5
stack backtrace:
   0:     0x7ffbd88d9fbf - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hf958371dc84a30d1
   1:     0x7ffbd8914b5a - core::fmt::write::h8bc5f8dfcde4777f
   2:     0x7ffbd88cc749 - <std::io::IoSlice as core::fmt::Debug>::fmt::hab1bb118c5bfde47
   3:     0x7ffbd88dd8bb - std::panicking::default_hook::hcfea80c086f9466a
   4:     0x7ffbd88dd535 - std::panicking::default_hook::hcfea80c086f9466a
   5:     0x7ffbc668c404 - rustc_driver[a0a607043376aa59]::pretty::print_after_hir_lowering
   6:     0x7ffbd88de062 - std::panicking::rust_panic_with_hook::h43b18a7cf7089063
   7:     0x7ffbd88dddfd - <std::panicking::begin_panic_handler::StrPanicPayload as core::panic::BoxMeUp>::get::h51b3df288982544c
   8:     0x7ffbd88dabf7 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hf958371dc84a30d1
   9:     0x7ffbd88ddad9 - rust_begin_unwind
  10:     0x7ffbd894ae95 - core::panicking::panic_fmt::h8a30ca8e1c32c5a5
  11:     0x7ffbd891819b - core::slice::index::slice_end_index_len_fail_rt::h50f0026ee1d37708
  12:     0x7ffbd8908cd9 - <alloc::string::FromUtf16Error as core::fmt::Debug>::fmt::h3c7bd1d5ad2e3173
  13:     0x7ffbd890fb59 - <core::num::error::ParseIntError as core::fmt::Display>::fmt::h02d30396acb0f40b
  14:     0x7ffbd894b039 - core::slice::index::slice_end_index_len_fail::hd043e08f80e8bf95
  15:     0x7ffbc88a4a6b - <rustc_middle[345e23a01d15c30c]::ty::generics::Generics>::own_substs
  16:     0x7ffbc87c4791 - <rustc_infer[9921ae7fd9eefb8a]::infer::error_reporting::need_type_info::FindInferSourceVisitor as rustc_hir[94f5a242fc3ad22c]::intravisit::Visitor>::visit_expr
  17:     0x7ffbc87c45aa - <rustc_infer[9921ae7fd9eefb8a]::infer::error_reporting::need_type_info::FindInferSourceVisitor as rustc_hir[94f5a242fc3ad22c]::intravisit::Visitor>::visit_expr
  18:     0x7ffbc87c2d61 - <rustc_infer[9921ae7fd9eefb8a]::infer::error_reporting::need_type_info::FindInferSourceVisitor as rustc_hir[94f5a242fc3ad22c]::intravisit::Visitor>::visit_body
  19:     0x7ffbc87bfb66 - <rustc_infer[9921ae7fd9eefb8a]::infer::resolve::UnresolvedTypeFinder as rustc_middle[345e23a01d15c30c]::ty::visit::TypeVisitor>::visit_ty
  20:     0x7ffbc8817164 - <rustc_infer[9921ae7fd9eefb8a]::infer::lexical_region_resolve::RegionResolutionError as core[f4e460384c48c425]::fmt::Debug>::fmt
  21:     0x7ffbc87c45aa - <rustc_infer[9921ae7fd9eefb8a]::infer::error_reporting::need_type_info::FindInferSourceVisitor as rustc_hir[94f5a242fc3ad22c]::intravisit::Visitor>::visit_expr
  22:     0x7ffbc8816ff0 - <rustc_infer[9921ae7fd9eefb8a]::infer::lexical_region_resolve::RegionResolutionError as core[f4e460384c48c425]::fmt::Debug>::fmt
  23:     0x7ffbc87c45aa - <rustc_infer[9921ae7fd9eefb8a]::infer::error_reporting::need_type_info::FindInferSourceVisitor as rustc_hir[94f5a242fc3ad22c]::intravisit::Visitor>::visit_expr
  24:     0x7ffbc8816ff0 - <rustc_infer[9921ae7fd9eefb8a]::infer::lexical_region_resolve::RegionResolutionError as core[f4e460384c48c425]::fmt::Debug>::fmt
  25:     0x7ffbc87c45aa - <rustc_infer[9921ae7fd9eefb8a]::infer::error_reporting::need_type_info::FindInferSourceVisitor as rustc_hir[94f5a242fc3ad22c]::intravisit::Visitor>::visit_expr
  26:     0x7ffbc87c4582 - <rustc_infer[9921ae7fd9eefb8a]::infer::error_reporting::need_type_info::FindInferSourceVisitor as rustc_hir[94f5a242fc3ad22c]::intravisit::Visitor>::visit_expr
  27:     0x7ffbc8817074 - <rustc_infer[9921ae7fd9eefb8a]::infer::lexical_region_resolve::RegionResolutionError as core[f4e460384c48c425]::fmt::Debug>::fmt
  28:     0x7ffbc87c45aa - <rustc_infer[9921ae7fd9eefb8a]::infer::error_reporting::need_type_info::FindInferSourceVisitor as rustc_hir[94f5a242fc3ad22c]::intravisit::Visitor>::visit_expr
  29:     0x7ffbc8813e5d - <rustc_infer[9921ae7fd9eefb8a]::infer::lexical_region_resolve::RegionResolutionError as core[f4e460384c48c425]::fmt::Debug>::fmt
  30:     0x7ffbc87c2b19 - <rustc_infer[9921ae7fd9eefb8a]::infer::error_reporting::need_type_info::FindInferSourceVisitor as rustc_hir[94f5a242fc3ad22c]::intravisit::Visitor>::visit_local
  31:     0x7ffbc8813ce8 - <rustc_infer[9921ae7fd9eefb8a]::infer::lexical_region_resolve::RegionResolutionError as core[f4e460384c48c425]::fmt::Debug>::fmt
  32:     0x7ffbc87c45aa - <rustc_infer[9921ae7fd9eefb8a]::infer::error_reporting::need_type_info::FindInferSourceVisitor as rustc_hir[94f5a242fc3ad22c]::intravisit::Visitor>::visit_expr
  33:     0x7ffbc878baf8 - <rustc_infer[9921ae7fd9eefb8a]::infer::InferCtxt>::emit_inference_failure_err
  34:     0x7ffbc87581f6 - <rustc_infer[9921ae7fd9eefb8a]::infer::InferCtxt as rustc_trait_selection[d95719c364848bec]::traits::error_reporting::InferCtxtPrivExt>::maybe_report_ambiguity
  35:     0x7ffbc87463af - <rustc_infer[9921ae7fd9eefb8a]::infer::InferCtxt as rustc_trait_selection[d95719c364848bec]::traits::error_reporting::InferCtxtExt>::report_fulfillment_errors
  36:     0x7ffbc5b8c05c - <rustc_infer[9921ae7fd9eefb8a]::infer::outlives::env::OutlivesEnvironment as rustc_typeck[d2a199ddac7b0ad4]::check::regionck::OutlivesEnvironmentExt>::add_implied_bounds
  37:     0x7ffbc5b489a5 - <rustc_typeck[d2a199ddac7b0ad4]::check::UnsafetyState>::recurse
  38:     0x7ffbc4a8ee88 - rustc_query_impl[eb123e80d0f4deec]::profiling_support::alloc_self_profile_query_strings
  39:     0x7ffbc4bd5081 - <&[rustc_span[7d253b2ad3f54c9a]::def_id::DefId] as rustc_serialize[f7496f00b61bd66d]::serialize::Decodable<rustc_query_impl[eb123e80d0f4deec]::on_disk_cache::CacheDecoder>>::decode
  40:     0x7ffbc6059adc - <rustc_span[7d253b2ad3f54c9a]::def_id::DefId as rustc_serialize[f7496f00b61bd66d]::serialize::Encodable<rustc_query_impl[eb123e80d0f4deec]::on_disk_cache::CacheEncoder>>::encode
  41:     0x7ffbc5f9cbd2 - <rustc_query_impl[eb123e80d0f4deec]::Queries as rustc_middle[345e23a01d15c30c]::ty::query::QueryEngine>::as_any
  42:     0x7ffbc5b77be5 - <<rustc_typeck[d2a199ddac7b0ad4]::check::fn_ctxt::FnCtxt>::instantiate_value_path::CreateCtorSubstsContext as rustc_typeck[d2a199ddac7b0ad4]::astconv::CreateSubstsForGenericArgsCtxt>::inferred_kind
  43:     0x7ffbc488006a - <rustc_typeck[d2a199ddac7b0ad4]::check::fn_ctxt::FnCtxt>::write_user_type_annotation
  44:     0x7ffbc4896b11 - rustc_typeck[d2a199ddac7b0ad4]::check::provide
  45:     0x7ffbc4a909ae - rustc_query_impl[eb123e80d0f4deec]::profiling_support::alloc_self_profile_query_strings
  46:     0x7ffbc4bf555e - <&[rustc_span[7d253b2ad3f54c9a]::def_id::DefId] as rustc_serialize[f7496f00b61bd66d]::serialize::Decodable<rustc_query_impl[eb123e80d0f4deec]::on_disk_cache::CacheDecoder>>::decode
  47:     0x7ffbc4b6a08d - <&[rustc_span[7d253b2ad3f54c9a]::def_id::DefId] as rustc_serialize[f7496f00b61bd66d]::serialize::Decodable<rustc_query_impl[eb123e80d0f4deec]::on_disk_cache::CacheDecoder>>::decode
  48:     0x7ffbc4ba8b3c - <&[rustc_span[7d253b2ad3f54c9a]::def_id::DefId] as rustc_serialize[f7496f00b61bd66d]::serialize::Decodable<rustc_query_impl[eb123e80d0f4deec]::on_disk_cache::CacheDecoder>>::decode
  49:     0x7ffbc487fb9a - <rustc_typeck[d2a199ddac7b0ad4]::check::fn_ctxt::FnCtxt>::write_user_type_annotation
  50:     0x7ffbc482e62b - rustc_typeck[d2a199ddac7b0ad4]::check_crate
  51:     0x7ffbc4095e45 - rustc_interface[e31b1d572a2c621e]::passes::analysis
  52:     0x7ffbc4a905de - rustc_query_impl[eb123e80d0f4deec]::profiling_support::alloc_self_profile_query_strings
  53:     0x7ffbc4beffd6 - <&[rustc_span[7d253b2ad3f54c9a]::def_id::DefId] as rustc_serialize[f7496f00b61bd66d]::serialize::Decodable<rustc_query_impl[eb123e80d0f4deec]::on_disk_cache::CacheDecoder>>::decode
  54:     0x7ffbc4b5a65f - <&[rustc_span[7d253b2ad3f54c9a]::def_id::DefId] as rustc_serialize[f7496f00b61bd66d]::serialize::Decodable<rustc_query_impl[eb123e80d0f4deec]::on_disk_cache::CacheDecoder>>::decode
  55:     0x7ffbc4bc189d - <&[rustc_span[7d253b2ad3f54c9a]::def_id::DefId] as rustc_serialize[f7496f00b61bd66d]::serialize::Decodable<rustc_query_impl[eb123e80d0f4deec]::on_disk_cache::CacheDecoder>>::decode
  56:     0x7ffbc4057cb4 - <unknown>
  57:     0x7ffbc403bd8b - <unknown>
  58:     0x7ffbc4033110 - <unknown>
  59:     0x7ffbc403cdf0 - <unknown>
  60:     0x7ffbc4068cb9 - rustc_driver[a0a607043376aa59]::args::arg_expand_all
  61:     0x7ffbc40583bd - <unknown>
  62:     0x7ffbd88eebdc - std::sys::windows::thread::Thread::new::hdf946fbfa5577747
  63:     0x7ffc315e7034 - BaseThreadInitThunk
  64:     0x7ffc31fc26a1 - RtlUserThreadStart

error: internal compiler error: unexpected panic

note: 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.64.0 (a55dd71d5 2022-09-19) running on x86_64-pc-windows-msvc

note: compiler flags: --crate-type lib -C embed-bitcode=no -C debuginfo=2 -C incremental

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

query stack during panic:
#0 [typeck] type-checking `parse::list`
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack

The part which causes issue looks like this:

struct A<T> {
    inner: T,
}

fn do_smth() -> Result<(), A<Vec<()>>> {
    Err(()).map_err(|_| {
        let inner = std::iter::once(()).collect();

        // This line triggers ICE
        A { inner }
    })?;

    Ok(())
}

Collecting into Vec makes ICE go away, e.g. let inner: Vec<_> = ....
However, this specific example compiles and I'm really struggling to produce a workable one. I hope this is helpful.

@cjgillot
Copy link
Contributor

cjgillot commented Oct 9, 2022

@haibane-tenshi your backtrace points to a different place in the compiler, this is probably a different bug. Could you open a new issue with a more complete code snippet? I could not reproduce the ICE with the one you provided.

@JohnTitor
Copy link
Member

Triage: Fixed on the latest nightly (possibly related to #108297), marking as E-needs-test.

@JohnTitor JohnTitor added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Mar 3, 2023
@chenyukang
Copy link
Member

Fixed by #108297, and we already have similar UI for it.

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. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. glacier ICE tracked in rust-lang/glacier. 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.
Projects
None yet
Development

No branches or pull requests

8 participants