From ba5b146dfa215db4da4ee10ea7f828636c3fa8d9 Mon Sep 17 00:00:00 2001 From: xfy Date: Thu, 2 Jul 2026 16:49:31 +0800 Subject: [PATCH] =?UTF-8?q?fix(theme):=20=E6=B6=88=E9=99=A4=20detect=5Fini?= =?UTF-8?q?tial=5Ftheme=20=E7=9A=84=20unreachable=5Fcode=20=E8=AD=A6?= =?UTF-8?q?=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit wasm 分支末尾的 return Theme::System 在 wasm target 下让尾部兜底 Theme::System 不可达(unreachable_code 警告)。把尾部兜底用 #[cfg(not(target_arch = "wasm32"))] 限定,使其只在 server 分支 (cookie 未命中)或边角构建时编译,wasm target 下函数以 wasm 分支的 return 自然结束,两端都零警告。 --- src/theme.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/theme.rs b/src/theme.rs index 69b6e3c..29f78fa 100644 --- a/src/theme.rs +++ b/src/theme.rs @@ -140,6 +140,9 @@ fn detect_initial_theme() -> Theme { } } + // wasm 分支末尾已无条件 return Theme::System,不会到达这里; + // 此兜底仅服务 server 分支(cookie 未命中)或其他边角构建。 + #[cfg(not(target_arch = "wasm32"))] Theme::System }