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: Missing constant with generic_const_exprs #105608

Closed
Noratrieb opened this issue Dec 12, 2022 · 1 comment · Fixed by #105611
Closed

ICE: Missing constant with generic_const_exprs #105608

Noratrieb opened this issue Dec 12, 2022 · 1 comment · Fixed by #105611
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)]` 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

@Noratrieb
Copy link
Member

Continuation of rust-lang/clippy#10032. I minimized this together with @Byter09, thank you for your help and originally finding the issue!

Code

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=03c6d14bce8d34ec6be5d395dbdebd58

#![allow(incomplete_features, unstable_features)]
#![feature(generic_const_exprs)]

struct Combination<const STRATEGIES: usize>;

impl<const STRATEGIES: usize> Combination<STRATEGIES> {
    fn and<M>(self) -> Combination<{ STRATEGIES + 1 }> {
        Combination
    }
}

pub fn trigger_the_ice() {
    Combination::<0>.and::<_>().and::<_>();
}

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

The first and most relevant delayed bug:

error: internal compiler error: Missing value for constant, but no error reported?
  --> src/lib.rs:13:33
   |
13 |     Combination::<0>.and::<_>().and::<_>();
   |                                 ^^^
   |
   = note: delayed at compiler/rustc_trait_selection/src/traits/const_evaluatable.rs:77:71

All the delayed bugs and the usual backtrace:

Backtrace

error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: Missing value for constant, but no error reported?
  --> src/lib.rs:13:33
   |
13 |     Combination::<0>.and::<_>().and::<_>();
   |                                 ^^^
   |
   = note: delayed at compiler/rustc_trait_selection/src/traits/const_evaluatable.rs:77:71

error: internal compiler error: `report_selection_error` did not emit an error
  --> src/lib.rs:13:33
   |
13 |     Combination::<0>.and::<_>().and::<_>();
   |                                 ^^^
   |
   = note: delayed at compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:591:22

error: internal compiler error: `ErrorGuaranteed` without an error
  --> src/lib.rs:13:33
   |
13 |     Combination::<0>.and::<_>().and::<_>();
   |                                 ^^^
   |
   = note: delayed at compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:1366:31

error: internal compiler error: expected fullfillment errors
  |
  = note: delayed at compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:460:23

error: internal compiler error: TyKind::Error constructed but no error reported
  |
  = note: delayed at /rustc/bdb07a8ec8e77aa10fb84fae1d4ff71c21180bb4/compiler/rustc_middle/src/ty/relate.rs:425:59

error: internal compiler error: TyKind::Error constructed but no error reported
  |
  = note: delayed at compiler/rustc_mir_build/src/build/mod.rs:637:18

error: internal compiler error: broken MIR in DefId(0:11 ~ playground[9d05]::trigger_the_ice) ("return type"): bad type [type error]
  --> src/lib.rs:12:1
   |
12 | pub fn trigger_the_ice() {
   | ^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: delayed at compiler/rustc_borrowck/src/type_check/mod.rs:520:13

error: internal compiler error: TyKind::Error constructed but no error reported
  |
  = note: delayed at compiler/rustc_borrowck/src/type_check/mod.rs:768:20

error: internal compiler error: broken MIR in DefId(0:11 ~ playground[9d05]::trigger_the_ice) (LocalDecl { mutability: Mut, local_info: None, internal: false, is_block_tail: None, ty: [type error], user_ty: None, source_info: SourceInfo { span: src/lib.rs:12:1: 12:25 (#0), scope: scope[0] } }): bad type [type error]
  --> src/lib.rs:12:1
   |
12 | pub fn trigger_the_ice() {
   | ^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: delayed at compiler/rustc_borrowck/src/type_check/mod.rs:520:13

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1610:13
stack backtrace:
   0:     0x7fee231b796a - std::backtrace_rs::backtrace::libunwind::trace::h3bfe63c4aecfa0e2
                               at /rustc/bdb07a8ec8e77aa10fb84fae1d4ff71c21180bb4/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7fee231b796a - std::backtrace_rs::backtrace::trace_unsynchronized::h978c02637c6cb8f9
                               at /rustc/bdb07a8ec8e77aa10fb84fae1d4ff71c21180bb4/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fee231b796a - std::sys_common::backtrace::_print_fmt::h86a708dcb1665377
                               at /rustc/bdb07a8ec8e77aa10fb84fae1d4ff71c21180bb4/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7fee231b796a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hdbf89765373fb801
                               at /rustc/bdb07a8ec8e77aa10fb84fae1d4ff71c21180bb4/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7fee1f1b02ee - core::fmt::write::hbf11a3bb4e6d2aba
                               at /rustc/bdb07a8ec8e77aa10fb84fae1d4ff71c21180bb4/library/core/src/fmt/mod.rs:1208:17
   5:     0x7fee231abbe5 - std::io::Write::write_fmt::hd68261eacc348bbd
                               at /rustc/bdb07a8ec8e77aa10fb84fae1d4ff71c21180bb4/library/std/src/io/mod.rs:1682:15
   6:     0x7fee231b7735 - std::sys_common::backtrace::_print::ha8e375b58cdeca4a
                               at /rustc/bdb07a8ec8e77aa10fb84fae1d4ff71c21180bb4/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7fee231b7735 - std::sys_common::backtrace::print::he3086c07df1167ca
                               at /rustc/bdb07a8ec8e77aa10fb84fae1d4ff71c21180bb4/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7fee231b9abf - std::panicking::default_hook::{{closure}}::h0c12a9095c948e43
                               at /rustc/bdb07a8ec8e77aa10fb84fae1d4ff71c21180bb4/library/std/src/panicking.rs:267:22
   9:     0x7fee231b97fb - std::panicking::default_hook::h1ae5478ad617eb24
                               at /rustc/bdb07a8ec8e77aa10fb84fae1d4ff71c21180bb4/library/std/src/panicking.rs:286:9
  10:     0x7fee22407741 - <rustc_driver[c8d19d3afee4bdc9]::DEFAULT_HOOK::{closure#0}::{closure#0} as core[5029ced7f280b950]::ops::function::FnOnce<(&core[5029ced7f280b950]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  11:     0x7fee231ba2bd - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h237cca5e72caa7e7
                               at /rustc/bdb07a8ec8e77aa10fb84fae1d4ff71c21180bb4/library/alloc/src/boxed.rs:2032:9
  12:     0x7fee231ba2bd - std::panicking::rust_panic_with_hook::h63a24f957ccb5d93
                               at /rustc/bdb07a8ec8e77aa10fb84fae1d4ff71c21180bb4/library/std/src/panicking.rs:692:13
  13:     0x7fee22440531 - std[ebc28cf04754cd8d]::panicking::begin_panic::<rustc_errors[4c9e772a36c84051]::ExplicitBug>::{closure#0}
  14:     0x7fee2243ee06 - std[ebc28cf04754cd8d]::sys_common::backtrace::__rust_end_short_backtrace::<std[ebc28cf04754cd8d]::panicking::begin_panic<rustc_errors[4c9e772a36c84051]::ExplicitBug>::{closure#0}, !>
  15:     0x7fee2241df16 - std[ebc28cf04754cd8d]::panicking::begin_panic::<rustc_errors[4c9e772a36c84051]::ExplicitBug>
  16:     0x7fee2243c866 - std[ebc28cf04754cd8d]::panic::panic_any::<rustc_errors[4c9e772a36c84051]::ExplicitBug>
  17:     0x7fee21926386 - <rustc_errors[4c9e772a36c84051]::HandlerInner>::flush_delayed::<alloc[fabf6a335e17022]::vec::Vec<rustc_errors[4c9e772a36c84051]::diagnostic::Diagnostic>, &str>
  18:     0x7fee2166976c - <rustc_interface[649c07bcaa826da7]::passes::QueryContext>::enter::<<rustc_interface[649c07bcaa826da7]::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core[5029ced7f280b950]::result::Result<alloc[fabf6a335e17022]::boxed::Box<dyn core[5029ced7f280b950]::any::Any>, rustc_errors[4c9e772a36c84051]::ErrorGuaranteed>>
  19:     0x7fee21666a36 - <rustc_interface[649c07bcaa826da7]::queries::Queries>::ongoing_codegen
  20:     0x7fee21665f57 - <rustc_interface[649c07bcaa826da7]::interface::Compiler>::enter::<rustc_driver[c8d19d3afee4bdc9]::run_compiler::{closure#1}::{closure#2}, core[5029ced7f280b950]::result::Result<core[5029ced7f280b950]::option::Option<rustc_interface[649c07bcaa826da7]::queries::Linker>, rustc_errors[4c9e772a36c84051]::ErrorGuaranteed>>
  21:     0x7fee21660f78 - rustc_span[61aa4dc18b27dd6c]::with_source_map::<core[5029ced7f280b950]::result::Result<(), rustc_errors[4c9e772a36c84051]::ErrorGuaranteed>, rustc_interface[649c07bcaa826da7]::interface::run_compiler<core[5029ced7f280b950]::result::Result<(), rustc_errors[4c9e772a36c84051]::ErrorGuaranteed>, rustc_driver[c8d19d3afee4bdc9]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  22:     0x7fee21660a65 - <scoped_tls[5892410b08f734b5]::ScopedKey<rustc_span[61aa4dc18b27dd6c]::SessionGlobals>>::set::<rustc_interface[649c07bcaa826da7]::interface::run_compiler<core[5029ced7f280b950]::result::Result<(), rustc_errors[4c9e772a36c84051]::ErrorGuaranteed>, rustc_driver[c8d19d3afee4bdc9]::run_compiler::{closure#1}>::{closure#0}, core[5029ced7f280b950]::result::Result<(), rustc_errors[4c9e772a36c84051]::ErrorGuaranteed>>
  23:     0x7fee21660052 - std[ebc28cf04754cd8d]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[649c07bcaa826da7]::util::run_in_thread_pool_with_globals<rustc_interface[649c07bcaa826da7]::interface::run_compiler<core[5029ced7f280b950]::result::Result<(), rustc_errors[4c9e772a36c84051]::ErrorGuaranteed>, rustc_driver[c8d19d3afee4bdc9]::run_compiler::{closure#1}>::{closure#0}, core[5029ced7f280b950]::result::Result<(), rustc_errors[4c9e772a36c84051]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[5029ced7f280b950]::result::Result<(), rustc_errors[4c9e772a36c84051]::ErrorGuaranteed>>
  24:     0x7fee21cd3fee - <<std[ebc28cf04754cd8d]::thread::Builder>::spawn_unchecked_<rustc_interface[649c07bcaa826da7]::util::run_in_thread_pool_with_globals<rustc_interface[649c07bcaa826da7]::interface::run_compiler<core[5029ced7f280b950]::result::Result<(), rustc_errors[4c9e772a36c84051]::ErrorGuaranteed>, rustc_driver[c8d19d3afee4bdc9]::run_compiler::{closure#1}>::{closure#0}, core[5029ced7f280b950]::result::Result<(), rustc_errors[4c9e772a36c84051]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[5029ced7f280b950]::result::Result<(), rustc_errors[4c9e772a36c84051]::ErrorGuaranteed>>::{closure#1} as core[5029ced7f280b950]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  25:     0x7fee231c1623 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::heae35e1afc4b24eb
                               at /rustc/bdb07a8ec8e77aa10fb84fae1d4ff71c21180bb4/library/alloc/src/boxed.rs:2000:9
  26:     0x7fee231c1623 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h82b51f76f931d41c
                               at /rustc/bdb07a8ec8e77aa10fb84fae1d4ff71c21180bb4/library/alloc/src/boxed.rs:2000:9
  27:     0x7fee231c1623 - std::sys::unix::thread::Thread::new::thread_start::h66d484584973ef33
                               at /rustc/bdb07a8ec8e77aa10fb84fae1d4ff71c21180bb4/library/std/src/sys/unix/thread.rs:108:17
  28:     0x7fee1f01f609 - start_thread
  29:     0x7fee1ef42133 - clone
  30:                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 (bdb07a8ec 2022-12-11) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2

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

query stack during panic:
end of query stack
error: could not compile `playground`

@Noratrieb Noratrieb 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
@BoxyUwU BoxyUwU added the A-const-generics Area: const generics (parameters and arguments) label Dec 12, 2022
@Noratrieb
Copy link
Member Author

Noratrieb commented Dec 12, 2022

Regressed the the ConstKind::Expr PR: #99798

searched nightlies: from nightly-2021-01-01 to nightly-2022-12-12
regressed nightly: nightly-2022-11-27
searched commit range: 8681d4c...80a9646
regressed commit: aff003b

bisected with cargo-bisect-rustc v0.6.4

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

cargo bisect-rustc --access github --regress ice

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)]` 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

Successfully merging a pull request may close this issue.

2 participants