Open chadaustin opened 5 months ago
Oh, here's the error message:
error: internal compiler error: compiler\rustc_middle\src\ty\mod.rs:1588:13: item_name: no name for DefPath { data: [DisambiguatedDefPathData { data: TypeNs("ChannelSender"), disambiguator: 0 }, DisambiguatedDefPathData { data: TypeNs(""
), disambiguator: 0 }], krate: crate0 }
Minimizing the code is nontrivial. Let me know if it is required to make a branch that reproduces the issue.
Yep, I can't fix this with no code. It's not clear what the issue is from the ICE backtrace alone.
you could probably fix https://github.com/rust-lang/rust/issues/125099 and it would fix this one as well?
Clone the batch-channel project and check out the async-closure-autobatch:
git clone https://github.com/chadaustin/batch-channel.git
cd batch-channel
git checkout async-closure-autobatch
Then cargo check the throughput benchmark:
cargo +nightly check --bench throughput
Self-contained reproduction (probably can be minimized further):
use std::future::Future;
trait AsyncCallback<A>: FnOnce(A) -> Self::Fut {
type Fut: Future<Output = ()>;
}
impl<A, Out: Future<Output = ()>, F: FnOnce(A) -> Out> AsyncCallback<A> for F {
type Fut = Out;
}
struct BatchSender<T>(T);
trait ChannelSender<T>: Clone + Send {
type BatchSender;
fn autobatch<F>(self, f: F) -> impl Future<Output = ()> + Send
where
F: for<'a> AsyncCallback<&'a mut Self::BatchSender>;
}
struct Sender<T>(T);
impl<T: Send> ChannelSender<T> for Sender<T> {
type BatchSender = BatchSender<T>;
fn autobatch<F>(self, f: F) -> impl Future<Output = ()> + Send
where
F: for<'a> AsyncCallback<&'a mut Self::BatchSender>,
{
async {}
}
}
Notably doesn't require the async_closure feature.
@rustbot label -F-async_closure
Thanks!!
Minimized (I can't get it smaller than this) and got rid of dependence on std:
trait MyFn<T> {
type Output;
}
trait MyFnAlias<A>: MyFn<A, Output = Self::OutputAlias> {
type OutputAlias;
}
impl<A, F: MyFn<A>> MyFnAlias<A> for F {
type OutputAlias = F::Output;
}
struct Thing;
trait Trait {}
impl Trait for Thing {}
trait ChannelSender {
type Arg;
fn autobatch<F>(self) -> impl Trait
where
F: MyFnAlias<Self::Arg>;
}
struct Sender;
impl ChannelSender for Sender {
type Arg = i32;
fn autobatch<F>(self) -> impl Trait
where
F: MyFnAlias<Self::Arg>,
{
Thing
}
}
I believe this code should compile.
Oh yeah, this has nothing to do with async closures at all.
This is a shortcoming of the old trait solver having to do with -- and pardon for my technical jargon -- not being able to normalize param envs correctly. I think there should be other issues like this, probably labeled fixed-by-next-solver...
I'll look into the ICE though, since I think we crash the compiler when trying to report the error lol.
rustc-ice-2024-07-04T18_10_25-10188.txt
Code
Minimizing the code is nontrivial. Let me know if it is required to make a branch that reproduces the issue.
Meta
Error output
See attached rust-ice.