rust-lang / rust-lang/rust

Encountered anon const with inference variable args but no error reported

Open
#140,701 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug I-ICE S-needs-info S-needs-repro T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Backtrace

            0: std::backtrace::Backtrace::create
             1: <rustc_errors::DiagCtxtInner>::emit_diagnostic
             2: <rustc_errors::DiagCtxtHandle>::emit_diagnostic
             3: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
             4: <rustc_errors::DiagCtxtHandle>::delayed_bug::<&str>
             5: rustc_trait_selection::traits::try_evaluate_const
             6: <rustc_trait_selection::traits::normalize::AssocTypeNormalizer as rustc_type_ir::fold::TypeFolder<rustc_middle::ty::context::TyCtxt>>::fold_const
             7: <&rustc_middle::ty::list::RawList<(), rustc_middle::ty::generic_args::GenericArg> as rustc_type_ir::fold::TypeFoldable<rustc_middle::ty::context::TyCtxt>>::try_fold_with::<rustc_trait_selection::traits::normalize::AssocTypeNormalizer>
             8: <rustc_middle::ty::Ty as rustc_type_ir::fold::TypeSuperFoldable<rustc_middle::ty::context::TyCtxt>>::try_super_fold_with::<rustc_trait_selection::traits::normalize::AssocTypeNormalizer>
             9: <rustc_infer::infer::at::At as rustc_trait_selection::traits::normalize::NormalizeExt>::normalize::<rustc_middle::ty::Ty>
            10: <rustc_hir_typeck::fn_ctxt::FnCtxt>::normalize::<rustc_middle::ty::Ty>
            11: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_struct_fields
            12: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_kind
            13: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
            14: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_decl
            15: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_block
            16: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
            17: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_return_or_body_tail
            18: rustc_hir_typeck::check::check_fn
            19: rustc_hir_typeck::typeck_with_inspect::{closure#0}
            20: rustc_hir_typeck::typeck
            21: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
            22: 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; 8]>, rustc_query_system::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
            23: rustc_query_impl::query_impl::typeck::get_query_incr::__rust_end_short_backtrace
            24: <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis::check_crate::{closure#3}>::{closure#0}
            25: rustc_hir_analysis::check_crate
            26: rustc_interface::passes::run_required_analyses
            27: rustc_interface::passes::analysis
            28: 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]>>
            29: 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, true>
            30: rustc_query_impl::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
            31: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>
            32: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
            33: 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}, ()>
            34: <<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}
            35: std::sys::pal::unix::thread::Thread::new::thread_start
            36: __pthread_cond_wait

rustc-ice-2025-05-06T12_15_48-6382.txt

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the attached backtrace, especially rustc_trait_selection::traits::try_evaluate_const and rustc_hir_typeck::fn_ctxt::FnCtxt::check_expr_struct_fields. Find or reproduce the anonymous-const case with inference-variable arguments, then determine why no error is reported and verify that the case produces the expected diagnostic.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.