Skip to content

Bizarre higher-ranked type mismatch causes ICE on stable #109796

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

Closed
Radbuglet opened this issue Mar 30, 2023 · 1 comment
Closed

Bizarre higher-ranked type mismatch causes ICE on stable #109796

Radbuglet opened this issue Mar 30, 2023 · 1 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.

Comments

@Radbuglet
Copy link

Radbuglet commented Mar 30, 2023

Code

pub trait Sig<'a> {
    type Input;
    type Output;
}

fn a<C, F>(_: F)
where
    C: Sig<'static>,
    F: FnMut(<C as Sig<'static>>::Input) -> C::Output,
{
}

pub fn b<C>()
where
    C: Sig<'static>,
{
    a::<C, _>(move |input: &'_ <C as Sig<'_>>::Input| unimplemented!());
}

Thanks to Talchas (whose Github username I do not know) for help minimizing this ICE.

Meta

rustc --version --verbose:

rustc 1.68.2 (9eb3afe9e 2023-03-27)
binary: rustc
commit-hash: 9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0
commit-date: 2023-03-27
host: x86_64-pc-windows-msvc
release: 1.68.2
LLVM version: 15.0.6

Error output

    Checking cool-ice v0.1.0 (C:\path\to\cool-ice)
error: internal compiler error: compiler\rustc_infer\src\infer\region_constraints\mod.rs:568:17: cannot relate bound region: ReLateBound(DebruijnIndex(0), BoundRegion { var: 
1, kind: BrNamed(DefId(0:14 ~ cool_ice[5d71]::b::'_#1), '_) }) <= ReStatic

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0\compiler\rustc_errors\src\lib.rs:987:33
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

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.68.2 (9eb3afe9e 2023-03-27) 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 [typeck] type-checking `b`
#1 [typeck_item_bodies] type-checking all item bodies
end of query stack
error: could not compile `cool-ice`
Backtrace

    Checking cool-ice v0.1.0 (C:\path\to\cool-ice)
error: internal compiler error: compiler\rustc_infer\src\infer\region_constraints\mod.rs:568:17: cannot relate bound region: ReLateBound(DebruijnIndex(0), BoundRegion { var: 
1, kind: BrNamed(DefId(0:14 ~ cool_ice[5d71]::b::'_#1), '_) }) <= ReStatic

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0\compiler\rustc_errors\src\lib.rs:987:33
stack backtrace:
   0:     0x7ff946f39d02 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hbb6eec21cb8e3d1b
   1:     0x7ff946f7570b - core::fmt::write::h3f34d6e08b5a11e8
   2:     0x7ff946f2cdfa - <std::io::IoSlice as core::fmt::Debug>::fmt::h1d8b4e60e4c9e548
   3:     0x7ff946f39a4b - std::sys::common::alloc::realloc_fallback::h258dcd65da5985d2
   4:     0x7ff946f3d3f9 - std::panicking::default_hook::h90b70b966050cb60
   5:     0x7ff946f3d07b - std::panicking::default_hook::h90b70b966050cb60
   6:     0x7ff9264f9425 - rustc_driver[fbeb20e0897b27eb]::describe_lints
   7:     0x7ff946f3dd5f - std::panicking::rust_panic_with_hook::h1d50ae3462f62f01
   8:     0x7ff9287ba703 - <<rustc_infer[e1f2f17455595243]::infer::error_reporting::TypeErrCtxt>::construct_generic_bound_failure::SubOrigin as core[15ae0b8045847941]::fmt::Debug>::fmt
   9:     0x7ff9287b8c19 - <<rustc_infer[e1f2f17455595243]::infer::error_reporting::TypeErrCtxt>::construct_generic_bound_failure::SubOrigin as core[15ae0b8045847941]::fmt::Debug>::fmt
  10:     0x7ff9287b8bb9 - <<rustc_infer[e1f2f17455595243]::infer::error_reporting::TypeErrCtxt>::construct_generic_bound_failure::SubOrigin as core[15ae0b8045847941]::fmt::Debug>::fmt
  11:     0x7ff9287b8ba9 - <<rustc_infer[e1f2f17455595243]::infer::error_reporting::TypeErrCtxt>::construct_generic_bound_failure::SubOrigin as core[15ae0b8045847941]::fmt::Debug>::fmt
  12:     0x7ff9287b8220 - <<rustc_infer[e1f2f17455595243]::infer::error_reporting::TypeErrCtxt>::construct_generic_bound_failure::SubOrigin as core[15ae0b8045847941]::fmt::Debug>::fmt
  13:     0x7ff9287b8079 - <<rustc_infer[e1f2f17455595243]::infer::error_reporting::TypeErrCtxt>::construct_generic_bound_failure::SubOrigin as core[15ae0b8045847941]::fmt::Debug>::fmt
  14:     0x7ff9287c04c9 - <rustc_infer[e1f2f17455595243]::infer::opaque_types::table::OpaqueTypeStorage as core[15ae0b8045847941]::fmt::Debug>::fmt
  15:     0x7ff9287c052d - <rustc_infer[e1f2f17455595243]::infer::opaque_types::table::OpaqueTypeStorage as core[15ae0b8045847941]::fmt::Debug>::fmt
  16:     0x7ff9287bf73a - <rustc_infer[e1f2f17455595243]::infer::opaque_types::table::OpaqueTypeStorage as core[15ae0b8045847941]::fmt::Debug>::fmt
  17:     0x7ff9287bf678 - <rustc_infer[e1f2f17455595243]::infer::opaque_types::table::OpaqueTypeStorage as core[15ae0b8045847941]::fmt::Debug>::fmt
  18:     0x7ff9287bf636 - <rustc_infer[e1f2f17455595243]::infer::opaque_types::table::OpaqueTypeStorage as core[15ae0b8045847941]::fmt::Debug>::fmt
  19:     0x7ff92632776a - <rustc_infer[e1f2f17455595243]::infer::combine::ConstInferUnifier as rustc_middle[1d4803ea9c08b419]::ty::relate::TypeRelation>::consts
  20:     0x7ff92631f90a - <rustc_infer[e1f2f17455595243]::infer::combine::ConstInferUnifier as rustc_middle[1d4803ea9c08b419]::ty::relate::TypeRelation>::consts
  21:     0x7ff924aee9f1 - <rustc_infer[e1f2f17455595243]::infer::combine::Generalizer as rustc_middle[1d4803ea9c08b419]::ty::relate::TypeRelation>::regions
  22:     0x7ff92633698e - <rustc_middle[1d4803ea9c08b419]::ty::sty::AliasTy as rustc_infer[e1f2f17455595243]::infer::at::ToTrace>::to_trace
  23:     0x7ff9262f1909 - <rustc_infer[e1f2f17455595243]::infer::equate::Equate as rustc_middle[1d4803ea9c08b419]::ty::relate::TypeRelation>::tys
  24:     0x7ff924abd78a - <rustc_middle[1d4803ea9c08b419]::traits::specialization_graph::Children as rustc_trait_selection[5f0f54a03cd0c301]::traits::specialize::specialization_graph::ChildrenExt>::insert_blindly
  25:     0x7ff924aab10b - <rustc_trait_selection[5f0f54a03cd0c301]::traits::project::AssocTypeNormalizer as rustc_middle[1d4803ea9c08b419]::ty::fold::TypeFolder>::fold_const  26:     0x7ff928709218 - <rustc_trait_selection[5f0f54a03cd0c301]::solve::search_graph::StackDepth as core[15ae0b8045847941]::fmt::Debug>::fmt
  27:     0x7ff9286a7a09 - <rustc_trait_selection[5f0f54a03cd0c301]::traits::error_reporting::method_chain::CollectAllMismatches as rustc_middle[1d4803ea9c08b419]::ty::relate::TypeRelation>::consts
  28:     0x7ff9287216c3 - <rustc_infer[e1f2f17455595243]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[5f0f54a03cd0c301]::traits::error_reporting::suggestions::TypeErrCtxtExt>::report_closure_arg_mismatch
  29:     0x7ff928734bdb - <rustc_infer[e1f2f17455595243]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[5f0f54a03cd0c301]::traits::error_reporting::TypeErrCtxtExt>::report_selection_error
  30:     0x7ff928741805 - <rustc_infer[e1f2f17455595243]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[5f0f54a03cd0c301]::traits::error_reporting::InferCtxtPrivExt>::report_fulfillment_error
  31:     0x7ff928731569 - <rustc_infer[e1f2f17455595243]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[5f0f54a03cd0c301]::traits::error_reporting::TypeErrCtxtExt>::report_fulfillment_errors
  32:     0x7ff925664cbb - <rustc_hir_typeck[527c1058ba999897]::fn_ctxt::FnCtxt>::demand_coerce
  33:     0x7ff92560efd8 - <rustc_hir_typeck[527c1058ba999897]::inherited::Inherited as core[15ae0b8045847941]::ops::deref::Deref>::deref
  34:     0x7ff9246de669 - <rustc_query_impl[22fc8f5fe5921e7d]::on_disk_cache::CacheEncoder as rustc_type_ir[76501457ae8f3cde]::codec::TyEncoder>::encode_alloc_id
  35:     0x7ff9247447c5 - <&[(rustc_middle[1d4803ea9c08b419]::ty::Predicate, rustc_span[31f727a51b7d57bd]::span_encoding::Span)] as rustc_serialize[637af69557f69e4e]::serialize::Decodable<rustc_query_impl[22fc8f5fe5921e7d]::on_disk_cache::CacheDecoder>>::decode
  36:     0x7ff925ed08ad - <&[(rustc_middle[1d4803ea9c08b419]::ty::Clause, rustc_span[31f727a51b7d57bd]::span_encoding::Span)] as rustc_serialize[637af69557f69e4e]::serialize::Decodable<rustc_query_impl[22fc8f5fe5921e7d]::on_disk_cache::CacheDecoder>>::decode
  37:     0x7ff925da7093 - <rustc_query_impl[22fc8f5fe5921e7d]::Queries as rustc_middle[1d4803ea9c08b419]::ty::query::QueryEngine>::as_any
  38:     0x7ff9256b85d3 - <rustc_hir_typeck[527c1058ba999897]::fn_ctxt::FnCtxt>::resolve_fully_qualified_call
  39:     0x7ff92438b9d1 - <rustc_hir_typeck[527c1058ba999897]::inherited::Inherited>::build
  40:     0x7ff9246e043f - <rustc_query_impl[22fc8f5fe5921e7d]::on_disk_cache::CacheEncoder as rustc_type_ir[76501457ae8f3cde]::codec::TyEncoder>::encode_alloc_id
  41:     0x7ff92476376f - <&[(rustc_middle[1d4803ea9c08b419]::ty::Predicate, rustc_span[31f727a51b7d57bd]::span_encoding::Span)] as rustc_serialize[637af69557f69e4e]::serialize::Decodable<rustc_query_impl[22fc8f5fe5921e7d]::on_disk_cache::CacheDecoder>>::decode
  42:     0x7ff9247d24f1 - <&[(rustc_middle[1d4803ea9c08b419]::ty::Predicate, rustc_span[31f727a51b7d57bd]::span_encoding::Span)] as rustc_serialize[637af69557f69e4e]::serialize::Decodable<rustc_query_impl[22fc8f5fe5921e7d]::on_disk_cache::CacheDecoder>>::decode
  43:     0x7ff9246b3152 - <rustc_query_impl[22fc8f5fe5921e7d]::Queries as rustc_middle[1d4803ea9c08b419]::ty::query::QueryEngine>::try_mark_green
  44:     0x7ff9243ea1aa - <<dyn rustc_hir_analysis[9d3badbe7d08bcd8]::astconv::AstConv>::create_substs_for_ast_path::{closure#0}::SubstsForAstPathCtxt as rustc_hir_analysis[9d3badbe7d08bcd8]::astconv::CreateSubstsForGenericArgsCtxt>::inferred_kind
  45:     0x7ff9243e1ea9 - rustc_hir_analysis[9d3badbe7d08bcd8]::check_crate
  46:     0x7ff923cc2295 - rustc_interface[5b253cef4d5aad89]::passes::analysis
  47:     0x7ff9246dff1f - <rustc_query_impl[22fc8f5fe5921e7d]::on_disk_cache::CacheEncoder as rustc_type_ir[76501457ae8f3cde]::codec::TyEncoder>::encode_alloc_id
  48:     0x7ff92475ed19 - <&[(rustc_middle[1d4803ea9c08b419]::ty::Predicate, rustc_span[31f727a51b7d57bd]::span_encoding::Span)] as rustc_serialize[637af69557f69e4e]::serialize::Decodable<rustc_query_impl[22fc8f5fe5921e7d]::on_disk_cache::CacheDecoder>>::decode
  49:     0x7ff92484b611 - <&[(rustc_middle[1d4803ea9c08b419]::ty::Predicate, rustc_span[31f727a51b7d57bd]::span_encoding::Span)] as rustc_serialize[637af69557f69e4e]::serialize::Decodable<rustc_query_impl[22fc8f5fe5921e7d]::on_disk_cache::CacheDecoder>>::decode
  50:     0x7ff9246b094f - <rustc_query_impl[22fc8f5fe5921e7d]::Queries as rustc_middle[1d4803ea9c08b419]::ty::query::QueryEngine>::try_mark_green
  51:     0x7ff923c6d1a9 - <rustc_middle[1d4803ea9c08b419]::ty::SymbolName as core[15ae0b8045847941]::fmt::Debug>::fmt
  52:     0x7ff923c7e7fa - rustc_driver[fbeb20e0897b27eb]::args::arg_expand_all
  53:     0x7ff923c62ac1 - <unknown>
  54:     0x7ff923c6cacb - <rustc_middle[1d4803ea9c08b419]::ty::SymbolName as core[15ae0b8045847941]::fmt::Debug>::fmt
  55:     0x7ff923c6c319 - <rustc_middle[1d4803ea9c08b419]::ty::SymbolName as core[15ae0b8045847941]::fmt::Debug>::fmt
  56:     0x7ff923c6404d - <rustc_middle[1d4803ea9c08b419]::ty::SymbolName as core[15ae0b8045847941]::fmt::Debug>::fmt
  57:     0x7ff946f5021c - std::sys::windows::thread::Thread::new::hf7aab9c244c58572
  58:     0x7ff9b1647614 - BaseThreadInitThunk
  59:     0x7ff9b31c26a1 - RtlUserThreadStart

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.68.2 (9eb3afe9e 2023-03-27) 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 [typeck] type-checking `b`
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `cool-ice`

@Radbuglet Radbuglet 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 Mar 30, 2023
@aliemjay
Copy link
Member

aliemjay commented Apr 2, 2023

This is #109361. It is fixed in the current beta/nightly.

Closing this in favor of #109361 which should track a possible backport to the stable version. Thanks for reporting!

@aliemjay aliemjay closed this as not planned Won't fix, can't repro, duplicate, stale Apr 2, 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. 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

No branches or pull requests

2 participants