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: type parameter C/#1 (C/1) out of range when substituting, substs=[] with generic_const_exprs #105631

Closed
Tracked by #106994
matthiaskrgr opened this issue Dec 12, 2022 · 4 comments
Assignees
Labels
A-const-generics Area: const generics (parameters and arguments) C-bug Category: This is a bug. F-generic_const_exprs `#![feature(generic_const_exprs)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Dec 12, 2022

Code

#![feature(generic_const_exprs)]

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

fn main() {}

Meta

rustc --version --verbose:

rustc 1.68.0-nightly (bdb07a8ec 2022-12-11)
binary: rustc
commit-hash: bdb07a8ec8e77aa10fb84fae1d4ff71c21180bb4
commit-date: 2022-12-11
host: x86_64-unknown-linux-gnu
release: 1.68.0-nightly
LLVM version: 15.0.6

Error output

rustc 50314435a21ec2b74a4dc68e60cc6deb46a13cf5.rs "-Zcrate-attr=feature(generic_const_exprs)"

<output>
Backtrace

error: generic parameters with a default must be trailing
 --> 50314435a21ec2b74a4dc68e60cc6deb46a13cf5.rs:1:16
  |
1 | 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
 --> <crate attribute>:1:9
  |
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[E0601]: `main` function not found in crate `50314435a21ec2b74a4dc68e60cc6deb46a13cf5`
 --> 50314435a21ec2b74a4dc68e60cc6deb46a13cf5.rs:1:31
  |
1 | struct A<const B: str = 1, C>;
  |                               ^ consider adding a `main` function to `50314435a21ec2b74a4dc68e60cc6deb46a13cf5.rs`

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

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/37d7de337903a558dbeb1e82c844fe915ab8ff25/compiler/rustc_errors/src/lib.rs:1576:9
stack backtrace:
   0:     0x7f3ceddfc08a - std::backtrace_rs::backtrace::libunwind::trace::hfda0c84a965521cd
                               at /rustc/37d7de337903a558dbeb1e82c844fe915ab8ff25/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f3ceddfc08a - std::backtrace_rs::backtrace::trace_unsynchronized::hb4c77e9a0ab39876
                               at /rustc/37d7de337903a558dbeb1e82c844fe915ab8ff25/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f3ceddfc08a - std::sys_common::backtrace::_print_fmt::h90a0f36d188872e4
                               at /rustc/37d7de337903a558dbeb1e82c844fe915ab8ff25/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f3ceddfc08a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hcf69d31a684178f0
                               at /rustc/37d7de337903a558dbeb1e82c844fe915ab8ff25/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f3ce9dc92ee - core::fmt::write::h19bd8e6ee5a43794
                               at /rustc/37d7de337903a558dbeb1e82c844fe915ab8ff25/library/core/src/fmt/mod.rs:1208:17
   5:     0x7f3ceddf0265 - std::io::Write::write_fmt::h3dff860cdcbf5447
                               at /rustc/37d7de337903a558dbeb1e82c844fe915ab8ff25/library/std/src/io/mod.rs:1682:15
   6:     0x7f3ceddfbe55 - std::sys_common::backtrace::_print::h48017f73c87ac794
                               at /rustc/37d7de337903a558dbeb1e82c844fe915ab8ff25/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f3ceddfbe55 - std::sys_common::backtrace::print::hb42dffa5d9accf4b
                               at /rustc/37d7de337903a558dbeb1e82c844fe915ab8ff25/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f3ceddfe1df - std::panicking::default_hook::{{closure}}::hfc58fc344bf73349
                               at /rustc/37d7de337903a558dbeb1e82c844fe915ab8ff25/library/std/src/panicking.rs:267:22
   9:     0x7f3ceddfdf1b - std::panicking::default_hook::hfaa22e37daf4a9c7
                               at /rustc/37d7de337903a558dbeb1e82c844fe915ab8ff25/library/std/src/panicking.rs:286:9
  10:     0x7f3ced041981 - rustc_driver[bdbb702eb16d0476]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f3ceddfe9dd - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hb2dc1035f48c2d6b
                               at /rustc/37d7de337903a558dbeb1e82c844fe915ab8ff25/library/alloc/src/boxed.rs:2032:9
  12:     0x7f3ceddfe9dd - std::panicking::rust_panic_with_hook::h3019baa6ec2271e6
                               at /rustc/37d7de337903a558dbeb1e82c844fe915ab8ff25/library/std/src/panicking.rs:692:13
  13:     0x7f3ced4faef1 - std[5b7bc53473a6a785]::panicking::begin_panic::<rustc_errors[319696ed16cd0c04]::ExplicitBug>::{closure#0}
  14:     0x7f3ced4f77a6 - std[5b7bc53473a6a785]::sys_common::backtrace::__rust_end_short_backtrace::<std[5b7bc53473a6a785]::panicking::begin_panic<rustc_errors[319696ed16cd0c04]::ExplicitBug>::{closure#0}, !>
  15:     0x7f3ced5158d6 - std[5b7bc53473a6a785]::panicking::begin_panic::<rustc_errors[319696ed16cd0c04]::ExplicitBug>
  16:     0x7f3ced4dbda6 - std[5b7bc53473a6a785]::panic::panic_any::<rustc_errors[319696ed16cd0c04]::ExplicitBug>
  17:     0x7f3ced4d8436 - <rustc_errors[319696ed16cd0c04]::HandlerInner>::bug::<&alloc[72aac1fd12f17fda]::string::String>
  18:     0x7f3ced4d80a0 - <rustc_errors[319696ed16cd0c04]::Handler>::bug::<&alloc[72aac1fd12f17fda]::string::String>
  19:     0x7f3ced4ba37e - rustc_middle[6397d9e15d1d5931]::ty::context::tls::with_context_opt::<rustc_middle[6397d9e15d1d5931]::ty::context::tls::with_opt<rustc_middle[6397d9e15d1d5931]::util::bug::opt_span_bug_fmt<rustc_span[6dcdc27d3fb72bcd]::span_encoding::Span>::{closure#0}, ()>::{closure#0}, ()>
  20:     0x7f3ced4bb7e6 - rustc_middle[6397d9e15d1d5931]::util::bug::opt_span_bug_fmt::<rustc_span[6dcdc27d3fb72bcd]::span_encoding::Span>
  21:     0x7f3ceb34be33 - rustc_middle[6397d9e15d1d5931]::util::bug::bug_fmt
  22:     0x7f3ced50c6de - <rustc_middle[6397d9e15d1d5931]::ty::subst::SubstFolder>::type_param_out_of_range
  23:     0x7f3ceb07224a - <rustc_middle[6397d9e15d1d5931]::ty::subst::SubstFolder as rustc_middle[6397d9e15d1d5931]::ty::fold::FallibleTypeFolder>::try_fold_ty
  24:     0x7f3ceb0b7360 - <rustc_middle[6397d9e15d1d5931]::ty::generics::GenericPredicates>::instantiate_into
  25:     0x7f3ceb654fec - <rustc_trait_selection[515fa11591fd8c16]::traits::wf::WfPredicates>::nominal_obligations_inner
  26:     0x7f3ceb651f8c - <rustc_trait_selection[515fa11591fd8c16]::traits::wf::WfPredicates>::compute
  27:     0x7f3ceb3178ba - <rustc_trait_selection[515fa11591fd8c16]::traits::fulfill::FulfillProcessor as rustc_data_structures[2590a8ceb977e72a]::obligation_forest::ObligationProcessor>::process_obligation
  28:     0x7f3ceb314cfe - <rustc_data_structures[2590a8ceb977e72a]::obligation_forest::ObligationForest<rustc_trait_selection[515fa11591fd8c16]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[515fa11591fd8c16]::traits::fulfill::FulfillProcessor>
  29:     0x7f3ceb6c145b - <rustc_trait_selection[515fa11591fd8c16]::traits::engine::ObligationCtxt>::select_all_or_error
  30:     0x7f3cebd4c41f - rustc_hir_analysis[dddb797ff337249c]::check::wfcheck::check_type_defn
  31:     0x7f3cebd2db62 - rustc_hir_analysis[dddb797ff337249c]::check::wfcheck::check_well_formed
  32:     0x7f3ceb2bedd9 - rustc_query_system[1e0b5d04c0053b3e]::query::plumbing::get_query::<rustc_query_impl[3b5b4a0367d35251]::queries::check_well_formed, rustc_query_impl[3b5b4a0367d35251]::plumbing::QueryCtxt>
  33:     0x7f3cec459a88 - rustc_data_structures[2590a8ceb977e72a]::sync::par_for_each_in::<&[rustc_hir[5ad32269bf4a59a0]::hir::ItemId], <rustc_middle[6397d9e15d1d5931]::hir::ModuleItems>::par_items<rustc_hir_analysis[dddb797ff337249c]::check::wfcheck::check_mod_type_wf::{closure#0}>::{closure#0}>
  34:     0x7f3cec459897 - rustc_hir_analysis[dddb797ff337249c]::check::wfcheck::check_mod_type_wf
  35:     0x7f3cebb733cd - rustc_query_system[1e0b5d04c0053b3e]::query::plumbing::try_execute_query::<rustc_query_impl[3b5b4a0367d35251]::plumbing::QueryCtxt, rustc_query_system[1e0b5d04c0053b3e]::query::caches::VecCache<rustc_span[6dcdc27d3fb72bcd]::def_id::LocalDefId, ()>>
  36:     0x7f3cec435f83 - rustc_query_system[1e0b5d04c0053b3e]::query::plumbing::get_query::<rustc_query_impl[3b5b4a0367d35251]::queries::check_mod_type_wf, rustc_query_impl[3b5b4a0367d35251]::plumbing::QueryCtxt>
  37:     0x7f3ceb5d87b8 - rustc_data_structures[2590a8ceb977e72a]::sync::par_for_each_in::<&[rustc_hir[5ad32269bf4a59a0]::hir_id::OwnerId], <rustc_middle[6397d9e15d1d5931]::hir::map::Map>::par_for_each_module<rustc_hir_analysis[dddb797ff337249c]::check_crate::{closure#5}::{closure#0}::{closure#0}>::{closure#0}>
  38:     0x7f3ceb5d85a3 - <rustc_session[5df4e27bf1f67b65]::session::Session>::track_errors::<rustc_hir_analysis[dddb797ff337249c]::check_crate::{closure#5}, ()>
  39:     0x7f3ceb5d7ebd - rustc_hir_analysis[dddb797ff337249c]::check_crate
  40:     0x7f3ceb5d7b5b - rustc_interface[93e822c6d39e8f73]::passes::analysis
  41:     0x7f3cec809ab7 - rustc_query_system[1e0b5d04c0053b3e]::query::plumbing::try_execute_query::<rustc_query_impl[3b5b4a0367d35251]::plumbing::QueryCtxt, rustc_query_system[1e0b5d04c0053b3e]::query::caches::DefaultCache<(), core[1fc7cd95a807b574]::result::Result<(), rustc_errors[319696ed16cd0c04]::ErrorGuaranteed>>>
  42:     0x7f3cec8097b0 - rustc_query_system[1e0b5d04c0053b3e]::query::plumbing::get_query::<rustc_query_impl[3b5b4a0367d35251]::queries::analysis, rustc_query_impl[3b5b4a0367d35251]::plumbing::QueryCtxt>
  43:     0x7f3cec223553 - <rustc_interface[93e822c6d39e8f73]::passes::QueryContext>::enter::<rustc_driver[bdbb702eb16d0476]::run_compiler::{closure#1}::{closure#2}::{closure#2}, core[1fc7cd95a807b574]::result::Result<(), rustc_errors[319696ed16cd0c04]::ErrorGuaranteed>>
  44:     0x7f3cec21f903 - <rustc_interface[93e822c6d39e8f73]::interface::Compiler>::enter::<rustc_driver[bdbb702eb16d0476]::run_compiler::{closure#1}::{closure#2}, core[1fc7cd95a807b574]::result::Result<core[1fc7cd95a807b574]::option::Option<rustc_interface[93e822c6d39e8f73]::queries::Linker>, rustc_errors[319696ed16cd0c04]::ErrorGuaranteed>>
  45:     0x7f3cec21a958 - rustc_span[6dcdc27d3fb72bcd]::with_source_map::<core[1fc7cd95a807b574]::result::Result<(), rustc_errors[319696ed16cd0c04]::ErrorGuaranteed>, rustc_interface[93e822c6d39e8f73]::interface::run_compiler<core[1fc7cd95a807b574]::result::Result<(), rustc_errors[319696ed16cd0c04]::ErrorGuaranteed>, rustc_driver[bdbb702eb16d0476]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  46:     0x7f3cec21a445 - <scoped_tls[25e3808d32e5689d]::ScopedKey<rustc_span[6dcdc27d3fb72bcd]::SessionGlobals>>::set::<rustc_interface[93e822c6d39e8f73]::interface::run_compiler<core[1fc7cd95a807b574]::result::Result<(), rustc_errors[319696ed16cd0c04]::ErrorGuaranteed>, rustc_driver[bdbb702eb16d0476]::run_compiler::{closure#1}>::{closure#0}, core[1fc7cd95a807b574]::result::Result<(), rustc_errors[319696ed16cd0c04]::ErrorGuaranteed>>
  47:     0x7f3cec219a32 - std[5b7bc53473a6a785]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[93e822c6d39e8f73]::util::run_in_thread_pool_with_globals<rustc_interface[93e822c6d39e8f73]::interface::run_compiler<core[1fc7cd95a807b574]::result::Result<(), rustc_errors[319696ed16cd0c04]::ErrorGuaranteed>, rustc_driver[bdbb702eb16d0476]::run_compiler::{closure#1}>::{closure#0}, core[1fc7cd95a807b574]::result::Result<(), rustc_errors[319696ed16cd0c04]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[1fc7cd95a807b574]::result::Result<(), rustc_errors[319696ed16cd0c04]::ErrorGuaranteed>>
  48:     0x7f3cec90521e - <<std[5b7bc53473a6a785]::thread::Builder>::spawn_unchecked_<rustc_interface[93e822c6d39e8f73]::util::run_in_thread_pool_with_globals<rustc_interface[93e822c6d39e8f73]::interface::run_compiler<core[1fc7cd95a807b574]::result::Result<(), rustc_errors[319696ed16cd0c04]::ErrorGuaranteed>, rustc_driver[bdbb702eb16d0476]::run_compiler::{closure#1}>::{closure#0}, core[1fc7cd95a807b574]::result::Result<(), rustc_errors[319696ed16cd0c04]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[1fc7cd95a807b574]::result::Result<(), rustc_errors[319696ed16cd0c04]::ErrorGuaranteed>>::{closure#1} as core[1fc7cd95a807b574]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  49:     0x7f3cede05d43 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h42efb82b00c95319
                               at /rustc/37d7de337903a558dbeb1e82c844fe915ab8ff25/library/alloc/src/boxed.rs:2000:9
  50:     0x7f3cede05d43 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h4633c69af83ebe41
                               at /rustc/37d7de337903a558dbeb1e82c844fe915ab8ff25/library/alloc/src/boxed.rs:2000:9
  51:     0x7f3cede05d43 - std::sys::unix::thread::Thread::new::thread_start::h3684c40002084fda
                               at /rustc/37d7de337903a558dbeb1e82c844fe915ab8ff25/library/std/src/sys/unix/thread.rs:108:17
  52:     0x7f3ce9b068fd - <unknown>
  53:     0x7f3ce9b88a60 - <unknown>
  54:                0x0 - <unknown>

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.68.0-nightly (37d7de337 2022-12-12) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z crate-attr=feature(generic_const_exprs)

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 3 previous errors; 1 warning 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. requires-nightly This issue requires a nightly compiler in some way. F-generic_const_exprs `#![feature(generic_const_exprs)]` labels Dec 12, 2022
@compiler-errors compiler-errors changed the title ICE: type parameter C/#1 (C/1) out of range when substituting, substs=[] with generic_const_exprs ICE: type parameter C/#1 (C/1) out of range when substituting, substs=[] with generic_const_exprs Dec 12, 2022
@jruderman
Copy link
Contributor

Regression in nightly-2021-09-01

Commits in range
  commit[0] 2021-08-30UTC: Auto merge of #88466 - sexxi-goose:issue-88372, r=nikomatsakis
  commit[1] 2021-08-30UTC: Auto merge of #88369 - lcnr:cec-rename, r=oli-obk
  commit[2] 2021-08-31UTC: Auto merge of #88100 - HTG-YT:edition2021-compopt-stabilization, r=m-ou-se
  commit[3] 2021-08-31UTC: Auto merge of #88414 - Aaron1011:guess-foreign-head-span, r=estebank
  commit[4] 2021-08-31UTC: Auto merge of #88467 - sexxi-goose:issue-88431, r=nikomatsakis
  commit[5] 2021-08-31UTC: Auto merge of #88491 - RalfJung:miri, r=RalfJung
  commit[6] 2021-08-31UTC: Auto merge of #88527 - m-ou-se:rollup-az6xtc5, r=m-ou-se
  commit[7] 2021-08-31UTC: Auto merge of #88535 - m-ou-se:rollup-jeusxbo, r=m-ou-se
  commit[8] 2021-08-31UTC: Auto merge of #88506 - Mark-Simulacrum:fix-rlibs, r=ehuss

@Rageking8
Copy link
Contributor

Similar to #101036

@matthiaskrgr
Copy link
Member Author

https://github.com/rust-lang/rust/issues?q=is%3Aissue++%22out+of+range+when+substituting%22+
🤷

@BoxyUwU
Copy link
Member

BoxyUwU commented Jan 17, 2023

closing in favor of #106994

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-generics Area: const generics (parameters and arguments) C-bug Category: This is a bug. F-generic_const_exprs `#![feature(generic_const_exprs)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. 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

6 participants