Remove blanket impl of Host for all impls of SyncHost
- Langage dominant
- Rust
- Étoiles
- 772
- Forks
- 352
- Merge moyen
- 1 j 7 h
- PR mergées (30 j)
- 84
Description
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`.
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Look for the blanket impl of Host for SyncHost in the processor module. Examine the DapHostWrapper type in the debugger to understand the conflict. The task is to remove the blanket impl and add equivalent Host implementations for each concrete type that currently relies on it. Check for any existing tests related to Host/SyncHost traits to ensure the refactor doesn't break functionality.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- rust
- Domaine
- backend
- Type d'issue
- Refactorisation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- Calme
- Clarté
- Clairement spécifiée
- Accessibilité débutants
- 45/100