From df3536969fa7dd26d3e49e00c160bbd29e7751a2 Mon Sep 17 00:00:00 2001 From: David Peter Date: Fri, 20 Dec 2024 09:34:42 +0100 Subject: [PATCH] ::default() instead of ::new() --- .../red_knot_python_semantic/src/semantic_index/builder.rs | 2 +- .../red_knot_python_semantic/src/semantic_index/use_def.rs | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/red_knot_python_semantic/src/semantic_index/builder.rs b/crates/red_knot_python_semantic/src/semantic_index/builder.rs index ef42aed58b..3eac622903 100644 --- a/crates/red_knot_python_semantic/src/semantic_index/builder.rs +++ b/crates/red_knot_python_semantic/src/semantic_index/builder.rs @@ -161,7 +161,7 @@ impl<'db> SemanticIndexBuilder<'db> { let file_scope_id = self.scopes.push(scope); self.symbol_tables.push(SymbolTableBuilder::default()); - self.use_def_maps.push(UseDefMapBuilder::new()); + self.use_def_maps.push(UseDefMapBuilder::default()); let ast_id_scope = self.ast_ids.push(AstIdsBuilder::default()); let scope_id = ScopeId::new(self.db, self.file, file_scope_id, countme::Count::default()); diff --git a/crates/red_knot_python_semantic/src/semantic_index/use_def.rs b/crates/red_knot_python_semantic/src/semantic_index/use_def.rs index a7ecedddcb..85cc30be43 100644 --- a/crates/red_knot_python_semantic/src/semantic_index/use_def.rs +++ b/crates/red_knot_python_semantic/src/semantic_index/use_def.rs @@ -468,8 +468,8 @@ pub(super) struct UseDefMapBuilder<'db> { symbol_states: IndexVec, } -impl<'db> UseDefMapBuilder<'db> { - pub(super) fn new() -> Self { +impl Default for UseDefMapBuilder<'_> { + fn default() -> Self { Self { all_definitions: IndexVec::from_iter([None]), all_constraints: IndexVec::new(), @@ -480,7 +480,9 @@ impl<'db> UseDefMapBuilder<'db> { symbol_states: IndexVec::new(), } } +} +impl<'db> UseDefMapBuilder<'db> { pub(super) fn add_symbol(&mut self, symbol: ScopedSymbolId) { let new_symbol = self .symbol_states