Skip to content

ICE with assoc const equality & closure: Type system constant with non valtree'able type evaluated but no error emitted #119783

Open
@fmease

Description

@fmease

We don't employ any checks à la check_param_wf for assoc const equality constraints / we don't ensure that the type impls std::marker::ConstParamTy.

#![feature(associated_const_equality)]

trait Trait { const F: fn(); }

fn take(_: impl Trait<F = { || {} }>) {}

fn main() {}
error: internal compiler error: no errors encountered even though `span_delayed_bug` issued

error: internal compiler error: `ty::Const::eval` called on a non-valtree-compatible type
  |
  = note: delayed at /rustc/3cdd004e55c869faa2b7b25efd3becf50346e7d6/compiler/rustc_middle/src/ty/consts.rs:325:39 - disabled backtrace
full stderr & backtrace
warning: function `take` is never used
 --> cl.rs:5:4
  |
5 | fn take(_: impl Trait<F = { || {} }>) {}
  |    ^^^^
  |
  = note: `#[warn(dead_code)]` on by default

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

error: internal compiler error: `ty::Const::eval` called on a non-valtree-compatible type
  |
  = note: delayed at /rustc/3cdd004e55c869faa2b7b25efd3becf50346e7d6/compiler/rustc_middle/src/ty/consts.rs:325:39
             0: <rustc_errors::DiagCtxtInner>::emit_diagnostic_without_consuming
             1: <rustc_errors::DiagCtxt>::emit_diagnostic_without_consuming
             2: <rustc_errors::DiagCtxt>::emit_diagnostic
             3: <rustc_errors::DiagCtxt>::span_delayed_bug::<rustc_span::span_encoding::Span, &str>
             4: <rustc_middle::ty::consts::Const>::eval.cold.0
             5: <rustc_trait_selection::traits::normalize_param_env_or_error::{closure#0}::ConstNormalizer as rustc_type_ir::fold::TypeFolder<rustc_middle::ty::context::TyCtxt>>::fold_const
             6: rustc_trait_selection::traits::normalize_param_env_or_error
             7: rustc_ty_utils::ty::param_env
             8: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::param_env::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
             9: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::DefId, rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
            10: rustc_query_impl::query_impl::param_env::get_query_non_incr::__rust_end_short_backtrace
            11: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::DefId, rustc_middle::query::erase::Erased<[u8; 8]>>>
            12: rustc_hir_analysis::check::wfcheck::check_item_fn
            13: rustc_hir_analysis::check::wfcheck::check_well_formed
            14: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 1]>>
            15: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::VecCache<rustc_hir::hir_id::OwnerId, rustc_middle::query::erase::Erased<[u8; 1]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
            16: rustc_query_impl::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
            17: rustc_hir_analysis::check::wfcheck::check_mod_type_wf
            18: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 1]>>
            19: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::LocalModDefId, rustc_middle::query::erase::Erased<[u8; 1]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
            20: rustc_query_impl::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
            21: <rustc_middle::hir::map::Map>::try_par_for_each_module::<rustc_hir_analysis::check_crate::{closure#4}::{closure#0}>::{closure#0}
            22: rustc_hir_analysis::check_crate
            23: rustc_interface::passes::analysis
            24: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 1]>>
            25: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 1]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
            26: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
            27: rustc_interface::interface::run_compiler::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}
            28: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
            29: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
            30: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                       at /rustc/3cdd004e55c869faa2b7b25efd3becf50346e7d6/library/alloc/src/boxed.rs:2015:9
            31: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                       at /rustc/3cdd004e55c869faa2b7b25efd3becf50346e7d6/library/alloc/src/boxed.rs:2015:9
            32: std::sys::unix::thread::Thread::new::thread_start
                       at /rustc/3cdd004e55c869faa2b7b25efd3becf50346e7d6/library/std/src/sys/unix/thread.rs:108:17
            33: <unknown>
            34: <unknown>


error: internal compiler error: `ty::Const::eval` called on a non-valtree-compatible type
  |
  = note: delayed at /rustc/3cdd004e55c869faa2b7b25efd3becf50346e7d6/compiler/rustc_middle/src/ty/consts.rs:325:39
             0: <rustc_errors::DiagCtxtInner>::emit_diagnostic_without_consuming
             1: <rustc_errors::DiagCtxt>::emit_diagnostic_without_consuming
             2: <rustc_errors::DiagCtxt>::emit_diagnostic
             3: <rustc_errors::DiagCtxt>::span_delayed_bug::<rustc_span::span_encoding::Span, &str>
             4: <rustc_middle::ty::consts::Const>::eval.cold.0
             5: <rustc_trait_selection::traits::project::AssocTypeNormalizer as rustc_type_ir::fold::TypeFolder<rustc_middle::ty::context::TyCtxt>>::fold_const
             6: <rustc_trait_selection::traits::project::AssocTypeNormalizer as rustc_type_ir::fold::FallibleTypeFolder<rustc_middle::ty::context::TyCtxt>>::try_fold_predicate.cold.0
             7: rustc_hir_analysis::check::wfcheck::check_where_clauses
             8: rustc_hir_analysis::check::wfcheck::check_fn_or_method
             9: rustc_hir_analysis::check::wfcheck::check_item_fn
            10: rustc_hir_analysis::check::wfcheck::check_well_formed
            11: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 1]>>
            12: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::VecCache<rustc_hir::hir_id::OwnerId, rustc_middle::query::erase::Erased<[u8; 1]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
            13: rustc_query_impl::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
            14: rustc_hir_analysis::check::wfcheck::check_mod_type_wf
            15: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 1]>>
            16: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::LocalModDefId, rustc_middle::query::erase::Erased<[u8; 1]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
            17: rustc_query_impl::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
            18: <rustc_middle::hir::map::Map>::try_par_for_each_module::<rustc_hir_analysis::check_crate::{closure#4}::{closure#0}>::{closure#0}
            19: rustc_hir_analysis::check_crate
            20: rustc_interface::passes::analysis
            21: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 1]>>
            22: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 1]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
            23: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
            24: rustc_interface::interface::run_compiler::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}
            25: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
            26: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
            27: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                       at /rustc/3cdd004e55c869faa2b7b25efd3becf50346e7d6/library/alloc/src/boxed.rs:2015:9
            28: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                       at /rustc/3cdd004e55c869faa2b7b25efd3becf50346e7d6/library/alloc/src/boxed.rs:2015:9
            29: std::sys::unix::thread::Thread::new::thread_start
                       at /rustc/3cdd004e55c869faa2b7b25efd3becf50346e7d6/library/std/src/sys/unix/thread.rs:108:17
            30: <unknown>
            31: <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 `/home/fmease/programming/rust/rustc-ice-2024-01-09T21_08_54-23408.txt` to your bug report

query stack during panic:
end of query stack
error: aborting due to 3 previous errors; 1 warning emitted

rustc -Vv (old nightly but whatever):

rustc 1.77.0-nightly (3cdd004e5 2023-12-29)
binary: rustc
commit-hash: 3cdd004e55c869faa2b7b25efd3becf50346e7d6
commit-date: 2023-12-29
host: x86_64-unknown-linux-gnu
release: 1.77.0-nightly
LLVM version: 17.0.6

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.F-associated_const_equality`#![feature(associated_const_equality)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

Status

To Do

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions