Closed
Description
rustc-ice-2025-02-12T19_02_34-223082.txt
Code
futures = "0.3.31"
#![feature(trait_alias)]
use futures::channel::mpsc::{channel, Sender};
use futures::future::BoxFuture;
use futures::StreamExt;
use std::future::Future;
use std::marker::PhantomData;
pub trait Spawn: Send {
fn spawn(future: impl Future<Output = ()> + Send + 'static);
}
pub trait FnOnceTrait<'a, T: 'a, U> = FnOnce(&'a mut T) -> BoxFuture<'a, U> + Send + 'static;
pub type BoxFn<T> = Box<dyn for<'a> FnOnceTrait<'a, T, ()>>;
pub struct Critical<S, T>(Sender<BoxFn<T>>, PhantomData<S>);
impl<S: Spawn, T: Send + 'static> Critical<S, T> {
pub fn new(mut value: T) -> Self {
let (sink, mut stream) = channel::<BoxFn<T>>(1024);
S::spawn(async move {
while let Some(f) = stream.next().await {
f(&mut value).await;
}
});
Self(sink, PhantomData)
}
}
Meta
rustc --version --verbose
:
rustc 1.86.0-nightly (92bedea1c 2025-02-11)
binary: rustc
commit-hash: 92bedea1c51e3a969d60972be854506ffd8c5cb6
commit-date: 2025-02-11
host: x86_64-unknown-linux-gnu
release: 1.86.0-nightly
LLVM version: 19.1.7
Error output
Compiling error_test v0.1.0 (/home/lenny/Projects/error_test)
thread 'rustc' panicked at compiler/rustc_infer/src/infer/mod.rs:1204:26:
index out of bounds: the len is 0 but the index is 0
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
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/lenny/Projects/error_test/rustc-ice-2025-02-12T19_00_29-220361.txt` to your bug report
note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [evaluate_obligation] evaluating trait selection obligation `alloc::boxed::Box<(dyn for<'a> core::ops::function::FnOnce(&'a mut T) -> core::pin::Pin<alloc::boxed::Box<(dyn core::future:
:future::Future<Output = ()> + core::marker::Send + 'a)>> + core::marker::Send + 'b)>: core::ops::function::FnOnce<(^1_1,)>`
#1 [typeck] type-checking `<impl at src/main.rs:18:1: 18:49>::new`
... and 1 other queries... use `env RUST_BACKTRACE=1` to see the full query stack
error: could not compile `error_test` (bin "error_test")
Caused by:
process didn't exit successfully: `/home/lenny/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rustc --crate-name error_test --edition=2021 src/main.rs --error-format=json --json
=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=188 --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 --check-cfg 'cfg(docsrs,test)' --check-c
fg 'cfg(feature, values())' -C metadata=2766be39fb0fc4e7 -C extra-filename=-e06ef52b36ba5195 --out-dir /home/lenny/Projects/error_test/target/debug/deps -C incremental=/home/lenny/Projects
/error_test/target/debug/incremental -L dependency=/home/lenny/Projects/error_test/target/debug/deps --extern chrono=/home/lenny/Projects/error_test/target/debug/deps/libchrono-4f2b9403fa2
f8267.rlib --extern chrono_tz=/home/lenny/Projects/error_test/target/debug/deps/libchrono_tz-2bfc3c953512e5e9.rlib --extern futures=/home/lenny/Projects/error_test/target/debug/deps/libfut
ures-b2e5c549630d83b4.rlib --extern thiserror=/home/lenny/Projects/error_test/target/debug/deps/libthiserror-91714834ffdcbc83.rlib --extern tokio=/home/lenny/Projects/error_test/target/deb
ug/deps/libtokio-c4e8920040c3c7f3.rlib --extern tokio_stream=/home/lenny/Projects/error_test/target/debug/deps/libtokio_stream-e2c0de47bcea37dc.rlib --extern tokio_util=/home/lenny/Project
s/error_test/target/debug/deps/libtokio_util-858aafb43cee218e.rlib` (exit status: 101)
Backtrace
Compiling error_test v0.1.0 (/home/lenny/Projects/error_test)
thread 'rustc' panicked at compiler/rustc_infer/src/infer/mod.rs:1204:26:
index out of bounds: the len is 0 but the index is 0
stack backtrace:
0: rust_begin_unwind
1: core::panicking::panic_fmt
2: core::panicking::panic_bounds_check
3: <rustc_middle::ty::fold::BoundVarReplacer<<rustc_infer::infer::InferCtxt>::instantiate_binder_with_fresh_vars::ToFreshVars> as rustc_type_ir::fold::TypeFolder<rustc_middle::ty::conte
xt::TyCtxt>>::fold_ty
4: <&rustc_middle::ty::list::RawList<(), rustc_middle::ty::Ty> as rustc_type_ir::fold::TypeFoldable<rustc_middle::ty::context::TyCtxt>>::try_fold_with::<rustc_middle::ty::fold::BoundVar
Replacer<<rustc_infer::infer::InferCtxt>::instantiate_binder_with_fresh_vars::ToFreshVars>>
5: <rustc_middle::ty::fold::BoundVarReplacer<<rustc_infer::infer::InferCtxt>::instantiate_binder_with_fresh_vars::ToFreshVars> as rustc_type_ir::fold::TypeFolder<rustc_middle::ty::conte
xt::TyCtxt>>::fold_ty
6: <&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_midd
le::ty::fold::BoundVarReplacer<<rustc_infer::infer::InferCtxt>::instantiate_binder_with_fresh_vars::ToFreshVars>>
7: <rustc_infer::infer::InferCtxt>::instantiate_binder_with_fresh_vars::<rustc_type_ir::predicate::TraitRef<rustc_middle::ty::context::TyCtxt>>
8: <rustc_trait_selection::traits::select::SelectionContext>::match_normalize_trait_ref
9: <rustc_trait_selection::traits::select::SelectionContext>::candidate_from_obligation::{closure#0}::{closure#0}
10: <rustc_trait_selection::traits::select::SelectionContext>::candidate_from_obligation::{closure#0}
11: <rustc_trait_selection::traits::select::SelectionContext>::evaluate_trait_predicate_recursively
12: <rustc_trait_selection::traits::select::SelectionContext>::evaluate_candidate::{closure#0}
13: <rustc_trait_selection::traits::select::SelectionContext>::evaluate_trait_predicate_recursively
14: <rustc_trait_selection::traits::select::SelectionContext>::evaluate_root_obligation
15: rustc_traits::evaluate_obligation::evaluate_obligation
[... omitted 1 frame ...]
16: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt>::evaluate_obligation_no_overflow
17: <rustc_hir_typeck::fn_ctxt::FnCtxt>::lookup_method_in_trait
18: <rustc_hir_typeck::fn_ctxt::FnCtxt>::try_overloaded_call_traits
19: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
20: <rustc_hir_typeck::fn_ctxt::FnCtxt>::confirm_builtin_call
21: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
22: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_match::{closure#0}
23: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
24: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_block
25: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
26: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
27: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_block
28: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
29: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_block
30: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
31: rustc_hir_typeck::check::check_fn
32: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_closure
33: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
34: <rustc_hir_typeck::fn_ctxt::FnCtxt>::confirm_builtin_call
35: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
36: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_block
37: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
38: rustc_hir_typeck::check::check_fn
39: rustc_hir_typeck::typeck_with_inspect::{closure#0}
[... omitted 1 frame ...]
40: <rustc_middle::hir::map::Map>::par_body_owners::<rustc_hir_analysis::check_crate::{closure#3}>::{closure#0}
41: rustc_hir_analysis::check_crate
42: rustc_interface::passes::run_required_analyses
43: rustc_interface::passes::analysis
[... omitted 1 frame ...]
44: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2
}::{closure#0}
45: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
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/lenny/Projects/error_test/rustc-ice-2025-02-12T19_01_14-220588.txt` to your bug report
note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [evaluate_obligation] evaluating trait selection obligation `alloc::boxed::Box<(dyn for<'a> core::ops::function::FnOnce(&'a mut T) -> core::pin::Pin<alloc::boxed::Box<(dyn core::future:
:future::Future<Output = ()> + core::marker::Send + 'a)>> + core::marker::Send + 'b)>: core::ops::function::FnOnce<(^1_1,)>`
#1 [typeck] type-checking `<impl at src/main.rs:18:1: 18:49>::new`
#2 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `error_test` (bin "error_test")
Caused by:
process didn't exit successfully: `/home/lenny/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rustc --crate-name error_test --edition=2021 src/main.rs --error-format=json --json
=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=188 --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 --check-cfg 'cfg(docsrs,test)' --check-c
fg 'cfg(feature, values())' -C metadata=2766be39fb0fc4e7 -C extra-filename=-e06ef52b36ba5195 --out-dir /home/lenny/Projects/error_test/target/debug/deps -C incremental=/home/lenny/Projects
/error_test/target/debug/incremental -L dependency=/home/lenny/Projects/error_test/target/debug/deps --extern chrono=/home/lenny/Projects/error_test/target/debug/deps/libchrono-4f2b9403fa2
f8267.rlib --extern chrono_tz=/home/lenny/Projects/error_test/target/debug/deps/libchrono_tz-2bfc3c953512e5e9.rlib --extern futures=/home/lenny/Projects/error_test/target/debug/deps/libfut
ures-b2e5c549630d83b4.rlib --extern thiserror=/home/lenny/Projects/error_test/target/debug/deps/libthiserror-91714834ffdcbc83.rlib --extern tokio=/home/lenny/Projects/error_test/target/deb
ug/deps/libtokio-c4e8920040c3c7f3.rlib --extern tokio_stream=/home/lenny/Projects/error_test/target/debug/deps/libtokio_stream-e2c0de47bcea37dc.rlib --extern tokio_util=/home/lenny/Project
s/error_test/target/debug/deps/libtokio_util-858aafb43cee218e.rlib` (exit status: 101)
Metadata
Metadata
Assignees
Labels
Category: This is a bug.`#![feature(trait_alias)]`Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Status: A bisection has been found for this issueStatus: A Minimal Complete and Verifiable Example has been found for this issueRelevant to the compiler team, which will review and decide on the PR/issue.