Skip to content

ICE: potentially unconstrained type parameters weren't evaluated #136854

Closed
@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

//@compile-flags: --crate-type=lib
#![feature(with_negative_coherence, negative_impls, min_generic_const_args)]
trait Trait {}
impl<T> Trait for [(); N] {}

fn N() {}

original:

//~^ WARN the feature `unsized_const_params` is incomplete//! const with the array length of the `Self` type was succeeding under the
//! assumption that an error had already been reported.

#![feature(with_negative_coherence, negative_impls,min_generic_const_args)]
trait Trait {}
impl<T> Trait for [(); N] {}
impl<const N: i8> Trait for [(); N] {}
// Proving `W<!T>: !A<"">` requires proving `CONST alias-eq ""`, which requires proving

fn N() {}

Version information

rustc 1.86.0-nightly (ffa9afef1 2025-02-11)
binary: rustc
commit-hash: ffa9afef183a3496a277c8da2e61403582a99508
commit-date: 2025-02-11
host: x86_64-unknown-linux-gnu
release: 1.86.0-nightly
LLVM version: 19.1.7

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc --crate-type=lib

Program output

warning: the feature `min_generic_const_args` is incomplete and may not be safe to use and/or cause compiler crashes
 --> /tmp/icemaker_global_tempdir.6MLlzRC0yNES/rustc_testrunner_tmpdir_reporting.clx3Mm7S4IdR/mvce.rs:1:53
  |
1 | #![feature(with_negative_coherence, negative_impls, min_generic_const_args)]
  |                                                     ^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #132980 <https://github.com/rust-lang/rust/issues/132980> for more information
  = note: `#[warn(incomplete_features)]` on by default

warning: trait `Trait` is never used
 --> /tmp/icemaker_global_tempdir.6MLlzRC0yNES/rustc_testrunner_tmpdir_reporting.clx3Mm7S4IdR/mvce.rs:2:7
  |
2 | trait Trait {}
  |       ^^^^^
  |
  = note: `#[warn(dead_code)]` on by default

warning: function `N` is never used
 --> /tmp/icemaker_global_tempdir.6MLlzRC0yNES/rustc_testrunner_tmpdir_reporting.clx3Mm7S4IdR/mvce.rs:5:4
  |
5 | fn N() {}
  |    ^

warning: function `N` should have a snake case name
 --> /tmp/icemaker_global_tempdir.6MLlzRC0yNES/rustc_testrunner_tmpdir_reporting.clx3Mm7S4IdR/mvce.rs:5:4
  |
5 | fn N() {}
  |    ^ help: convert the identifier to snake case: `n`
  |
  = note: `#[warn(non_snake_case)]` on by default

warning: 4 warnings emitted

note: no errors encountered even though delayed bugs were created

note: those delayed bugs will now be shown as internal compiler errors

error: internal compiler error: fn items cannot be used as const args
 --> /tmp/icemaker_global_tempdir.6MLlzRC0yNES/rustc_testrunner_tmpdir_reporting.clx3Mm7S4IdR/mvce.rs:3:24
  |
3 | impl<T> Trait for [(); N] {}
  |                        ^
  |
note: delayed at compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:2157:60
         0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
         1: <rustc_errors::DiagCtxtHandle>::emit_diagnostic
         2: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
         3: <rustc_errors::DiagCtxtHandle>::span_delayed_bug::<rustc_span::span_encoding::Span, &str>
         4: <rustc_middle::ty::consts::Const>::new_error_with_message::<rustc_span::span_encoding::Span, &str>
         5: <dyn rustc_hir_analysis::hir_ty_lowering::HirTyLowerer>::lower_const_arg.cold
         6: <dyn rustc_hir_analysis::hir_ty_lowering::HirTyLowerer>::lower_ty
         7: rustc_hir_analysis::collect::type_of::type_of
         8: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::type_of::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::DefIdCache<rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        10: rustc_query_impl::query_impl::type_of::get_query_non_incr::__rust_end_short_backtrace
        11: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 8]>>>
        12: rustc_middle::ty::trait_def::trait_impls_of_provider
        13: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::trait_impls_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
        14: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        15: rustc_query_impl::query_impl::trait_impls_of::get_query_non_incr::__rust_end_short_backtrace
        16: <rustc_trait_selection::traits::select::SelectionContext>::assemble_candidates_from_impls
        17: <rustc_trait_selection::traits::select::SelectionContext>::candidate_from_obligation::{closure#0}::{closure#0}
        18: <rustc_trait_selection::traits::select::SelectionContext>::poly_select::{closure#0}
        19: <rustc_trait_selection::traits::fulfill::FulfillProcessor as rustc_data_structures::obligation_forest::ObligationProcessor>::process_obligation
        20: <rustc_data_structures::obligation_forest::ObligationForest<rustc_trait_selection::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection::traits::fulfill::FulfillProcessor>
        21: <rustc_trait_selection::traits::fulfill::FulfillmentContext<rustc_trait_selection::traits::FulfillmentError> as rustc_infer::traits::engine::TraitEngine<rustc_trait_selection::traits::FulfillmentError>>::select_all_or_error
        22: rustc_hir_analysis::check::wfcheck::check_trait
        23: rustc_hir_analysis::check::wfcheck::check_well_formed
        24: 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]>>
        25: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 1]>, rustc_query_system::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        26: rustc_query_impl::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
        27: rustc_hir_analysis::check::wfcheck::check_mod_type_wf
        28: 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]>>
        29: 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>
        30: rustc_query_impl::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
        31: rustc_hir_analysis::check_crate
        32: rustc_interface::passes::run_required_analyses
        33: rustc_interface::passes::analysis
        34: 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; 0]>>
        35: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 0]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        36: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
        37: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
        38: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
        39: std::sys::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<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
        40: <<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<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
        41: std::sys::pal::unix::thread::Thread::new::thread_start
        42: <unknown>
        43: <unknown>
 --> /tmp/icemaker_global_tempdir.6MLlzRC0yNES/rustc_testrunner_tmpdir_reporting.clx3Mm7S4IdR/mvce.rs:3:24
  |
3 | impl<T> Trait for [(); N] {}
  |                        ^

error: internal compiler error: potentially unconstrained type parameters weren't evaluated: [(); {const error}]
 --> /tmp/icemaker_global_tempdir.6MLlzRC0yNES/rustc_testrunner_tmpdir_reporting.clx3Mm7S4IdR/mvce.rs:3:1
  |
3 | impl<T> Trait for [(); N] {}
  | ^^^^^^^^^^^^^^^^^^^^^^^^^
  |
note: delayed at compiler/rustc_hir_analysis/src/impl_wf_check.rs:180:19
         0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
         1: <rustc_errors::DiagCtxtHandle>::emit_diagnostic
         2: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
         3: <rustc_errors::DiagCtxtHandle>::span_delayed_bug::<rustc_span::span_encoding::Span, alloc::string::String>
         4: rustc_hir_analysis::impl_wf_check::enforce_impl_non_lifetime_params_are_constrained
         5: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::enforce_impl_non_lifetime_params_are_constrained::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 1]>>
         6: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 1]>, rustc_query_system::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
         7: rustc_query_impl::query_impl::enforce_impl_non_lifetime_params_are_constrained::get_query_non_incr::__rust_end_short_backtrace
         8: rustc_hir_analysis::check::wfcheck::check_well_formed
         9: 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]>>
        10: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 1]>, rustc_query_system::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        11: rustc_query_impl::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
        12: rustc_hir_analysis::check::wfcheck::check_mod_type_wf
        13: 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]>>
        14: 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>
        15: rustc_query_impl::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
        16: rustc_hir_analysis::check_crate
        17: rustc_interface::passes::run_required_analyses
        18: rustc_interface::passes::analysis
        19: 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; 0]>>
        20: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 0]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        21: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
        22: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
        23: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
        24: std::sys::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<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
        25: <<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<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
        26: std::sys::pal::unix::thread::Thread::new::thread_start
        27: <unknown>
        28: <unknown>
 --> /tmp/icemaker_global_tempdir.6MLlzRC0yNES/rustc_testrunner_tmpdir_reporting.clx3Mm7S4IdR/mvce.rs:3:1
  |
3 | impl<T> Trait for [(); N] {}
  | ^^^^^^^^^^^^^^^^^^^^^^^^^

error: internal compiler error: potentially unconstrained type parameters weren't evaluated: [(); {const error}]
 --> /tmp/icemaker_global_tempdir.6MLlzRC0yNES/rustc_testrunner_tmpdir_reporting.clx3Mm7S4IdR/mvce.rs:3:1
  |
3 | impl<T> Trait for [(); N] {}
  | ^^^^^^^^^^^^^^^^^^^^^^^^^
  |
note: delayed at compiler/rustc_hir_analysis/src/impl_wf_check.rs:82:19
         0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
         1: <rustc_errors::DiagCtxtHandle>::emit_diagnostic
         2: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
         3: <rustc_errors::DiagCtxtHandle>::span_delayed_bug::<rustc_span::span_encoding::Span, alloc::string::String>
         4: rustc_hir_analysis::impl_wf_check::enforce_impl_lifetime_params_are_constrained
         5: rustc_hir_analysis::check::wfcheck::check_well_formed
         6: 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]>>
         7: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 1]>, rustc_query_system::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
         8: rustc_query_impl::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
         9: rustc_hir_analysis::check::wfcheck::check_mod_type_wf
        10: 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]>>
        11: 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>
        12: rustc_query_impl::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
        13: rustc_hir_analysis::check_crate
        14: rustc_interface::passes::run_required_analyses
        15: rustc_interface::passes::analysis
        16: 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; 0]>>
        17: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 0]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        18: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
        19: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
        20: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
        21: std::sys::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<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
        22: <<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<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
        23: std::sys::pal::unix::thread::Thread::new::thread_start
        24: <unknown>
        25: <unknown>
 --> /tmp/icemaker_global_tempdir.6MLlzRC0yNES/rustc_testrunner_tmpdir_reporting.clx3Mm7S4IdR/mvce.rs:3:1
  |
3 | impl<T> Trait for [(); N] {}
  | ^^^^^^^^^^^^^^^^^^^^^^^^^

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.86.0-nightly (ffa9afef1 2025-02-11) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -Z dump-mir-dir=dir

query stack during panic:
end of query stack

@rustbot label +F-with_negative_coherence +F-negative_impls +F-min_generic_const_args

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions