Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[crash] adt_const_params + generic_const_exprs "const parameter ... out of range when substituting args" #117496

Closed
Tracked by #106994
DavidSampson opened this issue Nov 1, 2023 · 2 comments
Labels
C-bug Category: This is a bug. F-adt_const_params `#![feature(adt_const_params)]` F-generic_const_exprs `#![feature(generic_const_exprs)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-incomplete-features This issue requires the use of 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

@DavidSampson
Copy link

Code

#![feature(adt_const_params)]
#![feature(generic_const_exprs)]

use core::marker::ConstParamTy;

#[derive(PartialEq, Copy, Clone, Eq, ConstParamTy)]
pub enum Foo {}
impl Foo {
    pub const fn size(self) -> usize {
        1
    }
}

pub struct Bar<const F: Foo, const SIZE: usize = { F.size() }>([u64; SIZE])
where
    [u64; SIZE]: Sized;

pub struct Quux<const F: Foo> {}
impl<const F: Foo> Quux<{ F }> {
    pub unsafe fn nothing(&self, bar: &mut Bar<{ F }>) {}
}

Meta

rustc --version --verbose:

rustc 1.75.0-nightly (9d83ac217 2023-10-31)
binary: rustc
commit-hash: 9d83ac217957eece2189eccf4a7232caec7232ee
commit-date: 2023-10-31
host: aarch64-apple-darwin
release: 1.75.0-nightly
LLVM version: 17.0.3

Error output

error: internal compiler error: compiler/rustc_middle/src/ty/generic_args.rs:947:9: const parameter `SIZE/#1` (SIZE/#1: usize/1) out of range when substituting args=[F/#0: Foo]
Backtrace

thread 'rustc' panicked at /rustc/9d83ac217957eece2189eccf4a7232caec7232ee/compiler/rustc_errors/src/lib.rs:1661:9:
Box<dyn Any>
stack backtrace:
   0:        0x102f302b8 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hdcf5a8f170d2fa38
   1:        0x102f7fd30 - core::fmt::write::h43a20d1d43ba2c4c
   2:        0x102f26ba4 - std::io::Write::write_fmt::hc8f02cc7d187633a
   3:        0x102f300f4 - std::sys_common::backtrace::print::h0f98126c99b558bc
   4:        0x102f32af4 - std::panicking::default_hook::{{closure}}::h37ce2903b5a4a707
   5:        0x102f3283c - std::panicking::default_hook::hdce48845581ed2b0
   6:        0x10bcf1d2c - <alloc[6976fb96cd38c50]::boxed::Box<rustc_driver_impl[64f83dff39c374ae]::install_ice_hook::{closure#0}> as core[d9e5c436b7fa2511]::ops::function::Fn<(&dyn for<'a, 'b> core[d9e5c436b7fa2511]::ops::function::Fn<(&'a core[d9e5c436b7fa2511]::panic::panic_info::PanicInfo<'b>,), Output = ()> + core[d9e5c436b7fa2511]::marker::Send + core[d9e5c436b7fa2511]::marker::Sync, &core[d9e5c436b7fa2511]::panic::panic_info::PanicInfo)>>::call
   7:        0x102f3316c - std::panicking::rust_panic_with_hook::h130fbf332c6cdd6d
   8:        0x10c680964 - std[445e387e9aba505f]::panicking::begin_panic::<rustc_errors[c55e65e1258c6d06]::ExplicitBug>::{closure#0}
   9:        0x10c67f340 - std[445e387e9aba505f]::sys_common::backtrace::__rust_end_short_backtrace::<std[445e387e9aba505f]::panicking::begin_panic<rustc_errors[c55e65e1258c6d06]::ExplicitBug>::{closure#0}, !>
  10:        0x10f8e4ae0 - std[445e387e9aba505f]::panicking::begin_panic::<rustc_errors[c55e65e1258c6d06]::ExplicitBug>
  11:        0x10c653450 - <rustc_errors[c55e65e1258c6d06]::HandlerInner>::bug::<alloc[6976fb96cd38c50]::string::String>
  12:        0x10c653258 - <rustc_errors[c55e65e1258c6d06]::Handler>::bug::<alloc[6976fb96cd38c50]::string::String>
  13:        0x10c776790 - rustc_middle[60e9a44f7a592fc2]::util::bug::opt_span_bug_fmt::<rustc_span[4a0b636bfafc9c3]::span_encoding::Span>::{closure#0}
  14:        0x10c76da4c - rustc_middle[60e9a44f7a592fc2]::ty::context::tls::with_opt::<rustc_middle[60e9a44f7a592fc2]::util::bug::opt_span_bug_fmt<rustc_span[4a0b636bfafc9c3]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  15:        0x10c76da18 - rustc_middle[60e9a44f7a592fc2]::ty::context::tls::with_context_opt::<rustc_middle[60e9a44f7a592fc2]::ty::context::tls::with_opt<rustc_middle[60e9a44f7a592fc2]::util::bug::opt_span_bug_fmt<rustc_span[4a0b636bfafc9c3]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  16:        0x10f8f2018 - rustc_middle[60e9a44f7a592fc2]::util::bug::bug_fmt
  17:        0x10f8ea78c - <rustc_middle[60e9a44f7a592fc2]::ty::generic_args::ArgFolder>::const_param_out_of_range
  18:        0x10c712e10 - <rustc_middle[60e9a44f7a592fc2]::ty::generic_args::ArgFolder as rustc_type_ir[f5b2f2ee10dd83e3]::fold::TypeFolder<rustc_middle[60e9a44f7a592fc2]::ty::context::TyCtxt>>::fold_const
  19:        0x10c76eab0 - <rustc_middle[60e9a44f7a592fc2]::ty::Ty as rustc_type_ir[f5b2f2ee10dd83e3]::fold::TypeSuperFoldable<rustc_middle[60e9a44f7a592fc2]::ty::context::TyCtxt>>::try_super_fold_with::<rustc_middle[60e9a44f7a592fc2]::ty::generic_args::ArgFolder>
  20:        0x10c68ca28 - <&rustc_middle[60e9a44f7a592fc2]::ty::list::List<rustc_middle[60e9a44f7a592fc2]::ty::generic_args::GenericArg> as rustc_type_ir[f5b2f2ee10dd83e3]::fold::TypeFoldable<rustc_middle[60e9a44f7a592fc2]::ty::context::TyCtxt>>::try_fold_with::<rustc_middle[60e9a44f7a592fc2]::ty::generic_args::ArgFolder>
  21:        0x10c6fa010 - <rustc_type_ir[f5b2f2ee10dd83e3]::predicate_kind::ClauseKind<rustc_middle[60e9a44f7a592fc2]::ty::context::TyCtxt> as rustc_type_ir[f5b2f2ee10dd83e3]::fold::TypeFoldable<rustc_middle[60e9a44f7a592fc2]::ty::context::TyCtxt>>::try_fold_with::<rustc_middle[60e9a44f7a592fc2]::ty::generic_args::ArgFolder>
  22:        0x10c6fa888 - <rustc_type_ir[f5b2f2ee10dd83e3]::predicate_kind::PredicateKind<rustc_middle[60e9a44f7a592fc2]::ty::context::TyCtxt> as rustc_type_ir[f5b2f2ee10dd83e3]::fold::TypeFoldable<rustc_middle[60e9a44f7a592fc2]::ty::context::TyCtxt>>::try_fold_with::<rustc_middle[60e9a44f7a592fc2]::ty::generic_args::ArgFolder>
  23:        0x10c7619f4 - <rustc_middle[60e9a44f7a592fc2]::ty::Predicate as rustc_type_ir[f5b2f2ee10dd83e3]::fold::TypeSuperFoldable<rustc_middle[60e9a44f7a592fc2]::ty::context::TyCtxt>>::super_fold_with::<rustc_middle[60e9a44f7a592fc2]::ty::generic_args::ArgFolder>
  24:        0x10c6979fc - <rustc_middle[60e9a44f7a592fc2]::ty::generics::GenericPredicates>::instantiate_into
  25:        0x10d1fedc4 - <rustc_trait_selection[20765d819e279547]::traits::wf::WfPredicates>::nominal_obligations
  26:        0x10d1fdce8 - <rustc_trait_selection[20765d819e279547]::traits::wf::WfPredicates>::compute
  27:        0x10d1fafe8 - rustc_trait_selection[20765d819e279547]::traits::wf::obligations
  28:        0x10d1fca5c - <rustc_trait_selection[20765d819e279547]::traits::fulfill::FulfillProcessor as rustc_data_structures[d0d9fd49f16e47e]::obligation_forest::ObligationProcessor>::process_obligation
  29:        0x10d32cf8c - <rustc_data_structures[d0d9fd49f16e47e]::obligation_forest::ObligationForest<rustc_trait_selection[20765d819e279547]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[20765d819e279547]::traits::fulfill::FulfillProcessor>
  30:        0x10d1f9210 - <rustc_trait_selection[20765d819e279547]::traits::fulfill::FulfillmentContext as rustc_infer[8b7d97ee9fa22e77]::traits::engine::TraitEngine>::select_where_possible
  31:        0x10d36c6bc - <rustc_infer[8b7d97ee9fa22e77]::infer::at::At as rustc_trait_selection[20765d819e279547]::traits::project::NormalizeExt>::deeply_normalize::<rustc_middle[60e9a44f7a592fc2]::ty::Ty>
  32:        0x10d1d7af4 - <rustc_trait_selection[20765d819e279547]::traits::engine::ObligationCtxt>::assumed_wf_types
  33:        0x10c027f44 - rustc_hir_analysis[547b6125a0805be3]::check::wfcheck::check_associated_item
  34:        0x10c01ce88 - rustc_hir_analysis[547b6125a0805be3]::check::wfcheck::check_well_formed
  35:        0x10cda2028 - rustc_query_impl[119047522f02295c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[119047522f02295c]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[60e9a44f7a592fc2]::query::erase::Erased<[u8; 1usize]>>
  36:        0x10ce4f348 - <rustc_query_impl[119047522f02295c]::query_impl::check_well_formed::dynamic_query::{closure#2} as core[d9e5c436b7fa2511]::ops::function::FnOnce<(rustc_middle[60e9a44f7a592fc2]::ty::context::TyCtxt, rustc_hir[b135f998e98d7cf8]::hir_id::OwnerId)>>::call_once
  37:        0x10cd63388 - rustc_query_system[bddff3f00126116c]::query::plumbing::try_execute_query::<rustc_query_impl[119047522f02295c]::DynamicConfig<rustc_query_system[bddff3f00126116c]::query::caches::VecCache<rustc_hir[b135f998e98d7cf8]::hir_id::OwnerId, rustc_middle[60e9a44f7a592fc2]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[119047522f02295c]::plumbing::QueryCtxt, true>
  38:        0x10cdf7148 - rustc_query_impl[119047522f02295c]::query_impl::check_well_formed::get_query_incr::__rust_end_short_backtrace
  39:        0x10c02f33c - <rustc_data_structures[d0d9fd49f16e47e]::sync::parallel::ParallelGuard>::run::<core[d9e5c436b7fa2511]::result::Result<(), rustc_span[4a0b636bfafc9c3]::ErrorGuaranteed>, rustc_data_structures[d0d9fd49f16e47e]::sync::parallel::disabled::try_par_for_each_in<&[rustc_hir[b135f998e98d7cf8]::hir::TraitItemId], rustc_span[4a0b636bfafc9c3]::ErrorGuaranteed, <rustc_middle[60e9a44f7a592fc2]::hir::ModuleItems>::par_trait_items<rustc_hir_analysis[547b6125a0805be3]::check::wfcheck::check_mod_type_wf::{closure#2}>::{closure#0}>::{closure#0}::{closure#0}::{closure#0}>
  40:        0x10c018b44 - rustc_data_structures[d0d9fd49f16e47e]::sync::parallel::disabled::try_par_for_each_in::<&[rustc_hir[b135f998e98d7cf8]::hir::ImplItemId], rustc_span[4a0b636bfafc9c3]::ErrorGuaranteed, <rustc_middle[60e9a44f7a592fc2]::hir::ModuleItems>::par_impl_items<rustc_hir_analysis[547b6125a0805be3]::check::wfcheck::check_mod_type_wf::{closure#1}>::{closure#0}>
  41:        0x10c02358c - rustc_hir_analysis[547b6125a0805be3]::check::wfcheck::check_mod_type_wf
  42:        0x10cda2008 - rustc_query_impl[119047522f02295c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[119047522f02295c]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[60e9a44f7a592fc2]::query::erase::Erased<[u8; 1usize]>>
  43:        0x10ce4f094 - <rustc_query_impl[119047522f02295c]::query_impl::check_mod_type_wf::dynamic_query::{closure#2} as core[d9e5c436b7fa2511]::ops::function::FnOnce<(rustc_middle[60e9a44f7a592fc2]::ty::context::TyCtxt, rustc_span[4a0b636bfafc9c3]::def_id::LocalModDefId)>>::call_once
  44:        0x10cd33490 - rustc_query_system[bddff3f00126116c]::query::plumbing::try_execute_query::<rustc_query_impl[119047522f02295c]::DynamicConfig<rustc_query_system[bddff3f00126116c]::query::caches::DefaultCache<rustc_span[4a0b636bfafc9c3]::def_id::LocalModDefId, rustc_middle[60e9a44f7a592fc2]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[119047522f02295c]::plumbing::QueryCtxt, true>
  45:        0x10cde80fc - rustc_query_impl[119047522f02295c]::query_impl::check_mod_type_wf::get_query_incr::__rust_end_short_backtrace
  46:        0x10c02f5c8 - <rustc_data_structures[d0d9fd49f16e47e]::sync::parallel::ParallelGuard>::run::<core[d9e5c436b7fa2511]::result::Result<(), rustc_span[4a0b636bfafc9c3]::ErrorGuaranteed>, rustc_data_structures[d0d9fd49f16e47e]::sync::parallel::disabled::try_par_for_each_in<&[rustc_hir[b135f998e98d7cf8]::hir_id::OwnerId], rustc_span[4a0b636bfafc9c3]::ErrorGuaranteed, <rustc_middle[60e9a44f7a592fc2]::hir::map::Map>::try_par_for_each_module<rustc_hir_analysis[547b6125a0805be3]::check_crate::{closure#4}::{closure#0}>::{closure#0}>::{closure#0}::{closure#0}::{closure#0}>
  47:        0x10c0125c8 - <rustc_session[923a8d059042d934]::session::Session>::time::<core[d9e5c436b7fa2511]::result::Result<(), rustc_span[4a0b636bfafc9c3]::ErrorGuaranteed>, rustc_hir_analysis[547b6125a0805be3]::check_crate::{closure#4}>
  48:        0x10c045af4 - rustc_hir_analysis[547b6125a0805be3]::check_crate
  49:        0x10c372d4c - rustc_interface[ff8256179d10224c]::passes::analysis
  50:        0x10cda501c - rustc_query_impl[119047522f02295c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[119047522f02295c]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[60e9a44f7a592fc2]::query::erase::Erased<[u8; 1usize]>>
  51:        0x10ce52594 - <rustc_query_impl[119047522f02295c]::query_impl::analysis::dynamic_query::{closure#2} as core[d9e5c436b7fa2511]::ops::function::FnOnce<(rustc_middle[60e9a44f7a592fc2]::ty::context::TyCtxt, ())>>::call_once
  52:        0x10cd0f654 - rustc_query_system[bddff3f00126116c]::query::plumbing::try_execute_query::<rustc_query_impl[119047522f02295c]::DynamicConfig<rustc_query_system[bddff3f00126116c]::query::caches::SingleCache<rustc_middle[60e9a44f7a592fc2]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[119047522f02295c]::plumbing::QueryCtxt, true>
  53:        0x10cdda080 - rustc_query_impl[119047522f02295c]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
  54:        0x10bce285c - <rustc_middle[60e9a44f7a592fc2]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[64f83dff39c374ae]::run_compiler::{closure#1}::{closure#2}::{closure#6}, core[d9e5c436b7fa2511]::result::Result<(), rustc_span[4a0b636bfafc9c3]::ErrorGuaranteed>>
  55:        0x10bcfd75c - rustc_span[4a0b636bfafc9c3]::set_source_map::<core[d9e5c436b7fa2511]::result::Result<(), rustc_span[4a0b636bfafc9c3]::ErrorGuaranteed>, rustc_interface[ff8256179d10224c]::interface::run_compiler<core[d9e5c436b7fa2511]::result::Result<(), rustc_span[4a0b636bfafc9c3]::ErrorGuaranteed>, rustc_driver_impl[64f83dff39c374ae]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  56:        0x10bcedea8 - std[445e387e9aba505f]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[ff8256179d10224c]::util::run_in_thread_with_globals<rustc_interface[ff8256179d10224c]::interface::run_compiler<core[d9e5c436b7fa2511]::result::Result<(), rustc_span[4a0b636bfafc9c3]::ErrorGuaranteed>, rustc_driver_impl[64f83dff39c374ae]::run_compiler::{closure#1}>::{closure#0}, core[d9e5c436b7fa2511]::result::Result<(), rustc_span[4a0b636bfafc9c3]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d9e5c436b7fa2511]::result::Result<(), rustc_span[4a0b636bfafc9c3]::ErrorGuaranteed>>
  57:        0x10bcf0eb0 - <<std[445e387e9aba505f]::thread::Builder>::spawn_unchecked_<rustc_interface[ff8256179d10224c]::util::run_in_thread_with_globals<rustc_interface[ff8256179d10224c]::interface::run_compiler<core[d9e5c436b7fa2511]::result::Result<(), rustc_span[4a0b636bfafc9c3]::ErrorGuaranteed>, rustc_driver_impl[64f83dff39c374ae]::run_compiler::{closure#1}>::{closure#0}, core[d9e5c436b7fa2511]::result::Result<(), rustc_span[4a0b636bfafc9c3]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d9e5c436b7fa2511]::result::Result<(), rustc_span[4a0b636bfafc9c3]::ErrorGuaranteed>>::{closure#1} as core[d9e5c436b7fa2511]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  58:        0x102f3c204 - std::sys::unix::thread::Thread::new::thread_start::h6ec953440f4c1b30
  59:        0x1a677ffa8 - __pthread_joiner_wake

Full log:
rustc-ice-2023-11-01T20_18_31-88324.txt

@DavidSampson DavidSampson 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 Nov 1, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 1, 2023
@compiler-errors
Copy link
Member

Pretty sure this is a dupe of #106994.

@saethlin saethlin added F-generic_const_exprs `#![feature(generic_const_exprs)]` F-adt_const_params `#![feature(adt_const_params)]` and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Nov 1, 2023
@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Apr 15, 2024
@workingjubilee workingjubilee added the requires-incomplete-features This issue requires the use of incomplete features. label Jun 6, 2024
@BoxyUwU
Copy link
Member

BoxyUwU commented Jul 2, 2024

Closing this in favour of #106994

@BoxyUwU BoxyUwU closed this as completed Jul 2, 2024
@fmease fmease closed this as not planned Won't fix, can't repro, duplicate, stale Sep 17, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C-bug Category: This is a bug. F-adt_const_params `#![feature(adt_const_params)]` F-generic_const_exprs `#![feature(generic_const_exprs)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-incomplete-features This issue requires the use of 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