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

Compiler crash: 'assertion failed: self.scc_universes[scc] == ty::UniverseIndex::ROOT' #104196

Closed
danheuck opened this issue Nov 9, 2022 · 0 comments · Fixed by #113575
Closed
Labels
C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. 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

@danheuck
Copy link

danheuck commented Nov 9, 2022

This appears to be the same assertion as #100818, #97099, and #103186 (though I'm unclear if the cause is the same) occurring on both stable rust 1.65.0 and nightly 1.67.0. The below reproduction is as minimal as I could get it. Worth noting that I don't believe this code would compile even without the ICE.

Code

use core::future::Future;

pub struct Struct<C, Fu, F>
where
    F: Fn(&C) -> Fu,
    Fu: Future,
{
    handler: F,
    context: C,
}

impl<C, Fu, R, F> Struct<C, Fu, F>
where
    F: Fn(&C) -> Fu,
    Fu: Future<Output = R>,
{
    pub const fn new(handler: F, context: C) -> Self {
        Self { handler, context }
    }
}

type TestC = &'static usize;
type TestFu = impl Future;
type TestF = impl Fn(&TestC) -> TestFu;
type TestStruct = Struct<TestC, TestFu, TestF>;

async fn test_handler(context: &TestC) -> () {
    ()
}

fn get_test_struct() -> &'static TestStruct {
    static test_actor: TestStruct = TestStruct::new(test_handler, &0);
    &test_actor
}

Meta

rustc --version --verbose:

rustc 1.65.0 (897e37553 2022-11-02)
binary: rustc
commit-hash: 897e37553bba8b42751c67658967889d11ecd120
commit-date: 2022-11-02
host: x86_64-pc-windows-msvc
release: 1.65.0
LLVM version: 15.0.0

Error output

thread 'rustc' panicked at 'assertion failed: self.scc_universes[scc] == ty::UniverseIndex::ROOT', compiler\rustc_borrowck\src\region_infer\mod.rs:721:9
Backtrace

stack backtrace:
   0:     0x7ffa62ca8fb2 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h1086ecfa86360858
   1:     0x7ffa62ce40db - core::fmt::write::hbadbc3de7beb6abb
   2:     0x7ffa62c9b8aa - <std::io::IoSlice as core::fmt::Debug>::fmt::hb7e33fb242ec9ac1
   3:     0x7ffa62cac5b4 - std::panicking::default_hook::hb8b3ce065b661264
   4:     0x7ffa62cac1ea - std::panicking::default_hook::hb8b3ce065b661264
   5:     0x7ffa3abe25ee - rustc_driver[c6471a3a75cc3305]::describe_lints
   6:     0x7ffa62cacfb2 - std::panicking::rust_panic_with_hook::h33e40e3f5d3be1f3
   7:     0x7ffa62caccfa - <std::panicking::begin_panic_handler::StrPanicPayload as core::panic::BoxMeUp>::get::h5aceb4e60531e534
   8:     0x7ffa62ca9cbf - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h1086ecfa86360858
   9:     0x7ffa62caca00 - rust_begin_unwind
  10:     0x7ffa62d19905 - core::panicking::panic_fmt::h0af4781e6a0c54d3
  11:     0x7ffa62d197ac - core::panicking::panic::hd1f6d7a0e46f29da
  12:     0x7ffa3a3f7435 - <rustc_infer[3acbbff32055c339]::infer::InferCtxt as rustc_borrowck[7ffb48d475d38a4e]::universal_regions::InferCtxtExt>::replace_late_bound_regions_with_nll_infer_vars
  13:     0x7ffa3a3ea95e - <rustc_borrowck[7ffb48d475d38a4e]::constraints::OutlivesConstraintSet as core[8087a2e8d825f5e1]::ops::index::Index<rustc_borrowck[7ffb48d475d38a4e]::constraints::OutlivesConstraintIndex>>::index
  14:     0x7ffa3a2e31a8 - <rustc_middle[12c473a188441910]::ty::adjustment::AutoBorrowMutability as rustc_mir_build[236c88af9e57eadb]::thir::cx::expr::ToBorrowKind>::to_borrow_kind
  15:     0x7ffa3a2db836 - <rustc_middle[12c473a188441910]::ty::adjustment::AutoBorrowMutability as rustc_mir_build[236c88af9e57eadb]::thir::cx::expr::ToBorrowKind>::to_borrow_kind
  16:     0x7ffa3a2dae38 - <rustc_middle[12c473a188441910]::ty::adjustment::AutoBorrowMutability as rustc_mir_build[236c88af9e57eadb]::thir::cx::expr::ToBorrowKind>::to_borrow_kind
  17:     0x7ffa38f76ba8 - <rustc_query_impl[9648f954f060bbf5]::queries::is_reachable_non_generic as rustc_query_system[658c00a88212f6cf]::query::config::QueryDescription<rustc_query_impl[9648f954f060bbf5]::plumbing::QueryCtxt>>::execute_query
  18:     0x7ffa390cffbe - <&[rustc_type_ir[1421f89e31f06786]::Variance] as rustc_serialize[5ba6e6ef117c5717]::serialize::Decodable<rustc_query_impl[9648f954f060bbf5]::on_disk_cache::CacheDecoder>>::decode  
  19:     0x7ffa3a60b7a3 - <&[(rustc_middle[12c473a188441910]::ty::Predicate, rustc_span[335b190b38ec46cb]::span_encoding::Span)] as rustc_serialize[5ba6e6ef117c5717]::serialize::Decodable<rustc_query_impl[9648f954f060bbf5]::on_disk_cache::CacheDecoder>>::decode
  20:     0x7ffa3a54a875 - <rustc_query_impl[9648f954f060bbf5]::Queries as rustc_middle[12c473a188441910]::ty::query::QueryEngine>::as_any
  21:     0x7ffa3c24ad66 - <rustc_typeck[49c87e7593e195a8]::collect::type_of::find_opaque_ty_constraints_for_tait::ConstraintLocator as rustc_hir[fcc301f55e55bb6a]::intravisit::Visitor>::visit_trait_item    
  22:     0x7ffa3c23da23 - <rustc_typeck[49c87e7593e195a8]::check::method::suggest::SelfSource as core[8087a2e8d825f5e1]::fmt::Debug>::fmt
  23:     0x7ffa3c2c7f7b - <rustc_typeck[49c87e7593e195a8]::check::upvar::MigrationWarningReason as core[8087a2e8d825f5e1]::fmt::Debug>::fmt
  24:     0x7ffa3c23d9e3 - <rustc_typeck[49c87e7593e195a8]::check::method::suggest::SelfSource as core[8087a2e8d825f5e1]::fmt::Debug>::fmt
  25:     0x7ffa3c2d0048 - <rustc_typeck[49c87e7593e195a8]::check::upvar::MigrationWarningReason as core[8087a2e8d825f5e1]::fmt::Debug>::fmt
  26:     0x7ffa3c23da2e - <rustc_typeck[49c87e7593e195a8]::check::method::suggest::SelfSource as core[8087a2e8d825f5e1]::fmt::Debug>::fmt
  27:     0x7ffa3c2cc649 - <rustc_typeck[49c87e7593e195a8]::check::upvar::MigrationWarningReason as core[8087a2e8d825f5e1]::fmt::Debug>::fmt
  28:     0x7ffa3c24a5c9 - <rustc_typeck[49c87e7593e195a8]::check::PlaceOp as core[8087a2e8d825f5e1]::fmt::Debug>::fmt
  29:     0x7ffa3a116700 - <rustc_typeck[49c87e7593e195a8]::check::UnsafetyState>::recurse
  30:     0x7ffa3a69f389 - <&[(rustc_middle[12c473a188441910]::ty::Predicate, rustc_span[335b190b38ec46cb]::span_encoding::Span)] as rustc_serialize[5ba6e6ef117c5717]::serialize::Decodable<rustc_query_impl[9648f954f060bbf5]::on_disk_cache::CacheDecoder>>::decode
  31:     0x7ffa3a67c76a - <&[(rustc_middle[12c473a188441910]::ty::Predicate, rustc_span[335b190b38ec46cb]::span_encoding::Span)] as rustc_serialize[5ba6e6ef117c5717]::serialize::Decodable<rustc_query_impl[9648f954f060bbf5]::on_disk_cache::CacheDecoder>>::decode
  32:     0x7ffa3aaae51c - <rustc_middle[12c473a188441910]::ty::context::TyCtxt>::bound_type_of
  33:     0x7ffa3a9508d0 - <rustc_trait_selection[51ac1f8d3e2d292c]::traits::select::SelectionContext>::evaluate_root_obligation
  34:     0x7ffa3a936ad6 - <rustc_trait_selection[51ac1f8d3e2d292c]::traits::select::SelectionContext>::evaluate_root_obligation
  35:     0x7ffa3a95dadb - <rustc_trait_selection[51ac1f8d3e2d292c]::traits::select::SelectionContext>::select
  36:     0x7ffa3a936bf5 - <rustc_trait_selection[51ac1f8d3e2d292c]::traits::select::SelectionContext>::evaluate_root_obligation
  37:     0x7ffa3a95dadb - <rustc_trait_selection[51ac1f8d3e2d292c]::traits::select::SelectionContext>::select
  38:     0x7ffa3a9359ca - <rustc_trait_selection[51ac1f8d3e2d292c]::traits::select::SelectionContext>::evaluate_root_obligation
  39:     0x7ffa3a41f836 - <regex[c10d5b7862cb2dbf]::re_bytes::CaptureNames as core[8087a2e8d825f5e1]::iter::traits::iterator::Iterator>::size_hint
  40:     0x7ffa3a40b925 - <rustc_infer[3acbbff32055c339]::infer::InferCtxt as rustc_borrowck[7ffb48d475d38a4e]::universal_regions::InferCtxtExt>::replace_late_bound_regions_with_nll_infer_vars
  41:     0x7ffa3a6953d2 - <&[(rustc_middle[12c473a188441910]::ty::Predicate, rustc_span[335b190b38ec46cb]::span_encoding::Span)] as rustc_serialize[5ba6e6ef117c5717]::serialize::Decodable<rustc_query_impl[9648f954f060bbf5]::on_disk_cache::CacheDecoder>>::decode
  42:     0x7ffa3a668608 - <&[(rustc_middle[12c473a188441910]::ty::Predicate, rustc_span[335b190b38ec46cb]::span_encoding::Span)] as rustc_serialize[5ba6e6ef117c5717]::serialize::Decodable<rustc_query_impl[9648f954f060bbf5]::on_disk_cache::CacheDecoder>>::decode
  43:     0x7ffa3a54f9a6 - <rustc_query_impl[9648f954f060bbf5]::Queries as rustc_middle[12c473a188441910]::ty::query::QueryEngine>::as_any
  44:     0x7ffa3a916be1 - <rustc_trait_selection[51ac1f8d3e2d292c]::traits::fulfill::FulfillProcessor as rustc_data_structures[1b20f7c7eb90dc04]::obligation_forest::ObligationProcessor>::process_obligation 
  45:     0x7ffa3a9c6f9f - <rustc_middle[12c473a188441910]::ty::Predicate as rustc_trait_selection[51ac1f8d3e2d292c]::traits::query::type_op::normalize::Normalizable>::type_op_method
  46:     0x7ffa3a90cc4b - <rustc_trait_selection[51ac1f8d3e2d292c]::traits::engine::ObligationCtxt>::select_all_or_error
  47:     0x7ffa38d4f3ca - <rustc_typeck[49c87e7593e195a8]::expr_use_visitor::ExprUseVisitor>::consume_body
  48:     0x7ffa38d2db00 - <<rustc_typeck[49c87e7593e195a8]::check::method::confirm::ConfirmContext>::instantiate_method_substs::MethodSubstsCtxt as rustc_typeck[49c87e7593e195a8]::astconv::CreateSubstsForGenericArgsCtxt>::inferred_kind
  49:     0x7ffa39fe4bc3 - <<rustc_typeck[49c87e7593e195a8]::check::method::confirm::ConfirmContext>::instantiate_method_substs::MethodSubstsCtxt as rustc_typeck[49c87e7593e195a8]::astconv::CreateSubstsForGenericArgsCtxt>::args_for_def_id
  50:     0x7ffa38f75a98 - <rustc_query_impl[9648f954f060bbf5]::queries::is_reachable_non_generic as rustc_query_system[658c00a88212f6cf]::query::config::QueryDescription<rustc_query_impl[9648f954f060bbf5]::plumbing::QueryCtxt>>::execute_query
  51:     0x7ffa390d3a9e - <&[rustc_type_ir[1421f89e31f06786]::Variance] as rustc_serialize[5ba6e6ef117c5717]::serialize::Decodable<rustc_query_impl[9648f954f060bbf5]::on_disk_cache::CacheDecoder>>::decode  
  52:     0x7ffa3a61066a - <&[(rustc_middle[12c473a188441910]::ty::Predicate, rustc_span[335b190b38ec46cb]::span_encoding::Span)] as rustc_serialize[5ba6e6ef117c5717]::serialize::Decodable<rustc_query_impl[9648f954f060bbf5]::on_disk_cache::CacheDecoder>>::decode
  53:     0x7ffa3a54e0c8 - <rustc_query_impl[9648f954f060bbf5]::Queries as rustc_middle[12c473a188441910]::ty::query::QueryEngine>::as_any
  54:     0x7ffa3a11b89f - rustc_typeck[49c87e7593e195a8]::check::rvalue_scopes::resolve_rvalue_scopes
  55:     0x7ffa38d2f6f5 - <<rustc_typeck[49c87e7593e195a8]::check::method::confirm::ConfirmContext>::instantiate_method_substs::MethodSubstsCtxt as rustc_typeck[49c87e7593e195a8]::astconv::CreateSubstsForGenericArgsCtxt>::inferred_kind
  56:     0x7ffa38f75a98 - <rustc_query_impl[9648f954f060bbf5]::queries::is_reachable_non_generic as rustc_query_system[658c00a88212f6cf]::query::config::QueryDescription<rustc_query_impl[9648f954f060bbf5]::plumbing::QueryCtxt>>::execute_query
  57:     0x7ffa390d3a9e - <&[rustc_type_ir[1421f89e31f06786]::Variance] as rustc_serialize[5ba6e6ef117c5717]::serialize::Decodable<rustc_query_impl[9648f954f060bbf5]::on_disk_cache::CacheDecoder>>::decode  
  58:     0x7ffa3a61066a - <&[(rustc_middle[12c473a188441910]::ty::Predicate, rustc_span[335b190b38ec46cb]::span_encoding::Span)] as rustc_serialize[5ba6e6ef117c5717]::serialize::Decodable<rustc_query_impl[9648f954f060bbf5]::on_disk_cache::CacheDecoder>>::decode
  59:     0x7ffa390b89bc - <&[rustc_type_ir[1421f89e31f06786]::Variance] as rustc_serialize[5ba6e6ef117c5717]::serialize::Decodable<rustc_query_impl[9648f954f060bbf5]::on_disk_cache::CacheDecoder>>::decode  
  60:     0x7ffa38d9b975 - <rustc_typeck[49c87e7593e195a8]::check::cast::CastCheck>::check
  61:     0x7ffa38dab74b - rustc_typeck[49c87e7593e195a8]::check::dropck::check_drop_impl
  62:     0x7ffa38d8848a - <rustc_typeck[49c87e7593e195a8]::check::fn_ctxt::FnCtxt>::write_user_type_annotation
  63:     0x7ffa38d34819 - rustc_typeck[49c87e7593e195a8]::check_crate
  64:     0x7ffa3945a63f - rustc_interface[9c167b8dd5fe1201]::passes::analysis
  65:     0x7ffa38f7830e - <rustc_query_impl[9648f954f060bbf5]::queries::is_reachable_non_generic as rustc_query_system[658c00a88212f6cf]::query::config::QueryDescription<rustc_query_impl[9648f954f060bbf5]::plumbing::QueryCtxt>>::execute_query
  66:     0x7ffa390ed9c3 - <&[rustc_type_ir[1421f89e31f06786]::Variance] as rustc_serialize[5ba6e6ef117c5717]::serialize::Decodable<rustc_query_impl[9648f954f060bbf5]::on_disk_cache::CacheDecoder>>::decode  
  67:     0x7ffa39070ca7 - <&[rustc_type_ir[1421f89e31f06786]::Variance] as rustc_serialize[5ba6e6ef117c5717]::serialize::Decodable<rustc_query_impl[9648f954f060bbf5]::on_disk_cache::CacheDecoder>>::decode  
  68:     0x7ffa390c10b6 - <&[rustc_type_ir[1421f89e31f06786]::Variance] as rustc_serialize[5ba6e6ef117c5717]::serialize::Decodable<rustc_query_impl[9648f954f060bbf5]::on_disk_cache::CacheDecoder>>::decode  
  69:     0x7ffa3855c9d9 - rustc_driver[c6471a3a75cc3305]::args::arg_expand_all
  70:     0x7ffa3852a3a8 - rustc_driver[c6471a3a75cc3305]::main
  71:     0x7ffa3855e32a - <rustc_middle[12c473a188441910]::ty::SymbolName as core[8087a2e8d825f5e1]::fmt::Debug>::fmt
  72:     0x7ffa38545e60 - rustc_driver[c6471a3a75cc3305]::main
  73:     0x7ffa3855d7d7 - <rustc_middle[12c473a188441910]::ty::SymbolName as core[8087a2e8d825f5e1]::fmt::Debug>::fmt
  74:     0x7ffa3854e109 - rustc_driver[c6471a3a75cc3305]::main
  75:     0x7ffa3854e56d - rustc_driver[c6471a3a75cc3305]::main
  76:     0x7ffa62cbd7cc - std::sys::windows::thread::Thread::new::h742bb0c6405f02e2
  77:     0x7ffb262b7034 - BaseThreadInitThunk
  78:     0x7ffb27c826a1 - RtlUserThreadStart

error: internal compiler error: unexpected panic

note: 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.65.0 (897e37553 2022-11-02) running on x86_64-pc-windows-msvc

note: compiler flags: --crate-type lib -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [mir_borrowck] borrow-checking `get_test_struct::test_actor`
#1 [type_of] computing type of `TestF::{opaque#0}`
#2 [evaluate_obligation] evaluating trait selection obligation `Struct<&'static usize, TestFu, TestF>: core::marker::Sync`
#3 [check_well_formed] checking that `get_test_struct::test_actor` is well-formed
#4 [check_mod_type_wf] checking that types are well-formed in top-level module
#5 [analysis] running analysis passes on this crate
end of query stack

@danheuck danheuck 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 Nov 9, 2022
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Dec 20, 2022
@bors bors closed this as completed in 03181e0 Aug 4, 2023
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. glacier ICE tracked in rust-lang/glacier. 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.

2 participants