Skip to content

main: gate the restart import to unix - #527

Open
obodnikov wants to merge 1 commit into
matrix-construct:mainfrom
obodnikov:fix/main-restart-import-gate
Open

main: gate the restart import to unix#527
obodnikov wants to merge 1 commit into
matrix-construct:mainfrom
obodnikov:fix/main-restart-import-gate

Conversation

@obodnikov

Copy link
Copy Markdown
Contributor

What does this PR do?

src/main/restart.rs is #![cfg(unix)]. A cfg-false module file is absent,
not empty, so on a non-unix target tuwunel::restart does not exist and the
unconditional import in main.rs is a hard error:

error[E0432]: unresolved import `tuwunel::restart`
 --> src/main/main.rs:3:47
  |
3 | use tuwunel::{Server, args, health::check, restart, runtime::Runtime};
  |                                            ^^^^^^^ no `restart` in the root

The call site is already gated:

#[cfg(unix)]
if server.server.restarting.load(Ordering::Acquire) {
    restart::restart();
}

so this only extends the same condition to the import that serves it. Ordering
follows for the same reason — its sole use is inside that block, so it is an
unused import on any non-unix target.

+#[cfg(unix)]
 use std::sync::atomic::Ordering;
 
-use tuwunel::{Server, args, health::check, restart, runtime::Runtime};
+#[cfg(unix)]
+use tuwunel::restart;
+use tuwunel::{Server, args, health::check, runtime::Runtime};

No behaviour change on unix. Same class of fix as #526.

On verification. CI builds Linux only, where none of this appears, so CI
cannot demonstrate the change. It was observed building v1.8.2 for
x86_64-pc-windows-msvc; the module-absence behaviour is reproducible with a
three-file crate on any host. cargo check and cargo clippy on the unix path
are clean before and after.

Checklist

  • Code is formatted with nightly cargo fmt and satisfies clippy and
    rustc lints; any allowed lint is justified by an obvious reason or a
    comment.
  • Complement compliance changes (new passes or new failures), if any,
    are noted in the description above. — none; no runtime path is touched.
  • Config option changes were made in src/core/config/mod.rs doc
    comments and the regenerated tuwunel-example.toml is committed. — n/a
  • User-facing changes are reflected in docs/. — n/a
  • I agree that my changes may be licensed under the Apache-2.0 licence
    and my conduct is in line with the Contributor's Covenant and
    Tuwunel's Code of Conduct.

`restart.rs` is `#![cfg(unix)]`, so on a non-unix target the module does not
exist at all -- a cfg-false module file is absent, not empty -- and the
unconditional import in `main.rs` fails to resolve:

    error[E0432]: unresolved import `tuwunel::restart`
      |     ^^^^^^^^^^^^^^^^ no `restart` in the root

The call site is already gated:

    #[cfg(unix)]
    if server.server.restarting.load(Ordering::Acquire) {
        restart::restart();
    }

so this only extends the same condition to the import that serves it. `Ordering`
follows, its sole use being inside that block.

No behaviour change on unix.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@jevolk jevolk added bug Something isn't right. build Related to compiling, Rust versions, dependency issues regression Bug resulting from another fix or feature. Only for released code, otherwise use release-blocker. labels Aug 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't right. build Related to compiling, Rust versions, dependency issues regression Bug resulting from another fix or feature. Only for released code, otherwise use release-blocker.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants