-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Labels
A-borrow-checkerArea: The borrow checkerArea: The borrow checkerC-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) ❄️S-has-bisectionStatus: A bisection has been found for this issueStatus: A bisection 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.
Description
auto-reduced (treereduce-rust):
//@compile-flags: --edition=2024
fn create_complex_future() -> impl Future<Output = impl ReturnsSend> {
async { create_complex_future().await }
}
trait ReturnsSend {}
original:
//@ edition: 2021
use Box::new;
fn invalid_future() -> impl Future {}
//@ run-pass
fn create_complex_future() -> impl Future<Output = impl ReturnsSend> {
async { create_complex_future().await }
}
fn coerce_impl_trait() -> impl Future<Output = impl Send> {
create_complex_future()
}
trait ReturnsSend {}
impl<F, R> ReturnsSend for F
where
F: Fn() -> R,
R: Send,
{
}
fn main() {}
Version information
rustc 1.91.0-nightly (fd75a9c32 2025-09-03)
binary: rustc
commit-hash: fd75a9c32d643f39c8c61df770d2cff60b3fefd5
commit-date: 2025-09-03
host: x86_64-unknown-linux-gnu
release: 1.91.0-nightly
LLVM version: 21.1.0
Possibly related line of code:
rust/compiler/rustc_borrowck/src/region_infer/opaque_types/mod.rs
Lines 500 to 512 in fd75a9c
opaque_types: &[(OpaqueTypeKey<'tcx>, OpaqueHiddenType<'tcx>)], | |
) -> Vec<DeferredOpaqueTypeError<'tcx>> { | |
let tcx = infcx.tcx; | |
let mut errors = Vec::new(); | |
for &(key, hidden_type) in opaque_types { | |
let Some(expected) = get_concrete_opaque_type(concrete_opaque_types, key.def_id) else { | |
assert!(tcx.use_typing_mode_borrowck(), "non-defining use in defining scope"); | |
errors.push(DeferredOpaqueTypeError::NonDefiningUseInDefiningScope { | |
span: hidden_type.span, | |
opaque_type_key: key, | |
}); | |
let guar = tcx.dcx().span_delayed_bug( | |
hidden_type.span, |
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc --edition=2024
Program output
error[E0601]: `main` function not found in crate `mvce`
--> /tmp/icemaker_global_tempdir.K1lCvHnMGsLU/rustc_testrunner_tmpdir_reporting.Inqk0tIKVrjs/mvce.rs:5:21
|
5 | trait ReturnsSend {}
| ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.K1lCvHnMGsLU/rustc_testrunner_tmpdir_reporting.Inqk0tIKVrjs/mvce.rs`
thread 'rustc' (4837) panicked at compiler/rustc_borrowck/src/region_infer/opaque_types/mod.rs:506:13:
non-defining use in defining scope
stack backtrace:
0: 0x7ff0dc9b0453 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h9edfddd7dc0bd583
1: 0x7ff0dd001998 - core::fmt::write::h88e60c27e15542b9
2: 0x7ff0dc9651b1 - std::io::Write::write_fmt::h239b955172045825
3: 0x7ff0dc976332 - std::sys::backtrace::BacktraceLock::print::he00602618008d690
4: 0x7ff0dc97c2b9 - std::panicking::default_hook::{{closure}}::hd731f16ef72096be
5: 0x7ff0dc97bde3 - std::panicking::default_hook::he12a20c3692e4cb7
6: 0x7ff0db9dea15 - std[40a039f02da9be5]::panicking::update_hook::<alloc[9e325f13687c9588]::boxed::Box<rustc_driver_impl[6bc00067fcdc553c]::install_ice_hook::{closure#1}>>::{closure#0}
7: 0x7ff0dc97c6df - std::panicking::panic_with_hook::h694d89e3fc21ffd6
8: 0x7ff0dc97c466 - std::panicking::panic_handler::{{closure}}::h5524e8eac2a495e5
9: 0x7ff0dc976469 - std::sys::backtrace::__rust_end_short_backtrace::h4b6fbbdc74cf2f46
10: 0x7ff0dc956d1d - __rustc[2cc2c7f1e3a23039]::rust_begin_unwind
11: 0x7ff0d90cb330 - core::panicking::panic_fmt::h594cf358aa009393
12: 0x7ff0ddb821c1 - <rustc_borrowck[8f789c4a8072f8c4]::root_cx::BorrowCheckRootCtxt>::do_mir_borrowck
13: 0x7ff0ddb70164 - rustc_borrowck[8f789c4a8072f8c4]::mir_borrowck
14: 0x7ff0ddb6ff21 - rustc_query_impl[e4969f750d187e98]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e4969f750d187e98]::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[cfc37889f8d46045]::query::erase::Erased<[u8; 8usize]>>
15: 0x7ff0dd2046c5 - rustc_query_system[7ac3c608b60e76af]::query::plumbing::try_execute_query::<rustc_query_impl[e4969f750d187e98]::DynamicConfig<rustc_data_structures[788fd6124e46ed5e]::vec_cache::VecCache<rustc_span[3aa7543d96f37683]::def_id::LocalDefId, rustc_middle[cfc37889f8d46045]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[7ac3c608b60e76af]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[e4969f750d187e98]::plumbing::QueryCtxt, false>
16: 0x7ff0dd203ec9 - rustc_query_impl[e4969f750d187e98]::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace
17: 0x7ff0de2d4d2f - rustc_hir_analysis[4feb2b3cccb2a05a]::collect::type_of::opaque::find_opaque_ty_constraints_for_rpit
18: 0x7ff0de2d4ab8 - rustc_hir_analysis[4feb2b3cccb2a05a]::collect::type_of::type_of_opaque
19: 0x7ff0de2d49ad - rustc_query_impl[e4969f750d187e98]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e4969f750d187e98]::query_impl::type_of_opaque::dynamic_query::{closure#2}::{closure#0}, rustc_middle[cfc37889f8d46045]::query::erase::Erased<[u8; 8usize]>>
20: 0x7ff0dd016af9 - rustc_query_system[7ac3c608b60e76af]::query::plumbing::try_execute_query::<rustc_query_impl[e4969f750d187e98]::DynamicConfig<rustc_query_system[7ac3c608b60e76af]::query::caches::DefIdCache<rustc_middle[cfc37889f8d46045]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[e4969f750d187e98]::plumbing::QueryCtxt, false>
21: 0x7ff0de1e8cdb - rustc_query_impl[e4969f750d187e98]::query_impl::type_of_opaque::get_query_non_incr::__rust_end_short_backtrace
22: 0x7ff0dd462cbd - rustc_hir_analysis[4feb2b3cccb2a05a]::collect::type_of::type_of
23: 0x7ff0dd017e66 - rustc_query_impl[e4969f750d187e98]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e4969f750d187e98]::query_impl::type_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[cfc37889f8d46045]::query::erase::Erased<[u8; 8usize]>>
24: 0x7ff0dd016af9 - rustc_query_system[7ac3c608b60e76af]::query::plumbing::try_execute_query::<rustc_query_impl[e4969f750d187e98]::DynamicConfig<rustc_query_system[7ac3c608b60e76af]::query::caches::DefIdCache<rustc_middle[cfc37889f8d46045]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[e4969f750d187e98]::plumbing::QueryCtxt, false>
25: 0x7ff0dd01669d - rustc_query_impl[e4969f750d187e98]::query_impl::type_of::get_query_non_incr::__rust_end_short_backtrace
26: 0x7ff0de2d546c - rustc_hir_analysis[4feb2b3cccb2a05a]::check::check::check_opaque
27: 0x7ff0dd906920 - rustc_hir_analysis[4feb2b3cccb2a05a]::check::check::check_item_type
28: 0x7ff0dd8fdfe7 - rustc_hir_analysis[4feb2b3cccb2a05a]::check::wfcheck::check_well_formed
29: 0x7ff0dd8fdfc9 - rustc_query_impl[e4969f750d187e98]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e4969f750d187e98]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[cfc37889f8d46045]::query::erase::Erased<[u8; 1usize]>>
30: 0x7ff0dd8fd809 - rustc_query_system[7ac3c608b60e76af]::query::plumbing::try_execute_query::<rustc_query_impl[e4969f750d187e98]::DynamicConfig<rustc_data_structures[788fd6124e46ed5e]::vec_cache::VecCache<rustc_span[3aa7543d96f37683]::def_id::LocalDefId, rustc_middle[cfc37889f8d46045]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[7ac3c608b60e76af]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[e4969f750d187e98]::plumbing::QueryCtxt, false>
31: 0x7ff0dd8fd316 - rustc_query_impl[e4969f750d187e98]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
32: 0x7ff0dd8f94cf - rustc_hir_analysis[4feb2b3cccb2a05a]::check::wfcheck::check_type_wf
33: 0x7ff0dd8f9365 - rustc_query_impl[e4969f750d187e98]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e4969f750d187e98]::query_impl::check_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[cfc37889f8d46045]::query::erase::Erased<[u8; 1usize]>>
34: 0x7ff0de09aed4 - rustc_query_system[7ac3c608b60e76af]::query::plumbing::try_execute_query::<rustc_query_impl[e4969f750d187e98]::DynamicConfig<rustc_query_system[7ac3c608b60e76af]::query::caches::SingleCache<rustc_middle[cfc37889f8d46045]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[e4969f750d187e98]::plumbing::QueryCtxt, false>
35: 0x7ff0de09acb6 - rustc_query_impl[e4969f750d187e98]::query_impl::check_type_wf::get_query_non_incr::__rust_end_short_backtrace
36: 0x7ff0dda16f39 - rustc_hir_analysis[4feb2b3cccb2a05a]::check_crate
37: 0x7ff0dd1fbf3e - rustc_interface[27387541cf04561a]::passes::analysis
38: 0x7ff0dd1fbc0b - rustc_query_impl[e4969f750d187e98]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e4969f750d187e98]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[cfc37889f8d46045]::query::erase::Erased<[u8; 0usize]>>
39: 0x7ff0de0a191a - rustc_query_system[7ac3c608b60e76af]::query::plumbing::try_execute_query::<rustc_query_impl[e4969f750d187e98]::DynamicConfig<rustc_query_system[7ac3c608b60e76af]::query::caches::SingleCache<rustc_middle[cfc37889f8d46045]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[e4969f750d187e98]::plumbing::QueryCtxt, false>
40: 0x7ff0de0a1550 - rustc_query_impl[e4969f750d187e98]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
41: 0x7ff0de2368a4 - rustc_interface[27387541cf04561a]::passes::create_and_enter_global_ctxt::<core[9a833c474fe77ed7]::option::Option<rustc_interface[27387541cf04561a]::queries::Linker>, rustc_driver_impl[6bc00067fcdc553c]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
42: 0x7ff0de26427e - rustc_interface[27387541cf04561a]::interface::run_compiler::<(), rustc_driver_impl[6bc00067fcdc553c]::run_compiler::{closure#0}>::{closure#1}
43: 0x7ff0de193b78 - std[40a039f02da9be5]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[27387541cf04561a]::util::run_in_thread_with_globals<rustc_interface[27387541cf04561a]::util::run_in_thread_pool_with_globals<rustc_interface[27387541cf04561a]::interface::run_compiler<(), rustc_driver_impl[6bc00067fcdc553c]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
44: 0x7ff0de19385c - <<std[40a039f02da9be5]::thread::Builder>::spawn_unchecked_<rustc_interface[27387541cf04561a]::util::run_in_thread_with_globals<rustc_interface[27387541cf04561a]::util::run_in_thread_pool_with_globals<rustc_interface[27387541cf04561a]::interface::run_compiler<(), rustc_driver_impl[6bc00067fcdc553c]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[9a833c474fe77ed7]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
45: 0x7ff0de1995cd - std::sys::pal::unix::thread::Thread::new::thread_start::h42df12c914dd61fe
46: 0x7ff0d7a969cb - <unknown>
47: 0x7ff0d7b1aa0c - <unknown>
48: 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: rustc 1.91.0-nightly (fd75a9c32 2025-09-03) running on x86_64-unknown-linux-gnu
note: compiler flags: -Z dump-mir-dir=dir
query stack during panic:
#0 [mir_borrowck] borrow-checking `create_complex_future`
#1 [type_of_opaque] computing type of opaque `create_complex_future::{opaque#0}`
#2 [type_of] computing type of `create_complex_future::{opaque#0}`
#3 [check_well_formed] checking that `create_complex_future::{opaque#0}` is well-formed
#4 [check_type_wf] checking that types are well-formed
#5 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0601`.
Metadata
Metadata
Assignees
Labels
A-borrow-checkerArea: The borrow checkerArea: The borrow checkerC-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) ❄️S-has-bisectionStatus: A bisection has been found for this issueStatus: A bisection 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.