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: unable to construct a valtree for the unevaluated constant #128232

Closed
matthiaskrgr opened this issue Jul 26, 2024 · 3 comments · Fixed by #132927
Closed

ICE: unable to construct a valtree for the unevaluated constant #128232

matthiaskrgr opened this issue Jul 26, 2024 · 3 comments · Fixed by #132927
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) ❄️ 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

@matthiaskrgr
Copy link
Member

auto-reduced (treereduce-rust):

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




fn function() -> u32 {
    17
}

struct Wrapper<const F: fn() -> u32>; 

impl<> Wrapper<bar(1, 1)> {
    
    fn call() -> u32 {
        F()
    }
}

fn main() {
    assert_eq!(Wrapper::<function>::call, 17);
}

original:

// Check that functions cannot be used as const parameters.
//@ revisions: min adt_const_params full

#![feature(generic_const_exprs, unsized_const_params, adt_const_params)]
#![zpk(full, allow(incomplete_features))]
#![cfg_attr(adt_const_params, feature(adt_const_params))]
#![cfg_attr(adt_const_params, allow(incomplete_features))]

fn function() -> u32 {
    17
}

struct Wrapper<const F: fn() -> u32>; //~ ERROR: using function pointers as const generic parameters

impl<const F: fn() -> u32> Wrapper<bar(1, 1)> {
    //~^ ERROR: using function pointers as const generic parameters
    fn call() -> u32 {
        F()
    }
}

fn main() {
    assert_eq!(Wrapper::<function>::call(generic_const_exprs, generic_arg_infer), 17);
}

Version information

rustc 1.82.0-nightly (6ef11b81c 2024-07-26)
binary: rustc
commit-hash: 6ef11b81c2c02c3c4b7556d1991a98572fe9af87
commit-date: 2024-07-26
host: x86_64-unknown-linux-gnu
release: 1.82.0-nightly
LLVM version: 18.1.7

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

error: expected type, found `1`
  --> /tmp/icemaker_global_tempdir.ktOk6Uccai2q/rustc_testrunner_tmpdir_reporting.oullzuqu4Neh/mvce.rs:15:20
   |
15 | impl<> Wrapper<bar(1, 1)> {
   |                    ^ expected type
   |
help: expressions must be enclosed in braces to be used as const generic arguments
   |
15 | impl<> Wrapper<{ bar(1, 1) }> {
   |                +           +

warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
 --> /tmp/icemaker_global_tempdir.ktOk6Uccai2q/rustc_testrunner_tmpdir_reporting.oullzuqu4Neh/mvce.rs:4:12
  |
4 | #![feature(generic_const_exprs, unsized_const_params, adt_const_params)]
  |            ^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
  = note: `#[warn(incomplete_features)]` on by default

warning: the feature `unsized_const_params` is incomplete and may not be safe to use and/or cause compiler crashes
 --> /tmp/icemaker_global_tempdir.ktOk6Uccai2q/rustc_testrunner_tmpdir_reporting.oullzuqu4Neh/mvce.rs:4:33
  |
4 | #![feature(generic_const_exprs, unsized_const_params, adt_const_params)]
  |                                 ^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #95174 <https://github.com/rust-lang/rust/issues/95174> for more information

error[E0741]: using function pointers as const generic parameters is forbidden
  --> /tmp/icemaker_global_tempdir.ktOk6Uccai2q/rustc_testrunner_tmpdir_reporting.oullzuqu4Neh/mvce.rs:13:25
   |
13 | struct Wrapper<const F: fn() -> u32>; 
   |                         ^^^^^^^^^^^

error[E0425]: cannot find function, tuple struct or tuple variant `F` in this scope
  --> /tmp/icemaker_global_tempdir.ktOk6Uccai2q/rustc_testrunner_tmpdir_reporting.oullzuqu4Neh/mvce.rs:18:9
   |
18 |         F()
   |         ^ not found in this scope

error: internal compiler error: compiler/rustc_infer/src/infer/mod.rs:1412:17: unable to construct a valtree for the unevaluated constant UnevaluatedConst { def: DefId(0:11 ~ mvce[ede4]::main::{constant#0}), args: [] }: type fn() -> u32 is not valtree-compatible
  --> /tmp/icemaker_global_tempdir.ktOk6Uccai2q/rustc_testrunner_tmpdir_reporting.oullzuqu4Neh/mvce.rs:23:26
   |
23 |     assert_eq!(Wrapper::<function>::call, 17);
   |                          ^^^^^^^^

thread 'rustc' panicked at compiler/rustc_infer/src/infer/mod.rs:1412:17:
Box<dyn Any>
stack backtrace:
   0:     0x7f448e505015 - std::backtrace_rs::backtrace::libunwind::trace::hba0c5d2da5d21d3b
                               at /rustc/6ef11b81c2c02c3c4b7556d1991a98572fe9af87/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
   1:     0x7f448e505015 - std::backtrace_rs::backtrace::trace_unsynchronized::h10df601c000a21db
                               at /rustc/6ef11b81c2c02c3c4b7556d1991a98572fe9af87/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f448e505015 - std::sys::backtrace::_print_fmt::h9c09a69e66997be5
                               at /rustc/6ef11b81c2c02c3c4b7556d1991a98572fe9af87/library/std/src/sys/backtrace.rs:68:9
   3:     0x7f448e505015 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h8df4565bb0e0abaf
                               at /rustc/6ef11b81c2c02c3c4b7556d1991a98572fe9af87/library/std/src/sys/backtrace.rs:41:26
   4:     0x7f448e5549eb - core::fmt::rt::Argument::fmt::h2285a02bb70a7a85
                               at /rustc/6ef11b81c2c02c3c4b7556d1991a98572fe9af87/library/core/src/fmt/rt.rs:173:76
   5:     0x7f448e5549eb - core::fmt::write::h9f3b68196c3b1892
                               at /rustc/6ef11b81c2c02c3c4b7556d1991a98572fe9af87/library/core/src/fmt/mod.rs:1182:21
   6:     0x7f448e4f985f - std::io::Write::write_fmt::h6876ab44488ea710
                               at /rustc/6ef11b81c2c02c3c4b7556d1991a98572fe9af87/library/std/src/io/mod.rs:1827:15
   7:     0x7f448e507801 - std::sys::backtrace::BacktraceLock::print::he09aebc2da930db5
                               at /rustc/6ef11b81c2c02c3c4b7556d1991a98572fe9af87/library/std/src/sys/backtrace.rs:44:9
   8:     0x7f448e507801 - std::panicking::default_hook::{{closure}}::h84a3b946e31027b8
                               at /rustc/6ef11b81c2c02c3c4b7556d1991a98572fe9af87/library/std/src/panicking.rs:269:22
   9:     0x7f448e5074dc - std::panicking::default_hook::hb8beb4cabfcfffe9
                               at /rustc/6ef11b81c2c02c3c4b7556d1991a98572fe9af87/library/std/src/panicking.rs:296:9
  10:     0x7f448aa4f85a - std[7d30d51779b00fdc]::panicking::update_hook::<alloc[a425665f29645c95]::boxed::Box<rustc_driver_impl[f229ff08257431b3]::install_ice_hook::{closure#0}>>::{closure#0}
  11:     0x7f448e5081cf - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h2a1b73f9826d619d
                               at /rustc/6ef11b81c2c02c3c4b7556d1991a98572fe9af87/library/alloc/src/boxed.rs:2163:9
  12:     0x7f448e5081cf - std::panicking::rust_panic_with_hook::hcb3a582e272725c3
                               at /rustc/6ef11b81c2c02c3c4b7556d1991a98572fe9af87/library/std/src/panicking.rs:808:13
  13:     0x7f448aa8a5d1 - std[7d30d51779b00fdc]::panicking::begin_panic::<rustc_errors[858d6b59f6c606fd]::ExplicitBug>::{closure#0}
  14:     0x7f448aa7d586 - std[7d30d51779b00fdc]::sys::backtrace::__rust_end_short_backtrace::<std[7d30d51779b00fdc]::panicking::begin_panic<rustc_errors[858d6b59f6c606fd]::ExplicitBug>::{closure#0}, !>
  15:     0x7f448aa78846 - std[7d30d51779b00fdc]::panicking::begin_panic::<rustc_errors[858d6b59f6c606fd]::ExplicitBug>
  16:     0x7f448aa93c11 - <rustc_errors[858d6b59f6c606fd]::diagnostic::BugAbort as rustc_errors[858d6b59f6c606fd]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  17:     0x7f448add7dcd - <rustc_errors[858d6b59f6c606fd]::DiagCtxtHandle>::span_bug::<rustc_span[9dc2d37556667bfe]::span_encoding::Span, alloc[a425665f29645c95]::string::String>
  18:     0x7f448adfdf98 - rustc_middle[79a84c3fef91123a]::util::bug::opt_span_bug_fmt::<rustc_span[9dc2d37556667bfe]::span_encoding::Span>::{closure#0}
  19:     0x7f448ae00eea - rustc_middle[79a84c3fef91123a]::ty::context::tls::with_opt::<rustc_middle[79a84c3fef91123a]::util::bug::opt_span_bug_fmt<rustc_span[9dc2d37556667bfe]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  20:     0x7f448ade190b - rustc_middle[79a84c3fef91123a]::ty::context::tls::with_context_opt::<rustc_middle[79a84c3fef91123a]::ty::context::tls::with_opt<rustc_middle[79a84c3fef91123a]::util::bug::opt_span_bug_fmt<rustc_span[9dc2d37556667bfe]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  21:     0x7f448a398237 - rustc_middle[79a84c3fef91123a]::util::bug::span_bug_fmt::<rustc_span[9dc2d37556667bfe]::span_encoding::Span>
  22:     0x7f448ae17121 - <rustc_infer[5a8779d3ea9a51cc]::infer::InferCtxt>::try_const_eval_resolve
  23:     0x7f44889b4cd5 - <rustc_trait_selection[7be6dcd4e93fc1a0]::traits::fulfill::FulfillProcessor as rustc_data_structures[c4c8cdbb129cb916]::obligation_forest::ObligationProcessor>::process_obligation
  24:     0x7f448c273c0a - <rustc_data_structures[c4c8cdbb129cb916]::obligation_forest::ObligationForest<rustc_trait_selection[7be6dcd4e93fc1a0]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[7be6dcd4e93fc1a0]::traits::fulfill::FulfillProcessor>
  25:     0x7f448c55a5e6 - <core[ed9eac647662a901]::iter::adapters::filter::Filter<core[ed9eac647662a901]::iter::adapters::map::Map<core[ed9eac647662a901]::slice::iter::Iter<rustc_hir_typeck[ac02ac983fee86f6]::method::probe::Candidate>, <rustc_hir_typeck[ac02ac983fee86f6]::method::probe::ProbeContext>::consider_candidates::{closure#0}>, <rustc_hir_typeck[ac02ac983fee86f6]::method::probe::ProbeContext>::consider_candidates::{closure#1}> as core[ed9eac647662a901]::iter::traits::iterator::Iterator>::next
  26:     0x7f448c565897 - <rustc_hir_typeck[ac02ac983fee86f6]::method::probe::ProbeContext>::pick_method
  27:     0x7f448c564fa7 - <rustc_hir_typeck[ac02ac983fee86f6]::method::probe::ProbeContext>::pick_core
  28:     0x7f448c508350 - <rustc_hir_typeck[ac02ac983fee86f6]::fn_ctxt::FnCtxt>::probe_for_name
  29:     0x7f448c51cbcf - <rustc_hir_typeck[ac02ac983fee86f6]::fn_ctxt::FnCtxt>::check_expr_path
  30:     0x7f448ca7e834 - <rustc_hir_typeck[ac02ac983fee86f6]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  31:     0x7f448ca8180b - <rustc_hir_typeck[ac02ac983fee86f6]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  32:     0x7f448ca85a2f - <rustc_hir_typeck[ac02ac983fee86f6]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  33:     0x7f448ca73f69 - <rustc_hir_typeck[ac02ac983fee86f6]::fn_ctxt::FnCtxt>::check_match::{closure#0}
  34:     0x7f448ca8221e - <rustc_hir_typeck[ac02ac983fee86f6]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  35:     0x7f448ca7aa5b - <rustc_hir_typeck[ac02ac983fee86f6]::fn_ctxt::FnCtxt>::check_block_with_expected
  36:     0x7f448ca8119d - <rustc_hir_typeck[ac02ac983fee86f6]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  37:     0x7f448c1cc677 - rustc_hir_typeck[ac02ac983fee86f6]::check::check_fn
  38:     0x7f448c1c23c3 - rustc_hir_typeck[ac02ac983fee86f6]::typeck
  39:     0x7f448c1c1d69 - rustc_query_impl[6f72a32bb9596f00]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[6f72a32bb9596f00]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[79a84c3fef91123a]::query::erase::Erased<[u8; 8usize]>>
  40:     0x7f448c36d4b3 - rustc_query_system[b72a41914d7622ff]::query::plumbing::try_execute_query::<rustc_query_impl[6f72a32bb9596f00]::DynamicConfig<rustc_query_system[b72a41914d7622ff]::query::caches::VecCache<rustc_span[9dc2d37556667bfe]::def_id::LocalDefId, rustc_middle[79a84c3fef91123a]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[6f72a32bb9596f00]::plumbing::QueryCtxt, false>
  41:     0x7f448c36c68d - rustc_query_impl[6f72a32bb9596f00]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  42:     0x7f448c36c28e - <rustc_middle[79a84c3fef91123a]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[799f0addd470a8f5]::check_crate::{closure#4}>::{closure#0}
  43:     0x7f448c36a0ce - rustc_hir_analysis[799f0addd470a8f5]::check_crate
  44:     0x7f448c360795 - rustc_interface[8d3212ab15a5ab63]::passes::analysis
  45:     0x7f448c360347 - rustc_query_impl[6f72a32bb9596f00]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[6f72a32bb9596f00]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[79a84c3fef91123a]::query::erase::Erased<[u8; 1usize]>>
  46:     0x7f448ce85265 - rustc_query_system[b72a41914d7622ff]::query::plumbing::try_execute_query::<rustc_query_impl[6f72a32bb9596f00]::DynamicConfig<rustc_query_system[b72a41914d7622ff]::query::caches::SingleCache<rustc_middle[79a84c3fef91123a]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[6f72a32bb9596f00]::plumbing::QueryCtxt, false>
  47:     0x7f448ce84fcf - rustc_query_impl[6f72a32bb9596f00]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  48:     0x7f448cd35385 - rustc_interface[8d3212ab15a5ab63]::interface::run_compiler::<core[ed9eac647662a901]::result::Result<(), rustc_span[9dc2d37556667bfe]::ErrorGuaranteed>, rustc_driver_impl[f229ff08257431b3]::run_compiler::{closure#0}>::{closure#1}
  49:     0x7f448cd1a709 - std[7d30d51779b00fdc]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[8d3212ab15a5ab63]::util::run_in_thread_with_globals<rustc_interface[8d3212ab15a5ab63]::util::run_in_thread_pool_with_globals<rustc_interface[8d3212ab15a5ab63]::interface::run_compiler<core[ed9eac647662a901]::result::Result<(), rustc_span[9dc2d37556667bfe]::ErrorGuaranteed>, rustc_driver_impl[f229ff08257431b3]::run_compiler::{closure#0}>::{closure#1}, core[ed9eac647662a901]::result::Result<(), rustc_span[9dc2d37556667bfe]::ErrorGuaranteed>>::{closure#0}, core[ed9eac647662a901]::result::Result<(), rustc_span[9dc2d37556667bfe]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[ed9eac647662a901]::result::Result<(), rustc_span[9dc2d37556667bfe]::ErrorGuaranteed>>
  50:     0x7f448cd1a4ba - <<std[7d30d51779b00fdc]::thread::Builder>::spawn_unchecked_<rustc_interface[8d3212ab15a5ab63]::util::run_in_thread_with_globals<rustc_interface[8d3212ab15a5ab63]::util::run_in_thread_pool_with_globals<rustc_interface[8d3212ab15a5ab63]::interface::run_compiler<core[ed9eac647662a901]::result::Result<(), rustc_span[9dc2d37556667bfe]::ErrorGuaranteed>, rustc_driver_impl[f229ff08257431b3]::run_compiler::{closure#0}>::{closure#1}, core[ed9eac647662a901]::result::Result<(), rustc_span[9dc2d37556667bfe]::ErrorGuaranteed>>::{closure#0}, core[ed9eac647662a901]::result::Result<(), rustc_span[9dc2d37556667bfe]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[ed9eac647662a901]::result::Result<(), rustc_span[9dc2d37556667bfe]::ErrorGuaranteed>>::{closure#1} as core[ed9eac647662a901]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  51:     0x7f448e51211b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hdb8f7dfc3eda67f4
                               at /rustc/6ef11b81c2c02c3c4b7556d1991a98572fe9af87/library/alloc/src/boxed.rs:2149:9
  52:     0x7f448e51211b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h969b7c01506b8601
                               at /rustc/6ef11b81c2c02c3c4b7556d1991a98572fe9af87/library/alloc/src/boxed.rs:2149:9
  53:     0x7f448e51211b - std::sys::pal::unix::thread::Thread::new::thread_start::he6f3cf1932d26a89
                               at /rustc/6ef11b81c2c02c3c4b7556d1991a98572fe9af87/library/std/src/sys/pal/unix/thread.rs:108:17
  54:     0x7f44874a6ded - <unknown>
  55:     0x7f448752a0dc - <unknown>
  56:                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 make sure that you have updated to the latest nightly

note: rustc 1.82.0-nightly (6ef11b81c 2024-07-26) running on x86_64-unknown-linux-gnu

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

Some errors have detailed explanations: E0425, E0741.
For more information about an error, try `rustc --explain E0425`.

@rustbot label +F-generic_const_exprs +F-unsized_const_params +F-adt_const_params

@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 26, 2024
@rustbot rustbot added needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. F-adt_const_params `#![feature(adt_const_params)]` F-generic_const_exprs `#![feature(generic_const_exprs)]` F-unsized_const_params `#![feature(unsized_const_params)]` labels Jul 26, 2024
@matthiaskrgr
Copy link
Member Author

#![feature(generic_const_exprs, unsized_const_params)]

fn function() {}

struct Wrapper<const F: fn()>;

impl Wrapper<{ bar() }> {
    fn call() {}
}

fn main() {
    Wrapper::<function>::call;
}

@GrigorenkoPV
Copy link
Contributor

auto-reduced (treereduce-rust):

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




fn function() -> u32 {
    17
}

struct Wrapper<const F: fn() -> u32>; 

impl<> Wrapper<bar(1, 1)> {
    
    fn call() -> u32 {
        F()
    }
}

fn main() {
    assert_eq!(Wrapper::<function>::call, 17);
}

Regression in #120847

original:

// Check that functions cannot be used as const parameters.
//@ revisions: min adt_const_params full

#![feature(generic_const_exprs, unsized_const_params, adt_const_params)]
#![zpk(full, allow(incomplete_features))]
#![cfg_attr(adt_const_params, feature(adt_const_params))]
#![cfg_attr(adt_const_params, allow(incomplete_features))]

fn function() -> u32 {
    17
}

struct Wrapper<const F: fn() -> u32>; //~ ERROR: using function pointers as const generic parameters

impl<const F: fn() -> u32> Wrapper<bar(1, 1)> {
    //~^ ERROR: using function pointers as const generic parameters
    fn call() -> u32 {
        F()
    }
}

fn main() {
    assert_eq!(Wrapper::<function>::call(generic_const_exprs, generic_arg_infer), 17);
}

Regression in #121154

#![feature(generic_const_exprs, unsized_const_params)]

fn function() {}

struct Wrapper<const F: fn()>;

impl Wrapper<{ bar() }> {
    fn call() {}
}

fn main() {
    Wrapper::<function>::call;
}

Regression in #120847

@BoxyUwU BoxyUwU removed the F-unsized_const_params `#![feature(unsized_const_params)]` label Jul 28, 2024
@BoxyUwU
Copy link
Member

BoxyUwU commented Jul 28, 2024

Can be reproduced without unsized_const_params so removing that label

@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 29, 2024
@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Sep 18, 2024
@bors bors closed this as completed in ea61714 Nov 12, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Nov 12, 2024
Rollup merge of rust-lang#132927 - BoxyUwU:consolidate_type_system_const_eval, r=compiler-errors

Consolidate type system const evaluation under `traits::evaluate_const`

Part of rust-lang#130704

Fixes rust-lang#128232
Fixes rust-lang#118545

Removes `ty::Const::{normalize_internal, eval_valtree}` and `InferCtxt::(try_)const_eval_resolve`, consolidating the associated logic into `evaluate_const` in `rustc_trait_selection`. This results in an API for `ty::Const` that is free of any normalization/evaluation functions that would be incorrect to use under `min_generic_const_args`/`associated_const_equality`/`generic_const_exprs` or, more generally, that would be incorrect to use in the presence of generic type system constants.

Moving this logic to `rustc_trait_selection` and out of `rustc_middle` is also a pre-requisite for ensuring that we do not evaluate constants whose where clauses do not hold.

From this point it should be relatively simple (hah) to implement more complex normalization of type system constants such as: checking wf'ness before invoking CTFE machinery, or being able to normalize const aliases that still refer to generic parameters.

r? `@compiler-errors`
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. 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) ❄️ 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

Successfully merging a pull request may close this issue.

5 participants