diff --git a/crates/oxc_semantic/src/builder.rs b/crates/oxc_semantic/src/builder.rs index 3735eb2fb3f244..a0a6321f17ecad 100644 --- a/crates/oxc_semantic/src/builder.rs +++ b/crates/oxc_semantic/src/builder.rs @@ -92,7 +92,7 @@ pub struct SemanticBuilder<'a> { pub class_table_builder: ClassTableBuilder, - ast_node_records: Vec>, + ast_node_records: Vec, } pub struct SemanticBuilderReturn<'a> { @@ -250,17 +250,18 @@ impl<'a> SemanticBuilder<'a> { } fn record_ast_nodes(&mut self) { - self.ast_node_records.push(None); + self.ast_node_records.push(AstNodeId::dummy()); } + #[allow(clippy::unnecessary_wraps)] fn retrieve_recorded_ast_node(&mut self) -> Option { - self.ast_node_records.pop().expect("there is no ast node record to stop.") + Some(self.ast_node_records.pop().expect("there is no ast node record to stop.")) } fn record_ast_node(&mut self) { if let Some(record) = self.ast_node_records.last_mut() { - if record.is_none() { - *record = Some(self.current_node_id); + if *record == AstNodeId::dummy() { + *record = self.current_node_id; } } }