From c6781f10d3b32c8437cef6e49c6dc5d06d6eaeef Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Fri, 18 Sep 2026 14:36:54 +0000 Subject: [PATCH] test(common): remove PortReservation::release With the archive tests on the shared fixture, no test releases a reservation before a service binds its port. Remove the method so the only way to start a service on a reserved address is to transfer the bound listener, which keeps the address held for the child's lifetime. Validation: `cargo check -p ngit-grasp --tests` finds no remaining caller. Assisted-by: Claude Fable 5.1 Co-Authored-By: Claude Fable 5.1 --- tests/common/port.rs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/tests/common/port.rs b/tests/common/port.rs index 5de7c4f..c9129a6 100644 --- a/tests/common/port.rs +++ b/tests/common/port.rs @@ -16,8 +16,8 @@ use std::net::TcpListener; /// process can be handed the same number. /// /// Transfer it with [`PortReservation::into_std_listener`] to start a service -/// without releasing its address. Dropping it or calling `release` relinquishes -/// the address and must not be used before starting a replacement service. +/// without releasing its address. Dropping it relinquishes the address, so a +/// reservation must be transferred, not dropped, to start a service on it. #[derive(Debug)] pub struct PortReservation { port: u16, @@ -59,14 +59,6 @@ impl PortReservation { _listener: listener, } } - - /// Relinquish the address. A later bind to this port is inherently racy. - pub fn release(self) -> u16 { - let port = self.port; - // `self` is consumed; the listener inside is dropped here. - drop(self); - port - } } /// Bind `127.0.0.1:0`, capture the assigned port, and **keep the listener