Skip to content

No bound vars found for HirId(DefId( in compiler/rustc_middle/src/ty/context.rs #125655

Closed
@Naserume

Description

Code

fn main() {
    static foo: dyn Fn() -> u32 = || -> u32 {
        //~^ ERROR the size for values of type
        //~| ERROR cannot be shared between threads safely
        //~| ERROR the size for values of type
        ...
        0
    };
}

Meta

rustc --version --verbose:

rustc 1.80.0-nightly (84b40fc90 2024-05-27)
binary: rustc
commit-hash: 84b40fc908c3adc7e0e470b3fbaa264df0e122b8
commit-date: 2024-05-27
host: x86_64-apple-darwin
release: 1.80.0-nightly
LLVM version: 18.1.6

Error output

info: syncing channel updates for 'nightly-x86_64-apple-darwin'

  nightly-x86_64-apple-darwin unchanged - rustc 1.80.0-nightly (84b40fc90 2024-05-27)

info: checking for self-update
error: unexpected token: `...`
 --> ./6FA6E1FD2230DECFC4A324415F1CE359CF44F0600A6F19AA26DE8E5404A6DAB9.rs:6:9
  |
6 |         ...
  |         ^^^
  |
help: use `..` for an exclusive range
  |
6 |         ..
  |
help: or `..=` for an inclusive range
  |
6 |         ..=
  |

error[E0277]: `(dyn Fn() -> u32 + 'static)` cannot be shared between threads safely
 --> ./6FA6E1FD2230DECFC4A324415F1CE359CF44F0600A6F19AA26DE8E5404A6DAB9.rs:2:17
  |
2 |     static foo: dyn Fn() -> u32 = || -> u32 {
  |                 ^^^^^^^^^^^^^^^ `(dyn Fn() -> u32 + 'static)` cannot be shared between threads safely
  |
  = help: the trait `Sync` is not implemented for `(dyn Fn() -> u32 + 'static)`
  = note: shared static variables must have a type that implements `Sync`

error[E0277]: the size for values of type `(dyn Fn() -> u32 + 'static)` cannot be known at compilation time
 --> ./6FA6E1FD2230DECFC4A324415F1CE359CF44F0600A6F19AA26DE8E5404A6DAB9.rs:2:17
  |
2 |     static foo: dyn Fn() -> u32 = || -> u32 {
  |                 ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
  |
  = help: the trait `Sized` is not implemented for `(dyn Fn() -> u32 + 'static)`

error[E0277]: the size for values of type `(dyn Fn() -> u32 + 'static)` cannot be known at compilation time
 --> ./6FA6E1FD2230DECFC4A324415F1CE359CF44F0600A6F19AA26DE8E5404A6DAB9.rs:2:35
  |
2 |       static foo: dyn Fn() -> u32 = || -> u32 {
  |  ___________________________________^
3 | |         //~^ ERROR the size for values of type
4 | |         //~| ERROR cannot be shared between threads safely
5 | |         //~| ERROR the size for values of type
6 | |         ...
7 | |         0
8 | |     };
  | |_____^ doesn't have a size known at compile-time
  |
  = help: the trait `Sized` is not implemented for `(dyn Fn() -> u32 + 'static)`
  = note: constant expressions must have a statically known size
Backtrace

error: internal compiler error: compiler/rustc_middle/src/ty/context.rs:2583:21: No bound vars found for HirId(DefId(0:4 ~ 6FA6E1FD2230DECFC4A324415F1CE359CF44F0600A6F19AA26DE8E5404A6DAB9[8430]::main::foo).0) (static foo)

thread 'rustc' panicked at compiler/rustc_middle/src/ty/context.rs:2583:21:
Box<dyn Any>
stack backtrace:
   0:        0x10ac9c193 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h51921f2e52d686b8
   1:        0x10ace77cb - core::fmt::write::h2b73508d07b1ddda
   2:        0x10ac9224e - std::io::Write::write_fmt::h1a4990725cb94d19
   3:        0x10ac9bf81 - std::sys_common::backtrace::print::hbaa9d5d0b6ae5771
   4:        0x10ac9ed49 - std::panicking::default_hook::{{closure}}::hb29728a481024744
   5:        0x10ac9eac8 - std::panicking::default_hook::h863a389bd8aa7cb6
   6:        0x113a2db1c - std[1da7d9055ec82a98]::panicking::update_hook::<alloc[d2ff4adad34ee5b0]::boxed::Box<rustc_driver_impl[d3ad18f46d0afcfd]::install_ice_hook::{closure#0}>>::{closure#0}
   7:        0x10ac9f853 - std::panicking::rust_panic_with_hook::h2d23fde0880a2e81
   8:        0x113a981ba - std[1da7d9055ec82a98]::panicking::begin_panic::<rustc_errors[6b485a6418fcb1e4]::ExplicitBug>::{closure#0}
   9:        0x113a8fe59 - std[1da7d9055ec82a98]::sys_common::backtrace::__rust_end_short_backtrace::<std[1da7d9055ec82a98]::panicking::begin_panic<rustc_errors[6b485a6418fcb1e4]::ExplicitBug>::{closure#0}, !>
  10:        0x118228039 - std[1da7d9055ec82a98]::panicking::begin_panic::<rustc_errors[6b485a6418fcb1e4]::ExplicitBug>
  11:        0x113aab326 - <rustc_errors[6b485a6418fcb1e4]::diagnostic::BugAbort as rustc_errors[6b485a6418fcb1e4]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:        0x1145c392e - rustc_middle[4fd479a6026b06e9]::util::bug::opt_span_bug_fmt::<rustc_span[5c871bc8a1860ee8]::span_encoding::Span>::{closure#0}
  13:        0x114574a07 - rustc_middle[4fd479a6026b06e9]::ty::context::tls::with_opt::<rustc_middle[4fd479a6026b06e9]::util::bug::opt_span_bug_fmt<rustc_span[5c871bc8a1860ee8]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:        0x1145744a5 - rustc_middle[4fd479a6026b06e9]::ty::context::tls::with_context_opt::<rustc_middle[4fd479a6026b06e9]::ty::context::tls::with_opt<rustc_middle[4fd479a6026b06e9]::util::bug::opt_span_bug_fmt<rustc_span[5c871bc8a1860ee8]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:        0x1182f289b - rustc_middle[4fd479a6026b06e9]::util::bug::bug_fmt
  16:        0x11458d73d - <rustc_middle[4fd479a6026b06e9]::ty::context::TyCtxt>::late_bound_vars
  17:        0x113fc5845 - <rustc_hir_typeck[70f6020ddbcdf028]::fn_ctxt::FnCtxt>::suggest_missing_return_type
  18:        0x113ebec2d - <rustc_hir_typeck[70f6020ddbcdf028]::coercion::CoerceMany<rustc_hir[187abc7f04de6ccd]::hir::Expr>>::report_return_mismatched_types
  19:        0x113f136ba - <rustc_hir_typeck[70f6020ddbcdf028]::fn_ctxt::FnCtxt>::check_block_with_expected
  20:        0x113ed3e7b - <rustc_hir_typeck[70f6020ddbcdf028]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  21:        0x113ed5ec4 - <rustc_hir_typeck[70f6020ddbcdf028]::fn_ctxt::FnCtxt>::check_return_expr
  22:        0x113f94950 - rustc_hir_typeck[70f6020ddbcdf028]::check::check_fn
  23:        0x113fb6f62 - <rustc_hir_typeck[70f6020ddbcdf028]::fn_ctxt::FnCtxt>::check_expr_kind
  24:        0x113ed3e7b - <rustc_hir_typeck[70f6020ddbcdf028]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  25:        0x113f8c86b - rustc_hir_typeck[70f6020ddbcdf028]::typeck
  26:        0x114ef755a - rustc_query_impl[3691b0e6aab602df]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[3691b0e6aab602df]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[4fd479a6026b06e9]::query::erase::Erased<[u8; 8usize]>>
  27:        0x114d6e607 - rustc_query_system[cc1e6c2a417942e6]::query::plumbing::try_execute_query::<rustc_query_impl[3691b0e6aab602df]::DynamicConfig<rustc_query_system[cc1e6c2a417942e6]::query::caches::VecCache<rustc_hir[187abc7f04de6ccd]::hir_id::OwnerId, rustc_middle[4fd479a6026b06e9]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[3691b0e6aab602df]::plumbing::QueryCtxt, false>
  28:        0x114f19abb - rustc_query_impl[3691b0e6aab602df]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  29:        0x113ccb2de - rustc_hir_analysis[5e381ea6a7b23192]::check::check::check_item_type
  30:        0x113cff284 - rustc_hir_analysis[5e381ea6a7b23192]::check::wfcheck::check_well_formed
  31:        0x114ef484a - rustc_query_impl[3691b0e6aab602df]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[3691b0e6aab602df]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[4fd479a6026b06e9]::query::erase::Erased<[u8; 1usize]>>
  32:        0x114d6c26c - rustc_query_system[cc1e6c2a417942e6]::query::plumbing::try_execute_query::<rustc_query_impl[3691b0e6aab602df]::DynamicConfig<rustc_query_system[cc1e6c2a417942e6]::query::caches::VecCache<rustc_hir[187abc7f04de6ccd]::hir_id::OwnerId, rustc_middle[4fd479a6026b06e9]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[3691b0e6aab602df]::plumbing::QueryCtxt, false>
  33:        0x114f3ae10 - rustc_query_impl[3691b0e6aab602df]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  34:        0x113c41c92 - rustc_middle[4fd479a6026b06e9]::query::plumbing::query_ensure_error_guaranteed::<rustc_query_system[cc1e6c2a417942e6]::query::caches::VecCache<rustc_hir[187abc7f04de6ccd]::hir_id::OwnerId, rustc_middle[4fd479a6026b06e9]::query::erase::Erased<[u8; 1usize]>>, ()>
  35:        0x113d0da21 - rustc_hir_analysis[5e381ea6a7b23192]::check::wfcheck::check_mod_type_wf
  36:        0x114ef483a - rustc_query_impl[3691b0e6aab602df]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[3691b0e6aab602df]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[4fd479a6026b06e9]::query::erase::Erased<[u8; 1usize]>>
  37:        0x114d225a1 - rustc_query_system[cc1e6c2a417942e6]::query::plumbing::try_execute_query::<rustc_query_impl[3691b0e6aab602df]::DynamicConfig<rustc_query_system[cc1e6c2a417942e6]::query::caches::DefaultCache<rustc_span[5c871bc8a1860ee8]::def_id::LocalModDefId, rustc_middle[4fd479a6026b06e9]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[3691b0e6aab602df]::plumbing::QueryCtxt, false>
  38:        0x114f18f10 - rustc_query_impl[3691b0e6aab602df]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
  39:        0x113d8a57c - rustc_hir_analysis[5e381ea6a7b23192]::check_crate
  40:        0x114210011 - rustc_interface[3f7acd64cf69f8d0]::passes::run_required_analyses
  41:        0x114212653 - rustc_interface[3f7acd64cf69f8d0]::passes::analysis
  42:        0x114ef75aa - rustc_query_impl[3691b0e6aab602df]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[3691b0e6aab602df]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[4fd479a6026b06e9]::query::erase::Erased<[u8; 1usize]>>
  43:        0x114cd894e - rustc_query_system[cc1e6c2a417942e6]::query::plumbing::try_execute_query::<rustc_query_impl[3691b0e6aab602df]::DynamicConfig<rustc_query_system[cc1e6c2a417942e6]::query::caches::SingleCache<rustc_middle[4fd479a6026b06e9]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[3691b0e6aab602df]::plumbing::QueryCtxt, false>
  44:        0x114f01767 - rustc_query_impl[3691b0e6aab602df]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  45:        0x1139de277 - <rustc_interface[3f7acd64cf69f8d0]::queries::QueryResult<&rustc_middle[4fd479a6026b06e9]::ty::context::GlobalCtxt>>::enter::<core[917b7ec437872f2c]::result::Result<(), rustc_span[5c871bc8a1860ee8]::ErrorGuaranteed>, rustc_driver_impl[d3ad18f46d0afcfd]::run_compiler::{closure#0}::{closure#1}::{closure#3}>
  46:        0x113a34ced - rustc_interface[3f7acd64cf69f8d0]::interface::run_compiler::<core[917b7ec437872f2c]::result::Result<(), rustc_span[5c871bc8a1860ee8]::ErrorGuaranteed>, rustc_driver_impl[d3ad18f46d0afcfd]::run_compiler::{closure#0}>::{closure#1}
  47:        0x113a1f1f1 - std[1da7d9055ec82a98]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[3f7acd64cf69f8d0]::util::run_in_thread_with_globals<rustc_interface[3f7acd64cf69f8d0]::util::run_in_thread_pool_with_globals<rustc_interface[3f7acd64cf69f8d0]::interface::run_compiler<core[917b7ec437872f2c]::result::Result<(), rustc_span[5c871bc8a1860ee8]::ErrorGuaranteed>, rustc_driver_impl[d3ad18f46d0afcfd]::run_compiler::{closure#0}>::{closure#1}, core[917b7ec437872f2c]::result::Result<(), rustc_span[5c871bc8a1860ee8]::ErrorGuaranteed>>::{closure#0}, core[917b7ec437872f2c]::result::Result<(), rustc_span[5c871bc8a1860ee8]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[917b7ec437872f2c]::result::Result<(), rustc_span[5c871bc8a1860ee8]::ErrorGuaranteed>>
  48:        0x113a3ba96 - <<std[1da7d9055ec82a98]::thread::Builder>::spawn_unchecked_<rustc_interface[3f7acd64cf69f8d0]::util::run_in_thread_with_globals<rustc_interface[3f7acd64cf69f8d0]::util::run_in_thread_pool_with_globals<rustc_interface[3f7acd64cf69f8d0]::interface::run_compiler<core[917b7ec437872f2c]::result::Result<(), rustc_span[5c871bc8a1860ee8]::ErrorGuaranteed>, rustc_driver_impl[d3ad18f46d0afcfd]::run_compiler::{closure#0}>::{closure#1}, core[917b7ec437872f2c]::result::Result<(), rustc_span[5c871bc8a1860ee8]::ErrorGuaranteed>>::{closure#0}, core[917b7ec437872f2c]::result::Result<(), rustc_span[5c871bc8a1860ee8]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[917b7ec437872f2c]::result::Result<(), rustc_span[5c871bc8a1860ee8]::ErrorGuaranteed>>::{closure#2} as core[917b7ec437872f2c]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  49:        0x10aca8f0b - std::sys::pal::unix::thread::Thread::new::thread_start::hff1aeae30732a5f5
  50:     0x7ff801f5318b - __pthread_start

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: please attach the file at `/Documents/rustc-ice-2024-05-28T12_02_57-74152.txt` to your bug report

query stack during panic:
#0 [typeck] type-checking `main::foo`
#1 [check_well_formed] checking that `main::foo` is well-formed
end of query stack
error: aborting due to 5 previous errors

Activity

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

Metadata

Assignees

No one assigned

    Labels

    A-type-systemArea: Type systemC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-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