Skip to content
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

ICE FulfillmentError in trait codegen #64401

Closed
ajuvercr opened this issue Sep 12, 2019 · 7 comments · Fixed by #99307
Closed

ICE FulfillmentError in trait codegen #64401

ajuvercr opened this issue Sep 12, 2019 · 7 comments · Fixed by #99307
Labels
A-codegen Area: Code generation C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. 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

@ajuvercr
Copy link

ajuvercr commented Sep 12, 2019

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/git.luolix.top-1ecc6299db9ec823/backtrace-0.3.29/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/git.luolix.top-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.

@jonas-schievink jonas-schievink added A-codegen Area: Code generation 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 Sep 12, 2019
@jonas-schievink
Copy link
Contributor

Please provide the source code needed to reproduce this

@ajuvercr
Copy link
Author

It can be found here https://github.com/ajuvercr/MOZAIC on the CRASH branch.
To compile you need capnproto etc also :/

@Centril Centril added the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Mar 10, 2020
@dwrensha
Copy link
Contributor

Here is a self-contained reduced example from that code. It can probably be reduced a lot more.

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=d7e1215d25002ec716b39015f9d82b6f

 pub trait Owned<'a> {
    type Reader: FromPointerReader<'a>;
}
pub trait FromPointerReader<'a> : Sized {
    fn get_from_pointer(reader: &'a[u8]) -> Self;
}

pub mod messaging {
    pub mod reactor {
        use std::collections::HashMap;
        use super::types::{Handler, AnyPtrHandler};
        use crate::any_pointer;
        use crate::Owned;

        pub trait Ctx : 'static + for<'a> Context<'a> {}
        impl<C> Ctx for C where C: 'static + for<'a> Context<'a> {}

        pub trait Context<'a> : Sized {
            type Handle: 'a + CtxHandle<Self>;
        }

        pub trait CtxHandle<C> {
            fn spawn<S>(&mut self, params: CoreParams<S, C>)
                where S: 'static + Send,
                      C: Ctx;
        }

        pub struct Reactor<S, C: Ctx> {
            pub internal_state: S,
            pub internal_handlers: HashMap<u64, CoreHandler<S, C>>,
        }

        pub struct LinkReducer<S, C>
            where C: Ctx
        {
            pub state: S,
            pub internal_handlers: LinkHandlers<S, C>,
        }

        pub struct ReactorHandle<'a, 'c: 'a, C: Ctx> {
            _ctx: &'a mut <C as Context<'c>>::Handle,
        }

        impl<'a, 'c, C: Ctx> ReactorHandle<'a, 'c, C> {
            pub fn open_link<S>(&mut self, _params: LinkParams<S, C>)
                where S: 'static + Send
            {
                todo!()
            }
        }

        pub struct LinkHandle<'a, 'c: 'a, C: Ctx> {
            _ctx: &'a mut <C as Context<'c>>::Handle,
        }

        pub struct HandlerCtx<'a, S, H> {
            state: &'a mut S,
            handle: &'a mut H,
        }

        impl<'a, S, H> HandlerCtx<'a, S, H> {
            pub fn state<'b>(&'b mut self) -> &'b mut S {
                &mut self.state
            }

            pub fn handle<'b>(&'b mut self) -> &'b mut H {
                &mut self.handle
            }
        }

        use std::marker::PhantomData;

        pub struct CtxHandler<M, F> {
            message_type: PhantomData<M>,
            function: F,
        }

        impl<M, F> CtxHandler<M, F> {
            pub fn new(function: F) -> Self {
                CtxHandler {
                    message_type: PhantomData,
                    function,
                }
            }
        }

        impl<'a, S, H, M, F> Handler<'a, HandlerCtx<'a, S, H>, M> for CtxHandler<M, F>
            where F: Fn(&mut S, &mut H, <M as Owned<'a>>::Reader),
                  F: Send,
                  M: Owned<'a> + 'static + Send
        {
            fn handle(&self, ctx: &mut HandlerCtx<'a, S, H>, reader: <M as Owned<'a>>::Reader)
            {
                (self.function)(&mut ctx.state, &mut ctx.handle, reader);
            }
        }

        pub struct CtxHandlerWithoutState<M, F> {
            message_type: PhantomData<M>,
            _function: F,
        }

        impl<M, F> CtxHandlerWithoutState<M, F> {
            pub fn new(_function: F) -> Self { todo!() }
        }

        impl<'a, S, H, M, F> Handler<'a, HandlerCtx<'a, S, H>, M> for CtxHandlerWithoutState<M, F>
            where F: Fn(&mut H, <M as Owned<'a>>::Reader),
                  F: Send,
                  M: Owned<'a> + 'static + Send
        {
            fn handle(&self, _ctx: &mut HandlerCtx<'a, S, H>, _reader: <M as Owned<'a>>::Reader)
            {
                todo!()
            }
        }

        pub type ReactorCtx<'a, 'c, S, C> = HandlerCtx<'a, S, ReactorHandle<'a, 'c, C>>;
        pub type LinkCtx<'a, 'c, S, C> = HandlerCtx<'a, S, LinkHandle<'a, 'c, C>>;

        type CoreHandler<S, C> = Box<
                dyn for <'a, 'c>
                Handler<
                        'a,
                    HandlerCtx<'a, S, ReactorHandle<'a, 'c, C>>,
                    any_pointer::Owned,
                        >
                >;

        type LinkHandler<S, C> = Box<
                dyn for<'a, 'c>
                Handler<'a,
                        HandlerCtx<'a, S, LinkHandle<'a, 'c, C>>,
                        any_pointer::Owned,
                        >
                >;

        type LinkHandlers<S, C> = HashMap<u64, LinkHandler<S, C>>;

        pub struct CoreParams<S, C: Ctx> {
            pub state: S,
            pub handlers: HashMap<u64, CoreHandler<S, C>>,
        }

        impl<S, C: Ctx> CoreParams<S, C> {
            pub fn new(_state: S) -> Self {
                todo!()
            }

            pub fn handler<M, H>(&mut self, _m: M, h: H)
                where M: for<'a> Owned<'a> + Send + 'static,
                      H: 'static + for <'a, 'c> Handler<'a, HandlerCtx<'a, S, ReactorHandle<'a, 'c, C>>, M>,
            {
                let boxed = Box::new(AnyPtrHandler::new(h));
                self.handlers.insert(
                    0,
                    boxed,
                );
            }
        }

        pub struct LinkParams<S, C: Ctx> {
            pub state: S,
            pub external_handlers: LinkHandlers<S, C>,
        }

        impl<S, C: Ctx> LinkParams<S, C> {
            pub fn new(_state: S) -> Self {
                todo!()
            }

            pub fn external_handler<M, H>(&mut self, _m: M, h: H)
                where M: for<'a> Owned<'a> + Send + 'static,
                      H: 'static + for <'a, 'c> Handler<'a, HandlerCtx<'a, S, LinkHandle<'a, 'c, C>>, M>
            {
                let boxed = Box::new(AnyPtrHandler::new(h));
                self.external_handlers.insert(
                    0,
                    boxed,
                );
            }

            pub fn send_external_to_internal<M>(&mut self, m: M,)
                where M: for<'a> Owned<'a> + Send + 'static,
            {
                self.external_handler(m, CtxHandlerWithoutState::new(e_to_i::<C, M>));
            }
        }

        fn e_to_i<C:Ctx, M>(_handle: &mut LinkHandle<C>, _msg: <M as Owned<'_>>::Reader)
            where
            M: for<'a> Owned<'a> + Send + 'static,
        {
            todo!()
        }
    }

    pub mod types {
        use std::marker::PhantomData;
        use crate::any_pointer;
        use crate::Owned;

        pub trait Handler<'a, S, M>: Send
            where M: Owned<'a>
        {
            fn handle(&self, state: &mut S, reader: <M as Owned<'a>>::Reader);
        }

        pub struct FnHandler<M, F> {
            message_type: PhantomData<M>,
            _function: F,
        }

        impl<M, F> FnHandler<M, F> {
            pub fn new(function: F) -> Self {
                FnHandler {
                    _function: function,
                    message_type: PhantomData,
                }
            }
        }

        impl<'a, S, M, F, T, E> Handler<'a, S, M> for FnHandler<M, F>
            where F: Fn(&mut S, <M as Owned<'a>>::Reader) -> Result<T, E>,
                  F: Send,
                  M: Owned<'a> + 'static + Send
        {
            fn handle(&self, _state: &mut S, _reader: <M as Owned<'a>>::Reader)
            {}
        }

        pub struct AnyPtrHandler<H, M> {
            message_type: PhantomData<M>,
            handler: H,
        }

        impl<H, M> AnyPtrHandler<H, M> {
            pub fn new(handler: H) -> Self {
                AnyPtrHandler {
                    handler,
                    message_type: PhantomData,
                }
            }
        }

        impl<'a, S, M, H> Handler<'a, S, any_pointer::Owned> for AnyPtrHandler<H, M>
            where H: Handler<'a, S, M>,
                  M: Send + Owned<'a>
        {
            fn handle(&self, state: &mut S, reader: any_pointer::Reader<'a>)
            {
                let m = reader.get_as();
                return self.handler.handle(state, m);
            }
        }
    }
}

pub mod runtime {
    use crate::messaging::reactor::{CtxHandle, CoreParams, Context};
    pub struct Runtime;

    pub fn spawn<S>(_core_params: CoreParams<S, Runtime>)
        where S: 'static + Send
    {
        todo!()
    }

    impl<'a> Context<'a> for Runtime {
        type Handle = DriverHandle<'a>;
    }

    pub struct DriverHandle<'a> {
        _broker: &'a (),
    }

    impl<'a> CtxHandle<Runtime> for DriverHandle<'a> {
        fn spawn<T>(&mut self, _params: CoreParams<T, Runtime>)
            where T: 'static + Send
        {
            todo!()
        }
    }
}

pub mod aggregator {
    use crate::messaging::reactor::{LinkParams, Ctx, ReactorHandle, CoreParams, CtxHandler};
    use crate::any_pointer;
    pub struct Aggregator;

    impl Aggregator {
        pub fn params<C: Ctx>() -> CoreParams<Self, C> {
            let me = Self;
            let mut params = CoreParams::new(me);
            params.handler(any_pointer::Owned, CtxHandler::new(Self::handle_initialize));
            return params;
        }

        fn handle_initialize<C: Ctx>(
            &mut self,
            handle: &mut ReactorHandle<C>,
            _: any_pointer::Reader,
        )
        {
            handle.open_link(HostLink::params());
        }
    }

    struct HostLink;
    impl HostLink {
        fn params<C: Ctx>() -> LinkParams<Self, C> {
            let mut params = LinkParams::new(HostLink);
            params.send_external_to_internal(any_pointer::Owned);
            return params;
        }
    }
}

pub mod any_pointer {
    pub struct Owned;

    impl <'a> crate::Owned<'a> for Owned {
        type Reader = Reader<'a>;
    }

    pub struct Reader<'a> {
        _reader: &'a[u8],
    }

    impl <'a> Reader<'a> {
        pub fn get_as<T: crate::FromPointerReader<'a>>(&self) -> T {
            todo!()
        }
    }

    impl <'a,> crate::FromPointerReader<'a> for Reader<'a,>  {
        fn get_from_pointer(_reader: &'a[u8]) -> Reader<'a,> {
            todo!()
        }
    }
}

pub fn foo() {
    crate::runtime::spawn(crate::aggregator::Aggregator::params());
}

@Johannesd3
Copy link

Johannesd3 commented May 8, 2021

Is this good enough as MCVE?

use std::marker::PhantomData;

trait Owned<'a> {
    type Reader;
}

impl<'a> Owned<'a> for () {
    type Reader = ();
}

trait Handler {
    fn handle(&self);
}

struct CtxHandlerWithoutState<M, F> {
    message_type: PhantomData<M>,
    _function: F,
}

impl<M, F> CtxHandlerWithoutState<M, F> {
    pub fn new(_function: F) -> Self {
        Self {
            message_type: PhantomData,
            _function,
        }
    }
}

impl<'a, M, F> Handler for CtxHandlerWithoutState<M, F>
where
    F: Fn(<M as Owned<'a>>::Reader),
    M: Owned<'a>,
{
    fn handle(&self) {}
}

fn e_to_i<M: for<'a> Owned<'a>>(_: <M as Owned<'_>>::Reader) {}

fn send_external_to_internal<M>()
where
    M: for<'a> Owned<'a>,
{
    let _: Box<dyn Handler> = Box::new(CtxHandlerWithoutState::<M, _>::new(e_to_i::<M>));
}

pub fn main() {
    send_external_to_internal::<()>()
}

Edit: Reduced it further

@jonas-schievink jonas-schievink removed the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label May 8, 2021
@matthiaskrgr
Copy link
Member

Seems to no longer ICE with rustc 1.57.0-nightly (497ee321a 2021-09-09)?

@rustbot modify labels: E-needs-test

@rustbot rustbot added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Sep 10, 2021
@dwrensha
Copy link
Contributor

searched nightlies: from nightly-2021-05-01 to nightly-2021-09-10
regressed nightly: nightly-2021-08-26
searched commits: from b03ccac to 0afc208
regressed commit: 0afc208

bisected with cargo-bisect-rustc v0.6.0

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc --start=2021-5-1 --end=2021-09-10 --regress non-ice 

@dwrensha
Copy link
Contributor

Looks like #85499 fixed this.

JohnTitor added a commit to JohnTitor/rust that referenced this issue Jul 16, 2022
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
bors added a commit to rust-lang-ci/rust that referenced this issue Jul 16, 2022
Rollup of 7 pull requests

Successful merges:

 - rust-lang#98387 (Add new unstable API `downcast` to `std::io::Error`)
 - rust-lang#98662 (Add std::fs::write documentation precision)
 - rust-lang#99253 (Remove FIXME from MIR `always_storage_live_locals`)
 - rust-lang#99264 (Fix typo in mod.rs)
 - rust-lang#99270 (Add `#[must_use]` to `Box::from_raw`)
 - rust-lang#99277 (Stabilize `core::ffi::CStr`, `alloc::ffi::CString`, and friends)
 - rust-lang#99307 (Add regression test for rust-lang#64401)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors closed this as completed in 202c11b Jul 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. 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

Successfully merging a pull request may close this issue.

7 participants