Closed
Description
Code
use std::collections::HashMap;
use std::future::Future;
use std::pin::Pin;
use async_trait::async_trait;
#[async_trait]
pub trait Trait {
async fn do_something(byte: u8);
}
pub struct Struct;
#[async_trait]
impl Trait for Struct {
async fn do_something(byte: u8) {
}
}
pub struct Map {
map: HashMap<u16, fn(u8) -> Pin<Box<dyn Future<Output = ()> + Send>>>,
}
impl Map {
pub fn new() -> Self {
let mut map = HashMap::new();
map.insert(1, Struct::do_something);
Self {
map,
}
}
}
Meta
rustc --version --verbose
:
rustc 1.69.0-nightly (e1eaa2d5d 2023-02-06)
binary: rustc
commit-hash: e1eaa2d5d4d1f5b7b89561a940718058d414e89c
commit-date: 2023-02-06
host: x86_64-unknown-linux-gnu
release: 1.69.0-nightly
LLVM version: 15.0.7
Error output
error: internal compiler error: no errors encountered even though `delay_span_bug` issued
error: internal compiler error: `TypeError` when attempting coercion but no error emitted
Backtrace
query stack during panic:
#0 [typeck] type-checking `<impl at src/lib.rs:24:1: 24:27>::new`
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack
error: internal compiler error: no errors encountered even though `delay_span_bug` issued
error: internal compiler error: `TypeError` when attempting coercion but no error emitted
--> src/lib.rs:29:13
|
29 | map,
| ^^^
|
= note: delayed at 0: <rustc_errors::HandlerInner>::emit_diagnostic
1: <rustc_errors::Handler>::delay_span_bug::<rustc_span::span_encoding::Span, &str>
2: <rustc_hir_typeck::fn_ctxt::FnCtxt>::demand_coerce_diag
3: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_struct_fields
4: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
5: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_block_with_expected
6: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
7: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_return_expr
8: rustc_hir_typeck::check::check_fn
9: rustc_hir_typeck::typeck
10: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, rustc_span::def_id::LocalDefId, &rustc_middle::ty::typeck_results::TypeckResults>
11: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::typeck, rustc_query_impl::plumbing::QueryCtxt>
12: rustc_data_structures::sync::par_for_each_in::<&[rustc_span::def_id::LocalDefId], <rustc_middle::hir::map::Map>::par_body_owners<rustc_hir_typeck::typeck_item_bodies::{closure#0}>::{closure#0}>
13: rustc_hir_typeck::typeck_item_bodies
14: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, (), ()>
15: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::typeck_item_bodies, rustc_query_impl::plumbing::QueryCtxt>
16: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::typeck_item_bodies
17: <rustc_session::session::Session>::time::<(), rustc_hir_analysis::check_crate::{closure#7}>
18: rustc_hir_analysis::check_crate
19: rustc_interface::passes::analysis
20: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, (), core::result::Result<(), rustc_errors::ErrorGuaranteed>>
21: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
22: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
23: <rustc_interface::passes::QueryContext>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}::{closure#3}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
24: <rustc_interface::interface::Compiler>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_errors::ErrorGuaranteed>>
25: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
26: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
27: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
28: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
29: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
at /rustc/e1eaa2d5d4d1f5b7b89561a940718058d414e89c/library/alloc/src/boxed.rs:1988:9
30: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
at /rustc/e1eaa2d5d4d1f5b7b89561a940718058d414e89c/library/alloc/src/boxed.rs:1988:9
31: std::sys::unix::thread::Thread::new::thread_start
at /rustc/e1eaa2d5d4d1f5b7b89561a940718058d414e89c/library/std/src/sys/unix/thread.rs:108:17
32: <unknown>
33: <unknown>
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.69.0-nightly (e1eaa2d5d 2023-02-06) running on x86_64-unknown-linux-gnu
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:
end of query stack
thread panicked while panicking. aborting.