Panic if closure parameter given a type #109972
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.
The code below depends on lol_html crate.
The panic occurs when the closure within text! is given a type as demonstrated in the example below. If the closure is defined simply as
|t| { ... }
, compilation is successful and the test runs. The reason I want to givet
a type is that I want to extract the closure out of the code where it is currently embedded for code hygiene reasons.Code
Meta
rustc 1.68.2 (9eb3afe 2023-03-27)
binary: rustc
commit-hash: 9eb3afe
commit-date: 2023-03-27
host: x86_64-pc-windows-msvc
release: 1.68.2
LLVM version: 15.0.6
Error output
error: internal compiler error: compiler\rustc_infer\src\infer\region_constraints\mod.rs:568:17: cannot relate bound region: ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:19 ~ test_html[9e65]::extract_content::'), ') }) <= ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrNamed(DefId(16:3503 ~ lol_html[7fdc]::rewriter::settings::{impl#0}::text::'#1), ') })
thread 'rustc' panicked at 'Box', /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0\compiler\rustc_errors\src\lib.rs:987:33
stack backtrace:
0: 0x7ffe8e419d02 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hbb6eec21cb8e3d1b
1: 0x7ffe8e45570b - core::fmt::write::h3f34d6e08b5a11e8
2: 0x7ffe8e40cdfa - <std::io::IoSlice as core::fmt::Debug>::fmt::h1d8b4e60e4c9e548
3: 0x7ffe8e419a4b - std::sys::common::alloc::realloc_fallback::h258dcd65da5985d2
4: 0x7ffe8e41d3f9 - std::panicking::default_hook::h90b70b966050cb60
5: 0x7ffe8e41d07b - std::panicking::default_hook::h90b70b966050cb60
6: 0x7ffe548f9425 - rustc_driver[fbeb20e0897b27eb]::describe_lints
7: 0x7ffe8e41dd5f - std::panicking::rust_panic_with_hook::h1d50ae3462f62f01
8: 0x7ffe56bba703 - <<rustc_infer[e1f2f17455595243]::infer::error_reporting::TypeErrCtxt>::construct_generic_bound_failure::SubOrigin as core[15ae0b8045847941]::fmt::Debug>::fmt
9: 0x7ffe56bb8c19 - <<rustc_infer[e1f2f17455595243]::infer::error_reporting::TypeErrCtxt>::construct_generic_bound_failure::SubOrigin as core[15ae0b8045847941]::fmt::Debug>::fmt
10: 0x7ffe56bb8bb9 - <<rustc_infer[e1f2f17455595243]::infer::error_reporting::TypeErrCtxt>::construct_generic_bound_failure::SubOrigin as core[15ae0b8045847941]::fmt::Debug>::fmt
11: 0x7ffe56bb8ba9 - <<rustc_infer[e1f2f17455595243]::infer::error_reporting::TypeErrCtxt>::construct_generic_bound_failure::SubOrigin as core[15ae0b8045847941]::fmt::Debug>::fmt
12: 0x7ffe56bb8220 - <<rustc_infer[e1f2f17455595243]::infer::error_reporting::TypeErrCtxt>::construct_generic_bound_failure::SubOrigin as core[15ae0b8045847941]::fmt::Debug>::fmt
13: 0x7ffe56bb8079 - <<rustc_infer[e1f2f17455595243]::infer::error_reporting::TypeErrCtxt>::construct_generic_bound_failure::SubOrigin as core[15ae0b8045847941]::fmt::Debug>::fmt
14: 0x7ffe56bc04c9 - <rustc_infer[e1f2f17455595243]::infer::opaque_types::table::OpaqueTypeStorage as core[15ae0b8045847941]::fmt::Debug>::fmt
15: 0x7ffe56bc052d - <rustc_infer[e1f2f17455595243]::infer::opaque_types::table::OpaqueTypeStorage as core[15ae0b8045847941]::fmt::Debug>::fmt
16: 0x7ffe56bbf73a - <rustc_infer[e1f2f17455595243]::infer::opaque_types::table::OpaqueTypeStorage as core[15ae0b8045847941]::fmt::Debug>::fmt
17: 0x7ffe56bbf678 - <rustc_infer[e1f2f17455595243]::infer::opaque_types::table::OpaqueTypeStorage as core[15ae0b8045847941]::fmt::Debug>::fmt
18: 0x7ffe56bbf636 - <rustc_infer[e1f2f17455595243]::infer::opaque_types::table::OpaqueTypeStorage as core[15ae0b8045847941]::fmt::Debug>::fmt
19: 0x7ffe5472776a - <rustc_infer[e1f2f17455595243]::infer::combine::ConstInferUnifier as rustc_middle[1d4803ea9c08b419]::ty::relate::TypeRelation>::consts
20: 0x7ffe5473650f - <rustc_middle[1d4803ea9c08b419]::ty::sty::AliasTy as rustc_infer[e1f2f17455595243]::infer::at::ToTrace>::to_trace
21: 0x7ffe546f1909 - <rustc_infer[e1f2f17455595243]::infer::equate::Equate as rustc_middle[1d4803ea9c08b419]::ty::relate::TypeRelation>::tys
22: 0x7ffe52ebd78a - <rustc_middle[1d4803ea9c08b419]::traits::specialization_graph::Children as rustc_trait_selection[5f0f54a03cd0c301]::traits::specialize::specialization_graph::ChildrenExt>::insert_blindly
23: 0x7ffe52eab10b - <rustc_trait_selection[5f0f54a03cd0c301]::traits::project::AssocTypeNormalizer as rustc_middle[1d4803ea9c08b419]::ty::fold::TypeFolder>::fold_const
24: 0x7ffe56b09218 - <rustc_trait_selection[5f0f54a03cd0c301]::solve::search_graph::StackDepth as core[15ae0b8045847941]::fmt::Debug>::fmt
25: 0x7ffe56aa7a09 - <rustc_trait_selection[5f0f54a03cd0c301]::traits::error_reporting::method_chain::CollectAllMismatches as rustc_middle[1d4803ea9c08b419]::ty::relate::TypeRelation>::consts
26: 0x7ffe56b216c3 - <rustc_infer[e1f2f17455595243]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[5f0f54a03cd0c301]::traits::error_reporting::suggestions::TypeErrCtxtExt>::report_closure_arg_mismatch
27: 0x7ffe56b34bdb - <rustc_infer[e1f2f17455595243]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[5f0f54a03cd0c301]::traits::error_reporting::TypeErrCtxtExt>::report_selection_error
28: 0x7ffe56b41805 - <rustc_infer[e1f2f17455595243]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[5f0f54a03cd0c301]::traits::error_reporting::InferCtxtPrivExt>::report_fulfillment_error
29: 0x7ffe56b31569 - <rustc_infer[e1f2f17455595243]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[5f0f54a03cd0c301]::traits::error_reporting::TypeErrCtxtExt>::report_fulfillment_errors
30: 0x7ffe53a7dee4 - <rustc_hir_typeck[527c1058ba999897]::fn_ctxt::FnCtxt>::probe_instantiate_query_response
31: 0x7ffe53a1bf03 - <rustc_hir_typeck[527c1058ba999897]::fn_ctxt::FnCtxt>::check_call
32: 0x7ffe53a47e20 - <rustc_hir_typeck[527c1058ba999897]::fn_ctxt::FnCtxt>::demand_coerce
33: 0x7ffe53a5f5c5 - <rustc_hir_typeck[527c1058ba999897]::fn_ctxt::FnCtxt>::demand_coerce
34: 0x7ffe53a49d63 - <rustc_hir_typeck[527c1058ba999897]::fn_ctxt::FnCtxt>::demand_coerce
35: 0x7ffe53a7bf90 - <rustc_hir_typeck[527c1058ba999897]::fn_ctxt::FnCtxt>::probe_instantiate_query_response
36: 0x7ffe53a1bf03 - <rustc_hir_typeck[527c1058ba999897]::fn_ctxt::FnCtxt>::check_call
37: 0x7ffe53a47e20 - <rustc_hir_typeck[527c1058ba999897]::fn_ctxt::FnCtxt>::demand_coerce
38: 0x7ffe53a88feb - <rustc_hir_typeck[527c1058ba999897]::fn_ctxt::FnCtxt>::check_struct_path
39: 0x7ffe53a8a5cf - <rustc_hir_typeck[527c1058ba999897]::fn_ctxt::FnCtxt>::check_struct_path
40: 0x7ffe53a47fbf - <rustc_hir_typeck[527c1058ba999897]::fn_ctxt::FnCtxt>::demand_coerce
41: 0x7ffe53a5d7c0 - <rustc_hir_typeck[527c1058ba999897]::fn_ctxt::FnCtxt>::demand_coerce
42: 0x7ffe53afc29d - <rustc_hir_typeck[527c1058ba999897]::writeback::WritebackCx as rustc_hir[38532e4666ac8dc2]::intravisit::Visitor>::visit_ty
43: 0x7ffe53a0efcc - <rustc_hir_typeck[527c1058ba999897]::inherited::Inherited as core[15ae0b8045847941]::ops::deref::Deref>::deref
44: 0x7ffe52ade669 - <rustc_query_impl[22fc8f5fe5921e7d]::on_disk_cache::CacheEncoder as rustc_type_ir[76501457ae8f3cde]::codec::TyEncoder>::encode_alloc_id
45: 0x7ffe52b447c5 - <&[(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
46: 0x7ffe542d08ad - <&[(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
47: 0x7ffe5659ccc7 - <alloc[d260749666d7db70]::vec::Vec as rustc_serialize[637af69557f69e4e]::serialize::Decodable<rustc_query_impl[22fc8f5fe5921e7d]::on_disk_cache::CacheDecoder>>::decode
48: 0x7ffe564d6161 - <rustc_query_impl[22fc8f5fe5921e7d]::plumbing::QueryCtxt>::try_print_query_stack
49: 0x7ffe5423be64 - <&[(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
50: 0x7ffe5423b3f2 - <&[(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
51: 0x7ffe52c70890 - <&[(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
52: 0x7ffe52bd2385 - <&[(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
53: 0x7ffe52ab3152 - <rustc_query_impl[22fc8f5fe5921e7d]::Queries as rustc_middle[1d4803ea9c08b419]::ty::query::QueryEngine>::try_mark_green
54: 0x7ffe527ea1aa - <<dyn rustc_hir_analysis[9d3badbe7d08bcd8]::astconv::AstConv>::create_substs_for_ast_path::{closure#0}::SubstsForAstPathCtxt as rustc_hir_analysis[9d3badbe7d08bcd8]::astconv::CreateSubstsForGenericArgsCtxt>::inferred_kind
55: 0x7ffe527e1ea9 - rustc_hir_analysis[9d3badbe7d08bcd8]::check_crate
56: 0x7ffe520c2295 - rustc_interface[5b253cef4d5aad89]::passes::analysis
57: 0x7ffe52adff1f - <rustc_query_impl[22fc8f5fe5921e7d]::on_disk_cache::CacheEncoder as rustc_type_ir[76501457ae8f3cde]::codec::TyEncoder>::encode_alloc_id
58: 0x7ffe52b5ed19 - <&[(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
59: 0x7ffe52c4b611 - <&[(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
60: 0x7ffe52ab094f - <rustc_query_impl[22fc8f5fe5921e7d]::Queries as rustc_middle[1d4803ea9c08b419]::ty::query::QueryEngine>::try_mark_green
61: 0x7ffe5206d1a9 - <rustc_middle[1d4803ea9c08b419]::ty::SymbolName as core[15ae0b8045847941]::fmt::Debug>::fmt
62: 0x7ffe5207e7fa - rustc_driver[fbeb20e0897b27eb]::args::arg_expand_all
63: 0x7ffe52062ac1 -
64: 0x7ffe5206cacb - <rustc_middle[1d4803ea9c08b419]::ty::SymbolName as core[15ae0b8045847941]::fmt::Debug>::fmt
65: 0x7ffe5206c319 - <rustc_middle[1d4803ea9c08b419]::ty::SymbolName as core[15ae0b8045847941]::fmt::Debug>::fmt
66: 0x7ffe5206404d - <rustc_middle[1d4803ea9c08b419]::ty::SymbolName as core[15ae0b8045847941]::fmt::Debug>::fmt
67: 0x7ffe8e43021c - std::sys::windows::thread::Thread::new::hf7aab9c244c58572
68: 0x7fff09c07614 - BaseThreadInitThunk
69: 0x7fff0ab826a1 - 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 (9eb3afe 2023-03-27) running on x86_64-pc-windows-msvc
note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED] -C target-feature=+crt-static
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [typeck] type-checking
extract_content
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack
The text was updated successfully, but these errors were encountered: