Open sgdxbc opened 2 months ago
@rustbot label fixed-by-next-solver
Somewhat minimized:
Thanks a lot for the further minimization @theemathas! You really saved me a day :)
Minimized:
use std::marker::PhantomData;
struct Wrap<U>(U);
trait Trait {
type InContext;
}
impl<U> Trait for Wrap<U> {
type InContext = Context<Wrap<U>>;
}
struct Context<T: Trait> {
// this is PhantomData<Self>
phantom: PhantomData<T::InContext>,
}
fn require_send<T: Send>() {}
fn f() {
require_send::<Context::<Wrap<_>>>();
}
Annotating the type as Context::<Wrap<i32>>
causes the error to go away.
The correct error should be "type annotation required".
The full reproducible case is here. Before committing further efforts on reducing it I would like to learn about maintainer's opinion on such issues. Whether it should be considered as bug? If so, will it be fixed straight way or need to go through some formalization first?
The skeleton is like this
If compiled like this it will fail with
(By the way, a minor issue here is that the trace does not properly fold the repeating steps. It also results in outputting hundreds of "long type" files (and even more if increasing recursion limit).)
If switch to define
crypto_task
at the commented location, it just compiles. Thecrypto_task
andclient_task
are independent definitions so it is semantically same to define in either order (in my original case they are futures so even nothing executed effectively by this two definitions).Giving annotation to the first
unbounded_channel()
call with at least::<ErasedEvent<State<()>, _>
makes it compile in the original order.It has always been the case where type inference does not work in some definition order, but most of the time a "type annotation required" error is reported. Should we fix this case to the extent that at least a less confusing error is reported? On the other hand I am actually curious about the internal mechanism here:
Send
, but eventually get stuck in checkingSized
, what's happening here?Thanks for any clarification!
Meta
rustc --version --verbose
:Also reproduced on nightly
Backtrace
```
```