-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Open
rynewang/rust
#4Labels
A-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️L-rust_2021_incompatible_closure_capturesLint: rust_2021_incompatible_closure_capturesLint: rust_2021_incompatible_closure_capturesS-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.
Description
I tried this code:
#![deny(rust_2021_incompatible_closure_captures)]
struct Foo();
struct S;
impl Drop for S {
fn drop() {}
}
struct T(S, S);
struct U(T, <Foo as NewTrait>::Assoc);
fn test_precise_analysis_long_path() {
let u = U(T(S, S), );
c = || {
let _x = u.0.0;
_x = u.0.1;
_x = u.1.1;
};
}
trait NewTrait {
type Assoc;
}
impl NewTrait for Foo {
type Assoc = T;
}
fn main(){}| Release channel | Result |
|---|---|
| Current Stable | ICE |
| Current Nightly | ICE |
Meta
rustc --version --verbose:
rustc 1.95.0-nightly (db3e99bba 2026-02-04)
binary: rustc
commit-hash: db3e99bbab28c6ca778b13222becdea54533d908
commit-date: 2026-02-04
host: x86_64-unknown-linux-gnu
release: 1.95.0-nightly
LLVM version: 22.1.0
Backtrace
error[E0425]: cannot find value `c` in this scope
--> bug.rs:11:6
|
3 | struct S;
| --------- similarly named unit struct `S` defined here
...
11 | c = || {
| ^
|
help: a unit struct with a similar name exists
|
11 - c = || {
11 + S = || {
|
help: you might have meant to introduce a new binding
|
11 | let c = || {
| +++
error[E0186]: method `drop` has a `&mut self` declaration in the trait, but not in the impl
--> bug.rs:5:5
|
5 | fn drop() {}
| ^^^^^^^^^ expected `&mut self` in impl
|
= note: `drop` from trait: `fn(&mut Self)`
error[E0061]: this struct takes 2 arguments but 1 argument was supplied
--> bug.rs:10:13
|
10 | let u = U(T(S, S), );
| ^----------- argument #2 of type `T` is missing
|
note: tuple struct defined here
--> bug.rs:8:8
|
8 | struct U(T, <Foo as NewTrait>::Assoc);
| ^
help: provide the argument
|
10 | let u = U(T(S, S), /* T */);
| +++++++
thread 'rustc' (2028239) panicked at /rustc-dev/db3e99bbab28c6ca778b13222becdea54533d908/compiler/rustc_hir_typeck/src/upvar.rs:1685:18:
internal error: entered unreachable code
stack backtrace:
0: 0x7fd12377438b - <<std[5b6453b30570829a]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[94716341d7c778ad]::fmt::Display>::fmt
1: 0x7fd123d3fd08 - core[94716341d7c778ad]::fmt::write
2: 0x7fd12378b676 - <std[5b6453b30570829a]::sys::stdio::unix::Stderr as std[5b6453b30570829a]::io::Write>::write_fmt
3: 0x7fd12374a388 - std[5b6453b30570829a]::panicking::default_hook::{closure#0}
4: 0x7fd123767763 - std[5b6453b30570829a]::panicking::default_hook
5: 0x7fd1227570ad - std[5b6453b30570829a]::panicking::update_hook::<alloc[4b4e8be454901a39]::boxed::Box<rustc_driver_impl[70175e87f37eb535]::install_ice_hook::{closure#1}>>::{closure#0}
6: 0x7fd123767a42 - std[5b6453b30570829a]::panicking::panic_with_hook
7: 0x7fd12374a47a - std[5b6453b30570829a]::panicking::panic_handler::{closure#0}
8: 0x7fd12373e9b9 - std[5b6453b30570829a]::sys::backtrace::__rust_end_short_backtrace::<std[5b6453b30570829a]::panicking::panic_handler::{closure#0}, !>
9: 0x7fd12374bead - __rustc[c8a7c5c4b6a2cdce]::rust_begin_unwind
10: 0x7fd1209b010c - core[94716341d7c778ad]::panicking::panic_fmt
11: 0x7fd11ff08a82 - core[94716341d7c778ad]::panicking::panic
12: 0x7fd122a5a3e9 - <rustc_hir_typeck[5789e0bb21a211b9]::fn_ctxt::FnCtxt>::has_significant_drop_outside_of_captures
13: 0x7fd122a5a2ab - <rustc_hir_typeck[5789e0bb21a211b9]::fn_ctxt::FnCtxt>::has_significant_drop_outside_of_captures
14: 0x7fd122a5698e - <rustc_hir_typeck[5789e0bb21a211b9]::fn_ctxt::FnCtxt>::perform_2229_migration_analysis
15: 0x7fd12492aaa4 - <rustc_hir_typeck[5789e0bb21a211b9]::fn_ctxt::FnCtxt>::analyze_closure
16: 0x7fd12402b012 - <rustc_hir_typeck[5789e0bb21a211b9]::upvar::InferBorrowKindVisitor as rustc_hir[a9e131cadb307f85]::intravisit::Visitor>::visit_expr
17: 0x7fd12402b327 - <rustc_hir_typeck[5789e0bb21a211b9]::upvar::InferBorrowKindVisitor as rustc_hir[a9e131cadb307f85]::intravisit::Visitor>::visit_expr
18: 0x7fd12402ae62 - <rustc_hir_typeck[5789e0bb21a211b9]::upvar::InferBorrowKindVisitor as rustc_hir[a9e131cadb307f85]::intravisit::Visitor>::visit_block
19: 0x7fd124ae14d7 - rustc_hir_typeck[5789e0bb21a211b9]::typeck_with_inspect::{closure#0}
20: 0x7fd124adf8b0 - rustc_query_impl[5ce950bad06ac490]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5ce950bad06ac490]::query_impl::typeck::make_query_vtable::{closure#1}::{closure#0}, rustc_middle[945890ed1064710a]::query::erase::ErasedData<[u8; 8usize]>>
21: 0x7fd1242a2d36 - rustc_query_system[cb5650c2b33f578c]::query::plumbing::try_execute_query::<rustc_query_impl[5ce950bad06ac490]::SemiDynamicQueryDispatcher<rustc_data_structures[1e615b1a93145c8c]::vec_cache::VecCache<rustc_span[64ec0f452ae8c55c]::def_id::LocalDefId, rustc_middle[945890ed1064710a]::query::erase::ErasedData<[u8; 8usize]>, rustc_query_system[cb5650c2b33f578c]::dep_graph::graph::DepNodeIndex>, {rustc_query_impl[5ce950bad06ac490]::QueryFlags { is_anon: false, is_depth_limit: false, is_feedable: false }}>, false>
22: 0x7fd1242a2909 - rustc_query_impl[5ce950bad06ac490]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
23: 0x7fd1242a94cc - <rustc_middle[945890ed1064710a]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis[e217d8de9cc0e6b4]::check_crate::{closure#2}>::{closure#0}
24: 0x7fd1242a8ee6 - rustc_hir_analysis[e217d8de9cc0e6b4]::check_crate
25: 0x7fd12429ca1b - rustc_interface[391380b3dd77dca3]::passes::analysis
26: 0x7fd12429c66b - rustc_query_impl[5ce950bad06ac490]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5ce950bad06ac490]::query_impl::analysis::make_query_vtable::{closure#1}::{closure#0}, rustc_middle[945890ed1064710a]::query::erase::ErasedData<[u8; 0usize]>>
27: 0x7fd124ebb5e6 - rustc_query_system[cb5650c2b33f578c]::query::plumbing::try_execute_query::<rustc_query_impl[5ce950bad06ac490]::SemiDynamicQueryDispatcher<rustc_query_system[cb5650c2b33f578c]::query::caches::SingleCache<rustc_middle[945890ed1064710a]::query::erase::ErasedData<[u8; 0usize]>>, {rustc_query_impl[5ce950bad06ac490]::QueryFlags { is_anon: false, is_depth_limit: false, is_feedable: false }}>, false>
28: 0x7fd124ebb348 - rustc_query_impl[5ce950bad06ac490]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
29: 0x7fd12502bda7 - <rustc_interface[391380b3dd77dca3]::passes::create_and_enter_global_ctxt<core[94716341d7c778ad]::option::Option<rustc_interface[391380b3dd77dca3]::queries::Linker>, rustc_driver_impl[70175e87f37eb535]::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core[94716341d7c778ad]::ops::function::FnOnce<(&rustc_session[79dda06290ce4e69]::session::Session, rustc_middle[945890ed1064710a]::ty::context::CurrentGcx, alloc[4b4e8be454901a39]::sync::Arc<rustc_data_structures[1e615b1a93145c8c]::jobserver::Proxy>, &std[5b6453b30570829a]::sync::once_lock::OnceLock<rustc_middle[945890ed1064710a]::ty::context::GlobalCtxt>, &rustc_data_structures[1e615b1a93145c8c]::sync::worker_local::WorkerLocal<rustc_middle[945890ed1064710a]::arena::Arena>, &rustc_data_structures[1e615b1a93145c8c]::sync::worker_local::WorkerLocal<rustc_hir[a9e131cadb307f85]::Arena>, rustc_driver_impl[70175e87f37eb535]::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
30: 0x7fd124edd0be - rustc_interface[391380b3dd77dca3]::interface::run_compiler::<(), rustc_driver_impl[70175e87f37eb535]::run_compiler::{closure#0}>::{closure#1}
31: 0x7fd124f1f6fe - std[5b6453b30570829a]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[391380b3dd77dca3]::util::run_in_thread_with_globals<rustc_interface[391380b3dd77dca3]::util::run_in_thread_pool_with_globals<rustc_interface[391380b3dd77dca3]::interface::run_compiler<(), rustc_driver_impl[70175e87f37eb535]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
32: 0x7fd124f1fc20 - <std[5b6453b30570829a]::thread::lifecycle::spawn_unchecked<rustc_interface[391380b3dd77dca3]::util::run_in_thread_with_globals<rustc_interface[391380b3dd77dca3]::util::run_in_thread_pool_with_globals<rustc_interface[391380b3dd77dca3]::interface::run_compiler<(), rustc_driver_impl[70175e87f37eb535]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[94716341d7c778ad]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
33: 0x7fd124f20aac - <std[5b6453b30570829a]::sys::thread::unix::Thread>::new::thread_start
34: 0x7fd11ead8609 - start_thread
at /build/glibc-B3wQXB/glibc-2.31/nptl/pthread_create.c:477:8
35: 0x7fd11e9fd353 - clone
at /build/glibc-B3wQXB/glibc-2.31/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:95:0
36: 0x0 - <unknown>
error: the compiler unexpectedly panicked. this is a bug.
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/laix/Study/Traitor/trait-fuzzer/test/rustc-ice-2026-02-06T04_03_16-2028141.txt` to your bug report
note: rustc 1.95.0-nightly (db3e99bba 2026-02-04) running on x86_64-unknown-linux-gnu
query stack during panic:
#0 [typeck] type-checking `test_precise_analysis_long_path`
#1 [analysis] running analysis passes on crate `bug`
end of query stack
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0061, E0186, E0425.
For more information about an error, try `rustc --explain E0061`.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️L-rust_2021_incompatible_closure_capturesLint: rust_2021_incompatible_closure_capturesLint: rust_2021_incompatible_closure_capturesS-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.