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 evaluatable failed for non-unevaluated const #114151

Closed
matthiaskrgr opened this issue Jul 27, 2023 · 4 comments
Closed

ICE: const evaluatable failed for non-unevaluated const #114151

matthiaskrgr opened this issue Jul 27, 2023 · 4 comments
Assignees
Labels
A-const-eval Area: constant evaluation (mir interpretation) 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

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Jul 27, 2023

Code

#![feature(generic_const_exprs)]

fn foo<const N: usize>(
    _: [u8; {
        {
            N
        }
    }],
) {
}

fn ice<const L: usize>()
where
    [(); (L - 1) + 1 + L]:,
{
    foo::<_, L>([(); L + 1 + L]);
}

Meta

rustc --version --verbose:

rustc 1.73.0-nightly (0d95f9132 2023-07-26)
binary: rustc
commit-hash: 0d95f9132909ae7c5f2456748d0ffd1c3ba4a8e8
commit-date: 2023-07-26
host: x86_64-unknown-linux-gnu
release: 1.73.0-nightly
LLVM version: 16.0.5

Error output

warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
 --> treereduce.out: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[E0601]: `main` function not found in crate `treereduce`
  --> treereduce.out:17:2
   |
17 | }
   |  ^ consider adding a `main` function to `treereduce.out`

error[E0107]: function takes 1 generic argument but 2 generic arguments were supplied
  --> treereduce.out:16:5
   |
16 |     foo::<_, L>([(); L + 1 + L]);
   |     ^^^      - help: remove this generic argument
   |     |
   |     expected 1 generic argument
   |
note: function defined here, with 1 generic parameter: `N`
  --> treereduce.out:3:4
   |
3  | fn foo<const N: usize>(
   |    ^^^ --------------

error[E0308]: mismatched types
  --> treereduce.out:16:18
   |
16 |     foo::<_, L>([(); L + 1 + L]);
   |                  ^^ expected `u8`, found `()`

error: unconstrained generic constant
  --> treereduce.out:16:22
   |
16 |     foo::<_, L>([(); L + 1 + L]);
   |                      ^^^^^^^^^
   |
   = help: try adding a `where` bound using this expression: `where [(); L + 1 + L]:`

error: unconstrained generic constant
  --> treereduce.out:16:17
   |
16 |     foo::<_, L>([(); L + 1 + L]);
   |     ----------- ^^^^^^^^^^^^^^^
   |     |
   |     required by a bound introduced by this call
   |
   = help: try adding a `where` bound using this expression: `where [(); {
                   {
                       N
                   }
               }]:`
note: required by a bound in `foo`
  --> treereduce.out:4:13
   |
3  |   fn foo<const N: usize>(
   |      --- required by a bound in this function
4  |       _: [u8; {
   |  _____________^
5  | |         {
6  | |             N
7  | |         }
8  | |     }],
   | |_____^ required by this bound in `foo`
Backtrace

error: internal compiler error: compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:3380:21: const evaluatable failed for non-unevaluated const `Const { ty: usize, kind: (Add: Const { ty: usize, kind: (Add: Const { ty: usize, kind: L/#0 }, Const { ty: usize, kind: Leaf(0x0000000000000001) }) }, Const { ty: usize, kind: L/#0 }) }`

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/0d95f9132909ae7c5f2456748d0ffd1c3ba4a8e8/compiler/rustc_errors/src/lib.rs:1640:9
stack backtrace:
   0:     0x7f8872725fc1 - std::backtrace_rs::backtrace::libunwind::trace::hf6e154905f06aaf4
                               at /rustc/0d95f9132909ae7c5f2456748d0ffd1c3ba4a8e8/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f8872725fc1 - std::backtrace_rs::backtrace::trace_unsynchronized::h18cebe760f1510fa
                               at /rustc/0d95f9132909ae7c5f2456748d0ffd1c3ba4a8e8/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f8872725fc1 - std::sys_common::backtrace::_print_fmt::hffe418505cdd97e8
                               at /rustc/0d95f9132909ae7c5f2456748d0ffd1c3ba4a8e8/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f8872725fc1 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h19176839053c7e42
                               at /rustc/0d95f9132909ae7c5f2456748d0ffd1c3ba4a8e8/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f887278c49c - core::fmt::rt::Argument::fmt::hf19c9b9307d45f5d
                               at /rustc/0d95f9132909ae7c5f2456748d0ffd1c3ba4a8e8/library/core/src/fmt/rt.rs:138:9
   5:     0x7f887278c49c - core::fmt::write::h79cbf0496735b1b7
                               at /rustc/0d95f9132909ae7c5f2456748d0ffd1c3ba4a8e8/library/core/src/fmt/mod.rs:1094:21
   6:     0x7f88727185ce - std::io::Write::write_fmt::h11f28dab14e62928
                               at /rustc/0d95f9132909ae7c5f2456748d0ffd1c3ba4a8e8/library/std/src/io/mod.rs:1714:15
   7:     0x7f8872725dd5 - std::sys_common::backtrace::_print::he32b2def77c6f779
                               at /rustc/0d95f9132909ae7c5f2456748d0ffd1c3ba4a8e8/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f8872725dd5 - std::sys_common::backtrace::print::h6be21ee209c4bf2f
                               at /rustc/0d95f9132909ae7c5f2456748d0ffd1c3ba4a8e8/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f8872728e2a - std::panicking::panic_hook_with_disk_dump::{{closure}}::h9e13983d414e65b8
                               at /rustc/0d95f9132909ae7c5f2456748d0ffd1c3ba4a8e8/library/std/src/panicking.rs:278:22
  10:     0x7f8872728ac3 - std::panicking::panic_hook_with_disk_dump::he404d3925670a989
                               at /rustc/0d95f9132909ae7c5f2456748d0ffd1c3ba4a8e8/library/std/src/panicking.rs:312:9
  11:     0x7f8871586f79 - rustc_driver_impl[11f9c42ddd32a232]::install_ice_hook::{closure#0}
  12:     0x7f88727296d0 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h8ce3cd052223b94b
                               at /rustc/0d95f9132909ae7c5f2456748d0ffd1c3ba4a8e8/library/alloc/src/boxed.rs:2021:9
  13:     0x7f88727296d0 - std::panicking::rust_panic_with_hook::h1fcb49fe91d725f0
                               at /rustc/0d95f9132909ae7c5f2456748d0ffd1c3ba4a8e8/library/std/src/panicking.rs:733:13
  14:     0x7f8871b53711 - std[2e963e9f253cdd71]::panicking::begin_panic::<rustc_errors[16c9db0e0ca0a6f7]::ExplicitBug>::{closure#0}
  15:     0x7f8871b51396 - std[2e963e9f253cdd71]::sys_common::backtrace::__rust_end_short_backtrace::<std[2e963e9f253cdd71]::panicking::begin_panic<rustc_errors[16c9db0e0ca0a6f7]::ExplicitBug>::{closure#0}, !>
  16:     0x7f8871ac2e96 - std[2e963e9f253cdd71]::panicking::begin_panic::<rustc_errors[16c9db0e0ca0a6f7]::ExplicitBug>
  17:     0x7f8871b6fb24 - <rustc_errors[16c9db0e0ca0a6f7]::HandlerInner>::bug::<alloc[d59d314c1498fc03]::string::String>
  18:     0x7f8871b6f788 - <rustc_errors[16c9db0e0ca0a6f7]::Handler>::bug::<alloc[d59d314c1498fc03]::string::String>
  19:     0x7f8871b6b10c - rustc_middle[2dbe2ef140938139]::util::bug::opt_span_bug_fmt::<rustc_span[6541493927a8eee4]::span_encoding::Span>::{closure#0}
  20:     0x7f8871b69f0a - rustc_middle[2dbe2ef140938139]::ty::context::tls::with_opt::<rustc_middle[2dbe2ef140938139]::util::bug::opt_span_bug_fmt<rustc_span[6541493927a8eee4]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7f8871b69ed8 - rustc_middle[2dbe2ef140938139]::ty::context::tls::with_context_opt::<rustc_middle[2dbe2ef140938139]::ty::context::tls::with_opt<rustc_middle[2dbe2ef140938139]::util::bug::opt_span_bug_fmt<rustc_span[6541493927a8eee4]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7f8870078f90 - rustc_middle[2dbe2ef140938139]::util::bug::bug_fmt
  23:     0x7f8872229e8f - <rustc_infer[d209e7ec2feaa707]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[29a196fad0f1dedf]::traits::error_reporting::InferCtxtPrivExt>::report_not_const_evaluatable_error
  24:     0x7f8872220617 - <rustc_infer[d209e7ec2feaa707]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[29a196fad0f1dedf]::traits::error_reporting::TypeErrCtxtExt>::report_selection_error
  25:     0x7f887222c5ab - <rustc_infer[d209e7ec2feaa707]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[29a196fad0f1dedf]::traits::error_reporting::InferCtxtPrivExt>::report_fulfillment_error
  26:     0x7f887221f15b - <rustc_infer[d209e7ec2feaa707]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[29a196fad0f1dedf]::traits::error_reporting::TypeErrCtxtExt>::report_fulfillment_errors
  27:     0x7f886f918b23 - <rustc_hir_typeck[dcea5a7d05095b9c]::fn_ctxt::FnCtxt>::check_call
  28:     0x7f886f88287d - <rustc_hir_typeck[dcea5a7d05095b9c]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  29:     0x7f886f8c1f67 - <rustc_hir_typeck[dcea5a7d05095b9c]::fn_ctxt::FnCtxt>::check_block_with_expected
  30:     0x7f886f882e15 - <rustc_hir_typeck[dcea5a7d05095b9c]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  31:     0x7f887001c6c6 - <rustc_hir_typeck[dcea5a7d05095b9c]::fn_ctxt::FnCtxt>::check_return_expr
  32:     0x7f8870012f6d - rustc_hir_typeck[dcea5a7d05095b9c]::check::check_fn
  33:     0x7f8870001697 - rustc_hir_typeck[dcea5a7d05095b9c]::typeck
  34:     0x7f886f63954e - rustc_query_impl[764276e1d4d25526]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[764276e1d4d25526]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[2dbe2ef140938139]::query::erase::Erased<[u8; 8usize]>>
  35:     0x7f886f63951e - <rustc_query_impl[764276e1d4d25526]::query_impl::typeck::dynamic_query::{closure#2} as core[5cd17d5b9f662bec]::ops::function::FnOnce<(rustc_middle[2dbe2ef140938139]::ty::context::TyCtxt, rustc_span[6541493927a8eee4]::def_id::LocalDefId)>>::call_once
  36:     0x7f886f7a607d - rustc_query_system[455882a7c9f92b0a]::query::plumbing::try_execute_query::<rustc_query_impl[764276e1d4d25526]::DynamicConfig<rustc_query_system[455882a7c9f92b0a]::query::caches::VecCache<rustc_span[6541493927a8eee4]::def_id::LocalDefId, rustc_middle[2dbe2ef140938139]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[764276e1d4d25526]::plumbing::QueryCtxt, false>
  37:     0x7f8870eef6cf - rustc_query_impl[764276e1d4d25526]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  38:     0x7f8870a24c2d - rustc_data_structures[456d5294c5533e9]::sync::par_for_each_in::<&[rustc_span[6541493927a8eee4]::def_id::LocalDefId], <rustc_middle[2dbe2ef140938139]::hir::map::Map>::par_body_owners<rustc_hir_analysis[7376a6bdbe652c9c]::check_crate::{closure#7}>::{closure#0}>
  39:     0x7f8870a23f0c - rustc_hir_analysis[7376a6bdbe652c9c]::check_crate
  40:     0x7f8870a1de9a - rustc_interface[7f8477932cb20ad4]::passes::analysis
  41:     0x7f8870a8539a - rustc_query_impl[764276e1d4d25526]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[764276e1d4d25526]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[2dbe2ef140938139]::query::erase::Erased<[u8; 1usize]>>
  42:     0x7f8870a85389 - <rustc_query_impl[764276e1d4d25526]::query_impl::analysis::dynamic_query::{closure#2} as core[5cd17d5b9f662bec]::ops::function::FnOnce<(rustc_middle[2dbe2ef140938139]::ty::context::TyCtxt, ())>>::call_once
  43:     0x7f8870c2c818 - rustc_query_system[455882a7c9f92b0a]::query::plumbing::try_execute_query::<rustc_query_impl[764276e1d4d25526]::DynamicConfig<rustc_query_system[455882a7c9f92b0a]::query::caches::SingleCache<rustc_middle[2dbe2ef140938139]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[764276e1d4d25526]::plumbing::QueryCtxt, false>
  44:     0x7f8870c2c5a7 - rustc_query_impl[764276e1d4d25526]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  45:     0x7f88707acad5 - <rustc_middle[2dbe2ef140938139]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[11f9c42ddd32a232]::run_compiler::{closure#1}::{closure#2}::{closure#4}, core[5cd17d5b9f662bec]::result::Result<(), rustc_span[6541493927a8eee4]::ErrorGuaranteed>>
  46:     0x7f88707ac102 - <rustc_interface[7f8477932cb20ad4]::interface::Compiler>::enter::<rustc_driver_impl[11f9c42ddd32a232]::run_compiler::{closure#1}::{closure#2}, core[5cd17d5b9f662bec]::result::Result<core[5cd17d5b9f662bec]::option::Option<rustc_interface[7f8477932cb20ad4]::queries::Linker>, rustc_span[6541493927a8eee4]::ErrorGuaranteed>>
  47:     0x7f88707a51a8 - std[2e963e9f253cdd71]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[7f8477932cb20ad4]::util::run_in_thread_pool_with_globals<rustc_interface[7f8477932cb20ad4]::interface::run_compiler<core[5cd17d5b9f662bec]::result::Result<(), rustc_span[6541493927a8eee4]::ErrorGuaranteed>, rustc_driver_impl[11f9c42ddd32a232]::run_compiler::{closure#1}>::{closure#0}, core[5cd17d5b9f662bec]::result::Result<(), rustc_span[6541493927a8eee4]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[5cd17d5b9f662bec]::result::Result<(), rustc_span[6541493927a8eee4]::ErrorGuaranteed>>
  48:     0x7f88707a492e - <<std[2e963e9f253cdd71]::thread::Builder>::spawn_unchecked_<rustc_interface[7f8477932cb20ad4]::util::run_in_thread_pool_with_globals<rustc_interface[7f8477932cb20ad4]::interface::run_compiler<core[5cd17d5b9f662bec]::result::Result<(), rustc_span[6541493927a8eee4]::ErrorGuaranteed>, rustc_driver_impl[11f9c42ddd32a232]::run_compiler::{closure#1}>::{closure#0}, core[5cd17d5b9f662bec]::result::Result<(), rustc_span[6541493927a8eee4]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[5cd17d5b9f662bec]::result::Result<(), rustc_span[6541493927a8eee4]::ErrorGuaranteed>>::{closure#1} as core[5cd17d5b9f662bec]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  49:     0x7f8872733dc5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h6a397ffa79ce97be
                               at /rustc/0d95f9132909ae7c5f2456748d0ffd1c3ba4a8e8/library/alloc/src/boxed.rs:2007:9
  50:     0x7f8872733dc5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hd63e3cd46e3d7a48
                               at /rustc/0d95f9132909ae7c5f2456748d0ffd1c3ba4a8e8/library/alloc/src/boxed.rs:2007:9
  51:     0x7f8872733dc5 - std::sys::unix::thread::Thread::new::thread_start::h06e8fe5bf1fac20c
                               at /rustc/0d95f9132909ae7c5f2456748d0ffd1c3ba4a8e8/library/std/src/sys/unix/thread.rs:108:17
  52:     0x7f886e25a44b - <unknown>
  53:     0x7f886e2dde40 - <unknown>
  54:                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 `/tmp/im/rustc-ice-2023-07-27T23:14:40.504323337Z-731981.txt` to your bug report

query stack during panic:
#0 [typeck] type-checking `ice`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 6 previous errors; 1 warning emitted

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

@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. A-const-eval Area: constant evaluation (mir interpretation) requires-nightly This issue requires a nightly compiler in some way. F-generic_const_exprs `#![feature(generic_const_exprs)]` labels Jul 27, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 27, 2023
@matthiaskrgr
Copy link
Member Author

Regression in nightly-2022-11-27
commit[0] 2022-11-25: Auto merge of #104902 - matthiaskrgr:rollup-oo27a4u, r=matthiaskrgr
commit[1] 2022-11-25: Auto merge of #99798 - JulianKnodt:ac1, r=BoxyUwU
commit[2] 2022-11-26: Auto merge of #104431 - alistair23:alistair/rv64-profiler, r=Mark-Simulacrum
commit[3] 2022-11-26: Auto merge of #104730 - petrochenkov:modchild5, r=cjgillot
commit[4] 2022-11-26: Auto merge of #103556 - clubby789:specialize-option-partial-eq, r=scottmcm
commit[5] 2022-11-26: Auto merge of #104935 - matthiaskrgr:rollup-nuca86l, r=matthiaskrgr
commit[6] 2022-11-26: Auto merge of #104731 - compiler-errors:early-binder-iter-size-hint, r=cjgillot
commit[7] 2022-11-26: Auto merge of #104945 - GuillaumeGomez:rollup-ygzbpbe, r=GuillaumeGomez

@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 29, 2023
@lenko-d
Copy link
Contributor

lenko-d commented Sep 26, 2023

@rustbot claim

@oli-obk
Copy link
Contributor

oli-obk commented Sep 26, 2023

The only thing that looks remotely related is #104835

Either way, be careful about fixing this ICE, it may not suffice to turn it into a nice error, there may be something deeper underlying that we should address.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Dec 12, 2023
…or_non_unevaluated_const, r=BoxyUwU

dont ICE when ConstKind::Expr for is_const_evaluatable

The problem is that we are not handling ConstKind::Expr inside report_not_const_evaluatable_error

Fixes [rust-lang#114151]
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Dec 12, 2023
Rollup merge of rust-lang#116740 - lenko-d:const_evaluatable_failed_for_non_unevaluated_const, r=BoxyUwU

dont ICE when ConstKind::Expr for is_const_evaluatable

The problem is that we are not handling ConstKind::Expr inside report_not_const_evaluatable_error

Fixes [rust-lang#114151]
@matthiaskrgr
Copy link
Member Author

Fixed by #116740

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-eval Area: constant evaluation (mir interpretation) 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

No branches or pull requests

5 participants