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: non-FnLike node found: with feature(async_closure) #128764

Closed
Naserume opened this issue Aug 7, 2024 · 0 comments · Fixed by #128792
Closed

ICE: non-FnLike node found: with feature(async_closure) #128764

Naserume opened this issue Aug 7, 2024 · 0 comments · Fixed by #128792
Assignees
Labels
C-bug Category: This is a bug. F-async_closure `#![feature(async_closure)]` 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

@Naserume
Copy link

Naserume commented Aug 7, 2024

Code

#![feature(async_closure)]

extern "C" {
    pub fn f();
}

async fn func<F>(f: F)
where
    F: for<'a> async Fn(&'a i32),
{}

fn main() {
    async {
        func(f);
    };
}

command: rustc ./file.rs --edition=2021

Meta

rustc --version --verbose:

rustc 1.82.0-nightly (60d146580 2024-08-06)
binary: rustc
commit-hash: 60d146580c10036ce89e019422c6bc2fd9729b65
commit-date: 2024-08-06
host: x86_64-apple-darwin
release: 1.82.0-nightly
LLVM version: 19.1.0

Error output

warning: unused variable: `f`
 --> ./AD23F.rs:7:18
  |
7 | async fn func<F>(f: F)
  |                  ^ help: if this is intentional, prefix it with an underscore: `_f`
  |
  = note: `#[warn(unused_variables)]` on by default
Backtrace

thread 'rustc' panicked at compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs:2678:18:
non-FnLike node found: ForeignItem(ForeignItem { ident: f#0, kind: Fn(FnDecl { inputs: [], output: DefaultReturn(./AD23F.rs:4:15: 4:15 (#0)), c_variadic: false, implicit_self: None, lifetime_elision_allowed: false }, [], Generics { params: [], predicates: [], has_where_clause_predicates: false, where_clause_span: ./AD23F.rs:4:15: 4:15 (#0), span: ./AD23F.rs:4:13: 4:13 (#0) }, Unsafe), owner_id: DefId(0:4 ~ AD23F[da9d]::{extern#0}::f), span: ./AD23F.rs:4:5: 4:16 (#0), vis_span: ./AD23F.rs:4:5: 4:8 (#0) })
stack backtrace:
   0:        0x10f3f3eb7 - std::backtrace::Backtrace::create::hab0b2157d02f6e92
   1:        0x10f3f3e05 - std::backtrace::Backtrace::force_capture::h20bc09614659a271
   2:        0x118a6f2b4 - std[513de39480af1bab]::panicking::update_hook::<alloc[88fbee91b568d05e]::boxed::Box<rustc_driver_impl[1a7a7dac5035a0ee]::install_ice_hook::{closure#0}>>::{closure#0}
   3:        0x10f40ded0 - std::panicking::rust_panic_with_hook::h68d7251319b974a6
   4:        0x10f40d755 - std::panicking::begin_panic_handler::{{closure}}::ha88851b9fb268d98
   5:        0x10f40acd9 - std::sys::backtrace::__rust_end_short_backtrace::h5540b8654da0543b
   6:        0x10f40d39c - _rust_begin_unwind
   7:        0x10f474aea - core::panicking::panic_fmt::h6a779485efe923d2
   8:        0x11a776104 - <rustc_trait_selection[5bb84c7d8ad5df26]::error_reporting::TypeErrCtxt>::get_fn_like_arguments
   9:        0x11a771b73 - <rustc_trait_selection[5bb84c7d8ad5df26]::error_reporting::TypeErrCtxt>::report_signature_mismatch_error
  10:        0x11a75c072 - <rustc_trait_selection[5bb84c7d8ad5df26]::error_reporting::TypeErrCtxt>::report_selection_error
  11:        0x11a821fc7 - <rustc_trait_selection[5bb84c7d8ad5df26]::error_reporting::TypeErrCtxt>::report_fulfillment_error
  12:        0x11a7b0550 - <rustc_trait_selection[5bb84c7d8ad5df26]::error_reporting::TypeErrCtxt>::report_fulfillment_errors
  13:        0x1190a460d - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_argument_types
  14:        0x119043e5d - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::confirm_builtin_call
  15:        0x1191549ab - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_expr_kind
  16:        0x11906f684 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  17:        0x1190b341e - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_block_with_expected
  18:        0x11906f684 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  19:        0x1190718b3 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_return_expr
  20:        0x119136ccc - rustc_hir_typeck[d66b43df352b27be]::check::check_fn
  21:        0x11915ad2c - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_expr_kind
  22:        0x11906f684 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  23:        0x1190b341e - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_block_with_expected
  24:        0x11906f684 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  25:        0x1190718b3 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_return_expr
  26:        0x119136ccc - rustc_hir_typeck[d66b43df352b27be]::check::check_fn
  27:        0x1191317e8 - rustc_hir_typeck[d66b43df352b27be]::typeck
  28:        0x11a119e5c - rustc_query_impl[db7d5818ebb544c0]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[db7d5818ebb544c0]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ef4ebef1f35b9a45]::query::erase::Erased<[u8; 8usize]>>
  29:        0x119f8ed4e - rustc_query_system[9c8bd583e072577f]::query::plumbing::try_execute_query::<rustc_query_impl[db7d5818ebb544c0]::DynamicConfig<rustc_query_system[9c8bd583e072577f]::query::caches::VecCache<rustc_hir[53162fccad4b280c]::hir_id::OwnerId, rustc_middle[ef4ebef1f35b9a45]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[db7d5818ebb544c0]::plumbing::QueryCtxt, false>
  30:        0x11a13dde1 - rustc_query_impl[db7d5818ebb544c0]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  31:        0x118d081a6 - <rustc_middle[ef4ebef1f35b9a45]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[540b4a187aa4fa02]::check_crate::{closure#4}>::{closure#0}
  32:        0x118e70d1c - rustc_hir_analysis[540b4a187aa4fa02]::check_crate
  33:        0x1193b2f98 - rustc_interface[55f0bb586236ba3f]::passes::run_required_analyses
  34:        0x1193b5463 - rustc_interface[55f0bb586236ba3f]::passes::analysis
  35:        0x11a119f0c - rustc_query_impl[db7d5818ebb544c0]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[db7d5818ebb544c0]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ef4ebef1f35b9a45]::query::erase::Erased<[u8; 1usize]>>
  36:        0x119ef8d8e - rustc_query_system[9c8bd583e072577f]::query::plumbing::try_execute_query::<rustc_query_impl[db7d5818ebb544c0]::DynamicConfig<rustc_query_system[9c8bd583e072577f]::query::caches::SingleCache<rustc_middle[ef4ebef1f35b9a45]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[db7d5818ebb544c0]::plumbing::QueryCtxt, false>
  37:        0x11a12445d - rustc_query_impl[db7d5818ebb544c0]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  38:        0x118a19c67 - <rustc_interface[55f0bb586236ba3f]::queries::QueryResult<&rustc_middle[ef4ebef1f35b9a45]::ty::context::GlobalCtxt>>::enter::<core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>, rustc_driver_impl[1a7a7dac5035a0ee]::run_compiler::{closure#0}::{closure#1}::{closure#5}>
  39:        0x118a765a9 - rustc_interface[55f0bb586236ba3f]::interface::run_compiler::<core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>, rustc_driver_impl[1a7a7dac5035a0ee]::run_compiler::{closure#0}>::{closure#1}
  40:        0x118a619c1 - std[513de39480af1bab]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[55f0bb586236ba3f]::util::run_in_thread_with_globals<rustc_interface[55f0bb586236ba3f]::util::run_in_thread_pool_with_globals<rustc_interface[55f0bb586236ba3f]::interface::run_compiler<core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>, rustc_driver_impl[1a7a7dac5035a0ee]::run_compiler::{closure#0}>::{closure#1}, core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>>::{closure#0}, core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>>
  41:        0x118a78a06 - <<std[513de39480af1bab]::thread::Builder>::spawn_unchecked_<rustc_interface[55f0bb586236ba3f]::util::run_in_thread_with_globals<rustc_interface[55f0bb586236ba3f]::util::run_in_thread_pool_with_globals<rustc_interface[55f0bb586236ba3f]::interface::run_compiler<core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>, rustc_driver_impl[1a7a7dac5035a0ee]::run_compiler::{closure#0}>::{closure#1}, core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>>::{closure#0}, core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>>::{closure#1} as core[31c80208252ed77d]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  42:        0x10f416afb - std::sys::pal::unix::thread::Thread::new::thread_start::h38612934f7248e43
  43:     0x7ff801f5318b - __pthread_start


rustc version: 1.82.0-nightly (60d146580 2024-08-06)
platform: x86_64-apple-darwin

query stack during panic:
#0 [typeck] type-checking `main`
#1 [analysis] running analysis passes on this crate
end of query stack

Note

ICE location:

Node::Ctor(variant_data) => {
let span = variant_data.ctor_hir_id().map_or(DUMMY_SP, |id| hir.span(id));
(span, None, vec![ArgKind::empty(); variant_data.fields().len()])
}
_ => panic!("non-FnLike node found: {node:?}"),
})

@rustbot label +F-async_closure

@Naserume Naserume 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 Aug 7, 2024
@rustbot rustbot added needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. F-async_closure `#![feature(async_closure)]` labels Aug 7, 2024
@compiler-errors compiler-errors self-assigned this Aug 7, 2024
bors added a commit to rust-lang-ci/rust that referenced this issue Aug 7, 2024
Use `FnSig` instead of raw `FnDecl` for `ForeignItemKind::Fn`, fix ICE for `Fn` trait error on safe foreign fn

Let's use `hir::FnSig` instead of `hir::FnDecl + hir::Safety` for `ForeignItemKind::Fn`. This consolidates some handling code between normal fns and foreign fns.

Separetly, fix an ICE where we weren't handling `Fn` trait errors for safe foreign fns.

If perf is bad for the first commit, I can rework the ICE fix to not rely on it. But if perf is good, I prefer we fix and clean up things all at once 👍

r? spastorino

Fixes rust-lang#128764
bors added a commit to rust-lang-ci/rust that referenced this issue Aug 7, 2024
Use `FnSig` instead of raw `FnDecl` for `ForeignItemKind::Fn`, fix ICE for `Fn` trait error on safe foreign fn

Let's use `hir::FnSig` instead of `hir::FnDecl + hir::Safety` for `ForeignItemKind::Fn`. This consolidates some handling code between normal fns and foreign fns.

Separetly, fix an ICE where we weren't handling `Fn` trait errors for safe foreign fns.

If perf is bad for the first commit, I can rework the ICE fix to not rely on it. But if perf is good, I prefer we fix and clean up things all at once 👍

r? spastorino

Fixes rust-lang#128764
bors added a commit to rust-lang-ci/rust that referenced this issue Aug 8, 2024
…orino

Use `FnSig` instead of raw `FnDecl` for `ForeignItemKind::Fn`, fix ICE for `Fn` trait error on safe foreign fn

Let's use `hir::FnSig` instead of `hir::FnDecl + hir::Safety` for `ForeignItemKind::Fn`. This consolidates some handling code between normal fns and foreign fns.

Separetly, fix an ICE where we weren't handling `Fn` trait errors for safe foreign fns.

If perf is bad for the first commit, I can rework the ICE fix to not rely on it. But if perf is good, I prefer we fix and clean up things all at once 👍

r? spastorino

Fixes rust-lang#128764
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Aug 8, 2024
…=lcnr

Don't implement `AsyncFn` for `FnDef`/`FnPtr` that wouldnt implement `Fn`

Due to unsafety, ABI, or the presence of target features, some `FnDef`/`FnPtr` types don't implement `Fn*`. Do the same for `AsyncFn*`.

Noticed this due to rust-lang#128764, but this isn't really related to that ICE, which is fixed in rust-lang#128792.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Aug 8, 2024
…=lcnr

Don't implement `AsyncFn` for `FnDef`/`FnPtr` that wouldnt implement `Fn`

Due to unsafety, ABI, or the presence of target features, some `FnDef`/`FnPtr` types don't implement `Fn*`. Do the same for `AsyncFn*`.

Noticed this due to rust-lang#128764, but this isn't really related to that ICE, which is fixed in rust-lang#128792.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Aug 8, 2024
…=lcnr

Don't implement `AsyncFn` for `FnDef`/`FnPtr` that wouldnt implement `Fn`

Due to unsafety, ABI, or the presence of target features, some `FnDef`/`FnPtr` types don't implement `Fn*`. Do the same for `AsyncFn*`.

Noticed this due to rust-lang#128764, but this isn't really related to that ICE, which is fixed in rust-lang#128792.
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Aug 9, 2024
Rollup merge of rust-lang#128791 - compiler-errors:async-fn-unsafe, r=lcnr

Don't implement `AsyncFn` for `FnDef`/`FnPtr` that wouldnt implement `Fn`

Due to unsafety, ABI, or the presence of target features, some `FnDef`/`FnPtr` types don't implement `Fn*`. Do the same for `AsyncFn*`.

Noticed this due to rust-lang#128764, but this isn't really related to that ICE, which is fixed in rust-lang#128792.
bors added a commit to rust-lang-ci/rust that referenced this issue Aug 12, 2024
…orino

Use `FnSig` instead of raw `FnDecl` for `ForeignItemKind::Fn`, fix ICE for `Fn` trait error on safe foreign fn

Let's use `hir::FnSig` instead of `hir::FnDecl + hir::Safety` for `ForeignItemKind::Fn`. This consolidates some handling code between normal fns and foreign fns.

Separetly, fix an ICE where we weren't handling `Fn` trait errors for safe foreign fns.

If perf is bad for the first commit, I can rework the ICE fix to not rely on it. But if perf is good, I prefer we fix and clean up things all at once 👍

r? spastorino

Fixes rust-lang#128764
bors added a commit to rust-lang-ci/rust that referenced this issue Aug 12, 2024
…orino

Use `FnSig` instead of raw `FnDecl` for `ForeignItemKind::Fn`, fix ICE for `Fn` trait error on safe foreign fn

Let's use `hir::FnSig` instead of `hir::FnDecl + hir::Safety` for `ForeignItemKind::Fn`. This consolidates some handling code between normal fns and foreign fns.

Separetly, fix an ICE where we weren't handling `Fn` trait errors for safe foreign fns.

If perf is bad for the first commit, I can rework the ICE fix to not rely on it. But if perf is good, I prefer we fix and clean up things all at once 👍

r? spastorino

Fixes rust-lang#128764
@bors bors closed this as completed in feeba19 Aug 17, 2024
@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 19, 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. F-async_closure `#![feature(async_closure)]` 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
4 participants