Remove blanket impl of Host for all impls of SyncHost
- Lenguaje dominante
- Rust
- Estrellas
- 772
- Forks
- 352
- Merge medio
- 1 d 12 h
- PR fusionados (30 d)
- 93
Descripción
The processor currently defines a blanket impl for `Host`:
```rust
impl Host for H {
# ...snip
}
```
This implementation makes it impossible for types which wrap a host to provide implementations of both the sync and async interfaces, so that the appropriate interface is used based on the capabilities of the host.
Concretely, the debugger has a host wrapper type `DapHostWrapper`, which wraps a host to provide certain functionality necessary for implementing debugging via Debug Adapter Protocol. The actual implementation regardless of whether the host is sync or async is sync, but because of the blanket impl, we are forced to use the async API internally when stepping execution, using a `poll_immediately` function, which is just pure overhead/unnecessary complexity.
The blanket impl makes it impossible to implement both `Host` and `SyncHost` for `DapHostWrapper` based on what trait `H` implements, without specialization (and thus using a nightly toolchain). Marker traits don't work here, because the relationship between the traits would require negative trait bounds to avoid the coherence conflict (i.e. `impl Host for DapHostWrapper { ... }`, meaning we only implement `Host` when `H` does _not_ implement `SyncHost`).
Since the `Host` impl for any `SyncHost` is trivial, I would suggest we just punt it to the concrete implementations to define how they implement `Host`. They can easily do the exact same thing the blanket impl does, and by not having the blanket impl we gain flexibility for use cases such as `DapHostWrapper`.
Guía de contribución
Evaluación
Este issue todavía no se ha evaluado.