Skip to content

ICE: Unevaluated 'ty::Const' in MIR body #133639

Closed
@matthiaskrgr

Description

@matthiaskrgr

Code

#![feature(with_negative_coherence)]
#![feature(min_specialization)]
#![feature(generic_const_exprs)]

#![crate_type = "lib"]
use std::str::FromStr;

struct a<const b: bool>;

trait c {}

impl<const d: u32> FromStr for e<d>
where
    a<{ d <= 2 }>: c,
{
    type Err = ();
    fn from_str(f: &str) -> Result<Self, Self::Err> {
        unimplemented!()
    }
}
struct e<const d: u32>;

impl<const d: u32> FromStr for e<d>
where
    a<{ d <= 2 }>: c,
{
    type Err = ();
    fn from_str(f: &str) -> Result<Self, Self::Err> {
        unimplemented!()
    }
}

Meta

rustc --version --verbose:

rustc 1.85.0-nightly (0c4f3a45b 2024-11-29)
binary: rustc
commit-hash: 0c4f3a45b86c77b0a89ff06703aa6097af35d924
commit-date: 2024-11-29
host: x86_64-unknown-linux-gnu
release: 1.85.0-nightly
LLVM version: 19.1.4

Error output

warning: type `a` should have an upper camel case name
 --> code.rs:8:8
  |
8 | struct a<const b: bool>;
  |        ^ help: convert the identifier to upper camel case: `A`
  |
  = note: `#[warn(non_camel_case_types)]` on by default

warning: trait `c` should have an upper camel case name
  --> code.rs:10:7
   |
10 | trait c {}
   |       ^ help: convert the identifier to upper camel case (notice the capitalization): `C`

warning: type `e` should have an upper camel case name
  --> code.rs:21:8
   |
21 | struct e<const d: u32>;
   |        ^ help: convert the identifier to upper camel case: `E`

warning: unused variable: `f`
  --> code.rs:17:17
   |
17 |     fn from_str(f: &str) -> Result<Self, Self::Err> {
   |                 ^ help: if this is intentional, prefix it with an underscore: `_f`
   |
   = note: `#[warn(unused_variables)]` on by default

warning: unused variable: `f`
  --> code.rs:28:17
   |
28 |     fn from_str(f: &str) -> Result<Self, Self::Err> {
   |                 ^ help: if this is intentional, prefix it with an underscore: `_f`

warning: const parameter `b` should have an upper case name
 --> code.rs:8:16
  |
8 | struct a<const b: bool>;
  |                ^ help: convert the identifier to upper case: `B`
  |
  = note: `#[warn(non_upper_case_globals)]` on by default

warning: const parameter `d` should have an upper case name
  --> code.rs:12:12
   |
12 | impl<const d: u32> FromStr for e<d>
   |            ^ help: convert the identifier to upper case: `D`

warning: const parameter `d` should have an upper case name
  --> code.rs:21:16
   |
21 | struct e<const d: u32>;
   |                ^ help: convert the identifier to upper case: `D`

warning: const parameter `d` should have an upper case name
  --> code.rs:23:12
   |
23 | impl<const d: u32> FromStr for e<d>
   |            ^ help: convert the identifier to upper case: `D`

warning: 10 warnings emitted
Backtrace

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: Unevaluated `ty::Const` in MIR body
  |
  = note: delayed at /rustc/a2545fd6fc66b4323f555223a860c451885d1d2b/compiler/rustc_middle/src/mir/consts.rs:334:40
             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>::delayed_bug::<&str>
             4: <rustc_const_eval::interpret::eval_context::InterpCx<rustc_const_eval::const_eval::machine::CompileTimeMachine>>::push_stack_frame_raw
             5: rustc_const_eval::const_eval::eval_queries::eval_to_allocation_raw_provider
             6: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::eval_to_allocation_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 24]>>
             7: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_middle::ty::PseudoCanonicalInput<rustc_middle::mir::interpret::GlobalId>, rustc_middle::query::erase::Erased<[u8; 24]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
             8: rustc_query_impl::query_impl::eval_to_allocation_raw::get_query_non_incr::__rust_end_short_backtrace
             9: rustc_const_eval::const_eval::valtrees::eval_to_valtree
            10: <rustc_const_eval::provide::{closure#0} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_middle::ty::PseudoCanonicalInput<rustc_middle::mir::interpret::GlobalId>)>>::call_once
            11: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::eval_to_valtree::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 24]>>
            12: <rustc_query_impl::query_impl::eval_to_valtree::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_middle::ty::PseudoCanonicalInput<rustc_middle::mir::interpret::GlobalId>)>>::call_once
            13: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_middle::ty::PseudoCanonicalInput<rustc_middle::mir::interpret::GlobalId>, rustc_middle::query::erase::Erased<[u8; 24]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
            14: rustc_query_impl::query_impl::eval_to_valtree::get_query_non_incr::__rust_end_short_backtrace
            15: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::DefaultCache<rustc_middle::ty::PseudoCanonicalInput<rustc_middle::mir::interpret::GlobalId>, rustc_middle::query::erase::Erased<[u8; 24]>>>
            16: <rustc_middle::ty::context::TyCtxt>::const_eval_global_id_for_typeck
            17: <rustc_middle::ty::context::TyCtxt>::const_eval_resolve_for_typeck
            18: rustc_trait_selection::traits::try_evaluate_const
            19: <rustc_trait_selection::solve::delegate::SolverDelegate as rustc_next_trait_solver::delegate::SolverDelegate>::evaluate_const
            20: <rustc_type_ir::search_graph::SearchGraph<rustc_next_trait_solver::solve::search_graph::SearchGraphDelegate<rustc_trait_selection::solve::delegate::SolverDelegate>, rustc_middle::ty::context::TyCtxt>>::evaluate_goal_in_task::<&mut <rustc_next_trait_solver::solve::eval_ctxt::EvalCtxt<rustc_trait_selection::solve::delegate::SolverDelegate, rustc_middle::ty::context::TyCtxt>>::evaluate_canonical_goal::{closure#0}::{closure#0}::{closure#0}>
            21: <rustc_type_ir::search_graph::SearchGraph<rustc_next_trait_solver::solve::search_graph::SearchGraphDelegate<rustc_trait_selection::solve::delegate::SolverDelegate>, rustc_middle::ty::context::TyCtxt>>::with_new_goal::<<rustc_next_trait_solver::solve::eval_ctxt::EvalCtxt<rustc_trait_selection::solve::delegate::SolverDelegate, rustc_middle::ty::context::TyCtxt>>::evaluate_canonical_goal::{closure#0}::{closure#0}::{closure#0}>
            22: <rustc_next_trait_solver::solve::eval_ctxt::EvalCtxt<rustc_trait_selection::solve::delegate::SolverDelegate, rustc_middle::ty::context::TyCtxt>>::evaluate_goal_raw
            23: <rustc_next_trait_solver::solve::eval_ctxt::EvalCtxt<rustc_trait_selection::solve::delegate::SolverDelegate, rustc_middle::ty::context::TyCtxt>>::try_evaluate_added_goals
            24: <rustc_type_ir::search_graph::SearchGraph<rustc_next_trait_solver::solve::search_graph::SearchGraphDelegate<rustc_trait_selection::solve::delegate::SolverDelegate>, rustc_middle::ty::context::TyCtxt>>::evaluate_goal_in_task::<&mut <rustc_next_trait_solver::solve::eval_ctxt::EvalCtxt<rustc_trait_selection::solve::delegate::SolverDelegate, rustc_middle::ty::context::TyCtxt>>::evaluate_canonical_goal::{closure#0}::{closure#0}::{closure#0}>
            25: <rustc_type_ir::search_graph::SearchGraph<rustc_next_trait_solver::solve::search_graph::SearchGraphDelegate<rustc_trait_selection::solve::delegate::SolverDelegate>, rustc_middle::ty::context::TyCtxt>>::with_new_goal::<<rustc_next_trait_solver::solve::eval_ctxt::EvalCtxt<rustc_trait_selection::solve::delegate::SolverDelegate, rustc_middle::ty::context::TyCtxt>>::evaluate_canonical_goal::{closure#0}::{closure#0}::{closure#0}>
            26: <rustc_next_trait_solver::solve::eval_ctxt::EvalCtxt<rustc_trait_selection::solve::delegate::SolverDelegate, rustc_middle::ty::context::TyCtxt>>::evaluate_goal_raw
            27: <rustc_next_trait_solver::solve::eval_ctxt::EvalCtxt<rustc_trait_selection::solve::delegate::SolverDelegate, rustc_middle::ty::context::TyCtxt>>::try_evaluate_added_goals
            28: <rustc_next_trait_solver::solve::eval_ctxt::EvalCtxt<rustc_trait_selection::solve::delegate::SolverDelegate, rustc_middle::ty::context::TyCtxt>>::evaluate_added_goals_and_make_canonical_response::{closure#0}
            29: <rustc_type_ir::predicate::TraitPredicate<rustc_middle::ty::context::TyCtxt> as rustc_next_trait_solver::solve::assembly::GoalKind<rustc_trait_selection::solve::delegate::SolverDelegate, rustc_middle::ty::context::TyCtxt>>::probe_and_match_goal_against_assumption::<<rustc_type_ir::predicate::TraitPredicate<rustc_middle::ty::context::TyCtxt> as rustc_next_trait_solver::solve::assembly::GoalKind<rustc_trait_selection::solve::delegate::SolverDelegate, rustc_middle::ty::context::TyCtxt>>::probe_and_consider_implied_clause<[(rustc_type_ir::solve::GoalSource, rustc_type_ir::solve::Goal<rustc_middle::ty::context::TyCtxt, rustc_middle::ty::predicate::Predicate>); 0]>::{closure#0}>
            30: <rustc_next_trait_solver::solve::eval_ctxt::EvalCtxt<rustc_trait_selection::solve::delegate::SolverDelegate, rustc_middle::ty::context::TyCtxt>>::compute_trait_goal
            31: <rustc_type_ir::search_graph::SearchGraph<rustc_next_trait_solver::solve::search_graph::SearchGraphDelegate<rustc_trait_selection::solve::delegate::SolverDelegate>, rustc_middle::ty::context::TyCtxt>>::evaluate_goal_in_task::<&mut <rustc_next_trait_solver::solve::eval_ctxt::EvalCtxt<rustc_trait_selection::solve::delegate::SolverDelegate, rustc_middle::ty::context::TyCtxt>>::evaluate_canonical_goal::{closure#0}::{closure#0}::{closure#0}>
            32: <rustc_type_ir::search_graph::SearchGraph<rustc_next_trait_solver::solve::search_graph::SearchGraphDelegate<rustc_trait_selection::solve::delegate::SolverDelegate>, rustc_middle::ty::context::TyCtxt>>::with_new_goal::<<rustc_next_trait_solver::solve::eval_ctxt::EvalCtxt<rustc_trait_selection::solve::delegate::SolverDelegate, rustc_middle::ty::context::TyCtxt>>::evaluate_canonical_goal::{closure#0}::{closure#0}::{closure#0}>
            33: <rustc_next_trait_solver::solve::eval_ctxt::EvalCtxt<rustc_trait_selection::solve::delegate::SolverDelegate, rustc_middle::ty::context::TyCtxt>>::evaluate_goal_raw
            34: <rustc_next_trait_solver::solve::eval_ctxt::EvalCtxt<rustc_trait_selection::solve::delegate::SolverDelegate, rustc_middle::ty::context::TyCtxt>>::enter_root::<core::result::Result<(rustc_next_trait_solver::solve::HasChanged, rustc_type_ir::solve::Certainty), rustc_type_ir::solve::NoSolution>, <rustc_trait_selection::solve::delegate::SolverDelegate as rustc_next_trait_solver::solve::eval_ctxt::SolverDelegateEvalExt>::evaluate_root_goal::{closure#0}>
            35: <rustc_trait_selection::solve::fulfill::FulfillmentCtxt<rustc_infer::traits::engine::ScrubbedTraitError> as rustc_infer::traits::engine::TraitEngine<rustc_infer::traits::engine::ScrubbedTraitError>>::select_where_possible
            36: <rustc_trait_selection::solve::fulfill::FulfillmentCtxt<rustc_infer::traits::engine::ScrubbedTraitError> as rustc_infer::traits::engine::TraitEngine<rustc_infer::traits::engine::ScrubbedTraitError>>::select_all_or_error
            37: rustc_trait_selection::traits::coherence::impl_intersection_has_negative_obligation
            38: rustc_trait_selection::traits::coherence::overlap
            39: <rustc_middle::traits::specialization_graph::Children as rustc_trait_selection::traits::specialize::specialization_graph::ChildrenExt>::insert
            40: <rustc_middle::traits::specialization_graph::Graph as rustc_trait_selection::traits::specialize::specialization_graph::GraphExt>::insert
            41: rustc_trait_selection::traits::specialize::specialization_graph_provider
            42: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::specialization_graph_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
            43: 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>
            44: rustc_query_impl::query_impl::specialization_graph_of::get_query_non_incr::__rust_end_short_backtrace
            45: <rustc_middle::ty::trait_def::TraitDef>::ancestors
            46: rustc_hir_analysis::impl_wf_check::min_specialization::check_min_specialization
            47: rustc_hir_analysis::check::wfcheck::check_well_formed
            48: 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]>>
            49: 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>
            50: rustc_query_impl::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
            51: rustc_hir_analysis::check::wfcheck::check_mod_type_wf
            52: 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]>>
            53: 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>
            54: rustc_query_impl::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
            55: rustc_hir_analysis::check_crate
            56: rustc_interface::passes::run_required_analyses
            57: rustc_interface::passes::analysis
            58: 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]>>
            59: 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>
            60: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
            61: rustc_interface::interface::run_compiler::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
            62: 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<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
            63: <<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#1}, 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}
            64: std::sys::pal::unix::thread::Thread::new::thread_start
            65: <unknown>
            66: <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: please attach the file at `/home/matthias/vcs/github/CRED/rustc-ice-2024-11-29T16_25_14-3443642.txt` to your bug report

query stack during panic:
end of query stack

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.F-generic_const_exprs`#![feature(generic_const_exprs)]`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

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions