From 18c5428d4737208c7a2d8d1fa6192b363cb9edb6 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Tue, 22 Oct 2024 12:32:50 +0200 Subject: [PATCH] codegen/object: Check for generate_safety_asserts when generating builders --- src/codegen/object.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/codegen/object.rs b/src/codegen/object.rs index e4cf3880b..9c212201f 100644 --- a/src/codegen/object.rs +++ b/src/codegen/object.rs @@ -457,11 +457,14 @@ fn generate_builder(w: &mut dyn Write, env: &Env, analysis: &analysis::object::I pub fn build(self) -> {name} {{", name = analysis.name, )?; - writeln!( - w, - "{}", - safety_assertion_mode_to_str(SafetyAssertionMode::InMainThread) - )?; + + if env.config.generate_safety_asserts { + writeln!( + w, + "{}", + safety_assertion_mode_to_str(SafetyAssertionMode::InMainThread) + )?; + } // The split allows us to not have clippy::let_and_return lint disabled if let Some(code) = analysis.builder_postprocess.as_ref() {