ICE: error from fully_perform, with HRTB on GAT
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.2k
- PR merge metrics
- PR metrics pending
Description
Code
Minimal example below, with rust playground link. This may be related to #130797, as both involve type inference when there is a HRTB over a GAT, though that bug specifically involves usage with trait objects, where this bug did not occur when using trait objects.
trait FunctionLikeTrait {}
impl<Func> FunctionLikeTrait for Func where Func: Fn() {}
trait ArgTrait {
type Unwrapped<'a>;
}
impl<'t> ArgTrait for &'t () {
type Unwrapped<'a> = &'a ();
}
struct FunctionWrapper<Func, Arg> {
_phantom: std::marker::PhantomData<(Func, Arg)>,
}
impl<Func, Arg> FunctionLikeTrait for FunctionWrapper<Func, Arg>
where
Func: Fn(Arg),
for<'a> Arg: ArgTrait<Unwrapped<'a> = Arg>,
{
}
fn apply_func<Func, Arg>(_: Func)
where
FunctionWrapper<Func, Arg>: FunctionLikeTrait,
{
}
fn main() {
apply_func(|_: &()| {});
}
Meta
rustc --version --verbose:
rustc 1.86.0-nightly (a9730c3b5 2025-02-05)
binary: rustc
commit-hash: a9730c3b5f84a001c052c60c97ed0765e9ceac04
commit-date: 2025-02-05
host: x86_64-unknown-linux-gnu
release: 1.86.0-nightly
LLVM version: 19.1.7
Also tested on stable channel, with the same behavior.
rustc 1.84.1 (e71f9a9a9 2025-01-27)
binary: rustc
commit-hash: e71f9a9a98b0faf423844bf0ba7438f29dc27d58
commit-date: 2025-01-27
host: x86_64-unknown-linux-gnu
release: 1.84.1
LLVM version: 19.1.5
Error output
<output>
Compiling bug_mwe v0.1.0 (/home/username/bug_mwe)
note: no errors encountered even though delayed bugs were created
note: those delayed bugs will now be shown as internal compiler errors
error: internal compiler error: error performing operation: fully_perform
--> src/main.rs:31:5
|
31 | apply_func(|_: &()| {});
| ^^^^^^^^^^^^^^^^^^^^^^^
|
note: delayed at /rustc/a9730c3b5f84a001c052c60c97ed0765e9ceac04/compiler/rustc_trait_selection/src/traits/query/type_op/custom.rs:87:25 - disabled backtrace
--> src/main.rs:31:5
|
31 | apply_func(|_: &()| {});
| ^^^^^^^^^^^^^^^^^^^^^^^
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/username/bug_mwe/rustc-ice-2025-02-06T15_08_40-780362.txt` to your bug report
note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C link-arg=-B/usr/local/libexec/mold
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
end of query stack
error: could not compile `bug_mwe` (bin "bug_mwe")
Caused by:
process didn't exit successfully: `/home/username/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rustc --crate-name bug_mwe --edition=2021 src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values())' -C metadata=81c7c60b51af13e3 -C extra-filename=-bca91fa17f684345 --out-dir /home/username/bug_mwe/target/debug/deps -L dependency=/home/username/bug_mwe/target/debug/deps -C link-arg=-B/usr/local/libexec/mold` (exit status: 101)
Backtrace
<backtrace>
note: delayed at /rustc/a9730c3b5f84a001c052c60c97ed0765e9ceac04/compiler/rustc_trait_selection/src/traits/query/type_op/custom.rs:87:25
0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
1: <rustc_errors::DiagCtxtHandle>::emit_diagnostic
2: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
3: <rustc_errors::DiagCtxtHandle>::span_delayed_bug::<rustc_span::span_encoding::Span, alloc::string::String>
4: <rustc_borrowck::type_check::TypeChecker>::fully_perform_op::<(), rustc_middle::ty::ParamEnvAnd<rustc_middle::traits::query::type_op::ProvePredicate>>
5: <rustc_borrowck::type_check::TypeChecker>::normalize_and_prove_instantiated_predicates
6: <rustc_borrowck::type_check::TypeVerifier as rustc_middle::mir::visit::Visitor>::visit_const_operand
7: <rustc_borrowck::type_check::TypeVerifier as rustc_middle::mir::visit::Visitor>::visit_body
8: rustc_borrowck::type_check::type_check
9: rustc_borrowck::nll::compute_regions
10: rustc_borrowck::do_mir_borrowck
11: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
12: 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, false>
13: rustc_query_impl::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace
14: rustc_interface::passes::run_required_analyses
15: rustc_interface::passes::analysis
16: 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]>>
17: 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, false>
18: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
19: 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}
20: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
21: 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}, ()>
22: <<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}
23: std::sys::pal::unix::thread::Thread::new::thread_start
24: start_thread
at ./nptl/pthread_create.c:447:8
25: clone3
at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78:0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the ICE with the minimal example from the issue and the linked Rust Playground. Then trace the reported path through compiler/rustc_trait_selection/src/traits/query/type_op/custom.rs:87 and rustc_borrowck::type_check::TypeChecker::fully_perform; done means this input no longer produces an internal compiler error.
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
- Mostly clear
- Newbie friendliness
- 35/100