[ICE]: `no type for local variable`
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 45/100
Direzione di ricerca
Start with the reproducer in the issue and the referenced regression test, tests/ui/const-generics/defaults/const-param-default-body-param-env-ice.rs. Follow the ICE to compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs around line 166 and inspect the FnCtxt::local_ty call path in the backtrace. Done when the reproducer reports compiler diagnostics without panicking and a regression test covers the case.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Code
#![feature(move_expr)]
#![expect(incomplete_features)]
impl<const N: usize = { || [0; &move(X)] }, X> dyn PartialEq<X> {}
fn main() {}
A mutant of tests/ui/const-generics/defaults/const-param-default-body-param-env-ice.rs.
Meta
rustc --version --verbose:
rustc 1.101.0-nightly (c980177d8 2026-11-06)
binary: rustc
commit-hash: c980177d81d16f843a500905ac98c0cf3af1fd8d
commit-date: 2026-11-06
host: aarch64-apple-darwin
release: 1.101.0-nightly
LLVM version: 23.1.5
Error output
Command: rustc --edition 2024
error: generic parameters with a default must be trailing
--> asdf.rs:4:12
|
4 | impl<const N: usize = { || [0; &move(X)] }, X> dyn PartialEq<X> {}
| ^
error[E0128]: generic parameter defaults cannot reference parameters before they are declared
--> asdf.rs:4:38
|
4 | impl<const N: usize = { || [0; &move(X)] }, X> dyn PartialEq<X> {}
| ^ cannot reference `X` before it is declared
error: defaults for generic parameters are not allowed here
--> asdf.rs:4:6
|
4 | impl<const N: usize = { || [0; &move(X)] }, X> dyn PartialEq<X> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0207]: the const parameter `N` is not constrained by the impl trait, self type, or predicates
--> asdf.rs:4:6
|
4 | impl<const N: usize = { || [0; &move(X)] }, X> dyn PartialEq<X> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unconstrained const parameter
|
= note: expressions using a const parameter must map each value to a distinct output value
= note: proving the result of expressions other than the parameter are unique is not supported
error[E0116]: cannot define inherent `impl` for a type outside of the crate where the type is defined
--> asdf.rs:4:1
|
4 | impl<const N: usize = { || [0; &move(X)] }, X> dyn PartialEq<X> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl for type defined outside of crate
|
= help: consider defining a trait and implementing it for the type or using a newtype wrapper like `struct MyType(ExternalType);` and implement it
= note: for more details about the orphan rules, see <https://doc.rust-lang.org/reference/items/implementations.html?highlight=orphan#orphan-rules>
error: internal compiler error: /rustc-dev/c980177d81d16f843a500905ac98c0cf3af1fd8d/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs:166:13: no type for local variable HirId(DefId(0:3 ~ asdf[9b60]::{impl#0}).12) (pat `X`)
--> asdf.rs:4:33
|
4 | impl<const N: usize = { || [0; &move(X)] }, X> dyn PartialEq<X> {}
| ^^^^^^^
thread 'rustc' (7296436) panicked at /rustc-dev/c980177d81d16f843a500905ac98c0cf3af1fd8d/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs:166:13:
Box<dyn Any>
Backtrace
thread 'rustc' (7305383) panicked at /rustc-dev/c980177d81d16f843a500905ac98c0cf3af1fd8d/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs:166:13:
Box<dyn Any>
stack backtrace:
0: std::panicking::begin_panic::<rustc_span::macros::ExplicitBug>
1: rustc_span::macros::bug_impl
2: <rustc_hir_typeck::fn_ctxt::FnCtxt>::local_ty::{closure#0}
3: <rustc_hir_typeck::fn_ctxt::FnCtxt>::local_ty
4: <rustc_hir_typeck::fn_ctxt::FnCtxt>::instantiate_value_path
5: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_path
6: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
7: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_addr_of
8: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
9: rustc_hir_typeck::typeck_with_inspect::{closure#0}
10: rustc_hir_typeck::typeck_root
11: rustc_query_impl::execution::try_execute_query::<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::ErasedData<[u8; 8]>, rustc_middle::dep_graph::graph::DepNodeIndex>, false>
12: <rustc_middle::ty::context::TyCtxt>::typeck::<rustc_span::def_id::LocalDefId>
13: rustc_mir_build::thir::pattern::check_match::check_match
[... omitted 1 frame ...]
14: rustc_mir_build::builder::build_mir_inner_impl
15: rustc_mir_transform::mir_built
16: rustc_query_impl::execution::try_execute_query::<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::ErasedData<[u8; 8]>, rustc_middle::dep_graph::graph::DepNodeIndex>, false>
17: rustc_mir_transform::trivial_const::trivial_const_provider
[... omitted 1 frame ...]
18: rustc_const_eval::const_eval::eval_queries::eval_to_allocation_raw_provider
[... omitted 1 frame ...]
19: rustc_const_eval::const_eval::valtrees::eval_to_valtree
20: <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
[... omitted 1 frame ...]
21: <rustc_middle::ty::context::TyCtxt>::const_eval_global_id_for_typeck
22: <rustc_middle::ty::context::TyCtxt>::const_eval_resolve_for_typeck
23: <rustc_next_trait_solver::solve::eval_ctxt::EvalCtxt<rustc_trait_selection::solve::delegate::SolverDelegate, rustc_middle::ty::context::TyCtxt>>::evaluate_const
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
25: <rustc_next_trait_solver::solve::eval_ctxt::EvalCtxt<rustc_trait_selection::solve::delegate::SolverDelegate, rustc_middle::ty::context::TyCtxt>>::evaluate_in_search_graph
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>>::evaluate_goal_no_fast_paths
28: <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::GoalEvaluation<rustc_middle::ty::context::TyCtxt>, rustc_type_ir::solve::NoSolutionOrRerunNonErased>, <rustc_trait_selection::solve::delegate::SolverDelegate as rustc_next_trait_solver::solve::eval_ctxt::SolverDelegateEvalExt>::evaluate_root_goal::{closure#0}::{closure#0}>
29: <rustc_trait_selection::solve::delegate::SolverDelegate as rustc_next_trait_solver::solve::eval_ctxt::SolverDelegateEvalExt>::evaluate_root_goal
30: <rustc_next_trait_solver::normalize::NormalizationFolder<rustc_infer::infer::InferCtxt, rustc_middle::ty::context::TyCtxt, rustc_trait_selection::solve::normalize::normalize_with_universes<rustc_type_ir::binder::Binder<rustc_middle::ty::context::TyCtxt, rustc_type_ir::ty_kind::FnSig<rustc_middle::ty::context::TyCtxt>>>::{closure#0}>>::normalize_alias_term
31: <rustc_next_trait_solver::normalize::NormalizationFolder<rustc_infer::infer::InferCtxt, rustc_middle::ty::context::TyCtxt, rustc_trait_selection::solve::normalize::normalize_with_universes<rustc_type_ir::sty::consts::Const<rustc_middle::ty::context::TyCtxt>>::{closure#0}> as rustc_type_ir::fold::FallibleTypeFolder<rustc_middle::ty::context::TyCtxt>>::try_fold_const::{closure#0}
32: rustc_trait_selection::solve::normalize::normalize_with_universes::<rustc_type_ir::sty::consts::Const<rustc_middle::ty::context::TyCtxt>>
33: <rustc_hir_typeck::fn_ctxt::FnCtxt>::normalize::<rustc_type_ir::sty::consts::Const<rustc_middle::ty::context::TyCtxt>>
34: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_repeat
35: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
36: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_return_or_body_tail
37: rustc_hir_typeck::check::check_fn
38: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_closure
39: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
40: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_block
41: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
42: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_block
43: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
44: rustc_hir_typeck::typeck_with_inspect::{closure#0}
45: rustc_hir_typeck::typeck_root
46: rustc_query_impl::execution::try_execute_query::<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::ErasedData<[u8; 8]>, rustc_middle::dep_graph::graph::DepNodeIndex>, false>
47: <rustc_middle::ty::context::TyCtxt>::typeck::<rustc_span::def_id::LocalDefId>
48: rustc_hir_typeck::used_trait_imports
49: rustc_query_impl::execution::try_execute_query::<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::ErasedData<[u8; 8]>, rustc_middle::dep_graph::graph::DepNodeIndex>, false>
50: rustc_hir_analysis::check_unused::check_unused_traits
51: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::SingleCache<rustc_middle::query::erase::ErasedData<[u8; 0]>>, false>
52: rustc_hir_analysis::check_crate
53: rustc_interface::passes::analysis
54: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::SingleCache<rustc_middle::query::erase::ErasedData<[u8; 0]>>, false>
55: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::compiler_entrypoint::{closure#0}::{closure#1}>
56: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::compiler_entrypoint::{closure#0}>::{closure#2}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
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 `/Users/jb/workspace/tmp/rustc-ice-2026-11-07T09_19_55-42368.txt` to your bug report
note: rustc 1.101.0-nightly (c980177d8 2026-11-06) running on aarch64-apple-darwin
query stack during panic:
#0 [typeck_root] type-checking `<impl at asdf.rs:4:1: 4:64>::{constant#0}::{closure#0}::{constant#0}`
#1 [check_match] match-checking `<impl at asdf.rs:4:1: 4:64>::{constant#0}::{closure#0}::{constant#0}`
#2 [mir_built] building MIR for `<impl at asdf.rs:4:1: 4:64>::{constant#0}::{closure#0}::{constant#0}`
#3 [trivial_const] checking if `<impl at asdf.rs:4:1: 4:64>::{constant#0}::{closure#0}::{constant#0}` is a trivial const
#4 [eval_to_allocation_raw] const-evaluating + checking `<impl at asdf.rs:4:1: 4:64>::{constant#0}::{closure#0}::{constant#0}`
#5 [eval_to_valtree] evaluating type-level constant
#6 [typeck_root] type-checking `<impl at asdf.rs:4:1: 4:64>::{constant#0}`
#7 [used_trait_imports] finding used_trait_imports `<impl at asdf.rs:4:1: 4:64>::{constant#0}`
#8 [check_unused_traits] checking unused trait imports in crate
#9 [analysis] running analysis passes on crate `asdf`
end of query stack
error: aborting due to 6 previous errors
Notes
- ICE location:
compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rsLine-166.
- Might be related to #156509
@rustbot label +F-move_expr
- Lingua principale
- Rust
- Stelle
- 121k
- Fork
- 17.3k
- Merge medio
- 2g 16h
- PR unite (30g)
- 529
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di rust-lang/rust
-
Windows `File::set_permissions` silently does nothing when clearing `readonly` leaves `FileAttributes == 0`Forse già presa @ChrisDenton l’ha presa 1 giorno fa. ApertaA-filesystem C-bug O-windows T-libs
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
A-run-make relnotes relnotes-needs-review relnotes-tracking-issue T-lang T-libs
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
relnotes relnotes-needs-review relnotes-tracking-issue T-compiler T-libs
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
A-LLVM O-Arm O-UEFI O-x86_64 relnotes relnotes-needs-review relnotes-tracking-issue T-compiler
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
rust-lang/rust#165504 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
relnotes relnotes-tracking-issue T-libs
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di rust-lang/rust
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 94/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 2 giorni
-
ci enhancement need-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
I maintainer di solito rispondono entro 1 giorno
-
enhancement good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
area:ui
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
openfootmanager/openfootmanager#1365 ·
I maintainer di solito rispondono entro 1 giorno