Skip to content

Commit 86a6880

Browse files
refactor(server): use wildcard fallback for compiled-out compute drivers
Replace the `#[cfg(not(all(feature = "driver-*")))]`-gated `ConfiguredComputeDriver::Builtin(kind)` catch-all in the dispatch match with a plain `_ => unreachable!(...)` guarded by `#[allow(unreachable_patterns)]`. Adding or removing a driver feature no longer requires updating this arm, and there is no feature list to drift out of sync with the enum. The arm remains genuinely unreachable at runtime: config validation in `configured_compute_driver` rejects builtins whose feature was compiled out before dispatch runs. The trade-off is that the panic message no longer names the specific driver — acceptable because the actionable error operators see is the validation-layer message, which does name the driver and the Cargo feature that re-enables it. Signed-off-by: Dimitar Mirchev <[email protected]>
1 parent 61529cf commit 86a6880

1 file changed

Lines changed: 10 additions & 15 deletions

File tree

  • crates/openshell-server/src

‎crates/openshell-server/src/lib.rs‎

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -820,21 +820,16 @@ async fn build_compute_runtime(
820820
)
821821
.await
822822
}
823-
// Unreachable at runtime. This fallback is required for match exhaustiveness
824-
// in non-default builds (including the extension-only build with zero driver features),
825-
// where some or all of the arms above are cfg'd out.
826-
#[cfg(not(all(
827-
feature = "driver-kubernetes",
828-
feature = "driver-docker",
829-
feature = "driver-podman",
830-
feature = "driver-vm",
831-
)))]
832-
ConfiguredComputeDriver::Builtin(kind) => {
833-
unreachable!(
834-
"compute driver '{}' passed startup validation but is not compiled into this gateway",
835-
kind.as_str()
836-
);
837-
}
823+
// Unreachable at runtime: config validation in `configured_compute_driver`
824+
// rejects builtins whose feature was compiled out, so a `Builtin` variant
825+
// reaching here means validation and dispatch got out of sync.
826+
// `#[allow(unreachable_patterns)]` silences the lint in the default
827+
// build where every concrete arm above is compiled in and this
828+
// catch-all is unreachable at compile time.
829+
#[allow(unreachable_patterns)]
830+
_ => unreachable!(
831+
"configured compute driver passed startup validation but is not compiled into this gateway"
832+
),
838833
};
839834

840835
runtime.map_err(|e| Error::execution(format!("failed to create compute runtime: {e}")))

0 commit comments

Comments
 (0)