Skip to content

Commit

Permalink
codegen/builder: Assert the main thread is initalized
Browse files Browse the repository at this point in the history
Fixes #1590
  • Loading branch information
bilelmoussaoui committed Oct 19, 2024
1 parent af6703c commit 0a15f4e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/codegen/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ use super::{
use crate::{
analysis::{
self, bounds::BoundType, object::has_builder_properties, record_type::RecordType,
ref_mode::RefMode, rust_type::RustType,
ref_mode::RefMode, rust_type::RustType, safety_assertion_mode::SafetyAssertionMode,
},
env::Env,
library::{self, Nullable},
nameutil,
traits::IntoString,
writer::safety_assertion_mode_to_str,
};

pub fn generate(w: &mut dyn Write, env: &Env, analysis: &analysis::object::Info) -> Result<()> {
Expand Down Expand Up @@ -456,6 +457,11 @@ 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)
)?;

// The split allows us to not have clippy::let_and_return lint disabled
if let Some(code) = analysis.builder_postprocess.as_ref() {
Expand Down

0 comments on commit 0a15f4e

Please sign in to comment.