-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
for<'a> Send
is distinct from Send
?
#71462
Comments
somewhat minimized use std::future::Future;
trait Service<R> {
type Future: Future<Output = i32>;
fn call(&mut self, req: R) -> Self::Future;
}
struct BorrowerService<S> {
service: Option<S>,
}
impl<S> Service<Box<dyn Sync + Send>> for BorrowerService<S>
where
for<'b> S: Service<&'b (dyn 'static + Sync + Send)> + 'static + Send,
for<'b> <S as Service<&'b (dyn 'static + Sync + Send)>>::Future: Send,
{
type Future = Box<dyn Future<Output = i32> + Send>;
fn call(&mut self, req: Box<dyn Sync + Send>) -> Self::Future {
let mut service = self.service.take().unwrap();
Box::new(async move {
service.call(&req).await
})
}
} |
cc @rust-lang/wg-traits |
Here's a variant that doesn't involve trait objects at all: trait Service<R> {
type Future;
}
struct Inner;
impl<R> Service<R> for Inner {
type Future = ();
}
struct Outer<S> {
inner: S,
}
impl<S> Service<()> for Outer<S>
where
for<'a> S: Service<&'a ()>,
for<'a> <S as Service<&'a ()>>::Future: Send,
{
type Future = ();
}
fn is_service<S>(_: S)
where
S: Service<()>
{}
fn main() {
is_service(Outer { inner: Inner })
}
The error seems bogus, since |
Send
found type for<'a> Send
when trait objects are involvedfor<'a> Send
is distinct from Send
?
It looks to me like the issue is that we do not normalize projections which are inside of binders, so we are currently unable to normalize While I would be interested in implementing normalization inside of binders, I do not think that we currently have the capacity to do so. |
It looks like this has been at least partially fixed. The reproducer without trait objects compiles successfully today, while the original example fails with a different error that sounds a bit like #102211
|
This code fails to compile with a pretty strange error:
The use of the trait object appears to be important - if I replace that with e.g.
String
, it compiles just fine:The text was updated successfully, but these errors were encountered: