Skip to content

ICE FulfillmentError in trait codegen #64401

Description

@ajuvercr

When trying to use generic function with capnproto structs the compiler fails to infer types correctly.
I failed to distil the problem to a smaller size.
Capnproto generates code that implements traits like this
impl <'a> ::capnp::traits::Owned<'a> for Owned { type Reader = Reader<'a>; type Builder = Builder<'a>; }

Error

error: internal compiler error: src/librustc/traits/codegen/mod.rs:154: Encountered errors `[FulfillmentError(Obligation(predicate=Binder(TraitPredicate( fn(&'r mut mozaic::messaging::reactor::LinkHandle<'s, 't0, mozaic::server::runtime::Runtime>, >::Reader) -> std::result::Result<(), mozaic::errors::Error> {mozaic::messaging::reactor::e_to_i::} as std::ops::Fn<(&mut mozaic::messaging::reactor::LinkHandle, mozaic::client_capnp::host_message::Reader<'_>)>>)), depth=2),OutputTypeParameterMismatch(Binder( fn(&'r mut mozaic::messaging::reactor::LinkHandle<'s, 't0, mozaic::server::runtime::Runtime>, >::Reader) -> std::result::Result<(), mozaic::errors::Error> {mozaic::messaging::reactor::e_to_i::} as std::ops::Fn<(&mut mozaic::messaging::reactor::LinkHandle<'_, '_, mozaic::server::runtime::Runtime>, >::Reader)>>), Binder( fn(&'r mut mozaic::messaging::reactor::LinkHandle<'s, 't0, mozaic::server::runtime::Runtime>, >::Reader) -> std::result::Result<(), mozaic::errors::Error> {mozaic::messaging::reactor::e_to_i::} as std::ops::Fn<(&mut mozaic::messaging::reactor::LinkHandle, mozaic::client_capnp::host_message::Reader<'_>)>>), Sorts(ExpectedFound { expected: mozaic::client_capnp::host_message::Reader<'_>, found: >::Reader }))), FulfillmentError(Obligation(predicate=Binder(TraitPredicate( fn(&'r mut mozaic::messaging::reactor::LinkHandle<'s, 't0, mozaic::server::runtime::Runtime>, >::Reader) -> std::result::Result<(), mozaic::errors::Error> {mozaic::messaging::reactor::e_to_i::} as std::ops::Fn<(&mut mozaic::messaging::reactor::LinkHandle, mozaic::client_capnp::host_message::Reader<'_>)>>)), depth=2),OutputTypeParameterMismatch(Binder( fn(&'r mut mozaic::messaging::reactor::LinkHandle<'s, 't0, mozaic::server::runtime::Runtime>, >::Reader) -> std::result::Result<(), mozaic::errors::Error> {mozaic::messaging::reactor::e_to_i::} as std::ops::Fn<(&mut mozaic::messaging::reactor::LinkHandle<'_, '_, mozaic::server::runtime::Runtime>, >::Reader)>>), Binder( fn(&'r mut mozaic::messaging::reactor::LinkHandle<'s, 't0, mozaic::server::runtime::Runtime>, >::Reader) -> std::result::Result<(), mozaic::errors::Error> {mozaic::messaging::reactor::e_to_i::} as std::ops::Fn<(&mut mozaic::messaging::reactor::LinkHandle, mozaic::client_capnp::host_message::Reader<'_>)>>), Sorts(ExpectedFound { expected: mozaic::client_capnp::host_message::Reader<'_>, found: >::Reader }))), FulfillmentError(Obligation(predicate=Binder(TraitPredicate( fn(&'r mut mozaic::messaging::reactor::LinkHandle<'s, 't0, mozaic::server::runtime::Runtime>, >::Reader) -> std::result::Result<(), mozaic::errors::Error> {mozaic::messaging::reactor::e_to_i::} as std::ops::FnOnce<(&mut mozaic::messaging::reactor::LinkHandle, mozaic::client_capnp::host_message::Reader<'_>)>>)), depth=2),OutputTypeParameterMismatch(Binder( fn(&'r mut mozaic::messaging::reactor::LinkHandle<'s, 't0, mozaic::server::runtime::Runtime>, >::Reader) -> std::result::Result<(), mozaic::errors::Error> {mozaic::messaging::reactor::e_to_i::} as std::ops::FnOnce<(&mut mozaic::messaging::reactor::LinkHandle<'_, '_, mozaic::server::runtime::Runtime>, >::Reader)>>), Binder( fn(&'r mut mozaic::messaging::reactor::LinkHandle<'s, 't0, mozaic::server::runtime::Runtime>, >::Reader) -> std::result::Result<(), mozaic::errors::Error> {mozaic::messaging::reactor::e_to_i::} as std::ops::FnOnce<(&mut mozaic::messaging::reactor::LinkHandle, mozaic::client_capnp::host_message::Reader<'_>)>>), Sorts(ExpectedFound { expected: mozaic::client_capnp::host_message::Reader<'_>, found: >::Reader }))), FulfillmentError(Obligation(predicate=Binder(TraitPredicate( fn(&'r mut mozaic::messaging::reactor::LinkHandle<'s, 't0, mozaic::server::runtime::Runtime>, >::Reader) -> std::result::Result<(), mozaic::errors::Error> {mozaic::messaging::reactor::e_to_i::} as std::ops::FnOnce<(&mut mozaic::messaging::reactor::LinkHandle, mozaic::client_capnp::host_message::Reader<'_>)>>)), depth=2),OutputTypeParameterMismatch(Binder( fn(&'r mut mozaic::messaging::reactor::LinkHandle<'s, 't0, mozaic::server::runtime::Runtime>, >::Reader) -> std::result::Result<(), mozaic::errors::Error> {mozaic::messaging::reactor::e_to_i::} as std::ops::FnOnce<(&mut mozaic::messaging::reactor::LinkHandle<'_, '_, mozaic::server::runtime::Runtime>, >::Reader)>>), Binder( fn(&'r mut mozaic::messaging::reactor::LinkHandle<'s, 't0, mozaic::server::runtime::Runtime>, >::Reader) -> std::result::Result<(), mozaic::errors::Error> {mozaic::messaging::reactor::e_to_i::} as std::ops::FnOnce<(&mut mozaic::messaging::reactor::LinkHandle, mozaic::client_capnp::host_message::Reader<'_>)>>), Sorts(ExpectedFound { expected: mozaic::client_capnp::host_message::Reader<'_>, found: >::Reader })))]` resolving bounds after type-checking

Which I think can be distilled down to expected: host_message::Reader<'_>, found: <host_message::Owned as Owned<'_>>::Reader which is the same type.

Meta

rustc --version --verbose:
rustc 1.37.0 (eae3437df 2019-08-13) binary: rustc commit-hash: eae3437dfe991621e8afdc82734f4a172d7ddf9b commit-date: 2019-08-13 host: x86_64-unknown-linux-gnu release: 1.37.0 LLVM version: 8.0

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:650:9
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.29/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.29/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:47
   3: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:36
   4: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:200
   5: std::panicking::default_hook
             at src/libstd/panicking.rs:214
   6: rustc::util::common::panic_hook
   7: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:481
   8: std::panicking::begin_panic
   9: rustc_errors::Handler::bug
  10: rustc::util::bug::opt_span_bug_fmt::{{closure}}
  11: rustc::ty::context::tls::with_opt::{{closure}}
  12: rustc::ty::context::tls::with_context_opt
  13: rustc::ty::context::tls::with_opt
  14: rustc::util::bug::opt_span_bug_fmt
  15: rustc::util::bug::bug_fmt
  16: rustc::traits::codegen::<impl rustc::infer::InferCtxt>::drain_fulfillment_cx_or_panic
  17: rustc::ty::context::GlobalCtxt::enter_local
  18: rustc::traits::codegen::codegen_fulfill_obligation
  19: rustc::ty::query::__query_compute::codegen_fulfill_obligation
  20: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::codegen_fulfill_obligation>::compute
  21: rustc::dep_graph::graph::DepGraph::with_task_impl
  22: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  23: rustc::ty::instance::Instance::resolve
  24: rustc::ty::instance::Instance::resolve_for_vtable
  25: <core::iter::adapters::Cloned<I> as core::iter::traits::iterator::Iterator>::try_fold::{{closure}}
  26: <core::iter::adapters::Map<I,F> as core::iter::traits::iterator::Iterator>::try_fold
  27: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T,I>>::spec_extend
  28: <rustc_mir::monomorphize::collector::MirNeighborCollector as rustc::mir::visit::Visitor>::visit_rvalue
  29: rustc_mir::monomorphize::collector::collect_items_rec
  30: rustc_mir::monomorphize::collector::collect_items_rec
  31: rustc_mir::monomorphize::collector::collect_items_rec
  32: rustc_mir::monomorphize::collector::collect_items_rec
  33: rustc_mir::monomorphize::collector::collect_items_rec
  34: rustc_mir::monomorphize::collector::collect_items_rec
  35: rustc_mir::monomorphize::collector::collect_items_rec
  36: rustc_mir::monomorphize::collector::collect_items_rec
  37: rustc_mir::monomorphize::collector::collect_items_rec
  38: rustc_mir::monomorphize::collector::collect_items_rec
  39: rustc_mir::monomorphize::collector::collect_items_rec
  40: rustc_mir::monomorphize::collector::collect_items_rec
  41: rustc_mir::monomorphize::collector::collect_items_rec
  42: rustc_mir::monomorphize::collector::collect_items_rec
  43: rustc_mir::monomorphize::collector::collect_items_rec
  44: rustc_mir::monomorphize::collector::collect_items_rec
  45: rustc_mir::monomorphize::collector::collect_items_rec
  46: rustc_mir::monomorphize::collector::collect_crate_mono_items::{{closure}}
  47: rustc::util::common::time
  48: rustc_mir::monomorphize::collector::collect_crate_mono_items
  49: rustc::util::common::time
  50: rustc_mir::monomorphize::partitioning::collect_and_partition_mono_items
  51: rustc::ty::query::__query_compute::collect_and_partition_mono_items
  52: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::collect_and_partition_mono_items>::compute
  53: rustc::dep_graph::graph::DepGraph::with_task_impl
  54: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  55: rustc_codegen_ssa::base::codegen_crate
  56: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_utils::codegen_backend::CodegenBackend>::codegen_crate
  57: rustc::util::common::time
  58: rustc_interface::passes::start_codegen
  59: rustc::ty::context::tls::enter_global
  60: rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}
  61: rustc_interface::passes::create_global_ctxt::{{closure}}
  62: rustc_interface::passes::BoxedGlobalCtxt::enter
  63: rustc_interface::queries::Query<T>::compute
  64: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::ongoing_codegen
  65: rustc_interface::interface::run_compiler_in_existing_thread_pool
  66: std::thread::local::LocalKey<T>::with
  67: scoped_tls::ScopedKey<T>::set
  68: syntax::with_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
query stack during panic:
#0 [codegen_fulfill_obligation] checking if `mozaic::messaging::types::Handler` fulfills its obligations
#1 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack

My first issue btw, sorry for noobyness.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-codegenArea: Code generationC-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions