Skip to content

ICE: we captured CapturedPlace .. but it was not used in the child coroutine? #123821

Closed

Description

@matthiaskrgr

snippet:

fn test(s: &S, t: &i32) {
    async || {
        println!("{}", s.t);
        println!("{}", t);
    };
}

Version information

rustc 1.79.0-nightly (aa6a697a1 2024-04-11)
binary: rustc
commit-hash: aa6a697a1c75b0aa06954136f7641706edadc2be
commit-date: 2024-04-11
host: x86_64-unknown-linux-gnu
release: 1.79.0-nightly
LLVM version: 18.1.3

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc --edition=2018

Program output

error[E0412]: cannot find type `S` in this scope
 --> /tmp/icemaker_global_tempdir.zRc1iFaNOZFQ/rustc_testrunner_tmpdir_reporting.OAY0faPDYJlK/mvce.rs:1:13
  |
1 | fn test(s: &S, t: &i32) {
  |             ^ not found in this scope
  |
help: you might be missing a type parameter
  |
1 | fn test<S>(s: &S, t: &i32) {
  |        +++

error[E0658]: async closures are unstable
 --> /tmp/icemaker_global_tempdir.zRc1iFaNOZFQ/rustc_testrunner_tmpdir_reporting.OAY0faPDYJlK/mvce.rs:2:5
  |
2 |     async || {
  |     ^^^^^
  |
  = note: see issue #62290 <https://github.com/rust-lang/rust/issues/62290> for more information
  = help: add `#![feature(async_closure)]` to the crate attributes to enable
  = note: this compiler was built on 2024-04-11; consider upgrading it if it is out of date
  = help: to use an async block, remove the `||`: `async {`

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.zRc1iFaNOZFQ/rustc_testrunner_tmpdir_reporting.OAY0faPDYJlK/mvce.rs:6:2
  |
6 | }
  |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.zRc1iFaNOZFQ/rustc_testrunner_tmpdir_reporting.OAY0faPDYJlK/mvce.rs`

thread 'rustc' panicked at /rustc/aa6a697a1c75b0aa06954136f7641706edadc2be/compiler/rustc_middle/src/ty/closure.rs:460:13:
we captured CapturedPlace {
    var_ident: s#0,
    place: Place {
        base_ty: ?0t,
        base: Upvar(
            UpvarId(HirId(DefId(0:3 ~ mvce[4541]::test).2);`s`;DefId(0:4 ~ mvce[4541]::test::{closure#0})),
        ),
        projections: [],
    },
    info: CaptureInfo {
        capture_kind_expr_id: None,
        path_expr_id: None,
        capture_kind: ByRef(
            ImmBorrow,
        ),
    },
    mutability: Not,
    region: Some(
        '?48,
    ),
} but it was not used in the child coroutine?
stack backtrace:
   0:     0x7103909d5aa5 - std::backtrace_rs::backtrace::libunwind::trace::he840a2eb6b9d1010
                               at /rustc/aa6a697a1c75b0aa06954136f7641706edadc2be/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5
   1:     0x7103909d5aa5 - std::backtrace_rs::backtrace::trace_unsynchronized::hb5cbb588f6ff9e8a
                               at /rustc/aa6a697a1c75b0aa06954136f7641706edadc2be/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7103909d5aa5 - std::sys_common::backtrace::_print_fmt::h2bbcaca7d52fcace
                               at /rustc/aa6a697a1c75b0aa06954136f7641706edadc2be/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7103909d5aa5 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::ha8b35488b9373e82
                               at /rustc/aa6a697a1c75b0aa06954136f7641706edadc2be/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x710390a24f5b - core::fmt::rt::Argument::fmt::h7486f17592b5c408
                               at /rustc/aa6a697a1c75b0aa06954136f7641706edadc2be/library/core/src/fmt/rt.rs:142:9
   5:     0x710390a24f5b - core::fmt::write::h38f8b054f2ce97c4
                               at /rustc/aa6a697a1c75b0aa06954136f7641706edadc2be/library/core/src/fmt/mod.rs:1153:17
   6:     0x7103909ca6af - std::io::Write::write_fmt::hb5ba4b57b761add2
                               at /rustc/aa6a697a1c75b0aa06954136f7641706edadc2be/library/std/src/io/mod.rs:1832:15
   7:     0x7103909d587e - std::sys_common::backtrace::_print::habb7d0f73edf4cf4
                               at /rustc/aa6a697a1c75b0aa06954136f7641706edadc2be/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7103909d587e - std::sys_common::backtrace::print::hb2b9429afa3b500e
                               at /rustc/aa6a697a1c75b0aa06954136f7641706edadc2be/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7103909d8379 - std::panicking::default_hook::{{closure}}::h3f20dac427bbf670
  10:     0x7103909d8095 - std::panicking::default_hook::h3fe8f5c78340bac8
                               at /rustc/aa6a697a1c75b0aa06954136f7641706edadc2be/library/std/src/panicking.rs:291:9
  11:     0x71038d26a04b - std[36b140a5e3846230]::panicking::update_hook::<alloc[4cfca62bece663de]::boxed::Box<rustc_driver_impl[3824f3c10e5e1962]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7103909d8a7c - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hcd6fabc1cc1ca8f4
                               at /rustc/aa6a697a1c75b0aa06954136f7641706edadc2be/library/alloc/src/boxed.rs:2032:9
  13:     0x7103909d8a7c - std::panicking::rust_panic_with_hook::h7c0454bae1c09846
                               at /rustc/aa6a697a1c75b0aa06954136f7641706edadc2be/library/std/src/panicking.rs:792:13
  14:     0x7103909d8826 - std::panicking::begin_panic_handler::{{closure}}::hb579058774f0d6b4
                               at /rustc/aa6a697a1c75b0aa06954136f7641706edadc2be/library/std/src/panicking.rs:657:13
  15:     0x7103909d5f69 - std::sys_common::backtrace::__rust_end_short_backtrace::h5415cd9c85ea4680
                               at /rustc/aa6a697a1c75b0aa06954136f7641706edadc2be/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7103909d8557 - rust_begin_unwind
                               at /rustc/aa6a697a1c75b0aa06954136f7641706edadc2be/library/std/src/panicking.rs:645:5
  17:     0x710390a213f6 - core::panicking::panic_fmt::hd279f697292ad797
                               at /rustc/aa6a697a1c75b0aa06954136f7641706edadc2be/library/core/src/panicking.rs:72:14
  18:     0x71038d417eb9 - <core[52b5313fa7109ccf]::iter::sources::from_coroutine::FromCoroutine<rustc_middle[84100436d5b064b4]::ty::closure::analyze_coroutine_closure_captures<rustc_middle[84100436d5b064b4]::ty::Ty, core[52b5313fa7109ccf]::iter::adapters::flatten::Flatten<core[52b5313fa7109ccf]::option::IntoIter<core[52b5313fa7109ccf]::iter::adapters::flatten::FlatMap<indexmap[c9872e81d1406d94]::map::iter::Values<rustc_hir[640aa2bf9d482cc]::hir_id::HirId, alloc[4cfca62bece663de]::vec::Vec<rustc_middle[84100436d5b064b4]::ty::closure::CapturedPlace>>, core[52b5313fa7109ccf]::slice::iter::Iter<rustc_middle[84100436d5b064b4]::ty::closure::CapturedPlace>, <rustc_middle[84100436d5b064b4]::ty::typeck_results::TypeckResults>::closure_min_captures_flattened::{closure#0}::{closure#0}>>>, core[52b5313fa7109ccf]::iter::adapters::skip::Skip<core[52b5313fa7109ccf]::iter::adapters::flatten::Flatten<core[52b5313fa7109ccf]::option::IntoIter<core[52b5313fa7109ccf]::iter::adapters::flatten::FlatMap<indexmap[c9872e81d1406d94]::map::iter::Values<rustc_hir[640aa2bf9d482cc]::hir_id::HirId, alloc[4cfca62bece663de]::vec::Vec<rustc_middle[84100436d5b064b4]::ty::closure::CapturedPlace>>, core[52b5313fa7109ccf]::slice::iter::Iter<rustc_middle[84100436d5b064b4]::ty::closure::CapturedPlace>, <rustc_middle[84100436d5b064b4]::ty::typeck_results::TypeckResults>::closure_min_captures_flattened::{closure#0}::{closure#0}>>>>, <rustc_hir_typeck[4fd8731c11591e1f]::fn_ctxt::FnCtxt>::analyze_closure::{closure#0}>::{closure#0}> as core[52b5313fa7109ccf]::iter::traits::iterator::Iterator>::next
  19:     0x71038ef99cb0 - <rustc_hir_typeck[4fd8731c11591e1f]::fn_ctxt::FnCtxt>::analyze_closure
  20:     0x71038b6e7a0b - <rustc_hir_typeck[4fd8731c11591e1f]::upvar::InferBorrowKindVisitor as rustc_hir[640aa2bf9d482cc]::intravisit::Visitor>::visit_expr
  21:     0x71038e9b97c4 - <rustc_hir_typeck[4fd8731c11591e1f]::upvar::InferBorrowKindVisitor as rustc_hir[640aa2bf9d482cc]::intravisit::Visitor>::visit_block
  22:     0x71038e9bba9e - rustc_hir_typeck[4fd8731c11591e1f]::typeck
  23:     0x71038e9bb189 - rustc_query_impl[e4745a1b0909859d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e4745a1b0909859d]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[84100436d5b064b4]::query::erase::Erased<[u8; 8usize]>>
  24:     0x71038e9d3df1 - rustc_query_system[d932b23f04408b52]::query::plumbing::try_execute_query::<rustc_query_impl[e4745a1b0909859d]::DynamicConfig<rustc_query_system[d932b23f04408b52]::query::caches::VecCache<rustc_span[e30230202ad71cc6]::def_id::LocalDefId, rustc_middle[84100436d5b064b4]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[e4745a1b0909859d]::plumbing::QueryCtxt, false>
  25:     0x71038e9d270c - rustc_query_impl[e4745a1b0909859d]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  26:     0x71038e9d22d4 - <rustc_middle[84100436d5b064b4]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[65fee01cac67d305]::check_crate::{closure#4}>::{closure#0}
  27:     0x71038e9d0fa0 - rustc_hir_analysis[65fee01cac67d305]::check_crate
  28:     0x71038eb5fb96 - rustc_interface[98672636c24166f2]::passes::analysis
  29:     0x71038eb5f6dd - rustc_query_impl[e4745a1b0909859d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e4745a1b0909859d]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[84100436d5b064b4]::query::erase::Erased<[u8; 1usize]>>
  30:     0x71038f44b5e5 - rustc_query_system[d932b23f04408b52]::query::plumbing::try_execute_query::<rustc_query_impl[e4745a1b0909859d]::DynamicConfig<rustc_query_system[d932b23f04408b52]::query::caches::SingleCache<rustc_middle[84100436d5b064b4]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[e4745a1b0909859d]::plumbing::QueryCtxt, false>
  31:     0x71038f44b349 - rustc_query_impl[e4745a1b0909859d]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  32:     0x71038f2e6d93 - rustc_interface[98672636c24166f2]::interface::run_compiler::<core[52b5313fa7109ccf]::result::Result<(), rustc_span[e30230202ad71cc6]::ErrorGuaranteed>, rustc_driver_impl[3824f3c10e5e1962]::run_compiler::{closure#0}>::{closure#0}
  33:     0x71038f3bf45d - std[36b140a5e3846230]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[98672636c24166f2]::util::run_in_thread_with_globals<rustc_interface[98672636c24166f2]::util::run_in_thread_pool_with_globals<rustc_interface[98672636c24166f2]::interface::run_compiler<core[52b5313fa7109ccf]::result::Result<(), rustc_span[e30230202ad71cc6]::ErrorGuaranteed>, rustc_driver_impl[3824f3c10e5e1962]::run_compiler::{closure#0}>::{closure#0}, core[52b5313fa7109ccf]::result::Result<(), rustc_span[e30230202ad71cc6]::ErrorGuaranteed>>::{closure#0}, core[52b5313fa7109ccf]::result::Result<(), rustc_span[e30230202ad71cc6]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[52b5313fa7109ccf]::result::Result<(), rustc_span[e30230202ad71cc6]::ErrorGuaranteed>>
  34:     0x71038f3bf26a - <<std[36b140a5e3846230]::thread::Builder>::spawn_unchecked_<rustc_interface[98672636c24166f2]::util::run_in_thread_with_globals<rustc_interface[98672636c24166f2]::util::run_in_thread_pool_with_globals<rustc_interface[98672636c24166f2]::interface::run_compiler<core[52b5313fa7109ccf]::result::Result<(), rustc_span[e30230202ad71cc6]::ErrorGuaranteed>, rustc_driver_impl[3824f3c10e5e1962]::run_compiler::{closure#0}>::{closure#0}, core[52b5313fa7109ccf]::result::Result<(), rustc_span[e30230202ad71cc6]::ErrorGuaranteed>>::{closure#0}, core[52b5313fa7109ccf]::result::Result<(), rustc_span[e30230202ad71cc6]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[52b5313fa7109ccf]::result::Result<(), rustc_span[e30230202ad71cc6]::ErrorGuaranteed>>::{closure#1} as core[52b5313fa7109ccf]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  35:     0x7103909e297b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h64aa0f357081d070
                               at /rustc/aa6a697a1c75b0aa06954136f7641706edadc2be/library/alloc/src/boxed.rs:2018:9
  36:     0x7103909e297b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h1899233896b31bde
                               at /rustc/aa6a697a1c75b0aa06954136f7641706edadc2be/library/alloc/src/boxed.rs:2018:9
  37:     0x7103909e297b - std::sys::pal::unix::thread::Thread::new::thread_start::he3bcf1faa75389b7
                               at /rustc/aa6a697a1c75b0aa06954136f7641706edadc2be/library/std/src/sys/pal/unix/thread.rs:108:17
  38:     0x71039078055a - <unknown>
  39:     0x7103907fda3c - <unknown>
  40:                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.79.0-nightly (aa6a697a1 2024-04-11) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z dump-mir-dir=dir

query stack during panic:
#0 [typeck] type-checking `test`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 3 previous errors

Some errors have detailed explanations: E0412, E0601, E0658.
For more information about an error, try `rustc --explain E0412`.

Activity

  1. added
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    C-bugCategory: This is a bug.
    on Apr 11, 2024
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Apr 11, 2024
  3. matthiaskrgr commented on Apr 11, 2024

    @matthiaskrgr
    MemberAuthor

    @compiler-errors probably also caused by #123660 ?

  4. compiler-errors commented on Apr 11, 2024

    @compiler-errors
    Contributor

    yep ill put up a fix in a few

  5. removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Apr 12, 2024
  6. added a commit that references this issue on Apr 12, 2024
    1524fe0
  7. added a commit that references this issue on Apr 12, 2024
    f640ce0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions