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

ICE: no enclosing_body_owner for hir_id #129215

Closed
matthiaskrgr opened this issue Aug 17, 2024 · 1 comment · Fixed by #129223
Closed

ICE: no enclosing_body_owner for hir_id #129215

matthiaskrgr opened this issue Aug 17, 2024 · 1 comment · Fixed by #129223
Labels
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.

Comments

@matthiaskrgr
Copy link
Member

auto-reduced (treereduce-rust):

async const fn recurse(n: u32) -> u32 {
    if n == 0 {
        n
    } else {
        recurse(n - 1) 
    }
}




original:

//@ check-fail
//@ compile-flags: -Z tiny-const-eval-limit

#[rustfmt::skip]
async const fn recurse(n: u32) -> u32 {
    if n == 0 {
        n
    } else {
        recurse(n - 1) //~ ERROR is taking a long time
    }
}

const X: u32 = recurse(19);

fn main() {
    println!("{X}");
}

Version information

rustc 1.82.0-nightly (0f26ee4fd 2024-08-17)
binary: rustc
commit-hash: 0f26ee4fd95a1c046582dfb18892f520788e2c2c
commit-date: 2024-08-17
host: x86_64-unknown-linux-gnu
release: 1.82.0-nightly
LLVM version: 19.1.0

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

error[E0670]: `async fn` is not permitted in Rust 2015
 --> /tmp/icemaker_global_tempdir.aymIy9D67iB8/rustc_testrunner_tmpdir_reporting.mSQaM7ZX8tt3/mvce.rs:5:1
  |
5 | async const fn recurse(n: u32) -> u32 {
  | ^^^^^ to use `async fn`, switch to Rust 2018 or later
  |
  = help: pass `--edition 2021` to `rustc`
  = note: for more on editions, read https://doc.rust-lang.org/edition-guide

error: expected one of `extern`, `fn`, `safe`, or `unsafe`, found keyword `const`
 --> /tmp/icemaker_global_tempdir.aymIy9D67iB8/rustc_testrunner_tmpdir_reporting.mSQaM7ZX8tt3/mvce.rs:5:7
  |
5 | async const fn recurse(n: u32) -> u32 {
  | ------^^^^^
  | |     |
  | |     expected one of `extern`, `fn`, `safe`, or `unsafe`
  | help: `const` must come before `async`: `const async`
  |
  = note: keyword order for functions declaration is `pub`, `default`, `const`, `async`, `unsafe`, `extern`

error: functions cannot be both `const` and `async`
  --> /tmp/icemaker_global_tempdir.aymIy9D67iB8/rustc_testrunner_tmpdir_reporting.mSQaM7ZX8tt3/mvce.rs:5:1
   |
5  |   async const fn recurse(n: u32) -> u32 {
   |   -^^^^ ^^^^^ `const` because of this
   |   |
   |  _`async` because of this
   | |
6  | |     if n == 0 {
7  | |         n
8  | |     } else {
9  | |         recurse(n - 1) 
10 | |     }
11 | | }
   | |_-

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

error[E0277]: `u32` is not a future
 --> /tmp/icemaker_global_tempdir.aymIy9D67iB8/rustc_testrunner_tmpdir_reporting.mSQaM7ZX8tt3/mvce.rs:9:9
  |
9 |         recurse(n - 1) 
  |         ^^^^^^^^^^^^^^ `u32` is not a future
  |
  = help: the trait `Future` is not implemented for `u32`

error[E0277]: `u32` is not a future
 --> /tmp/icemaker_global_tempdir.aymIy9D67iB8/rustc_testrunner_tmpdir_reporting.mSQaM7ZX8tt3/mvce.rs:5:1
  |
5 | async const fn recurse(n: u32) -> u32 {
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `u32` is not a future
  |
  = help: the trait `Future` is not implemented for `u32`

error: internal compiler error: compiler/rustc_middle/src/hir/map/mod.rs:557:73: no `enclosing_body_owner` for hir_id `HirId(DefId(0:3 ~ mvce[5918]::recurse).0)`

thread 'rustc' panicked at compiler/rustc_middle/src/hir/map/mod.rs:557:73:
Box<dyn Any>
stack backtrace:
   0:     0x72af1cfc429d - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hce35dec2bed7e8e1
   1:     0x72af1d805297 - core::fmt::write::haaf8a728f3019c12
   2:     0x72af1eabbd91 - std::io::Write::write_fmt::hb0dc5188703aea0d
   3:     0x72af1cfc697b - std::panicking::default_hook::{{closure}}::h35c501ae74c82675
   4:     0x72af1cfc65ee - std::panicking::default_hook::hc1ddd62643c4c855
   5:     0x72af1c158729 - std[54b021f941472252]::panicking::update_hook::<alloc[8840b3d3a55bb7af]::boxed::Box<rustc_driver_impl[ec4d44b725e7aa11]::install_ice_hook::{closure#0}>>::{closure#0}
   6:     0x72af1cfc7297 - std::panicking::rust_panic_with_hook::h7960ad04eaeb646d
   7:     0x72af1c193111 - std[54b021f941472252]::panicking::begin_panic::<rustc_errors[2e519a482e3c741a]::ExplicitBug>::{closure#0}
   8:     0x72af1c186156 - std[54b021f941472252]::sys::backtrace::__rust_end_short_backtrace::<std[54b021f941472252]::panicking::begin_panic<rustc_errors[2e519a482e3c741a]::ExplicitBug>::{closure#0}, !>
   9:     0x72af1c181536 - std[54b021f941472252]::panicking::begin_panic::<rustc_errors[2e519a482e3c741a]::ExplicitBug>
  10:     0x72af1c19c0f1 - <rustc_errors[2e519a482e3c741a]::diagnostic::BugAbort as rustc_errors[2e519a482e3c741a]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x72af1c75f6c4 - rustc_middle[10ec7aec7d9fdda3]::util::bug::opt_span_bug_fmt::<rustc_span[a5a4c6b08f7cf6f]::span_encoding::Span>::{closure#0}
  12:     0x72af1c7452da - rustc_middle[10ec7aec7d9fdda3]::ty::context::tls::with_opt::<rustc_middle[10ec7aec7d9fdda3]::util::bug::opt_span_bug_fmt<rustc_span[a5a4c6b08f7cf6f]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  13:     0x72af1c74516b - rustc_middle[10ec7aec7d9fdda3]::ty::context::tls::with_context_opt::<rustc_middle[10ec7aec7d9fdda3]::ty::context::tls::with_opt<rustc_middle[10ec7aec7d9fdda3]::util::bug::opt_span_bug_fmt<rustc_span[a5a4c6b08f7cf6f]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  14:     0x72af1a250ac0 - rustc_middle[10ec7aec7d9fdda3]::util::bug::bug_fmt
  15:     0x72af1d98bc34 - <rustc_middle[10ec7aec7d9fdda3]::hir::map::Map>::enclosing_body_owner
  16:     0x72af1d98c3fe - <rustc_middle[10ec7aec7d9fdda3]::hir::map::Map>::get_fn_id_for_return_block
  17:     0x72af1e7c42e4 - <rustc_hir_typeck[cd6451a3b3fe12c4]::fn_ctxt::FnCtxt>::get_fn_decl
  18:     0x72af1c42d09d - <rustc_hir_typeck[cd6451a3b3fe12c4]::coercion::CoerceMany<rustc_hir[9989108a6ccf70c1]::hir::Expr>>::report_return_mismatched_types
  19:     0x72af1da44f52 - rustc_hir_typeck[cd6451a3b3fe12c4]::check::check_fn
  20:     0x72af1dffbf1f - rustc_hir_typeck[cd6451a3b3fe12c4]::typeck
  21:     0x72af1dffb975 - rustc_query_impl[69287ea093d06d1d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[69287ea093d06d1d]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[10ec7aec7d9fdda3]::query::erase::Erased<[u8; 8usize]>>
  22:     0x72af1dad4bf9 - rustc_query_system[1449707d44461b06]::query::plumbing::try_execute_query::<rustc_query_impl[69287ea093d06d1d]::DynamicConfig<rustc_query_system[1449707d44461b06]::query::caches::VecCache<rustc_span[a5a4c6b08f7cf6f]::def_id::LocalDefId, rustc_middle[10ec7aec7d9fdda3]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[69287ea093d06d1d]::plumbing::QueryCtxt, false>
  23:     0x72af1dad3e15 - rustc_query_impl[69287ea093d06d1d]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  24:     0x72af1e050233 - rustc_middle[10ec7aec7d9fdda3]::query::plumbing::query_get_at::<rustc_query_system[1449707d44461b06]::query::caches::VecCache<rustc_span[a5a4c6b08f7cf6f]::def_id::LocalDefId, rustc_middle[10ec7aec7d9fdda3]::query::erase::Erased<[u8; 8usize]>>>
  25:     0x72af1e6d4a2d - rustc_hir_analysis[c0d9d1e917b71b24]::collect::type_of::type_of_opaque
  26:     0x72af1e6d4965 - rustc_query_impl[69287ea093d06d1d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[69287ea093d06d1d]::query_impl::type_of_opaque::dynamic_query::{closure#2}::{closure#0}, rustc_middle[10ec7aec7d9fdda3]::query::erase::Erased<[u8; 8usize]>>
  27:     0x72af1d825ea7 - rustc_query_system[1449707d44461b06]::query::plumbing::try_execute_query::<rustc_query_impl[69287ea093d06d1d]::DynamicConfig<rustc_query_system[1449707d44461b06]::query::caches::DefIdCache<rustc_middle[10ec7aec7d9fdda3]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[69287ea093d06d1d]::plumbing::QueryCtxt, false>
  28:     0x72af1ea3b276 - rustc_query_impl[69287ea093d06d1d]::query_impl::type_of_opaque::get_query_non_incr::__rust_end_short_backtrace
  29:     0x72af1df545c0 - rustc_middle[10ec7aec7d9fdda3]::query::plumbing::query_get_at::<rustc_query_system[1449707d44461b06]::query::caches::DefIdCache<rustc_middle[10ec7aec7d9fdda3]::query::erase::Erased<[u8; 8usize]>>>
  30:     0x72af1ae7e80b - rustc_hir_analysis[c0d9d1e917b71b24]::collect::type_of::type_of
  31:     0x72af1d8271f0 - rustc_query_impl[69287ea093d06d1d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[69287ea093d06d1d]::query_impl::type_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[10ec7aec7d9fdda3]::query::erase::Erased<[u8; 8usize]>>
  32:     0x72af1d825ea7 - rustc_query_system[1449707d44461b06]::query::plumbing::try_execute_query::<rustc_query_impl[69287ea093d06d1d]::DynamicConfig<rustc_query_system[1449707d44461b06]::query::caches::DefIdCache<rustc_middle[10ec7aec7d9fdda3]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[69287ea093d06d1d]::plumbing::QueryCtxt, false>
  33:     0x72af1d825a67 - rustc_query_impl[69287ea093d06d1d]::query_impl::type_of::get_query_non_incr::__rust_end_short_backtrace
  34:     0x72af1df545c0 - rustc_middle[10ec7aec7d9fdda3]::query::plumbing::query_get_at::<rustc_query_system[1449707d44461b06]::query::caches::DefIdCache<rustc_middle[10ec7aec7d9fdda3]::query::erase::Erased<[u8; 8usize]>>>
  35:     0x72af1ae6a096 - rustc_hir_analysis[c0d9d1e917b71b24]::check::wfcheck::check_well_formed
  36:     0x72af1db9e287 - rustc_query_impl[69287ea093d06d1d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[69287ea093d06d1d]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[10ec7aec7d9fdda3]::query::erase::Erased<[u8; 1usize]>>
  37:     0x72af1db9e505 - rustc_query_system[1449707d44461b06]::query::plumbing::try_execute_query::<rustc_query_impl[69287ea093d06d1d]::DynamicConfig<rustc_query_system[1449707d44461b06]::query::caches::VecCache<rustc_hir[9989108a6ccf70c1]::hir_id::OwnerId, rustc_middle[10ec7aec7d9fdda3]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[69287ea093d06d1d]::plumbing::QueryCtxt, false>
  38:     0x72af1db9e262 - rustc_query_impl[69287ea093d06d1d]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  39:     0x72af1db9f03f - rustc_hir_analysis[c0d9d1e917b71b24]::check::wfcheck::check_mod_type_wf
  40:     0x72af1db9ee6d - rustc_query_impl[69287ea093d06d1d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[69287ea093d06d1d]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[10ec7aec7d9fdda3]::query::erase::Erased<[u8; 1usize]>>
  41:     0x72af1e75eb3b - rustc_query_system[1449707d44461b06]::query::plumbing::try_execute_query::<rustc_query_impl[69287ea093d06d1d]::DynamicConfig<rustc_query_system[1449707d44461b06]::query::caches::DefaultCache<rustc_span[a5a4c6b08f7cf6f]::def_id::LocalModDefId, rustc_middle[10ec7aec7d9fdda3]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[69287ea093d06d1d]::plumbing::QueryCtxt, false>
  42:     0x72af1e75e8ed - rustc_query_impl[69287ea093d06d1d]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
  43:     0x72af1dad143b - rustc_hir_analysis[c0d9d1e917b71b24]::check_crate
  44:     0x72af1df84cbf - rustc_interface[f40e7651e6b02ea1]::passes::run_required_analyses
  45:     0x72af1e35c49e - rustc_interface[f40e7651e6b02ea1]::passes::analysis
  46:     0x72af1e35c471 - rustc_query_impl[69287ea093d06d1d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[69287ea093d06d1d]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[10ec7aec7d9fdda3]::query::erase::Erased<[u8; 1usize]>>
  47:     0x72af1e7867ee - rustc_query_system[1449707d44461b06]::query::plumbing::try_execute_query::<rustc_query_impl[69287ea093d06d1d]::DynamicConfig<rustc_query_system[1449707d44461b06]::query::caches::SingleCache<rustc_middle[10ec7aec7d9fdda3]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[69287ea093d06d1d]::plumbing::QueryCtxt, false>
  48:     0x72af1e78654f - rustc_query_impl[69287ea093d06d1d]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  49:     0x72af1e5d38ea - rustc_interface[f40e7651e6b02ea1]::interface::run_compiler::<core[5070cb7ec77c977]::result::Result<(), rustc_span[a5a4c6b08f7cf6f]::ErrorGuaranteed>, rustc_driver_impl[ec4d44b725e7aa11]::run_compiler::{closure#0}>::{closure#1}
  50:     0x72af1e5b3210 - std[54b021f941472252]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[f40e7651e6b02ea1]::util::run_in_thread_with_globals<rustc_interface[f40e7651e6b02ea1]::util::run_in_thread_pool_with_globals<rustc_interface[f40e7651e6b02ea1]::interface::run_compiler<core[5070cb7ec77c977]::result::Result<(), rustc_span[a5a4c6b08f7cf6f]::ErrorGuaranteed>, rustc_driver_impl[ec4d44b725e7aa11]::run_compiler::{closure#0}>::{closure#1}, core[5070cb7ec77c977]::result::Result<(), rustc_span[a5a4c6b08f7cf6f]::ErrorGuaranteed>>::{closure#0}, core[5070cb7ec77c977]::result::Result<(), rustc_span[a5a4c6b08f7cf6f]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[5070cb7ec77c977]::result::Result<(), rustc_span[a5a4c6b08f7cf6f]::ErrorGuaranteed>>
  51:     0x72af1e5b387a - <<std[54b021f941472252]::thread::Builder>::spawn_unchecked_<rustc_interface[f40e7651e6b02ea1]::util::run_in_thread_with_globals<rustc_interface[f40e7651e6b02ea1]::util::run_in_thread_pool_with_globals<rustc_interface[f40e7651e6b02ea1]::interface::run_compiler<core[5070cb7ec77c977]::result::Result<(), rustc_span[a5a4c6b08f7cf6f]::ErrorGuaranteed>, rustc_driver_impl[ec4d44b725e7aa11]::run_compiler::{closure#0}>::{closure#1}, core[5070cb7ec77c977]::result::Result<(), rustc_span[a5a4c6b08f7cf6f]::ErrorGuaranteed>>::{closure#0}, core[5070cb7ec77c977]::result::Result<(), rustc_span[a5a4c6b08f7cf6f]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[5070cb7ec77c977]::result::Result<(), rustc_span[a5a4c6b08f7cf6f]::ErrorGuaranteed>>::{closure#1} as core[5070cb7ec77c977]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  52:     0x72af1e5b3beb - std::sys::pal::unix::thread::Thread::new::thread_start::he8fde62ed04f9a93
  53:     0x72af1fe0a39d - <unknown>
  54:     0x72af1fe8f49c - <unknown>
  55:                0x0 - <unknown>

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.82.0-nightly (0f26ee4fd 2024-08-17) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [typeck] type-checking `recurse`
#1 [type_of_opaque] computing type of opaque `recurse::{opaque#0}`
end of query stack
error: aborting due to 7 previous errors

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

@matthiaskrgr matthiaskrgr added 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. C-bug Category: This is a bug. labels Aug 17, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 17, 2024
@matthiaskrgr
Copy link
Member Author

mvce 😄

async fn a() {
    a()
}

@bors bors closed this as completed in 5ba877c Aug 19, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Aug 19, 2024
Rollup merge of rust-lang#129223 - wafarm:fix-129215, r=compiler-errors

 Fix wrong argument for `get_fn_decl`

Closes rust-lang#129215 (seems to be introduced in rust-lang#129168)
@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 20, 2024
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) ❄️ 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.

3 participants