-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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: invalid CoerceUnsized
impl_source: Err(FulfillmentError)
#135470
Comments
Working on minimizing this. |
Old partial reduction (150 lines)use std::future::IntoFuture;
use std::sync::Arc;
use std::{future::Future, pin::Pin};
trait Access {
type Lister;
fn list(&self) -> impl Future<Output = Self::Lister> + Send {
async { todo!() }
}
}
trait AccessDyn: Send + Sync {}
impl Access for Arc<dyn AccessDyn> {
type Lister = ();
}
struct OperatorFuture<F> {
_f: fn() -> F,
}
impl<F: Future> OperatorFuture<F> {
fn new(_: fn(Arc<dyn AccessDyn>) -> F) -> Self {
todo!()
}
}
impl<F> IntoFuture for OperatorFuture<F>
where
F: Future<Output = ()>,
{
type Output = ();
type IntoFuture = F;
fn into_future(self) -> Self::IntoFuture {
todo!()
}
}
pub async fn runner() {
OperatorFuture::new(|v| async move {
v.list().await;
})
.await;
}
struct BoxCloneService(
#[allow(dead_code)] Box<dyn Service<Future = Pin<Box<dyn Future<Output = ()>>>>>,
);
fn main() {
let body = async {
let svc = RuntimeServer(runner);
let inner = svc.map_future(|f| -> Pin<Box<dyn Future<Output = ()>>> { Box::pin(f) });
BoxCloneService(Box::new(inner));
};
let mut p = Box::pin(body);
let _ = p.as_mut().poll(make());
}
fn make<T>() -> T {
todo!()
}
struct RuntimeServer<T: 'static>(T);
type BoxFuture<T> = std::pin::Pin<Box<dyn Future<Output = T> + Send>>;
trait Runner: Send + Sync + Clone {}
impl<F, O> Runner for F
where
F: FnOnce() -> O + Send + Sync + Clone,
O: Future + Send,
{
}
struct LoadSvc<T>(T);
impl<T: Runner> UnaryService for LoadSvc<T> {
type Future = BoxFuture<()>;
}
impl<T> Service for RuntimeServer<T>
where
T: Runner,
{
type Future = BoxFuture<()>;
fn call(&mut self) -> Self::Future {
let inner = self.0.clone();
let fut = async {
unary(LoadSvc(inner)).await;
};
Box::pin(fut)
}
}
trait Service {
type Future: Future<Output = ()>;
fn call(&mut self) -> Self::Future {
todo!()
}
fn map_future<F>(self, _: F) -> MapFuture<Self, F>
where
Self: Sized,
{
todo!()
}
}
trait UnaryService {
type Future: Future;
fn call(&mut self) -> Self::Future {
todo!()
}
}
impl<T> UnaryService for T
where
T: Service,
{
type Future = T::Future;
}
fn unary<S>(mut service: S) -> impl Future
where
S: UnaryService,
{
service.call()
}
struct MapFuture<S, F> {
inner: S,
f: F,
}
impl<S, F, Fut> Service for MapFuture<S, F>
where
S: Service,
F: FnMut(S::Future) -> Fut,
Fut: Future<Output = ()>,
{
type Future = Fut;
fn call(&mut self) -> Self::Future {
(self.f)(self.inner.call())
}
} smaller reduction (50 lines): use std::future::Future;
use std::marker::PhantomData;
struct Arc<T: ?Sized = dyn Send>(PhantomData<T>);
trait Access {
type Lister;
fn list() -> impl Future<Output = Self::Lister> {
async { todo!() }
}
}
impl Access for Arc {
type Lister = ();
}
fn main() {
let svc = async {
async { Arc::list() }.await;
};
&svc as &dyn Service;
}
struct LoadSvc<T>(T);
impl<T: Send> UnaryService for LoadSvc<T> {}
impl<T> Service for T
where
T: Send,
{
fn call(&self) {
LoadSvc::<T>::call2();
}
}
trait Service {
fn call(&self);
}
trait UnaryService {
fn call2() {}
}
trait Unimplemented {}
impl<T> UnaryService for T where T: Unimplemented {} maybe a duplicate of #119095? |
Nice you were able to remove all the dependencies. Thanks. |
The best reduction I can make for this (and I don't think it can be shortened much more): use std::future::Future;
trait Access {
type Lister;
fn list() -> impl Future<Output = Self::Lister> {
async { todo!() }
}
}
trait Foo {}
impl Access for dyn Foo {
type Lister = ();
}
fn main() {
let svc = async {
async { <dyn Foo>::list() }.await;
};
&svc as &dyn Service;
}
trait UnaryService {
fn call2() {}
}
trait Unimplemented {}
impl<T: Unimplemented> UnaryService for T {}
struct Wrap<T>(T);
impl<T: Send> UnaryService for Wrap<T> {}
trait Service {
fn call(&self);
}
impl<T: Send> Service for T {
fn call(&self) {
Wrap::<T>::call2();
}
} @rustbot label -E-needs-mcve S-has-mcve |
bisects to
Given the backtrace it seems quiet likely to be #122568 cc: @RalfJung @rustbot label -E-needs-bisection +S-has-bisection |
I noticed the errors are different between the originally posted code and the reduced code in this comment The error for the reduced code is
Backtrace
|
That PR just monomorphizes more things. So possibly the ICE already existed before but was just not exposed? Cc @compiler-errors @lcnr somehow we are seeing a panic in |
If you need me to try to remove more of the dependencies please let me know but I got tired while producing the MRE. I managed to remove all the macros and shuttle dependencies but reached a local minimum and would have try to start unwrapping tonic next. If it's needed let me know but wasn't sure if it was worth the effort. The code can also be found in this repo. Because I didn't finish removing all the dependencies I've also included the
Cargo.toml
Cargo.toml
Code
Meta
rustc --version --verbose
:Error output
Backtrace
The text was updated successfully, but these errors were encountered: