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: const parameters cannot be generic #113462

Closed
matthiaskrgr opened this issue Jul 7, 2023 · 1 comment · Fixed by #114606
Closed

ICE: const parameters cannot be generic #113462

matthiaskrgr opened this issue Jul 7, 2023 · 1 comment · Fixed by #114606
Labels
C-bug Category: This is a bug. 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

@matthiaskrgr
Copy link
Member

Code

#[derive(Default)]
struct NonGeneric<'a, const N: NonGeneric> {}

Meta

rustc --version --verbose:

rustc 1.72.0-nightly (85bf07972 2023-07-06)
binary: rustc
commit-hash: 85bf07972a1041b9e25393b803d0e006bec3eaaf
commit-date: 2023-07-06
host: x86_64-unknown-linux-gnu
release: 1.72.0-nightly
LLVM version: 16.0.5

Error output

error[E0106]: missing lifetime specifier
 --> treereduce.out:2:32
  |
2 | struct NonGeneric<'a, const N: NonGeneric> {}
  |                                ^^^^^^^^^^ expected named lifetime parameter
  |
help: consider using the `'a` lifetime
  |
2 | struct NonGeneric<'a, const N: NonGeneric<'a>> {}
  |                                              

error[E0601]: `main` function not found in crate `treereduce`
 --> treereduce.out:2:46
  |
2 | struct NonGeneric<'a, const N: NonGeneric> {}
  |                                              ^ consider adding a `main` function to `treereduce.out`

error[E0107]: missing generics for struct `NonGeneric`
 --> treereduce.out:2:32
  |
2 | struct NonGeneric<'a, const N: NonGeneric> {}
  |                                ^^^^^^^^^^ expected 1 generic argument
  |
note: struct defined here, with 1 generic parameter: `N`
 --> treereduce.out:2:8
  |
2 | struct NonGeneric<'a, const N: NonGeneric> {}
  |        ^^^^^^^^^^     -------------------
help: add missing generic argument
  |
2 | struct NonGeneric<'a, const N: NonGeneric<N>> {}
  |                                             

error[E0391]: cycle detected when computing type of `NonGeneric::N`
 --> treereduce.out:2:32
  |
2 | struct NonGeneric<'a, const N: NonGeneric> {}
  |                                ^^^^^^^^^^
  |
  = note: ...which immediately requires computing type of `NonGeneric::N` again
note: cycle used when computing type of `NonGeneric`
 --> treereduce.out:2:1
  |
2 | struct NonGeneric<'a, const N: NonGeneric> {}
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0391]: cycle detected when computing type of `NonGeneric`
 --> treereduce.out:2:1
  |
2 | struct NonGeneric<'a, const N: NonGeneric> {}
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
note: ...which requires computing type of `NonGeneric::N`...
 --> treereduce.out:2:32
  |
2 | struct NonGeneric<'a, const N: NonGeneric> {}
  |                                ^^^^^^^^^^
  = note: ...which again requires computing type of `NonGeneric`, completing the cycle
note: cycle used when collecting item types in top-level module
 --> treereduce.out:1:1
  |
1 | / #[derive(Default)]
2 | | struct NonGeneric<'a, const N: NonGeneric> {}
  | |_____________________________________________^
Backtrace

thread 'rustc' panicked at 'const parameters cannot be generic', compiler/rustc_hir_analysis/src/collect/predicates_of.rs:249:22
stack backtrace:
   0:     0x7fa5a7211a71 - std::backtrace_rs::backtrace::libunwind::trace::h83338e21cbc3510e
                               at /rustc/85bf07972a1041b9e25393b803d0e006bec3eaaf/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7fa5a7211a71 - std::backtrace_rs::backtrace::trace_unsynchronized::h1663b95366fea7e1
                               at /rustc/85bf07972a1041b9e25393b803d0e006bec3eaaf/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fa5a7211a71 - std::sys_common::backtrace::_print_fmt::hcb919a5390faff94
                               at /rustc/85bf07972a1041b9e25393b803d0e006bec3eaaf/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7fa5a7211a71 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::ha8e8379de0738990
                               at /rustc/85bf07972a1041b9e25393b803d0e006bec3eaaf/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7fa5a7277d7f - core::fmt::rt::Argument::fmt::h12cd44e59c3e03f4
                               at /rustc/85bf07972a1041b9e25393b803d0e006bec3eaaf/library/core/src/fmt/rt.rs:138:9
   5:     0x7fa5a7277d7f - core::fmt::write::h0d2b2a94b10f259a
                               at /rustc/85bf07972a1041b9e25393b803d0e006bec3eaaf/library/core/src/fmt/mod.rs:1094:21
   6:     0x7fa5a72044b7 - std::io::Write::write_fmt::hf16cae54d031f42c
                               at /rustc/85bf07972a1041b9e25393b803d0e006bec3eaaf/library/std/src/io/mod.rs:1714:15
   7:     0x7fa5a7211885 - std::sys_common::backtrace::_print::h7c194ea6232bf362
                               at /rustc/85bf07972a1041b9e25393b803d0e006bec3eaaf/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7fa5a7211885 - std::sys_common::backtrace::print::hca89cc4c64fa92f2
                               at /rustc/85bf07972a1041b9e25393b803d0e006bec3eaaf/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7fa5a7214663 - std::panicking::default_hook::{{closure}}::hba1423900118f107
                               at /rustc/85bf07972a1041b9e25393b803d0e006bec3eaaf/library/std/src/panicking.rs:269:22
  10:     0x7fa5a72143f4 - std::panicking::default_hook::hf4868ae8eb550432
                               at /rustc/85bf07972a1041b9e25393b803d0e006bec3eaaf/library/std/src/panicking.rs:288:9
  11:     0x7fa5a607d65b - rustc_driver_impl[5fd2fff4e2ab1b68]::install_ice_hook::{closure#0}
  12:     0x7fa5a7214e8e - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h2d28fdec3189af27
                               at /rustc/85bf07972a1041b9e25393b803d0e006bec3eaaf/library/alloc/src/boxed.rs:2024:9
  13:     0x7fa5a7214e8e - std::panicking::rust_panic_with_hook::hdb6e4003315ae50a
                               at /rustc/85bf07972a1041b9e25393b803d0e006bec3eaaf/library/std/src/panicking.rs:709:13
  14:     0x7fa5a7214c17 - std::panicking::begin_panic_handler::{{closure}}::h05675051fb0f9296
                               at /rustc/85bf07972a1041b9e25393b803d0e006bec3eaaf/library/std/src/panicking.rs:597:13
  15:     0x7fa5a7211ed6 - std::sys_common::backtrace::__rust_end_short_backtrace::h9866f6ab4fcd5803
                               at /rustc/85bf07972a1041b9e25393b803d0e006bec3eaaf/library/std/src/sys_common/backtrace.rs:151:18
  16:     0x7fa5a7214962 - rust_begin_unwind
                               at /rustc/85bf07972a1041b9e25393b803d0e006bec3eaaf/library/std/src/panicking.rs:593:5
  17:     0x7fa5a7273fd3 - core::panicking::panic_fmt::h1490cb3aae65fe17
                               at /rustc/85bf07972a1041b9e25393b803d0e006bec3eaaf/library/core/src/panicking.rs:67:14
  18:     0x7fa5a7273d33 - core::panicking::panic_display::h09a137dc2025c35c
                               at /rustc/85bf07972a1041b9e25393b803d0e006bec3eaaf/library/core/src/panicking.rs:150:5
  19:     0x7fa5a7273d33 - core::panicking::panic_str::h867e2cb6f4418dd2
                               at /rustc/85bf07972a1041b9e25393b803d0e006bec3eaaf/library/core/src/panicking.rs:134:5
  20:     0x7fa5a7273d33 - core::option::expect_failed::h3aed3553b6e847cc
                               at /rustc/85bf07972a1041b9e25393b803d0e006bec3eaaf/library/core/src/option.rs:1952:5
  21:     0x7fa5a51a4f01 - rustc_hir_analysis[ac41804801612bf5]::collect::predicates_of::gather_explicit_predicates_of
  22:     0x7fa5a4373dd8 - rustc_query_impl[a5debbf18c9cda01]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a5debbf18c9cda01]::query_impl::explicit_predicates_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[6a835cc3e0a555e0]::query::erase::Erased<[u8; 24usize]>>
  23:     0x7fa5a41469b6 - rustc_query_system[9a6651a6b626ed91]::query::plumbing::try_execute_query::<rustc_query_impl[a5debbf18c9cda01]::DynamicConfig<rustc_query_system[9a6651a6b626ed91]::query::caches::DefaultCache<rustc_span[330d20617ff3531a]::def_id::DefId, rustc_middle[6a835cc3e0a555e0]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[a5debbf18c9cda01]::plumbing::QueryCtxt, false>
  24:     0x7fa5a414663f - rustc_query_impl[a5debbf18c9cda01]::query_impl::explicit_predicates_of::get_query_non_incr::__rust_end_short_backtrace
  25:     0x7fa5a58cbe8a - rustc_hir_analysis[ac41804801612bf5]::collect::predicates_defined_on
  26:     0x7fa5a403334d - rustc_query_impl[a5debbf18c9cda01]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a5debbf18c9cda01]::query_impl::predicates_defined_on::dynamic_query::{closure#2}::{closure#0}, rustc_middle[6a835cc3e0a555e0]::query::erase::Erased<[u8; 24usize]>>
  27:     0x7fa5a4146ca0 - rustc_query_system[9a6651a6b626ed91]::query::plumbing::try_execute_query::<rustc_query_impl[a5debbf18c9cda01]::DynamicConfig<rustc_query_system[9a6651a6b626ed91]::query::caches::DefaultCache<rustc_span[330d20617ff3531a]::def_id::DefId, rustc_middle[6a835cc3e0a555e0]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[a5debbf18c9cda01]::plumbing::QueryCtxt, false>
  28:     0x7fa5a59f8d5f - rustc_query_impl[a5debbf18c9cda01]::query_impl::predicates_defined_on::get_query_non_incr::__rust_end_short_backtrace
  29:     0x7fa5a55406ea - rustc_hir_analysis[ac41804801612bf5]::collect::predicates_of::predicates_of
  30:     0x7fa5a40333bd - rustc_query_impl[a5debbf18c9cda01]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a5debbf18c9cda01]::query_impl::predicates_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[6a835cc3e0a555e0]::query::erase::Erased<[u8; 24usize]>>
  31:     0x7fa5a414698a - rustc_query_system[9a6651a6b626ed91]::query::plumbing::try_execute_query::<rustc_query_impl[a5debbf18c9cda01]::DynamicConfig<rustc_query_system[9a6651a6b626ed91]::query::caches::DefaultCache<rustc_span[330d20617ff3531a]::def_id::DefId, rustc_middle[6a835cc3e0a555e0]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[a5debbf18c9cda01]::plumbing::QueryCtxt, false>
  32:     0x7fa5a59d1e9f - rustc_query_impl[a5debbf18c9cda01]::query_impl::predicates_of::get_query_non_incr::__rust_end_short_backtrace
  33:     0x7fa5a46cbcdb - <rustc_hir_analysis[ac41804801612bf5]::collect::CollectItemTypesVisitor as rustc_hir[10c9f4f629fa886a]::intravisit::Visitor>::visit_item
  34:     0x7fa5a46c9184 - <rustc_middle[6a835cc3e0a555e0]::hir::map::Map>::visit_item_likes_in_module::<rustc_hir_analysis[ac41804801612bf5]::collect::CollectItemTypesVisitor>
  35:     0x7fa5a46c909c - rustc_hir_analysis[ac41804801612bf5]::collect::collect_mod_item_types
  36:     0x7fa5a4ce67ec - rustc_query_impl[a5debbf18c9cda01]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a5debbf18c9cda01]::query_impl::collect_mod_item_types::dynamic_query::{closure#2}::{closure#0}, rustc_middle[6a835cc3e0a555e0]::query::erase::Erased<[u8; 0usize]>>
  37:     0x7fa5a4ce67ce - <rustc_query_impl[a5debbf18c9cda01]::query_impl::collect_mod_item_types::dynamic_query::{closure#2} as core[bcc6c1a0d905112a]::ops::function::FnOnce<(rustc_middle[6a835cc3e0a555e0]::ty::context::TyCtxt, rustc_span[330d20617ff3531a]::def_id::LocalDefId)>>::call_once
  38:     0x7fa5a46ebf0f - rustc_query_system[9a6651a6b626ed91]::query::plumbing::try_execute_query::<rustc_query_impl[a5debbf18c9cda01]::DynamicConfig<rustc_query_system[9a6651a6b626ed91]::query::caches::VecCache<rustc_span[330d20617ff3531a]::def_id::LocalDefId, rustc_middle[6a835cc3e0a555e0]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[a5debbf18c9cda01]::plumbing::QueryCtxt, false>
  39:     0x7fa5a59e8834 - rustc_query_impl[a5debbf18c9cda01]::query_impl::collect_mod_item_types::get_query_non_incr::__rust_end_short_backtrace
  40:     0x7fa5a549ddd7 - <rustc_middle[6a835cc3e0a555e0]::hir::map::Map>::for_each_module::<rustc_hir_analysis[ac41804801612bf5]::check_crate::{closure#0}::{closure#0}::{closure#0}>
  41:     0x7fa5a549da12 - <rustc_session[ab778da52d62d91c]::session::Session>::track_errors::<rustc_hir_analysis[ac41804801612bf5]::check_crate::{closure#0}, ()>
  42:     0x7fa5a549c1d1 - rustc_hir_analysis[ac41804801612bf5]::check_crate
  43:     0x7fa5a54932ea - rustc_interface[99b7bac6f3a68274]::passes::analysis
  44:     0x7fa5a552d80a - rustc_query_impl[a5debbf18c9cda01]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a5debbf18c9cda01]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[6a835cc3e0a555e0]::query::erase::Erased<[u8; 1usize]>>
  45:     0x7fa5a552d7f9 - <rustc_query_impl[a5debbf18c9cda01]::query_impl::analysis::dynamic_query::{closure#2} as core[bcc6c1a0d905112a]::ops::function::FnOnce<(rustc_middle[6a835cc3e0a555e0]::ty::context::TyCtxt, ())>>::call_once
  46:     0x7fa5a56aba98 - rustc_query_system[9a6651a6b626ed91]::query::plumbing::try_execute_query::<rustc_query_impl[a5debbf18c9cda01]::DynamicConfig<rustc_query_system[9a6651a6b626ed91]::query::caches::SingleCache<rustc_middle[6a835cc3e0a555e0]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[a5debbf18c9cda01]::plumbing::QueryCtxt, false>
  47:     0x7fa5a56ab869 - rustc_query_impl[a5debbf18c9cda01]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  48:     0x7fa5a5268a05 - <rustc_middle[6a835cc3e0a555e0]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[5fd2fff4e2ab1b68]::run_compiler::{closure#1}::{closure#2}::{closure#4}, core[bcc6c1a0d905112a]::result::Result<(), rustc_span[330d20617ff3531a]::ErrorGuaranteed>>
  49:     0x7fa5a5268032 - <rustc_interface[99b7bac6f3a68274]::interface::Compiler>::enter::<rustc_driver_impl[5fd2fff4e2ab1b68]::run_compiler::{closure#1}::{closure#2}, core[bcc6c1a0d905112a]::result::Result<core[bcc6c1a0d905112a]::option::Option<rustc_interface[99b7bac6f3a68274]::queries::Linker>, rustc_span[330d20617ff3531a]::ErrorGuaranteed>>
  50:     0x7fa5a525ed45 - rustc_span[330d20617ff3531a]::set_source_map::<core[bcc6c1a0d905112a]::result::Result<(), rustc_span[330d20617ff3531a]::ErrorGuaranteed>, rustc_interface[99b7bac6f3a68274]::interface::run_compiler<core[bcc6c1a0d905112a]::result::Result<(), rustc_span[330d20617ff3531a]::ErrorGuaranteed>, rustc_driver_impl[5fd2fff4e2ab1b68]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  51:     0x7fa5a525e7b6 - <scoped_tls[df29aac8beac7397]::ScopedKey<rustc_span[330d20617ff3531a]::SessionGlobals>>::set::<rustc_interface[99b7bac6f3a68274]::interface::run_compiler<core[bcc6c1a0d905112a]::result::Result<(), rustc_span[330d20617ff3531a]::ErrorGuaranteed>, rustc_driver_impl[5fd2fff4e2ab1b68]::run_compiler::{closure#1}>::{closure#0}, core[bcc6c1a0d905112a]::result::Result<(), rustc_span[330d20617ff3531a]::ErrorGuaranteed>>
  52:     0x7fa5a525dd7c - std[6f71ef261950bfb1]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[99b7bac6f3a68274]::util::run_in_thread_pool_with_globals<rustc_interface[99b7bac6f3a68274]::interface::run_compiler<core[bcc6c1a0d905112a]::result::Result<(), rustc_span[330d20617ff3531a]::ErrorGuaranteed>, rustc_driver_impl[5fd2fff4e2ab1b68]::run_compiler::{closure#1}>::{closure#0}, core[bcc6c1a0d905112a]::result::Result<(), rustc_span[330d20617ff3531a]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[bcc6c1a0d905112a]::result::Result<(), rustc_span[330d20617ff3531a]::ErrorGuaranteed>>
  53:     0x7fa5a525db45 - <<std[6f71ef261950bfb1]::thread::Builder>::spawn_unchecked_<rustc_interface[99b7bac6f3a68274]::util::run_in_thread_pool_with_globals<rustc_interface[99b7bac6f3a68274]::interface::run_compiler<core[bcc6c1a0d905112a]::result::Result<(), rustc_span[330d20617ff3531a]::ErrorGuaranteed>, rustc_driver_impl[5fd2fff4e2ab1b68]::run_compiler::{closure#1}>::{closure#0}, core[bcc6c1a0d905112a]::result::Result<(), rustc_span[330d20617ff3531a]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[bcc6c1a0d905112a]::result::Result<(), rustc_span[330d20617ff3531a]::ErrorGuaranteed>>::{closure#1} as core[bcc6c1a0d905112a]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  54:     0x7fa5a721f305 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hee94a9b600b92b27
                               at /rustc/85bf07972a1041b9e25393b803d0e006bec3eaaf/library/alloc/src/boxed.rs:2010:9
  55:     0x7fa5a721f305 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hb557fd709dd3520f
                               at /rustc/85bf07972a1041b9e25393b803d0e006bec3eaaf/library/alloc/src/boxed.rs:2010:9
  56:     0x7fa5a721f305 - std::sys::unix::thread::Thread::new::thread_start::h726c141aa23b2e83
                               at /rustc/85bf07972a1041b9e25393b803d0e006bec3eaaf/library/std/src/sys/unix/thread.rs:108:17
  57:     0x7fa5a2c6444b - <unknown>
  58:     0x7fa5a2ce7e40 - <unknown>
  59:                0x0 - <unknown>

error: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug, I-ICE, T-compiler&template=ice.md

note: rustc 1.72.0-nightly (85bf07972 2023-07-06) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [explicit_predicates_of] computing explicit predicates of `<impl at treereduce.out:1:10: 1:17>`
#1 [predicates_defined_on] computing predicates of `<impl at treereduce.out:1:10: 1:17>`
#2 [predicates_of] computing predicates of `<impl at treereduce.out:1:10: 1:17>`
#3 [collect_mod_item_types] collecting item types in top-level module
#4 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 5 previous errors

Some errors have detailed explanations: E0106, E0107, E0391, E0601.
For more information about an error, try `rustc --explain E0106`.

@matthiaskrgr matthiaskrgr added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Jul 7, 2023
@clubby789
Copy link
Contributor

searched nightlies: from nightly-2023-02-17 to nightly-2023-02-19
regressed nightly: nightly-2023-02-18
searched commit range: 9a7cc6c...9aa5c24
regressed commit: 9556b56 -> #107753 -> cc @kylematsuda

bisected with cargo-bisect-rustc v0.6.6

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc --start 2023-01-01 --prompt 

@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Jul 14, 2023
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Aug 8, 2023
fix: not insert missing lifetime for `ConstParamTy`

Fixes rust-lang#113462

We should ignore the missing lifetime, as it's illegal to include a lifetime in a const param.

r? `@compiler-errors`
@bors bors closed this as completed in 41d2694 Aug 9, 2023
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. 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

Successfully merging a pull request may close this issue.

3 participants