From 51015ce5af4f2c0b73026bb79581fc758cc58a93 Mon Sep 17 00:00:00 2001 From: Martin Kuntz Jacobsen Date: Sat, 14 Nov 2026 05:26:06 +0100 Subject: [PATCH] qt bridge: expect unsafe_code on env set_var (part of #12395) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Xut2hws3L7Tg4oUvpSvuYD --- qt/private/rust/src/main.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/qt/private/rust/src/main.rs b/qt/private/rust/src/main.rs index dbcacffda4..c61e4ef9c4 100644 --- a/qt/private/rust/src/main.rs +++ b/qt/private/rust/src/main.rs @@ -32,8 +32,12 @@ struct Generated { source: Vec, } +#[expect( + unsafe_code, + reason = "std::env::set_var is unsafe; cxx-qt reads CLANG_FORMAT_BINARY in-process" +)] fn main() -> ExitCode { - // SAFETY: the process is single-threaded here or the env lock is held. + // SAFETY: main has not spawned any thread yet, so nothing reads the environment concurrently. unsafe { std::env::set_var("CLANG_FORMAT_BINARY", "") }; let args: Vec = std::env::args().skip(1).collect(); match run(&args) {