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

internal compiler error for type parameter out of range when substituting #114317

Open
iamanonymouscs opened this issue Aug 1, 2023 · 7 comments
Labels
C-bug Category: This is a bug. F-generic_const_exprs `#![feature(generic_const_exprs)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-incomplete-features 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

@iamanonymouscs
Copy link

iamanonymouscs commented Aug 1, 2023

Code

#![feature(generic_const_exprs)]

struct A<const B: str = 1, C>;

fn main() {}

Meta

rustc --version --verbose:

rustc 1.73.0-nightly (db7ff98a7 2023-07-31)
binary: rustc
commit-hash: db7ff98a72f3e742b641f9cb16d0e8c285e87e9b
commit-date: 2023-07-31
host: x86_64-unknown-linux-gnu
release: 1.73.0-nightly
LLVM version: 16.0.5

Error output

error: generic parameters with a default must be trailing
 --> 1.rs:3:16
  |
3 | struct A<const B: str = 1, C>;
  |                ^

warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
 --> 1.rs:1:12
  |
1 | #![feature(generic_const_exprs)]
  |            ^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
  = note: `#[warn(incomplete_features)]` on by default

error: internal compiler error: compiler/rustc_middle/src/ty/generic_args.rs:900:9: type parameter `C/#1` (C/1) out of range when substituting, args=[]


Backtrace

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/db7ff98a72f3e742b641f9cb16d0e8c285e87e9b/compiler/rustc_errors/src/lib.rs:1645:9
stack backtrace:
   0:     0x7f7f59d564bc - std::backtrace_rs::backtrace::libunwind::trace::h00560e9152510f67
                               at /rustc/db7ff98a72f3e742b641f9cb16d0e8c285e87e9b/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f7f59d564bc - std::backtrace_rs::backtrace::trace_unsynchronized::h0f27c3665dd0a867
                               at /rustc/db7ff98a72f3e742b641f9cb16d0e8c285e87e9b/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f7f59d564bc - std::sys_common::backtrace::_print_fmt::h5dba0ff3e06fa698
                               at /rustc/db7ff98a72f3e742b641f9cb16d0e8c285e87e9b/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7f7f59d564bc - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h4debeea1996f535b
                               at /rustc/db7ff98a72f3e742b641f9cb16d0e8c285e87e9b/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f7f59dbcbac - core::fmt::rt::Argument::fmt::h1e53d9bbf5a265dd
                               at /rustc/db7ff98a72f3e742b641f9cb16d0e8c285e87e9b/library/core/src/fmt/rt.rs:138:9
   5:     0x7f7f59dbcbac - core::fmt::write::hcb86202702aeaf68
                               at /rustc/db7ff98a72f3e742b641f9cb16d0e8c285e87e9b/library/core/src/fmt/mod.rs:1094:21
   6:     0x7f7f59d48b1e - std::io::Write::write_fmt::h6b056feb2ab827f8
                               at /rustc/db7ff98a72f3e742b641f9cb16d0e8c285e87e9b/library/std/src/io/mod.rs:1714:15
   7:     0x7f7f59d562a5 - std::sys_common::backtrace::_print::h63c494f55c85c02e
                               at /rustc/db7ff98a72f3e742b641f9cb16d0e8c285e87e9b/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f7f59d562a5 - std::sys_common::backtrace::print::h0d84953923cd4383
                               at /rustc/db7ff98a72f3e742b641f9cb16d0e8c285e87e9b/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f7f59d593fa - std::panicking::panic_hook_with_disk_dump::{{closure}}::h0ded106e3e100970
                               at /rustc/db7ff98a72f3e742b641f9cb16d0e8c285e87e9b/library/std/src/panicking.rs:278:22
  10:     0x7f7f59d59093 - std::panicking::panic_hook_with_disk_dump::h80545efc2b457190
                               at /rustc/db7ff98a72f3e742b641f9cb16d0e8c285e87e9b/library/std/src/panicking.rs:312:9
  11:     0x7f7f58b272e9 - rustc_driver_impl[953ac255d00f3c7f]::install_ice_hook::{closure#0}
  12:     0x7f7f59d59ca0 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h005d394de554c94e
                               at /rustc/db7ff98a72f3e742b641f9cb16d0e8c285e87e9b/library/alloc/src/boxed.rs:2021:9
  13:     0x7f7f59d59ca0 - std::panicking::rust_panic_with_hook::ha35d072680b6716b
                               at /rustc/db7ff98a72f3e742b641f9cb16d0e8c285e87e9b/library/std/src/panicking.rs:733:13
  14:     0x7f7f59099711 - std[cfe24ee53075a1e5]::panicking::begin_panic::<rustc_errors[b1a6789dfd2ebe34]::ExplicitBug>::{closure#0}
  15:     0x7f7f59096cc6 - std[cfe24ee53075a1e5]::sys_common::backtrace::__rust_end_short_backtrace::<std[cfe24ee53075a1e5]::panicking::begin_panic<rustc_errors[b1a6789dfd2ebe34]::ExplicitBug>::{closure#0}, !>
  16:     0x7f7f590de776 - std[cfe24ee53075a1e5]::panicking::begin_panic::<rustc_errors[b1a6789dfd2ebe34]::ExplicitBug>
  17:     0x7f7f590a0594 - <rustc_errors[b1a6789dfd2ebe34]::HandlerInner>::bug::<alloc[9d71a00e6f43b08]::string::String>
  18:     0x7f7f590a0426 - <rustc_errors[b1a6789dfd2ebe34]::Handler>::bug::<alloc[9d71a00e6f43b08]::string::String>
  19:     0x7f7f5912dcec - rustc_middle[23eac342ec155d27]::util::bug::opt_span_bug_fmt::<rustc_span[c85fb125fe1c027]::span_encoding::Span>::{closure#0}
  20:     0x7f7f5912caea - rustc_middle[23eac342ec155d27]::ty::context::tls::with_opt::<rustc_middle[23eac342ec155d27]::util::bug::opt_span_bug_fmt<rustc_span[c85fb125fe1c027]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7f7f5912cab8 - rustc_middle[23eac342ec155d27]::ty::context::tls::with_context_opt::<rustc_middle[23eac342ec155d27]::ty::context::tls::with_opt<rustc_middle[23eac342ec155d27]::util::bug::opt_span_bug_fmt<rustc_span[c85fb125fe1c027]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7f7f5742fbc0 - rustc_middle[23eac342ec155d27]::util::bug::bug_fmt
  23:     0x7f7f590d76b5 - <rustc_middle[23eac342ec155d27]::ty::generic_args::ArgFolder>::type_param_out_of_range
  24:     0x7f7f56b7e8f6 - <alloc[9d71a00e6f43b08]::vec::Vec<rustc_middle[23eac342ec155d27]::ty::Clause> as alloc[9d71a00e6f43b08]::vec::spec_extend::SpecExtend<rustc_middle[23eac342ec155d27]::ty::Clause, core[24a2ba61524efef7]::iter::adapters::map::Map<core[24a2ba61524efef7]::slice::iter::Iter<(rustc_middle[23eac342ec155d27]::ty::Clause, rustc_span[c85fb125fe1c027]::span_encoding::Span)>, <rustc_middle[23eac342ec155d27]::ty::generics::GenericPredicates>::instantiate_into::{closure#0}>>>::spec_extend
  25:     0x7f7f56b7bc5c - <rustc_middle[23eac342ec155d27]::ty::generics::GenericPredicates>::instantiate_into
  26:     0x7f7f5713d86a - <rustc_trait_selection[eab02bee2fa61d32]::traits::wf::WfPredicates>::nominal_obligations_inner
  27:     0x7f7f57137345 - <rustc_trait_selection[eab02bee2fa61d32]::traits::wf::WfPredicates>::compute
  28:     0x7f7f56e9a3ae - <rustc_trait_selection[eab02bee2fa61d32]::traits::fulfill::FulfillProcessor as rustc_data_structures[1e82c702e6afba98]::obligation_forest::ObligationProcessor>::process_obligation
  29:     0x7f7f56e963f4 - <rustc_data_structures[1e82c702e6afba98]::obligation_forest::ObligationForest<rustc_trait_selection[eab02bee2fa61d32]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[eab02bee2fa61d32]::traits::fulfill::FulfillProcessor>
  30:     0x7f7f5724d44f - <rustc_trait_selection[eab02bee2fa61d32]::traits::engine::ObligationCtxt>::select_all_or_error
  31:     0x7f7f57548bdb - rustc_hir_analysis[2c6ebfa0ec54105a]::check::wfcheck::check_type_defn
  32:     0x7f7f57526568 - rustc_hir_analysis[2c6ebfa0ec54105a]::check::wfcheck::check_well_formed
  33:     0x7f7f56b2951c - rustc_query_impl[c1c3c70d39a20423]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[c1c3c70d39a20423]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[23eac342ec155d27]::query::erase::Erased<[u8; 0usize]>>
  34:     0x7f7f573f0246 - rustc_query_system[85489b7677581133]::query::plumbing::try_execute_query::<rustc_query_impl[c1c3c70d39a20423]::DynamicConfig<rustc_query_system[85489b7677581133]::query::caches::VecCache<rustc_hir[ef37331cc27c2adb]::hir_id::OwnerId, rustc_middle[23eac342ec155d27]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[c1c3c70d39a20423]::plumbing::QueryCtxt, false>
  35:     0x7f7f573eff62 - rustc_query_impl[c1c3c70d39a20423]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  36:     0x7f7f57e97bac - rustc_data_structures[1e82c702e6afba98]::sync::par_for_each_in::<&[rustc_hir[ef37331cc27c2adb]::hir::ImplItemId], <rustc_middle[23eac342ec155d27]::hir::ModuleItems>::par_impl_items<rustc_hir_analysis[2c6ebfa0ec54105a]::check::wfcheck::check_mod_type_wf::{closure#1}>::{closure#0}>
  37:     0x7f7f57e9798a - rustc_hir_analysis[2c6ebfa0ec54105a]::check::wfcheck::check_mod_type_wf
  38:     0x7f7f57865a4c - rustc_query_impl[c1c3c70d39a20423]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[c1c3c70d39a20423]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[23eac342ec155d27]::query::erase::Erased<[u8; 0usize]>>
  39:     0x7f7f57865a2e - <rustc_query_impl[c1c3c70d39a20423]::query_impl::check_mod_type_wf::dynamic_query::{closure#2} as core[24a2ba61524efef7]::ops::function::FnOnce<(rustc_middle[23eac342ec155d27]::ty::context::TyCtxt, rustc_span[c85fb125fe1c027]::def_id::LocalDefId)>>::call_once
  40:     0x7f7f573713ff - rustc_query_system[85489b7677581133]::query::plumbing::try_execute_query::<rustc_query_impl[c1c3c70d39a20423]::DynamicConfig<rustc_query_system[85489b7677581133]::query::caches::VecCache<rustc_span[c85fb125fe1c027]::def_id::LocalDefId, rustc_middle[23eac342ec155d27]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[c1c3c70d39a20423]::plumbing::QueryCtxt, false>
  41:     0x7f7f584ad142 - rustc_query_impl[c1c3c70d39a20423]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
  42:     0x7f7f57fdb547 - rustc_data_structures[1e82c702e6afba98]::sync::par_for_each_in::<&[rustc_hir[ef37331cc27c2adb]::hir_id::OwnerId], <rustc_middle[23eac342ec155d27]::hir::map::Map>::par_for_each_module<rustc_hir_analysis[2c6ebfa0ec54105a]::check_crate::{closure#5}::{closure#0}::{closure#0}>::{closure#0}>
  43:     0x7f7f57fda8fe - rustc_hir_analysis[2c6ebfa0ec54105a]::check_crate
  44:     0x7f7f57fd398a - rustc_interface[22a5bdce7fd6e981]::passes::analysis
  45:     0x7f7f58027c3a - rustc_query_impl[c1c3c70d39a20423]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[c1c3c70d39a20423]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[23eac342ec155d27]::query::erase::Erased<[u8; 1usize]>>
  46:     0x7f7f58027c29 - <rustc_query_impl[c1c3c70d39a20423]::query_impl::analysis::dynamic_query::{closure#2} as core[24a2ba61524efef7]::ops::function::FnOnce<(rustc_middle[23eac342ec155d27]::ty::context::TyCtxt, ())>>::call_once
  47:     0x7f7f581cbfa8 - rustc_query_system[85489b7677581133]::query::plumbing::try_execute_query::<rustc_query_impl[c1c3c70d39a20423]::DynamicConfig<rustc_query_system[85489b7677581133]::query::caches::SingleCache<rustc_middle[23eac342ec155d27]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[c1c3c70d39a20423]::plumbing::QueryCtxt, false>
  48:     0x7f7f581cbd37 - rustc_query_impl[c1c3c70d39a20423]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  49:     0x7f7f57da39a5 - <rustc_middle[23eac342ec155d27]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[953ac255d00f3c7f]::run_compiler::{closure#1}::{closure#2}::{closure#4}, core[24a2ba61524efef7]::result::Result<(), rustc_span[c85fb125fe1c027]::ErrorGuaranteed>>
  50:     0x7f7f57da2fd2 - <rustc_interface[22a5bdce7fd6e981]::interface::Compiler>::enter::<rustc_driver_impl[953ac255d00f3c7f]::run_compiler::{closure#1}::{closure#2}, core[24a2ba61524efef7]::result::Result<core[24a2ba61524efef7]::option::Option<rustc_interface[22a5bdce7fd6e981]::queries::Linker>, rustc_span[c85fb125fe1c027]::ErrorGuaranteed>>
  51:     0x7f7f57d9c0a8 - std[cfe24ee53075a1e5]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[22a5bdce7fd6e981]::util::run_in_thread_pool_with_globals<rustc_interface[22a5bdce7fd6e981]::interface::run_compiler<core[24a2ba61524efef7]::result::Result<(), rustc_span[c85fb125fe1c027]::ErrorGuaranteed>, rustc_driver_impl[953ac255d00f3c7f]::run_compiler::{closure#1}>::{closure#0}, core[24a2ba61524efef7]::result::Result<(), rustc_span[c85fb125fe1c027]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[24a2ba61524efef7]::result::Result<(), rustc_span[c85fb125fe1c027]::ErrorGuaranteed>>
  52:     0x7f7f57d9b82e - <<std[cfe24ee53075a1e5]::thread::Builder>::spawn_unchecked_<rustc_interface[22a5bdce7fd6e981]::util::run_in_thread_pool_with_globals<rustc_interface[22a5bdce7fd6e981]::interface::run_compiler<core[24a2ba61524efef7]::result::Result<(), rustc_span[c85fb125fe1c027]::ErrorGuaranteed>, rustc_driver_impl[953ac255d00f3c7f]::run_compiler::{closure#1}>::{closure#0}, core[24a2ba61524efef7]::result::Result<(), rustc_span[c85fb125fe1c027]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[24a2ba61524efef7]::result::Result<(), rustc_span[c85fb125fe1c027]::ErrorGuaranteed>>::{closure#1} as core[24a2ba61524efef7]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  53:     0x7f7f59d64445 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h021e65daf5fb4ee0
                               at /rustc/db7ff98a72f3e742b641f9cb16d0e8c285e87e9b/library/alloc/src/boxed.rs:2007:9
  54:     0x7f7f59d64445 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h7dda744b120f2954
                               at /rustc/db7ff98a72f3e742b641f9cb16d0e8c285e87e9b/library/alloc/src/boxed.rs:2007:9
  55:     0x7f7f59d64445 - std::sys::unix::thread::Thread::new::thread_start::hcffeb1067f9b6dfb
                               at /rustc/db7ff98a72f3e742b641f9cb16d0e8c285e87e9b/library/std/src/sys/unix/thread.rs:108:17
  56:     0x7f7f552f96db - start_thread
  57:     0x7f7f5502261f - clone
  58:                0x0 - <unknown>

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 attach the file at `/home/coding/rustc-ice-2023-08-01T01:45:42.590021771Z-10152.txt` to your bug report

query stack during panic:
#0 [check_well_formed] checking that `A` is well-formed
#1 [check_mod_type_wf] checking that types are well-formed in top-level module
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors; 1 warning emitted

@iamanonymouscs iamanonymouscs 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 Aug 1, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 1, 2023
@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 1, 2023
@asquared31415
Copy link
Contributor

This appears to be a different way to reproduce #114212

@rustbot label +F-generic-const-exprs +requires-incomplete-features

@iamanonymouscs
Copy link
Author

This appears to be a different way to reproduce #114212

@rustbot label +F-generic-const-exprs +requires-incomplete-features

Thank you for bringing this🤗. Upon a thorough review, it appears that the query stacks for these two issues differ, suggesting that they are distinct Internal Compiler Errors (ICEs). However, we also notice that the compiler versions associated with these issues also differ. Thus, we cannot ascertain whether the variance in the query stack is because of the compiler versions.

@NightEule5
Copy link

NightEule5 commented Aug 27, 2023

These seem like related but different issues, or maybe the same issue but changed in newer compiler versions. Edit: same issue, the file was renamed in #113591

I encountered an ICE similar to this one, but with a pattern more similar to the older issue:

pub const SIZE: usize = 8192;

pub struct Segment<
    const N: usize = SIZE, // replacing with literal 8192 fixes it
    T = u8
> {
    _data: PhantomData<T>
}

The source of the panic is generic_args.rs:900:9, whereas in the linked issue it's subst.rs:896:9. I'm on the latest nightly, 1.74.0 (2023-08-26).

Here's my backtrace, if it's helpful:

Backtrace
thread 'rustc' panicked at /rustc/69e97df5ce571a777acd654ec3697ae8d25962ea/compiler/rustc_errors/src/lib.rs:1649:9:
Box<dyn Any>
stack backtrace:
   0:     0x7fca5b562fac - std::backtrace_rs::backtrace::libunwind::trace::h7ead10aab469b9aa
                               at /rustc/69e97df5ce571a777acd654ec3697ae8d25962ea/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7fca5b562fac - std::backtrace_rs::backtrace::trace_unsynchronized::hf548e9e8c1fe3e8d
                               at /rustc/69e97df5ce571a777acd654ec3697ae8d25962ea/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fca5b562fac - std::sys_common::backtrace::_print_fmt::h4f790d56eeca616b
                               at /rustc/69e97df5ce571a777acd654ec3697ae8d25962ea/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7fca5b562fac - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h30e5bb3d4404f378
                               at /rustc/69e97df5ce571a777acd654ec3697ae8d25962ea/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7fca5b5c91dc - core::fmt::rt::Argument::fmt::h35f06f2256f98b43
                               at /rustc/69e97df5ce571a777acd654ec3697ae8d25962ea/library/core/src/fmt/rt.rs:138:9
   5:     0x7fca5b5c91dc - core::fmt::write::h5005ce68dd6774c4
                               at /rustc/69e97df5ce571a777acd654ec3697ae8d25962ea/library/core/src/fmt/mod.rs:1094:21
   6:     0x7fca5b555ace - std::io::Write::write_fmt::h2076d3e405c4c14e
                               at /rustc/69e97df5ce571a777acd654ec3697ae8d25962ea/library/std/src/io/mod.rs:1714:15
   7:     0x7fca5b562d94 - std::sys_common::backtrace::_print::hedccafa15bd98864
                               at /rustc/69e97df5ce571a777acd654ec3697ae8d25962ea/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7fca5b562d94 - std::sys_common::backtrace::print::h911d101d11c4e8b0
                               at /rustc/69e97df5ce571a777acd654ec3697ae8d25962ea/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7fca5b565e8a - std::panicking::panic_hook_with_disk_dump::{{closure}}::he8cf7cbd1dd11756
                               at /rustc/69e97df5ce571a777acd654ec3697ae8d25962ea/library/std/src/panicking.rs:278:22
  10:     0x7fca5b565b3a - std::panicking::panic_hook_with_disk_dump::h3baf172fecd393f6
                               at /rustc/69e97df5ce571a777acd654ec3697ae8d25962ea/library/std/src/panicking.rs:305:9
  11:     0x7fca5e74a279 - <rustc_driver_impl[98acc53e2d2f6ece]::install_ice_hook::{closure#0} as core[cb689c380e703cde]::ops::function::FnOnce<(&core[cb689c380e703cde]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  12:     0x7fca5b566731 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h8e3b5b4f77120996
                               at /rustc/69e97df5ce571a777acd654ec3697ae8d25962ea/library/alloc/src/boxed.rs:2021:9
  13:     0x7fca5b566731 - std::panicking::rust_panic_with_hook::hcec56ff9d71a6f8a
                               at /rustc/69e97df5ce571a777acd654ec3697ae8d25962ea/library/std/src/panicking.rs:733:13
  14:     0x7fca5ecfa761 - std[ebccec195fc5e844]::panicking::begin_panic::<rustc_errors[20973ea23cc60a53]::ExplicitBug>::{closure#0}
  15:     0x7fca5ecf8556 - std[ebccec195fc5e844]::sys_common::backtrace::__rust_end_short_backtrace::<std[ebccec195fc5e844]::panicking::begin_panic<rustc_errors[20973ea23cc60a53]::ExplicitBug>::{closure#0}, !>
  16:     0x7fca5eca72e6 - std[ebccec195fc5e844]::panicking::begin_panic::<rustc_errors[20973ea23cc60a53]::ExplicitBug>
  17:     0x7fca5ec64c64 - <rustc_errors[20973ea23cc60a53]::HandlerInner>::bug::<alloc[79ce024021085db3]::string::String>
  18:     0x7fca5ec64af6 - <rustc_errors[20973ea23cc60a53]::Handler>::bug::<alloc[79ce024021085db3]::string::String>
  19:     0x7fca5ed1fe3c - rustc_middle[464349d56e47250b]::util::bug::opt_span_bug_fmt::<rustc_span[c92a35b362599b57]::span_encoding::Span>::{closure#0}
  20:     0x7fca5ed1e47a - rustc_middle[464349d56e47250b]::ty::context::tls::with_opt::<rustc_middle[464349d56e47250b]::util::bug::opt_span_bug_fmt<rustc_span[c92a35b362599b57]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7fca5ed1e448 - rustc_middle[464349d56e47250b]::ty::context::tls::with_context_opt::<rustc_middle[464349d56e47250b]::ty::context::tls::with_opt<rustc_middle[464349d56e47250b]::util::bug::opt_span_bug_fmt<rustc_span[c92a35b362599b57]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7fca5d2e3f50 - rustc_middle[464349d56e47250b]::util::bug::bug_fmt
  23:     0x7fca5ed10290 - <rustc_middle[464349d56e47250b]::ty::generic_args::ArgFolder>::type_param_out_of_range
  24:     0x7fca5c861b23 - <&rustc_middle[464349d56e47250b]::ty::list::List<rustc_middle[464349d56e47250b]::ty::generic_args::GenericArg> as rustc_type_ir[e178ec1199739dae]::fold::TypeFoldable<rustc_middle[464349d56e47250b]::ty::context::TyCtxt>>::try_fold_with::<rustc_middle[464349d56e47250b]::ty::generic_args::ArgFolder>
  25:     0x7fca5c83efc5 - <rustc_middle[464349d56e47250b]::ty::generics::GenericPredicates>::instantiate_into
  26:     0x7fca5caf1420 - <rustc_trait_selection[29b3d3d8574f926e]::traits::wf::WfPredicates>::nominal_obligations
  27:     0x7fca5cad3085 - <rustc_trait_selection[29b3d3d8574f926e]::traits::wf::WfPredicates>::compute
  28:     0x7fca5cac2422 - <rustc_trait_selection[29b3d3d8574f926e]::traits::fulfill::FulfillProcessor as rustc_data_structures[7283f0e76412c80]::obligation_forest::ObligationProcessor>::process_obligation
  29:     0x7fca5cabdcf4 - <rustc_data_structures[7283f0e76412c80]::obligation_forest::ObligationForest<rustc_trait_selection[29b3d3d8574f926e]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[29b3d3d8574f926e]::traits::fulfill::FulfillProcessor>
  30:     0x7fca5d0fa8e1 - <rustc_trait_selection[29b3d3d8574f926e]::traits::engine::ObligationCtxt>::select_all_or_error
  31:     0x7fca5d04ff99 - rustc_hir_analysis[667fece327758e4f]::check::wfcheck::check_type_defn
  32:     0x7fca5d02dffe - rustc_hir_analysis[667fece327758e4f]::check::wfcheck::check_well_formed
  33:     0x7fca5c80409c - rustc_query_impl[58a3c40f53c1e9dd]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[58a3c40f53c1e9dd]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[464349d56e47250b]::query::erase::Erased<[u8; 0usize]>>
  34:     0x7fca5c80407c - <rustc_query_impl[58a3c40f53c1e9dd]::query_impl::check_well_formed::dynamic_query::{closure#2} as core[cb689c380e703cde]::ops::function::FnOnce<(rustc_middle[464349d56e47250b]::ty::context::TyCtxt, rustc_hir[3a72116ea74f2480]::hir_id::OwnerId)>>::call_once
  35:     0x7fca5c92d6cc - rustc_query_system[771da89a8e6a97f0]::query::plumbing::try_execute_query::<rustc_query_impl[58a3c40f53c1e9dd]::DynamicConfig<rustc_query_system[771da89a8e6a97f0]::query::caches::VecCache<rustc_hir[3a72116ea74f2480]::hir_id::OwnerId, rustc_middle[464349d56e47250b]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[58a3c40f53c1e9dd]::plumbing::QueryCtxt, true>
  36:     0x7fca5c92d03b - rustc_query_impl[58a3c40f53c1e9dd]::query_impl::check_well_formed::get_query_incr::__rust_end_short_backtrace
  37:     0x7fca5d9b9280 - rustc_data_structures[7283f0e76412c80]::sync::par_for_each_in::<&[rustc_hir[3a72116ea74f2480]::hir::ItemId], <rustc_middle[464349d56e47250b]::hir::ModuleItems>::par_items<rustc_hir_analysis[667fece327758e4f]::check::wfcheck::check_mod_type_wf::{closure#0}>::{closure#0}>
  38:     0x7fca5d9b904f - rustc_hir_analysis[667fece327758e4f]::check::wfcheck::check_mod_type_wf
  39:     0x7fca5d475c7c - rustc_query_impl[58a3c40f53c1e9dd]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[58a3c40f53c1e9dd]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[464349d56e47250b]::query::erase::Erased<[u8; 0usize]>>
  40:     0x7fca5d475c5e - <rustc_query_impl[58a3c40f53c1e9dd]::query_impl::check_mod_type_wf::dynamic_query::{closure#2} as core[cb689c380e703cde]::ops::function::FnOnce<(rustc_middle[464349d56e47250b]::ty::context::TyCtxt, rustc_span[c92a35b362599b57]::def_id::LocalModDefId)>>::call_once
  41:     0x7fca5ddae0fb - rustc_query_system[771da89a8e6a97f0]::query::plumbing::try_execute_query::<rustc_query_impl[58a3c40f53c1e9dd]::DynamicConfig<rustc_query_system[771da89a8e6a97f0]::query::caches::DefaultCache<rustc_span[c92a35b362599b57]::def_id::LocalModDefId, rustc_middle[464349d56e47250b]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[58a3c40f53c1e9dd]::plumbing::QueryCtxt, true>
  42:     0x7fca5e0ccee8 - rustc_query_impl[58a3c40f53c1e9dd]::query_impl::check_mod_type_wf::get_query_incr::__rust_end_short_backtrace
  43:     0x7fca5d67069b - rustc_hir_analysis[667fece327758e4f]::check_crate
  44:     0x7fca5d669c4a - rustc_interface[b81038288d48d278]::passes::analysis
  45:     0x7fca5dc5ca4a - rustc_query_impl[58a3c40f53c1e9dd]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[58a3c40f53c1e9dd]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[464349d56e47250b]::query::erase::Erased<[u8; 1usize]>>
  46:     0x7fca5dc5ca39 - <rustc_query_impl[58a3c40f53c1e9dd]::query_impl::analysis::dynamic_query::{closure#2} as core[cb689c380e703cde]::ops::function::FnOnce<(rustc_middle[464349d56e47250b]::ty::context::TyCtxt, ())>>::call_once
  47:     0x7fca5df34ab8 - rustc_query_system[771da89a8e6a97f0]::query::plumbing::try_execute_query::<rustc_query_impl[58a3c40f53c1e9dd]::DynamicConfig<rustc_query_system[771da89a8e6a97f0]::query::caches::SingleCache<rustc_middle[464349d56e47250b]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[58a3c40f53c1e9dd]::plumbing::QueryCtxt, true>
  48:     0x7fca5df34614 - rustc_query_impl[58a3c40f53c1e9dd]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
  49:     0x7fca5da28da6 - <rustc_middle[464349d56e47250b]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[98acc53e2d2f6ece]::run_compiler::{closure#1}::{closure#2}::{closure#6}, core[cb689c380e703cde]::result::Result<(), rustc_span[c92a35b362599b57]::ErrorGuaranteed>>
  50:     0x7fca5da2822c - <rustc_interface[b81038288d48d278]::interface::Compiler>::enter::<rustc_driver_impl[98acc53e2d2f6ece]::run_compiler::{closure#1}::{closure#2}, core[cb689c380e703cde]::result::Result<core[cb689c380e703cde]::option::Option<rustc_interface[b81038288d48d278]::queries::Linker>, rustc_span[c92a35b362599b57]::ErrorGuaranteed>>
  51:     0x7fca5da25548 - std[ebccec195fc5e844]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[b81038288d48d278]::util::run_in_thread_pool_with_globals<rustc_interface[b81038288d48d278]::interface::run_compiler<core[cb689c380e703cde]::result::Result<(), rustc_span[c92a35b362599b57]::ErrorGuaranteed>, rustc_driver_impl[98acc53e2d2f6ece]::run_compiler::{closure#1}>::{closure#0}, core[cb689c380e703cde]::result::Result<(), rustc_span[c92a35b362599b57]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[cb689c380e703cde]::result::Result<(), rustc_span[c92a35b362599b57]::ErrorGuaranteed>>
  52:     0x7fca5dfc60f5 - <<std[ebccec195fc5e844]::thread::Builder>::spawn_unchecked_<rustc_interface[b81038288d48d278]::util::run_in_thread_pool_with_globals<rustc_interface[b81038288d48d278]::interface::run_compiler<core[cb689c380e703cde]::result::Result<(), rustc_span[c92a35b362599b57]::ErrorGuaranteed>, rustc_driver_impl[98acc53e2d2f6ece]::run_compiler::{closure#1}>::{closure#0}, core[cb689c380e703cde]::result::Result<(), rustc_span[c92a35b362599b57]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[cb689c380e703cde]::result::Result<(), rustc_span[c92a35b362599b57]::ErrorGuaranteed>>::{closure#1} as core[cb689c380e703cde]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  53:     0x7fca5b571195 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hf6677bb1228f81ea
                               at /rustc/69e97df5ce571a777acd654ec3697ae8d25962ea/library/alloc/src/boxed.rs:2007:9
  54:     0x7fca5b571195 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h4f3130db7e13aaba
                               at /rustc/69e97df5ce571a777acd654ec3697ae8d25962ea/library/alloc/src/boxed.rs:2007:9
  55:     0x7fca5b571195 - std::sys::unix::thread::Thread::new::thread_start::h17fc5e491c7b31dd
                               at /rustc/69e97df5ce571a777acd654ec3697ae8d25962ea/library/std/src/sys/unix/thread.rs:108:17
  56:     0x7fca5b28c9eb - <unknown>
  57:     0x7fca5b310ebc - <unknown>
  58:                0x0 - <unknown>


rustc version: 1.74.0-nightly (69e97df5c 2023-08-26)
platform: x86_64-unknown-linux-gnu

query stack during panic:
#0 [check_well_formed] checking that `new::segment::Segment` is well-formed
#1 [check_mod_type_wf] checking that types are well-formed in module `new::segment`
#2 [analysis] running analysis passes on this crate
end of query stack

@iamanonymouscs
Copy link
Author

These seem like related but different issues, or maybe the same issue but changed in newer compiler versions. Edit: same issue, the file was renamed in #113591

I encountered an ICE similar to this one, but with a pattern more similar to the older issue:

pub const SIZE: usize = 8192;

pub struct Segment<
    const N: usize = SIZE, // replacing with literal 8192 fixes it
    T = u8
> {
    _data: PhantomData<T>
}

The source of the panic is generic_args.rs:900:9, whereas in the linked issue it's subst.rs:896:9. I'm on the latest nightly, 1.74.0 (2023-08-26).

Here's my backtrace, if it's helpful:

Backtrace

Thank you very much for your reply. I think I have gained a better understanding of Rustc😃🚀

@gurry
Copy link
Contributor

gurry commented Sep 9, 2023

@rustbot claim

@gurry
Copy link
Contributor

gurry commented Sep 13, 2023

Duplicate of #106994

Perhaps we can close this one in favour of that.

@gurry
Copy link
Contributor

gurry commented Sep 13, 2023

@rustbot release-assignment

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. F-generic_const_exprs `#![feature(generic_const_exprs)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-incomplete-features 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

8 participants