Skip to content

ice: hir: no entry found for key #121096

Closed
@matthiaskrgr

Description

auto-reduced (treereduce-rust):

//

fn make_coroutine() {
    let _gen = || {
        foo(|()| {
            _ = v;
            v.set();
            v.get();

            use std::ops::Add;

            _ = v + v;
            _ = v.add(3);
        })
        .await
    };
}

original:

// edition:2018
//
// Tests that the .await syntax can't be used to make a coroutine

async fn foo() {}

fn make_coroutine() {
    let _gen = || foo(|(), this: &mut S| {
        //~^ error: cannot borrow `v` as mutable more than once at a time
        //~| error: cannot borrow `v` as mutable more than once at a time

        _ = v;
        v.set();
        v.get();
        S::get(&v);

        use std::ops::Add;
        let v = 0u32;
        _ = v + v;
        _ = v.add(3);
    }).await;
    //~^ ERROR `await` is only allowed inside `async` functions and blocks
}

fn main() {}

Version information

rustc 1.78.0-nightly (340bb19fe 2024-02-14)
binary: rustc
commit-hash: 340bb19fea20fd5f9357bbfac542fad84fc7ea2b
commit-date: 2024-02-14
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 18.1.0

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

Program output

error[E0425]: cannot find value `v` in this scope
 --> /tmp/icemaker_global_tempdir.ZlAaAHhG1LPA/rustc_testrunner_tmpdir_reporting.SHRRRgPMatEd/mvce.rs:6:17
  |
6 |             _ = v;
  |                 ^ not found in this scope

error[E0425]: cannot find value `v` in this scope
 --> /tmp/icemaker_global_tempdir.ZlAaAHhG1LPA/rustc_testrunner_tmpdir_reporting.SHRRRgPMatEd/mvce.rs:7:13
  |
7 |             v.set();
  |             ^ not found in this scope

error[E0425]: cannot find value `v` in this scope
 --> /tmp/icemaker_global_tempdir.ZlAaAHhG1LPA/rustc_testrunner_tmpdir_reporting.SHRRRgPMatEd/mvce.rs:8:13
  |
8 |             v.get();
  |             ^ not found in this scope

error[E0425]: cannot find value `v` in this scope
  --> /tmp/icemaker_global_tempdir.ZlAaAHhG1LPA/rustc_testrunner_tmpdir_reporting.SHRRRgPMatEd/mvce.rs:12:17
   |
12 |             _ = v + v;
   |                 ^ not found in this scope

error[E0425]: cannot find value `v` in this scope
  --> /tmp/icemaker_global_tempdir.ZlAaAHhG1LPA/rustc_testrunner_tmpdir_reporting.SHRRRgPMatEd/mvce.rs:12:21
   |
12 |             _ = v + v;
   |                     ^ not found in this scope

error[E0425]: cannot find value `v` in this scope
  --> /tmp/icemaker_global_tempdir.ZlAaAHhG1LPA/rustc_testrunner_tmpdir_reporting.SHRRRgPMatEd/mvce.rs:13:17
   |
13 |             _ = v.add(3);
   |                 ^ not found in this scope

error[E0728]: `await` is only allowed inside `async` functions and blocks
  --> /tmp/icemaker_global_tempdir.ZlAaAHhG1LPA/rustc_testrunner_tmpdir_reporting.SHRRRgPMatEd/mvce.rs:15:10
   |
4  |     let _gen = || {
   |                -- this is not `async`
...
15 |         .await
   |          ^^^^^ only allowed inside `async` functions and blocks

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

thread 'rustc' panicked at /rustc/340bb19fea20fd5f9357bbfac542fad84fc7ea2b/compiler/rustc_middle/src/hir/mod.rs:145:21:
no entry found for key
stack backtrace:
   0:     0x7f1970031e46 - std::backtrace_rs::backtrace::libunwind::trace::h741b35e6ebf0ea82
                               at /rustc/340bb19fea20fd5f9357bbfac542fad84fc7ea2b/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7f1970031e46 - std::backtrace_rs::backtrace::trace_unsynchronized::hf3b09a36cbdb818e
                               at /rustc/340bb19fea20fd5f9357bbfac542fad84fc7ea2b/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f1970031e46 - std::sys_common::backtrace::_print_fmt::hd9ddcb56e855ae1f
                               at /rustc/340bb19fea20fd5f9357bbfac542fad84fc7ea2b/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f1970031e46 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h1d659f3f1b376713
                               at /rustc/340bb19fea20fd5f9357bbfac542fad84fc7ea2b/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f197008246c - core::fmt::rt::Argument::fmt::h268aa39b6fb00372
                               at /rustc/340bb19fea20fd5f9357bbfac542fad84fc7ea2b/library/core/src/fmt/rt.rs:142:9
   5:     0x7f197008246c - core::fmt::write::h3ca4c8a121ee4a21
                               at /rustc/340bb19fea20fd5f9357bbfac542fad84fc7ea2b/library/core/src/fmt/mod.rs:1120:17
   6:     0x7f197002587f - std::io::Write::write_fmt::hbae5643614f30ef5
                               at /rustc/340bb19fea20fd5f9357bbfac542fad84fc7ea2b/library/std/src/io/mod.rs:1854:15
   7:     0x7f1970031bf4 - std::sys_common::backtrace::_print::h46251963e880a6db
                               at /rustc/340bb19fea20fd5f9357bbfac542fad84fc7ea2b/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f1970031bf4 - std::sys_common::backtrace::print::hf7d8eafd5758e700
                               at /rustc/340bb19fea20fd5f9357bbfac542fad84fc7ea2b/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f197003493b - std::panicking::default_hook::{{closure}}::h762f7d01310422ff
  10:     0x7f1970034689 - std::panicking::default_hook::h6bf045830ee7f539
                               at /rustc/340bb19fea20fd5f9357bbfac542fad84fc7ea2b/library/std/src/panicking.rs:292:9
  11:     0x7f196cdf2bac - std[3c399c9137e7035e]::panicking::update_hook::<alloc[b5118abce3d9b84a]::boxed::Box<rustc_driver_impl[aed52aad4ff697f9]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f19700350a0 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h183d4d6c4a9f8452
                               at /rustc/340bb19fea20fd5f9357bbfac542fad84fc7ea2b/library/alloc/src/boxed.rs:2030:9
  13:     0x7f19700350a0 - std::panicking::rust_panic_with_hook::hf47919d70d1ff480
                               at /rustc/340bb19fea20fd5f9357bbfac542fad84fc7ea2b/library/std/src/panicking.rs:785:13
  14:     0x7f1970034de2 - std::panicking::begin_panic_handler::{{closure}}::h5fbc7433175e9186
                               at /rustc/340bb19fea20fd5f9357bbfac542fad84fc7ea2b/library/std/src/panicking.rs:659:13
  15:     0x7f1970032326 - std::sys_common::backtrace::__rust_end_short_backtrace::h2b0c01029bb6a245
                               at /rustc/340bb19fea20fd5f9357bbfac542fad84fc7ea2b/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7f1970034b14 - rust_begin_unwind
                               at /rustc/340bb19fea20fd5f9357bbfac542fad84fc7ea2b/library/std/src/panicking.rs:647:5
  17:     0x7f197007e975 - core::panicking::panic_fmt::h213e6f8381440dd9
                               at /rustc/340bb19fea20fd5f9357bbfac542fad84fc7ea2b/library/core/src/panicking.rs:72:14
  18:     0x7f197007eb41 - core::panicking::panic_display::h03461d30bfcd1505
                               at /rustc/340bb19fea20fd5f9357bbfac542fad84fc7ea2b/library/core/src/panicking.rs:196:5
  19:     0x7f197007e72b - core::panicking::panic_str::h9622d848b193cb0e
                               at /rustc/340bb19fea20fd5f9357bbfac542fad84fc7ea2b/library/core/src/panicking.rs:171:5
  20:     0x7f197007e72b - core::option::expect_failed::hd19662daedbf5cba
                               at /rustc/340bb19fea20fd5f9357bbfac542fad84fc7ea2b/library/core/src/option.rs:1993:5
  21:     0x7f196e3af7bc - rustc_query_impl[2b06c656d5e1ef18]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[2b06c656d5e1ef18]::query_impl::hir_owner_parent::dynamic_query::{closure#2}::{closure#0}, rustc_middle[70484f9a8b697519]::query::erase::Erased<[u8; 8usize]>>
  22:     0x7f196e3ae323 - rustc_query_system[27a374b315d29eb0]::query::plumbing::try_execute_query::<rustc_query_impl[2b06c656d5e1ef18]::DynamicConfig<rustc_query_system[27a374b315d29eb0]::query::caches::VecCache<rustc_hir[10d9dc25b96155c6]::hir_id::OwnerId, rustc_middle[70484f9a8b697519]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[2b06c656d5e1ef18]::plumbing::QueryCtxt, false>
  23:     0x7f196e3adfcc - rustc_query_impl[2b06c656d5e1ef18]::query_impl::hir_owner_parent::get_query_non_incr::__rust_end_short_backtrace
  24:     0x7f196e3aa850 - <rustc_middle[70484f9a8b697519]::lint::ShallowLintLevelMap>::lint_level_id_at_node
  25:     0x7f196e3a9f43 - <rustc_middle[70484f9a8b697519]::ty::context::TyCtxt>::lint_level_at_node
  26:     0x7f196e1870e6 - rustc_hir_analysis[9039da227dcdab28]::check_unused::check_unused_traits
  27:     0x7f196e186a33 - rustc_query_impl[2b06c656d5e1ef18]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[2b06c656d5e1ef18]::query_impl::check_unused_traits::dynamic_query::{closure#2}::{closure#0}, rustc_middle[70484f9a8b697519]::query::erase::Erased<[u8; 0usize]>>
  28:     0x7f196ee186e5 - rustc_query_system[27a374b315d29eb0]::query::plumbing::try_execute_query::<rustc_query_impl[2b06c656d5e1ef18]::DynamicConfig<rustc_query_system[27a374b315d29eb0]::query::caches::SingleCache<rustc_middle[70484f9a8b697519]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[2b06c656d5e1ef18]::plumbing::QueryCtxt, false>
  29:     0x7f196ee1844f - rustc_query_impl[2b06c656d5e1ef18]::query_impl::check_unused_traits::get_query_non_incr::__rust_end_short_backtrace
  30:     0x7f196e18379f - rustc_hir_analysis[9039da227dcdab28]::check_crate
  31:     0x7f196ea13593 - rustc_interface[85a46e65fd36dd64]::passes::analysis
  32:     0x7f196ea131e9 - rustc_query_impl[2b06c656d5e1ef18]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[2b06c656d5e1ef18]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[70484f9a8b697519]::query::erase::Erased<[u8; 1usize]>>
  33:     0x7f196efb0025 - rustc_query_system[27a374b315d29eb0]::query::plumbing::try_execute_query::<rustc_query_impl[2b06c656d5e1ef18]::DynamicConfig<rustc_query_system[27a374b315d29eb0]::query::caches::SingleCache<rustc_middle[70484f9a8b697519]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[2b06c656d5e1ef18]::plumbing::QueryCtxt, false>
  34:     0x7f196efafd89 - rustc_query_impl[2b06c656d5e1ef18]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  35:     0x7f196ee2e055 - rustc_interface[85a46e65fd36dd64]::interface::run_compiler::<core[7e3aa1eb1ad3b865]::result::Result<(), rustc_span[193b94924c128396]::ErrorGuaranteed>, rustc_driver_impl[aed52aad4ff697f9]::run_compiler::{closure#0}>::{closure#0}
  36:     0x7f196efc7b58 - std[3c399c9137e7035e]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[85a46e65fd36dd64]::util::run_in_thread_with_globals<rustc_interface[85a46e65fd36dd64]::util::run_in_thread_pool_with_globals<rustc_interface[85a46e65fd36dd64]::interface::run_compiler<core[7e3aa1eb1ad3b865]::result::Result<(), rustc_span[193b94924c128396]::ErrorGuaranteed>, rustc_driver_impl[aed52aad4ff697f9]::run_compiler::{closure#0}>::{closure#0}, core[7e3aa1eb1ad3b865]::result::Result<(), rustc_span[193b94924c128396]::ErrorGuaranteed>>::{closure#0}, core[7e3aa1eb1ad3b865]::result::Result<(), rustc_span[193b94924c128396]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[7e3aa1eb1ad3b865]::result::Result<(), rustc_span[193b94924c128396]::ErrorGuaranteed>>
  37:     0x7f196efc7984 - <<std[3c399c9137e7035e]::thread::Builder>::spawn_unchecked_<rustc_interface[85a46e65fd36dd64]::util::run_in_thread_with_globals<rustc_interface[85a46e65fd36dd64]::util::run_in_thread_pool_with_globals<rustc_interface[85a46e65fd36dd64]::interface::run_compiler<core[7e3aa1eb1ad3b865]::result::Result<(), rustc_span[193b94924c128396]::ErrorGuaranteed>, rustc_driver_impl[aed52aad4ff697f9]::run_compiler::{closure#0}>::{closure#0}, core[7e3aa1eb1ad3b865]::result::Result<(), rustc_span[193b94924c128396]::ErrorGuaranteed>>::{closure#0}, core[7e3aa1eb1ad3b865]::result::Result<(), rustc_span[193b94924c128396]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[7e3aa1eb1ad3b865]::result::Result<(), rustc_span[193b94924c128396]::ErrorGuaranteed>>::{closure#1} as core[7e3aa1eb1ad3b865]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  38:     0x7f197003e1e5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h1516af221a452bc1
                               at /rustc/340bb19fea20fd5f9357bbfac542fad84fc7ea2b/library/alloc/src/boxed.rs:2016:9
  39:     0x7f197003e1e5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hff2a9d52ad89d581
                               at /rustc/340bb19fea20fd5f9357bbfac542fad84fc7ea2b/library/alloc/src/boxed.rs:2016:9
  40:     0x7f197003e1e5 - std::sys::pal::unix::thread::Thread::new::thread_start::hf359248e8c5b2b25
                               at /rustc/340bb19fea20fd5f9357bbfac542fad84fc7ea2b/library/std/src/sys/pal/unix/thread.rs:108:17
  41:     0x7f1969eaa9eb - <unknown>
  42:     0x7f1969f2e7cc - <unknown>
  43:                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: rustc 1.78.0-nightly (340bb19fe 2024-02-14) running on x86_64-unknown-linux-gnu

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

query stack during panic:
#0 [hir_owner_parent] getting HIR parent of `make_coroutine::{closure#0}::{closure#0}::{use#0}`
#1 [check_unused_traits] checking unused trait imports in crate
#2 [analysis] running analysis passes on this crate
end of query stack
error[E0425]: cannot find function `foo` in this scope
 --> /tmp/icemaker_global_tempdir.ZlAaAHhG1LPA/rustc_testrunner_tmpdir_reporting.SHRRRgPMatEd/mvce.rs:5:9
  |
5 |         foo(|()| {
  |         ^^^ not found in this scope

error: aborting due to 9 previous errors

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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