-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Open
Labels
A-parallel-compilerArea: parallel compilerArea: parallel compilerC-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) ❄️T-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.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.This issue may need triage. Remove it if it has been sufficiently triaged.
Description
reduced
#![feature(unboxed_closures)]
fn iso<A>(a: Fn) -> Option<_>
where
dyn Fn(A) -> (): Sized,
{
Box::new(iso_un_option)
}
fn iso_un_option<B>() -> Box<_> {
iso(())
}
fn main() {
iso(())
}original:
pub fn iso<A, B, B, F2>(a: Fn, b: F2) -> (Option<_>, Box<dyn Fn() -> A>)
where
F1: (Fn(A) -> B) + 'static,
F2: (Fn(A) -> B) + 'static,
{
(Box::new(iso_un_option), o_a::new(b))
}
pub fn iso_un_option<A, B>() -> (Box<_>, Box<dyn Fn(B) -> Option>) {
let left = |o_a: Option<_>| o_a.unwrap();
let _: &mut S = unsafe {
let mut s = S;
let x = &raw const s;
let _: &S = unsafe { *x };
//~^ ERROR mismatched types
//~| HELP consider borrowing here
let x = &raw mut s;
let _: &mut S = unsafe { *x };
//~^ ERROR mismatched types
//~| HELP consider mutably borrowing here
};
iso(left, right)
//~^ ERROR overflow
}
fn main() {}Version information
rustc 1.96.0-nightly (ec818fda3 2026-03-02)
binary: rustc
commit-hash: ec818fda361ca216eb186f5cf45131bd9c776bb4
commit-date: 2026-03-02
host: x86_64-unknown-linux-gnu
release: 1.96.0-nightly
LLVM version: 22.1.0
Possibly related line of code:
rust/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
Lines 1658 to 1668 in ec818fd
| }; | |
| if let Some((params_with_generics, _)) = self.get_hir_param_info(def_id, is_method) { | |
| debug_assert_eq!(params_with_generics.len(), matched_inputs.len()); | |
| for (idx, (generic_param, _)) in params_with_generics.iter_enumerated() { | |
| if matched_inputs[idx].is_none() { | |
| continue; | |
| } | |
| let Some((_, matched_arg_span)) = provided_arg_tys.get(idx.to_provided_idx()) | |
| else { |
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zthreads=20
triggers around one in 3 times?
Program output
warning: trait objects without an explicit `dyn` are deprecated
--> code.rs:2:14
|
2 | fn iso<A>(a: Fn) -> Option<_>
| ^^
|
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2021/warnings-promoted-to-error.html>
= note: `#[warn(bare_trait_objects)]` (part of `#[warn(rust_2021_compatibility)]`) on by default
help: if this is a dyn-compatible trait, use `dyn`
|
2 | fn iso<A>(a: dyn Fn) -> Option<_>
| +++
error[E0107]: missing generics for trait `Fn`
--> code.rs:2:14
|
2 | fn iso<A>(a: Fn) -> Option<_>
| ^^ expected 1 generic argument
|
note: trait defined here, with 1 generic parameter: `Args`
--> /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:76:17
|
76 | pub const trait Fn<Args: Tuple>: [const] FnMut<Args> {
| ^^ ----
help: add missing generic argument
|
2 | fn iso<A>(a: Fn<Args>) -> Option<_>
| ++++++
error[E0277]: the size for values of type `(dyn Fn(_) + 'static)` cannot be known at compilation time
--> code.rs:9:5
|
9 | iso(())
| ^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `(dyn Fn(_) + 'static)`
note: required by a bound in `iso`
--> code.rs:4:22
|
2 | fn iso<A>(a: Fn) -> Option<_>
| --- required by a bound in this function
3 | where
4 | dyn Fn(A) -> (): Sized,
| ^^^^^ required by this bound in `iso`
thread 'rustc' (762204) panicked at /rustc-dev/ec818fda361ca216eb186f5cf45131bd9c776bb4/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs:1663:34:
index out of bounds: the len is 0 but the index is 0
stack backtrace:
0: 0x7fb4471532bb - <<std[eb110dcb1455ebbb]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[89784ade3600f19b]::fmt::Display>::fmt
1: 0x7fb4478202c8 - core[89784ade3600f19b]::fmt::write
2: 0x7fb44716a2c6 - <std[eb110dcb1455ebbb]::sys::stdio::unix::Stderr as std[eb110dcb1455ebbb]::io::Write>::write_fmt
3: 0x7fb447129398 - std[eb110dcb1455ebbb]::panicking::default_hook::{closure#0}
4: 0x7fb447146723 - std[eb110dcb1455ebbb]::panicking::default_hook
5: 0x7fb44613125c - std[eb110dcb1455ebbb]::panicking::update_hook::<alloc[29fb76bce34b892e]::boxed::Box<rustc_driver_impl[fb3bb71bcb51a2dc]::install_ice_hook::{closure#1}>>::{closure#0}
6: 0x7fb447146a02 - std[eb110dcb1455ebbb]::panicking::panic_with_hook
7: 0x7fb447129458 - std[eb110dcb1455ebbb]::panicking::panic_handler::{closure#0}
8: 0x7fb447120189 - std[eb110dcb1455ebbb]::sys::backtrace::__rust_end_short_backtrace::<std[eb110dcb1455ebbb]::panicking::panic_handler::{closure#0}, !>
9: 0x7fb44712aebd - __rustc[b5c62ea7d35cbfc4]::rust_begin_unwind
10: 0x7fb443cce2fc - core[89784ade3600f19b]::panicking::panic_fmt
11: 0x7fb444049b32 - core[89784ade3600f19b]::panicking::panic_bounds_check
12: 0x7fb446422f5a - <rustc_hir_typeck[8a5d87c05ae1a325]::fn_ctxt::FnCtxt>::label_generic_mismatches
13: 0x7fb44641e85a - <rustc_hir_typeck[8a5d87c05ae1a325]::fn_ctxt::FnCtxt>::report_arg_errors
14: 0x7fb447bcf6ad - <rustc_hir_typeck[8a5d87c05ae1a325]::fn_ctxt::FnCtxt>::check_expr_call
15: 0x7fb447bae350 - <rustc_hir_typeck[8a5d87c05ae1a325]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
16: 0x7fb447ba8530 - <rustc_hir_typeck[8a5d87c05ae1a325]::fn_ctxt::FnCtxt>::check_expr_block
17: 0x7fb447bae2d7 - <rustc_hir_typeck[8a5d87c05ae1a325]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
18: 0x7fb447b7cfca - rustc_hir_typeck[8a5d87c05ae1a325]::check::check_fn
19: 0x7fb44860eab2 - rustc_hir_typeck[8a5d87c05ae1a325]::typeck_with_inspect::{closure#0}
20: 0x7fb44860d532 - rustc_query_impl[52bc1cae8cb1f0f9]::query_impl::typeck::invoke_provider_fn::__rust_begin_short_backtrace
21: 0x7fb44797858a - rustc_query_impl[52bc1cae8cb1f0f9]::execution::try_execute_query::<rustc_data_structures[d0096a8ffe6a0514]::vec_cache::VecCache<rustc_span[566afffa9b4ced27]::def_id::LocalDefId, rustc_middle[35e622c0033dd948]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[35e622c0033dd948]::dep_graph::graph::DepNodeIndex>, false>
22: 0x7fb447977f03 - rustc_query_impl[52bc1cae8cb1f0f9]::query_impl::typeck::execute_query_non_incr::__rust_end_short_backtrace
23: 0x7fb447f2dfc9 - rustc_hir_analysis[eb8396faa04d2a8f]::collect::lower_fn_sig_recovering_infer_ret_ty
24: 0x7fb447abc157 - rustc_hir_analysis[eb8396faa04d2a8f]::collect::fn_sig
25: 0x7fb447abb826 - rustc_query_impl[52bc1cae8cb1f0f9]::query_impl::fn_sig::invoke_provider_fn::__rust_begin_short_backtrace
26: 0x7fb447abff4e - rustc_query_impl[52bc1cae8cb1f0f9]::execution::try_execute_query::<rustc_middle[35e622c0033dd948]::query::caches::DefIdCache<rustc_middle[35e622c0033dd948]::query::erase::ErasedData<[u8; 24usize]>>, false>
27: 0x7fb447abf425 - rustc_query_impl[52bc1cae8cb1f0f9]::query_impl::fn_sig::execute_query_non_incr::__rust_end_short_backtrace
28: 0x7fb44810bb18 - rustc_hir_analysis[eb8396faa04d2a8f]::check::check::check_item_type
29: 0x7fb448106ba6 - rustc_hir_analysis[eb8396faa04d2a8f]::check::wfcheck::check_well_formed
30: 0x7fb448106b87 - rustc_query_impl[52bc1cae8cb1f0f9]::query_impl::check_well_formed::invoke_provider_fn::__rust_begin_short_backtrace
31: 0x7fb448106119 - rustc_query_impl[52bc1cae8cb1f0f9]::execution::try_execute_query::<rustc_data_structures[d0096a8ffe6a0514]::vec_cache::VecCache<rustc_span[566afffa9b4ced27]::def_id::LocalDefId, rustc_middle[35e622c0033dd948]::query::erase::ErasedData<[u8; 1usize]>, rustc_middle[35e622c0033dd948]::dep_graph::graph::DepNodeIndex>, false>
32: 0x7fb448105e7b - rustc_query_impl[52bc1cae8cb1f0f9]::query_impl::check_well_formed::execute_query_non_incr::__rust_end_short_backtrace
33: 0x7fb44629619a - <rustc_middle[35e622c0033dd948]::hir::ModuleItems>::par_opaques::<rustc_hir_analysis[eb8396faa04d2a8f]::check::wfcheck::check_type_wf::{closure#5}>::{closure#0}
34: 0x7fb44632835b - <rustc_thread_pool[6e6cbbf42ebd39ad]::job::HeapJob<<rustc_thread_pool[6e6cbbf42ebd39ad]::scope::Scope>::spawn<rustc_data_structures[d0096a8ffe6a0514]::sync::parallel::par_slice<&rustc_hir[386fa4b273d4e920]::hir::ImplItemId, rustc_data_structures[d0096a8ffe6a0514]::sync::parallel::try_par_for_each_in<&[rustc_hir[386fa4b273d4e920]::hir::ImplItemId], rustc_span[566afffa9b4ced27]::ErrorGuaranteed, <rustc_middle[35e622c0033dd948]::hir::ModuleItems>::par_impl_items<rustc_hir_analysis[eb8396faa04d2a8f]::check::wfcheck::check_type_wf::{closure#1}>::{closure#0}>::{closure#0}::{closure#0}>::{closure#0}::{closure#0}>::{closure#0}> as rustc_thread_pool[6e6cbbf42ebd39ad]::job::Job>::execute
35: 0x7fb446e484bf - <rustc_thread_pool[6e6cbbf42ebd39ad]::registry::WorkerThread>::wait_or_steal_until_cold
36: 0x7fb446e46f02 - <rustc_thread_pool[6e6cbbf42ebd39ad]::registry::ThreadBuilder>::run
37: 0x7fb446129d1c - std[eb110dcb1455ebbb]::sys::backtrace::__rust_begin_short_backtrace::<<rustc_thread_pool[6e6cbbf42ebd39ad]::ThreadPoolBuilder>::build_scoped<rustc_interface[e910a3c7e0b41bdb]::util::run_in_thread_pool_with_globals<rustc_interface[e910a3c7e0b41bdb]::interface::run_compiler<(), rustc_driver_impl[fb3bb71bcb51a2dc]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#5}::{closure#0}::{closure#0}, rustc_interface[e910a3c7e0b41bdb]::util::run_in_thread_pool_with_globals<rustc_interface[e910a3c7e0b41bdb]::interface::run_compiler<(), rustc_driver_impl[fb3bb71bcb51a2dc]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#5}::{closure#0}::{closure#1}, ()>::{closure#0}::{closure#0}::{closure#0}, ()>
38: 0x7fb446133e23 - <std[eb110dcb1455ebbb]::thread::lifecycle::spawn_unchecked<<rustc_thread_pool[6e6cbbf42ebd39ad]::ThreadPoolBuilder>::build_scoped<rustc_interface[e910a3c7e0b41bdb]::util::run_in_thread_pool_with_globals<rustc_interface[e910a3c7e0b41bdb]::interface::run_compiler<(), rustc_driver_impl[fb3bb71bcb51a2dc]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#5}::{closure#0}::{closure#0}, rustc_interface[e910a3c7e0b41bdb]::util::run_in_thread_pool_with_globals<rustc_interface[e910a3c7e0b41bdb]::interface::run_compiler<(), rustc_driver_impl[fb3bb71bcb51a2dc]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#5}::{closure#0}::{closure#1}, ()>::{closure#0}::{closure#0}::{closure#0}, ()>::{closure#1} as core[89784ade3600f19b]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
39: 0x7fb448a0e9ac - <std[eb110dcb1455ebbb]::sys::thread::unix::Thread>::new::thread_start
40: 0x7fb4424a598b - <unknown>
41: 0x7fb442529a0c - <unknown>
42: 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/matthias/vcs/github/CRED/rustc-ice-2026-03-03T21_14_41-762183.txt` to your bug report
note: rustc 1.96.0-nightly (ec818fda3 2026-03-02) running on x86_64-unknown-linux-gnu
note: compiler flags: -Z threads=20
query stack during panic:
#0 [typeck] type-checking `iso_un_option`
#1 [fn_sig] computing function signature of `iso_un_option`
#2 [check_well_formed] checking that `iso_un_option` is well-formed
#3 [check_type_wf] checking that types are well-formed
#4 [analysis] running analysis passes on crate `code`
end of query stack
error: aborting due to 2 previous errors; 1 warning emitted
Some errors have detailed explanations: E0107, E0277.
For more information about an error, try `rustc --explain E0107`.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-parallel-compilerArea: parallel compilerArea: parallel compilerC-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) ❄️T-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.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.This issue may need triage. Remove it if it has been sufficiently triaged.