From 2d892bc9f700289de917827a5147d290677db8c1 Mon Sep 17 00:00:00 2001 From: InSync Date: Sun, 23 Mar 2025 21:15:56 +0700 Subject: [PATCH] Fix typos (#16908) ## Summary The noun is spelled "descendant" and the adjective "descendent". ## Test Plan [From the English Wiktionary](https://en.wiktionary.org/wiki/descendent#Usage_notes): > The adjective, "descending from a biological ancestor", may be spelt either with an [a](https://en.wiktionary.org/wiki/-ant) or with an [e](https://en.wiktionary.org/wiki/-ent) in the final syllable (see [descendant](https://en.wiktionary.org/wiki/descendant)). However, the noun descendant, "one who is the progeny of someone", may be spelt only with an [a](https://en.wiktionary.org/wiki/-ant). Compare also [dependent](https://en.wiktionary.org/wiki/dependent#English) and [dependant](https://en.wiktionary.org/wiki/dependant#English). --- .../src/semantic_index.rs | 38 +++++++++---------- .../src/semantic_index/builder.rs | 2 +- .../src/semantic_index/symbol.rs | 14 +++---- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/crates/red_knot_python_semantic/src/semantic_index.rs b/crates/red_knot_python_semantic/src/semantic_index.rs index 59745505b5..f9426d735d 100644 --- a/crates/red_knot_python_semantic/src/semantic_index.rs +++ b/crates/red_knot_python_semantic/src/semantic_index.rs @@ -235,8 +235,8 @@ impl<'db> SemanticIndex<'db> { /// Returns an iterator over the descendent scopes of `scope`. #[allow(unused)] - pub(crate) fn descendent_scopes(&self, scope: FileScopeId) -> DescendentsIter { - DescendentsIter::new(self, scope) + pub(crate) fn descendent_scopes(&self, scope: FileScopeId) -> DescendantsIter { + DescendantsIter::new(self, scope) } /// Returns an iterator over the direct child scopes of `scope`. @@ -339,55 +339,55 @@ impl<'a> Iterator for AncestorsIter<'a> { impl FusedIterator for AncestorsIter<'_> {} -pub struct DescendentsIter<'a> { +pub struct DescendantsIter<'a> { next_id: FileScopeId, - descendents: std::slice::Iter<'a, Scope>, + descendants: std::slice::Iter<'a, Scope>, } -impl<'a> DescendentsIter<'a> { +impl<'a> DescendantsIter<'a> { fn new(symbol_table: &'a SemanticIndex, scope_id: FileScopeId) -> Self { let scope = &symbol_table.scopes[scope_id]; - let scopes = &symbol_table.scopes[scope.descendents()]; + let scopes = &symbol_table.scopes[scope.descendants()]; Self { next_id: scope_id + 1, - descendents: scopes.iter(), + descendants: scopes.iter(), } } } -impl<'a> Iterator for DescendentsIter<'a> { +impl<'a> Iterator for DescendantsIter<'a> { type Item = (FileScopeId, &'a Scope); fn next(&mut self) -> Option { - let descendent = self.descendents.next()?; + let descendant = self.descendants.next()?; let id = self.next_id; self.next_id = self.next_id + 1; - Some((id, descendent)) + Some((id, descendant)) } fn size_hint(&self) -> (usize, Option) { - self.descendents.size_hint() + self.descendants.size_hint() } } -impl FusedIterator for DescendentsIter<'_> {} +impl FusedIterator for DescendantsIter<'_> {} -impl ExactSizeIterator for DescendentsIter<'_> {} +impl ExactSizeIterator for DescendantsIter<'_> {} pub struct ChildrenIter<'a> { parent: FileScopeId, - descendents: DescendentsIter<'a>, + descendants: DescendantsIter<'a>, } impl<'a> ChildrenIter<'a> { fn new(module_symbol_table: &'a SemanticIndex, parent: FileScopeId) -> Self { - let descendents = DescendentsIter::new(module_symbol_table, parent); + let descendants = DescendantsIter::new(module_symbol_table, parent); Self { parent, - descendents, + descendants, } } } @@ -396,7 +396,7 @@ impl<'a> Iterator for ChildrenIter<'a> { type Item = (FileScopeId, &'a Scope); fn next(&mut self) -> Option { - self.descendents + self.descendants .find(|(_, scope)| scope.parent() == Some(self.parent)) } } @@ -1155,9 +1155,9 @@ def x(): let index = semantic_index(&db, file); - let descendents = index.descendent_scopes(FileScopeId::global()); + let descendants = index.descendent_scopes(FileScopeId::global()); assert_eq!( - scope_names(descendents, &db, file), + scope_names(descendants, &db, file), vec!["Test", "foo", "bar", "baz", "x"] ); 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 0d6ecb8b00..add2746341 100644 --- a/crates/red_knot_python_semantic/src/semantic_index/builder.rs +++ b/crates/red_knot_python_semantic/src/semantic_index/builder.rs @@ -229,7 +229,7 @@ impl<'db> SemanticIndexBuilder<'db> { let children_end = self.scopes.next_index(); let popped_scope = &mut self.scopes[popped_scope_id]; - popped_scope.extend_descendents(children_end); + popped_scope.extend_descendants(children_end); if !popped_scope.is_eager() { return popped_scope_id; diff --git a/crates/red_knot_python_semantic/src/semantic_index/symbol.rs b/crates/red_knot_python_semantic/src/semantic_index/symbol.rs index ba5e786b04..163c9fadbc 100644 --- a/crates/red_knot_python_semantic/src/semantic_index/symbol.rs +++ b/crates/red_knot_python_semantic/src/semantic_index/symbol.rs @@ -171,19 +171,19 @@ impl FileScopeId { pub struct Scope { parent: Option, node: NodeWithScopeKind, - descendents: Range, + descendants: Range, } impl Scope { pub(super) fn new( parent: Option, node: NodeWithScopeKind, - descendents: Range, + descendants: Range, ) -> Self { Scope { parent, node, - descendents, + descendants, } } @@ -199,12 +199,12 @@ impl Scope { self.node().scope_kind() } - pub fn descendents(&self) -> Range { - self.descendents.clone() + pub fn descendants(&self) -> Range { + self.descendants.clone() } - pub(super) fn extend_descendents(&mut self, children_end: FileScopeId) { - self.descendents = self.descendents.start..children_end; + pub(super) fn extend_descendants(&mut self, children_end: FileScopeId) { + self.descendants = self.descendants.start..children_end; } pub(crate) fn is_eager(&self) -> bool {