Closed
Description
Code
// crate a
#![feature(type_alias_impl_trait)]
use std::future::Future;
pub trait Service<Request> {
type Future: Future<Output = ()>;
fn call(&mut self, req: Request) -> Self::Future;
}
// NOTE: the pub(crate) here is critical
pub(crate) fn new() -> () {}
pub struct A;
impl Service<()> for A {
type Future = impl Future<Output = ()>;
fn call(&mut self, _: ()) -> Self::Future {
async { new() }
}
}
// crate b
use a::Service;
use std::future::Future;
use std::pin::Pin;
use std::task::Context;
fn broken(mut a: a::A, cx: &mut Context<'_>) {
let mut fut = a.call(());
let _ = unsafe { Pin::new_unchecked(&mut fut) }.poll(cx);
}
pub async fn main(cx: &mut Context<'_>) {
broken(a::A, cx);
}
Meta
$ rustc --version --verbose
rustc 1.43.0-nightly (96bb8b31c 2020-03-05)
binary: rustc
commit-hash: 96bb8b31c81dc2394317f2f083c3acf8087efea1
commit-date: 2020-03-05
host: x86_64-unknown-linux-gnu
release: 1.43.0-nightly
LLVM version: 9.0
Error output
error: internal compiler error: src/librustc_mir/monomorphize/collector.rs:745: cannot create local mono-item for DefId(15:8 ~ a[ffa2]::new[0])
thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:875:9
stack backtrace:
0: backtrace::backtrace::libunwind::trace
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.44/src/backtrace/libunwind.rs:86
1: backtrace::backtrace::trace_unsynchronized
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.44/src/backtrace/mod.rs:66
2: std::sys_common::backtrace::_print_fmt
at src/libstd/sys_common/backtrace.rs:78
3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
at src/libstd/sys_common/backtrace.rs:59
4: core::fmt::write
at src/libcore/fmt/mod.rs:1053
5: std::io::Write::write_fmt
at src/libstd/io/mod.rs:1428
6: std::sys_common::backtrace::_print
at src/libstd/sys_common/backtrace.rs:62
7: std::sys_common::backtrace::print
at src/libstd/sys_common/backtrace.rs:49
8: std::panicking::default_hook::{{closure}}
at src/libstd/panicking.rs:204
9: std::panicking::default_hook
at src/libstd/panicking.rs:224
10: rustc_driver::report_ice
11: std::panicking::rust_panic_with_hook
at src/libstd/panicking.rs:474
12: std::panicking::begin_panic
13: rustc_errors::HandlerInner::bug
14: rustc_errors::Handler::bug
15: rustc::util::bug::opt_span_bug_fmt::{{closure}}
16: rustc::ty::context::tls::with_opt::{{closure}}
17: rustc::ty::context::tls::with_opt
18: rustc::util::bug::opt_span_bug_fmt
19: rustc::util::bug::bug_fmt
20: rustc_mir::monomorphize::collector::should_monomorphize_locally
21: <rustc_mir::monomorphize::collector::MirNeighborCollector as rustc::mir::visit::Visitor>::visit_terminator_kind
22: rustc_mir::monomorphize::collector::collect_items_rec
23: rustc_mir::monomorphize::collector::collect_items_rec
24: rustc_mir::monomorphize::collector::collect_items_rec
25: rustc_session::utils::<impl rustc_session::session::Session>::time
26: rustc_mir::monomorphize::collector::collect_crate_mono_items
27: rustc_mir::monomorphize::partitioning::collect_and_partition_mono_items
28: rustc::dep_graph::graph::DepGraph::with_task_impl
29: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::force_query
30: rustc::ty::query::plumbing::force_from_dep_node
31: rustc::dep_graph::graph::DepGraph::try_mark_previous_green
32: rustc::dep_graph::graph::DepGraph::try_mark_green
33: rustc::dep_graph::graph::DepGraph::try_mark_green_and_read
34: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
35: rustc_metadata::rmeta::encoder::EncodeContext::encode_crate_root
36: rustc::dep_graph::graph::DepGraph::with_ignore
37: rustc_metadata::rmeta::encoder::encode_metadata
38: rustc_metadata::rmeta::decoder::cstore_impl::<impl rustc::middle::cstore::CrateStore for rustc_metadata::creader::CStore>::encode_metadata
39: rustc::ty::context::TyCtxt::encode_metadata
40: rustc_interface::passes::start_codegen
41: rustc::ty::context::tls::enter_global
42: rustc_interface::queries::Queries::ongoing_codegen
43: rustc_interface::interface::run_compiler_in_existing_thread_pool
44: rustc_ast::attr::with_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: rustc 1.43.0-nightly (96bb8b31c 2020-03-05) running on x86_64-unknown-linux-gnu
note: compiler flags: -C debuginfo=2 -C incremental -C target-cpu=native --crate-type lib
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [collect_and_partition_mono_items] collect_and_partition_mono_items
#1 [exported_symbols] exported_symbols
end of query stack
error: aborting due to previous error
error: could not compile `b`.
This is probably a smaller reproduction of #57430.
Metadata
Metadata
Assignees
Labels
Area: Async & AwaitArea: Code generationAsync-await issues that have been triaged during a working group meeting.Category: This is a bug.`#[feature(type_alias_impl_trait)]`Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Helping to "clean up" bugs with minimal examples and bisectionsMedium priorityRelevant to the compiler team, which will review and decide on the PR/issue.This issue requires a nightly compiler in some way.
Type
Projects
Status
Done