Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deref_target_place is not a deref projection #105881

Closed
trinity-1686a opened this issue Dec 18, 2022 · 13 comments
Closed

deref_target_place is not a deref projection #105881

trinity-1686a opened this issue Dec 18, 2022 · 13 comments
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@trinity-1686a
Copy link
Contributor

trinity-1686a commented Dec 18, 2022

Code

use futures::{select, FutureExt, StreamExt}; // 0.3.25

async fn next_message() -> () {
    todo!()
}

async fn run_one_step() {
    let mut all_next_messages = vec![Box::pin(next_message())];

    select! {
        _ = futures::future::select_all(all_next_messages.iter_mut()).fuse() => {
            let _ = all_next_messages;
        },
    }
}

Meta

rustc --version --verbose:

rustc 1.68.0-nightly (0468a00ae 2022-12-17)
binary: rustc
commit-hash: 0468a00ae3fd6ef1a6a0f9eaf637d7aa9e604acc
commit-date: 2022-12-17
host: x86_64-unknown-linux-gnu
release: 1.68.0-nightly
LLVM version: 15.0.6

Error output

error: internal compiler error: compiler/rustc_borrowck/src/diagnostics/move_errors.rs:301:18: deref_target_place is not a deref projection
Backtrace

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/0468a00ae3fd6ef1a6a0f9eaf637d7aa9e604acc/compiler/rustc_errors/src/lib.rs:1576:9
stack backtrace:
   0:     0x7f162930085a - std::backtrace_rs::backtrace::libunwind::trace::h51cb40f2f8f23f31
                               at /rustc/0468a00ae3fd6ef1a6a0f9eaf637d7aa9e604acc/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f162930085a - std::backtrace_rs::backtrace::trace_unsynchronized::hebc3338ffed58a56
                               at /rustc/0468a00ae3fd6ef1a6a0f9eaf637d7aa9e604acc/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f162930085a - std::sys_common::backtrace::_print_fmt::h136f982a4680ac7f
                               at /rustc/0468a00ae3fd6ef1a6a0f9eaf637d7aa9e604acc/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f162930085a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hd1514baae6e42eb6
                               at /rustc/0468a00ae3fd6ef1a6a0f9eaf637d7aa9e604acc/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f162936336e - core::fmt::write::hfbed4b54a5eebfee
                               at /rustc/0468a00ae3fd6ef1a6a0f9eaf637d7aa9e604acc/library/core/src/fmt/mod.rs:1208:17
   5:     0x7f16292f0bd5 - std::io::Write::write_fmt::h9f6098b6a54a9a94
                               at /rustc/0468a00ae3fd6ef1a6a0f9eaf637d7aa9e604acc/library/std/src/io/mod.rs:1682:15
   6:     0x7f1629300625 - std::sys_common::backtrace::_print::h6e7a2bc7da6ecf73
                               at /rustc/0468a00ae3fd6ef1a6a0f9eaf637d7aa9e604acc/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f1629300625 - std::sys_common::backtrace::print::h631b25ef82a0eea1
                               at /rustc/0468a00ae3fd6ef1a6a0f9eaf637d7aa9e604acc/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f162930336f - std::panicking::default_hook::{{closure}}::h41299fc951b157c9
                               at /rustc/0468a00ae3fd6ef1a6a0f9eaf637d7aa9e604acc/library/std/src/panicking.rs:267:22
   9:     0x7f16293030ab - std::panicking::default_hook::hd317023abfdceaed
                               at /rustc/0468a00ae3fd6ef1a6a0f9eaf637d7aa9e604acc/library/std/src/panicking.rs:286:9
  10:     0x7f162c5cfcc1 - rustc_driver[8fc339cf4408bec4]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f1629303bad - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h813f31c5cc72640d
                               at /rustc/0468a00ae3fd6ef1a6a0f9eaf637d7aa9e604acc/library/alloc/src/boxed.rs:2032:9
  12:     0x7f1629303bad - std::panicking::rust_panic_with_hook::h2e61684db9120e8e
                               at /rustc/0468a00ae3fd6ef1a6a0f9eaf637d7aa9e604acc/library/std/src/panicking.rs:692:13
  13:     0x7f162ca76731 - std[14b7645e29e8dad4]::panicking::begin_panic::<rustc_errors[5442e185e098f882]::ExplicitBug>::{closure#0}
  14:     0x7f162ca75df6 - std[14b7645e29e8dad4]::sys_common::backtrace::__rust_end_short_backtrace::<std[14b7645e29e8dad4]::panicking::begin_panic<rustc_errors[5442e185e098f882]::ExplicitBug>::{closure#0}, !>
  15:     0x7f162cacfa86 - std[14b7645e29e8dad4]::panicking::begin_panic::<rustc_errors[5442e185e098f882]::ExplicitBug>
  16:     0x7f162ca745f6 - std[14b7645e29e8dad4]::panic::panic_any::<rustc_errors[5442e185e098f882]::ExplicitBug>
  17:     0x7f162ca73476 - <rustc_errors[5442e185e098f882]::HandlerInner>::bug::<&alloc[1a97d1c4ba9fe4a2]::string::String>
  18:     0x7f162ca730e0 - <rustc_errors[5442e185e098f882]::Handler>::bug::<&alloc[1a97d1c4ba9fe4a2]::string::String>
  19:     0x7f162cb38afe - rustc_middle[1a40b9d11a76de60]::ty::context::tls::with_context_opt::<rustc_middle[1a40b9d11a76de60]::ty::context::tls::with_opt<rustc_middle[1a40b9d11a76de60]::util::bug::opt_span_bug_fmt<rustc_span[fd000e025c1fef5b]::span_encoding::Span>::{closure#0}, ()>::{closure#0}, ()>
  20:     0x7f162cb38dc6 - rustc_middle[1a40b9d11a76de60]::util::bug::opt_span_bug_fmt::<rustc_span[fd000e025c1fef5b]::span_encoding::Span>
  21:     0x7f162a88d103 - rustc_middle[1a40b9d11a76de60]::util::bug::bug_fmt
  22:     0x7f162c34748e - <rustc_borrowck[c86664c7788b1f3c]::MirBorrowckCtxt>::report
  23:     0x7f162b1c1070 - rustc_borrowck[c86664c7788b1f3c]::do_mir_borrowck
  24:     0x7f162b1a8c69 - rustc_borrowck[c86664c7788b1f3c]::mir_borrowck
  25:     0x7f162b1a8145 - <rustc_borrowck[c86664c7788b1f3c]::provide::{closure#0} as core[486592e7c49a8aa]::ops::function::FnOnce<(rustc_middle[1a40b9d11a76de60]::ty::context::TyCtxt, rustc_span[fd000e025c1fef5b]::def_id::LocalDefId)>>::call_once
  26:     0x7f162b5ae564 - <rustc_query_system[259206d12eac588b]::dep_graph::graph::DepGraph<rustc_middle[1a40b9d11a76de60]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[1a40b9d11a76de60]::ty::context::TyCtxt, rustc_span[fd000e025c1fef5b]::def_id::LocalDefId, &rustc_middle[1a40b9d11a76de60]::mir::query::BorrowCheckResult>
  27:     0x7f162b5ad32c - rustc_query_system[259206d12eac588b]::query::plumbing::try_execute_query::<rustc_query_impl[bc8faa08c5c89942]::plumbing::QueryCtxt, rustc_query_system[259206d12eac588b]::query::caches::VecCache<rustc_span[fd000e025c1fef5b]::def_id::LocalDefId, &rustc_middle[1a40b9d11a76de60]::mir::query::BorrowCheckResult>>
  28:     0x7f162bf7ef8a - <rustc_query_impl[bc8faa08c5c89942]::Queries as rustc_middle[1a40b9d11a76de60]::ty::query::QueryEngine>::mir_borrowck
  29:     0x7f162b299d21 - <rustc_borrowck[c86664c7788b1f3c]::type_check::TypeChecker>::prove_closure_bounds
  30:     0x7f162b278fc5 - <rustc_borrowck[c86664c7788b1f3c]::type_check::TypeChecker>::typeck_mir
  31:     0x7f162b207c76 - rustc_borrowck[c86664c7788b1f3c]::type_check::type_check
  32:     0x7f162b1d8a35 - rustc_borrowck[c86664c7788b1f3c]::nll::compute_regions
  33:     0x7f162b1bd3ac - rustc_borrowck[c86664c7788b1f3c]::do_mir_borrowck
  34:     0x7f162b1a8c69 - rustc_borrowck[c86664c7788b1f3c]::mir_borrowck
  35:     0x7f162b1a8145 - <rustc_borrowck[c86664c7788b1f3c]::provide::{closure#0} as core[486592e7c49a8aa]::ops::function::FnOnce<(rustc_middle[1a40b9d11a76de60]::ty::context::TyCtxt, rustc_span[fd000e025c1fef5b]::def_id::LocalDefId)>>::call_once
  36:     0x7f162b5ae564 - <rustc_query_system[259206d12eac588b]::dep_graph::graph::DepGraph<rustc_middle[1a40b9d11a76de60]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[1a40b9d11a76de60]::ty::context::TyCtxt, rustc_span[fd000e025c1fef5b]::def_id::LocalDefId, &rustc_middle[1a40b9d11a76de60]::mir::query::BorrowCheckResult>
  37:     0x7f162b5ad32c - rustc_query_system[259206d12eac588b]::query::plumbing::try_execute_query::<rustc_query_impl[bc8faa08c5c89942]::plumbing::QueryCtxt, rustc_query_system[259206d12eac588b]::query::caches::VecCache<rustc_span[fd000e025c1fef5b]::def_id::LocalDefId, &rustc_middle[1a40b9d11a76de60]::mir::query::BorrowCheckResult>>
  38:     0x7f162bf7ef8a - <rustc_query_impl[bc8faa08c5c89942]::Queries as rustc_middle[1a40b9d11a76de60]::ty::query::QueryEngine>::mir_borrowck
  39:     0x7f162b299d21 - <rustc_borrowck[c86664c7788b1f3c]::type_check::TypeChecker>::prove_closure_bounds
  40:     0x7f162b278fc5 - <rustc_borrowck[c86664c7788b1f3c]::type_check::TypeChecker>::typeck_mir
  41:     0x7f162b207c76 - rustc_borrowck[c86664c7788b1f3c]::type_check::type_check
  42:     0x7f162b1d8a35 - rustc_borrowck[c86664c7788b1f3c]::nll::compute_regions
  43:     0x7f162b1bd3ac - rustc_borrowck[c86664c7788b1f3c]::do_mir_borrowck
  44:     0x7f162b1a8c69 - rustc_borrowck[c86664c7788b1f3c]::mir_borrowck
  45:     0x7f162b1a8145 - <rustc_borrowck[c86664c7788b1f3c]::provide::{closure#0} as core[486592e7c49a8aa]::ops::function::FnOnce<(rustc_middle[1a40b9d11a76de60]::ty::context::TyCtxt, rustc_span[fd000e025c1fef5b]::def_id::LocalDefId)>>::call_once
  46:     0x7f162b5ae564 - <rustc_query_system[259206d12eac588b]::dep_graph::graph::DepGraph<rustc_middle[1a40b9d11a76de60]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[1a40b9d11a76de60]::ty::context::TyCtxt, rustc_span[fd000e025c1fef5b]::def_id::LocalDefId, &rustc_middle[1a40b9d11a76de60]::mir::query::BorrowCheckResult>
  47:     0x7f162b5ad32c - rustc_query_system[259206d12eac588b]::query::plumbing::try_execute_query::<rustc_query_impl[bc8faa08c5c89942]::plumbing::QueryCtxt, rustc_query_system[259206d12eac588b]::query::caches::VecCache<rustc_span[fd000e025c1fef5b]::def_id::LocalDefId, &rustc_middle[1a40b9d11a76de60]::mir::query::BorrowCheckResult>>
  48:     0x7f162bf7ef8a - <rustc_query_impl[bc8faa08c5c89942]::Queries as rustc_middle[1a40b9d11a76de60]::ty::query::QueryEngine>::mir_borrowck
  49:     0x7f162bdd36f9 - rustc_hir_analysis[1b7141b29bd2e9d]::collect::type_of::type_of
  50:     0x7f162ae90c96 - <rustc_query_system[259206d12eac588b]::dep_graph::graph::DepGraph<rustc_middle[1a40b9d11a76de60]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[1a40b9d11a76de60]::ty::context::TyCtxt, rustc_span[fd000e025c1fef5b]::def_id::DefId, rustc_middle[1a40b9d11a76de60]::ty::Ty>
  51:     0x7f162ae8e830 - rustc_query_system[259206d12eac588b]::query::plumbing::get_query::<rustc_query_impl[bc8faa08c5c89942]::queries::type_of, rustc_query_impl[bc8faa08c5c89942]::plumbing::QueryCtxt>
  52:     0x7f162b6b0460 - rustc_hir_analysis[1b7141b29bd2e9d]::check::check::check_mod_item_types
  53:     0x7f162b149ff4 - <rustc_query_system[259206d12eac588b]::dep_graph::graph::DepGraph<rustc_middle[1a40b9d11a76de60]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[1a40b9d11a76de60]::ty::context::TyCtxt, rustc_span[fd000e025c1fef5b]::def_id::LocalDefId, ()>
  54:     0x7f162b14818e - rustc_query_system[259206d12eac588b]::query::plumbing::try_execute_query::<rustc_query_impl[bc8faa08c5c89942]::plumbing::QueryCtxt, rustc_query_system[259206d12eac588b]::query::caches::VecCache<rustc_span[fd000e025c1fef5b]::def_id::LocalDefId, ()>>
  55:     0x7f162b9c1403 - rustc_query_system[259206d12eac588b]::query::plumbing::get_query::<rustc_query_impl[bc8faa08c5c89942]::queries::check_mod_item_types, rustc_query_impl[bc8faa08c5c89942]::plumbing::QueryCtxt>
  56:     0x7f162bc6aa55 - <rustc_middle[1a40b9d11a76de60]::hir::map::Map>::for_each_module::<rustc_hir_analysis[1b7141b29bd2e9d]::check_crate::{closure#6}::{closure#0}>
  57:     0x7f162ab50292 - rustc_hir_analysis[1b7141b29bd2e9d]::check_crate
  58:     0x7f162ab4fedb - rustc_interface[58e4822cc60d2a6c]::passes::analysis
  59:     0x7f162bd93e85 - <rustc_query_system[259206d12eac588b]::dep_graph::graph::DepGraph<rustc_middle[1a40b9d11a76de60]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[1a40b9d11a76de60]::ty::context::TyCtxt, (), core[486592e7c49a8aa]::result::Result<(), rustc_errors[5442e185e098f882]::ErrorGuaranteed>>
  60:     0x7f162bd93048 - rustc_query_system[259206d12eac588b]::query::plumbing::try_execute_query::<rustc_query_impl[bc8faa08c5c89942]::plumbing::QueryCtxt, rustc_query_system[259206d12eac588b]::query::caches::DefaultCache<(), core[486592e7c49a8aa]::result::Result<(), rustc_errors[5442e185e098f882]::ErrorGuaranteed>>>
  61:     0x7f162bd92ab0 - rustc_query_system[259206d12eac588b]::query::plumbing::get_query::<rustc_query_impl[bc8faa08c5c89942]::queries::analysis, rustc_query_impl[bc8faa08c5c89942]::plumbing::QueryCtxt>
  62:     0x7f162b8604f3 - <rustc_interface[58e4822cc60d2a6c]::passes::QueryContext>::enter::<rustc_driver[8fc339cf4408bec4]::run_compiler::{closure#1}::{closure#2}::{closure#2}, core[486592e7c49a8aa]::result::Result<(), rustc_errors[5442e185e098f882]::ErrorGuaranteed>>
  63:     0x7f162b85c8a3 - <rustc_interface[58e4822cc60d2a6c]::interface::Compiler>::enter::<rustc_driver[8fc339cf4408bec4]::run_compiler::{closure#1}::{closure#2}, core[486592e7c49a8aa]::result::Result<core[486592e7c49a8aa]::option::Option<rustc_interface[58e4822cc60d2a6c]::queries::Linker>, rustc_errors[5442e185e098f882]::ErrorGuaranteed>>
  64:     0x7f162b8578b8 - rustc_span[fd000e025c1fef5b]::with_source_map::<core[486592e7c49a8aa]::result::Result<(), rustc_errors[5442e185e098f882]::ErrorGuaranteed>, rustc_interface[58e4822cc60d2a6c]::interface::run_compiler<core[486592e7c49a8aa]::result::Result<(), rustc_errors[5442e185e098f882]::ErrorGuaranteed>, rustc_driver[8fc339cf4408bec4]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  65:     0x7f162b8573a5 - <scoped_tls[2f862aa259e87453]::ScopedKey<rustc_span[fd000e025c1fef5b]::SessionGlobals>>::set::<rustc_interface[58e4822cc60d2a6c]::interface::run_compiler<core[486592e7c49a8aa]::result::Result<(), rustc_errors[5442e185e098f882]::ErrorGuaranteed>, rustc_driver[8fc339cf4408bec4]::run_compiler::{closure#1}>::{closure#0}, core[486592e7c49a8aa]::result::Result<(), rustc_errors[5442e185e098f882]::ErrorGuaranteed>>
  66:     0x7f162b856992 - std[14b7645e29e8dad4]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[58e4822cc60d2a6c]::util::run_in_thread_pool_with_globals<rustc_interface[58e4822cc60d2a6c]::interface::run_compiler<core[486592e7c49a8aa]::result::Result<(), rustc_errors[5442e185e098f882]::ErrorGuaranteed>, rustc_driver[8fc339cf4408bec4]::run_compiler::{closure#1}>::{closure#0}, core[486592e7c49a8aa]::result::Result<(), rustc_errors[5442e185e098f882]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[486592e7c49a8aa]::result::Result<(), rustc_errors[5442e185e098f882]::ErrorGuaranteed>>
  67:     0x7f162be8dc1a - <<std[14b7645e29e8dad4]::thread::Builder>::spawn_unchecked_<rustc_interface[58e4822cc60d2a6c]::util::run_in_thread_pool_with_globals<rustc_interface[58e4822cc60d2a6c]::interface::run_compiler<core[486592e7c49a8aa]::result::Result<(), rustc_errors[5442e185e098f882]::ErrorGuaranteed>, rustc_driver[8fc339cf4408bec4]::run_compiler::{closure#1}>::{closure#0}, core[486592e7c49a8aa]::result::Result<(), rustc_errors[5442e185e098f882]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[486592e7c49a8aa]::result::Result<(), rustc_errors[5442e185e098f882]::ErrorGuaranteed>>::{closure#1} as core[486592e7c49a8aa]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  68:     0x7f162930d983 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hdbff13d45d6b3b01
                               at /rustc/0468a00ae3fd6ef1a6a0f9eaf637d7aa9e604acc/library/alloc/src/boxed.rs:2000:9
  69:     0x7f162930d983 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h1e5384a2b7a0037a
                               at /rustc/0468a00ae3fd6ef1a6a0f9eaf637d7aa9e604acc/library/alloc/src/boxed.rs:2000:9
  70:     0x7f162930d983 - std::sys::unix::thread::Thread::new::thread_start::h4b8540c4f94d9763
                               at /rustc/0468a00ae3fd6ef1a6a0f9eaf637d7aa9e604acc/library/std/src/sys/unix/thread.rs:108:17
  71:     0x7f162906e8fd - <unknown>
  72:     0x7f16290f0a60 - <unknown>
  73:                0x0 - <unknown>

note: 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: rustc 1.68.0-nightly (0468a00ae 2022-12-17) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C embed-bitcode=no -C debuginfo=2 -C linker=clang -C incremental=[REDACTED] -C link-arg=-fuse-ld=/bin/mold

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [mir_borrowck] borrow-checking `<impl at crates/tor-ptmgr/src/lib.rs:120:1: 120:30>::run_one_step::{closure#0}::{closure#1}`
#1 [mir_borrowck] borrow-checking `<impl at crates/tor-ptmgr/src/lib.rs:120:1: 120:30>::run_one_step::{closure#0}`
#2 [mir_borrowck] borrow-checking `<impl at crates/tor-ptmgr/src/lib.rs:120:1: 120:30>::run_one_step`
#3 [type_of] computing type of `<impl at crates/tor-ptmgr/src/lib.rs:120:1: 120:30>::run_one_step::{opaque#0}`
#4 [check_mod_item_types] checking item types in top-level module
#5 [analysis] running analysis passes on this crate
end of query stack

Additional information

I can't reproduce with rustc 1.68.0-nightly (ec56537c4 2022-12-15), but I can with rustc 1.68.0-nightly (9c07efe84 2022-12-16). It seems to be a recent regression

@trinity-1686a trinity-1686a added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 18, 2022
@jruderman
Copy link
Contributor

Regression from #103880 (CC @b-naber, @lcnr)

@jruderman
Copy link
Contributor

@rustbot label +regression-from-stable-to-nightly

@rustbot rustbot added regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Dec 19, 2022
bors added a commit to rust-lang-ci/rust that referenced this issue Dec 19, 2022
Revert rust-lang#103880 "Use non-ascribed type as field's type in mir"

This PR prepares a revert for rust-lang#103880 to fix rust-lang#105809, rust-lang#105881, rust-lang#105886 and others (like the duplicates of the first one), in case an actual fix can't get done today.

I've also added the MCVE from rust-lang#105809. There is no MCVE for the rust-lang#105881 and rust-lang#105886 ICEs yet however, so there are no tests for them here, although we'll need one before relanding the original changes.

Were this PR to land, it would also reopen rust-lang#96514 as it was fixed by the original PR.

Opening as draft to allow time for a possible fix.

r? `@jackh726`
@lqd
Copy link
Member

lqd commented Dec 20, 2022

This should be fixed in tomorrow's nightly now that #105905 has been merged. It would be great to even have the futures-0.3.25 crate removed from the example in the OP so that we can use it as a non-regression test.

@trinity-1686a
Copy link
Contributor Author

not sure whether I'll manage to get ride of all of it, but I'll give it a try

@albertlarsan68
Copy link
Member

I am working on reducing the issue, should I make a PR with the non-regression test, or do I simply post it here ?

@lqd
Copy link
Member

lqd commented Dec 20, 2022

Either is fine, but if you know how to make a UI test ensuring the regression happens without the revert, it'll be easier to land of course. Whatever is easiest for you, and I'll take care of the rest.

@albertlarsan68
Copy link
Member

albertlarsan68 commented Dec 20, 2022

Here is the standalone code:

use std::{
    future::{poll_fn, Future},
    pin::Pin,
    task::{Context, Poll},
};

pub struct SelectAll<Fut> {
    inner: Vec<Fut>,
}

pub struct Fuse<Fut> {
    inner: Option<Fut>,
}

impl<Fut: Future + Unpin> Future for SelectAll<Fut> {
    type Output = (Fut::Output, usize, Vec<Fut>);

    fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
        loop {}
    }
}

async fn next_message() {
    todo!()
}

impl<Fut: Future> Future for Fuse<Fut> {
    type Output = Fut::Output;

    fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Fut::Output> {
        loop {}
    }
}

async fn run_one_step() {
    let mut all_next_messages = vec![Box::pin(next_message())];

    {
        {
            enum __PrivResult<_0> {
                _0(_0),
            }
            let __select_result = {
                let mut _0 = {
                    let this = {
                        let iter = all_next_messages.iter_mut();
                        let ret = SelectAll {
                            inner: iter.into_iter().collect(),
                        };
                        ret
                    };
                    Fuse { inner: Some(this) }
                };
                let mut __poll_fn = |__cx: &mut core::task::Context<'_>| {
                    let mut _0 = |__cx: &mut core::task::Context<'_>| {
                        let mut _0 = unsafe { core::pin::Pin::new_unchecked(&mut _0) };
                        if true {
                            None
                        } else {
                            Some(_0.poll(__cx).map(__PrivResult::_0))
                        }
                    };
                    let mut __select_arr = [&mut _0];
                    for poller in &mut __select_arr {
                        match poller(__cx) {
                            Some(x @ core::task::Poll::Ready(_)) => return x,
                            Some(core::task::Poll::Pending) => {}
                            None => {}
                        }
                    }

                    core::task::Poll::Pending
                };
                poll_fn(__poll_fn).await
            };
            match __select_result {
                __PrivResult::_0(_) => {
                    let _ = all_next_messages;
                }
            }
        }
    }
}

I do have not minimized it to the full extent, but it is standalone now.
It still ICEs with the same message.

@trinity-1686a
Copy link
Contributor Author

best I got is

use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};

async fn new_future() {
    loop {}
}

pub struct SelectAll<Fut> {
    _inner: Fut,
}

fn select_all<I>(_: I) -> SelectAll<I::Item>
where
    I: IntoIterator,
    I::Item: Future + Unpin,
{
    loop {}
}

impl<Fut: Future> Future for SelectAll<Fut> {
    type Output = ();

    fn poll(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Self::Output> {
        loop {}
    }
}

async fn run_one_step() {
    let mut select = select_all(vec![Box::pin(new_future())]);
    let poll_fns = &mut |cx: &mut Context<'_>| Pin::new(&mut select).poll(cx);
    for _poll_fn in [poll_fns] {}
}

I'll make a PR later today if no one makes one before (feel free to make one if you want)

@albertlarsan68
Copy link
Member

This is what you should put as the test: it is your code, modified to make a UI test. I would put it in src/test/ui/borrowck/issue-105881.rs

// check-fail
use std::{
    future::Future,
    pin::Pin,
    task::{Context, Poll},
};

pub struct SelectAll<Fut> {
    _inner: Fut,
}

impl<Fut: Future> Future for SelectAll<Fut> {
    type Output = ();

    fn poll(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Self::Output> {
        loop {}
    }
}

async fn new_future() {
    loop {}
}

fn select_all<I>(_: I) -> SelectAll<I::Item>
where
    I: IntoIterator,
    I::Item: Future + Unpin,
{
    loop {}
}

async fn run_one_step() {
    let mut select = select_all(vec![Box::pin(new_future())]);
    let mut poll_fn = |cx: &mut Context<'_>| Pin::new(&mut select).poll(cx);
    for _poll_fn in [&mut poll_fn] {}
}

fn main() {}

@b-naber
Copy link
Contributor

b-naber commented Dec 20, 2022

@trinity-1686a I have a fix ready for the original PR that was reverted and caused this issue and will use your mcve as a test. Thanks for minimizing this issue.

@apiraino
Copy link
Contributor

WG-prioritization assigning priority (Zulip discussion).

@rustbot label -I-prioritize +P-high

@rustbot rustbot added P-high High priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Dec 21, 2022
@lcnr
Copy link
Contributor

lcnr commented Jan 13, 2023

This is fixed by #105905, isn't it?

@apiraino
Copy link
Contributor

This is fixed by #105905, isn't it?

I think so. I'll go ahead and close this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants