Skip to content

Commit 0c1077e

Browse files
Merge pull request #200 from ChayimFriedman2/fix-ra
Don't capture unneeded lifetimes in `impl Iterator` return types
2 parents 5181988 + 9dd084f commit 0c1077e

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

src/api.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ impl<L: Language> SyntaxNode<L> {
133133
self.raw.parent().map(Self::from)
134134
}
135135

136-
pub fn ancestors(&self) -> impl Iterator<Item = SyntaxNode<L>> {
136+
pub fn ancestors(&self) -> impl Iterator<Item = SyntaxNode<L>> + use<L> {
137137
self.raw.ancestors().map(SyntaxNode::from)
138138
}
139139

@@ -219,7 +219,7 @@ impl<L: Language> SyntaxNode<L> {
219219
self.raw.last_token().map(SyntaxToken::from)
220220
}
221221

222-
pub fn siblings(&self, direction: Direction) -> impl Iterator<Item = SyntaxNode<L>> {
222+
pub fn siblings(&self, direction: Direction) -> impl Iterator<Item = SyntaxNode<L>> + use<L> {
223223
self.raw.siblings(direction).map(SyntaxNode::from)
224224
}
225225

@@ -230,11 +230,11 @@ impl<L: Language> SyntaxNode<L> {
230230
self.raw.siblings_with_tokens(direction).map(SyntaxElement::from)
231231
}
232232

233-
pub fn descendants(&self) -> impl Iterator<Item = SyntaxNode<L>> {
233+
pub fn descendants(&self) -> impl Iterator<Item = SyntaxNode<L>> + use<L> {
234234
self.raw.descendants().map(SyntaxNode::from)
235235
}
236236

237-
pub fn descendants_with_tokens(&self) -> impl Iterator<Item = SyntaxElement<L>> {
237+
pub fn descendants_with_tokens(&self) -> impl Iterator<Item = SyntaxElement<L>> + use<L> {
238238
self.raw.descendants_with_tokens().map(NodeOrToken::from)
239239
}
240240

@@ -337,12 +337,12 @@ impl<L: Language> SyntaxToken<L> {
337337

338338
/// Iterator over all the ancestors of this token excluding itself.
339339
#[deprecated = "use `SyntaxToken::parent_ancestors` instead"]
340-
pub fn ancestors(&self) -> impl Iterator<Item = SyntaxNode<L>> {
340+
pub fn ancestors(&self) -> impl Iterator<Item = SyntaxNode<L>> + use<L> {
341341
self.parent_ancestors()
342342
}
343343

344344
/// Iterator over all the ancestors of this token excluding itself.
345-
pub fn parent_ancestors(&self) -> impl Iterator<Item = SyntaxNode<L>> {
345+
pub fn parent_ancestors(&self) -> impl Iterator<Item = SyntaxNode<L>> + use<L> {
346346
self.raw.ancestors().map(SyntaxNode::from)
347347
}
348348

@@ -356,7 +356,7 @@ impl<L: Language> SyntaxToken<L> {
356356
pub fn siblings_with_tokens(
357357
&self,
358358
direction: Direction,
359-
) -> impl Iterator<Item = SyntaxElement<L>> {
359+
) -> impl Iterator<Item = SyntaxElement<L>> + use<L> {
360360
self.raw.siblings_with_tokens(direction).map(SyntaxElement::from)
361361
}
362362

@@ -403,7 +403,7 @@ impl<L: Language> SyntaxElement<L> {
403403
}
404404
}
405405

406-
pub fn ancestors(&self) -> impl Iterator<Item = SyntaxNode<L>> {
406+
pub fn ancestors(&self) -> impl Iterator<Item = SyntaxNode<L>> + use<L> {
407407
let first = match self {
408408
NodeOrToken::Node(it) => Some(it.clone()),
409409
NodeOrToken::Token(it) => it.parent(),

src/cursor.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ impl SyntaxNode {
668668
}
669669

670670
#[inline]
671-
pub fn ancestors(&self) -> impl Iterator<Item = SyntaxNode> {
671+
pub fn ancestors(&self) -> impl Iterator<Item = SyntaxNode> + use<> {
672672
iter::successors(Some(self.clone()), SyntaxNode::parent)
673673
}
674674

@@ -831,7 +831,7 @@ impl SyntaxNode {
831831
}
832832

833833
#[inline]
834-
pub fn siblings(&self, direction: Direction) -> impl Iterator<Item = SyntaxNode> {
834+
pub fn siblings(&self, direction: Direction) -> impl Iterator<Item = SyntaxNode> + use<> {
835835
iter::successors(Some(self.clone()), move |node| match direction {
836836
Direction::Next => node.next_sibling(),
837837
Direction::Prev => node.prev_sibling(),
@@ -842,7 +842,7 @@ impl SyntaxNode {
842842
pub fn siblings_with_tokens(
843843
&self,
844844
direction: Direction,
845-
) -> impl Iterator<Item = SyntaxElement> {
845+
) -> impl Iterator<Item = SyntaxElement> + use<> {
846846
let me: SyntaxElement = self.clone().into();
847847
iter::successors(Some(me), move |el| match direction {
848848
Direction::Next => el.next_sibling_or_token(),
@@ -851,15 +851,15 @@ impl SyntaxNode {
851851
}
852852

853853
#[inline]
854-
pub fn descendants(&self) -> impl Iterator<Item = SyntaxNode> {
854+
pub fn descendants(&self) -> impl Iterator<Item = SyntaxNode> + use<> {
855855
self.preorder().filter_map(|event| match event {
856856
WalkEvent::Enter(node) => Some(node),
857857
WalkEvent::Leave(_) => None,
858858
})
859859
}
860860

861861
#[inline]
862-
pub fn descendants_with_tokens(&self) -> impl Iterator<Item = SyntaxElement> {
862+
pub fn descendants_with_tokens(&self) -> impl Iterator<Item = SyntaxElement> + use<> {
863863
self.preorder_with_tokens().filter_map(|event| match event {
864864
WalkEvent::Enter(it) => Some(it),
865865
WalkEvent::Leave(_) => None,
@@ -1054,7 +1054,7 @@ impl SyntaxToken {
10541054
}
10551055

10561056
#[inline]
1057-
pub fn ancestors(&self) -> impl Iterator<Item = SyntaxNode> {
1057+
pub fn ancestors(&self) -> impl Iterator<Item = SyntaxNode> + use<> {
10581058
std::iter::successors(self.parent(), SyntaxNode::parent)
10591059
}
10601060

@@ -1077,7 +1077,7 @@ impl SyntaxToken {
10771077
pub fn siblings_with_tokens(
10781078
&self,
10791079
direction: Direction,
1080-
) -> impl Iterator<Item = SyntaxElement> {
1080+
) -> impl Iterator<Item = SyntaxElement> + use<> {
10811081
let me: SyntaxElement = self.clone().into();
10821082
iter::successors(Some(me), move |el| match direction {
10831083
Direction::Next => el.next_sibling_or_token(),
@@ -1156,7 +1156,7 @@ impl SyntaxElement {
11561156
}
11571157

11581158
#[inline]
1159-
pub fn ancestors(&self) -> impl Iterator<Item = SyntaxNode> {
1159+
pub fn ancestors(&self) -> impl Iterator<Item = SyntaxNode> + use<> {
11601160
let first = match self {
11611161
NodeOrToken::Node(it) => Some(it.clone()),
11621162
NodeOrToken::Token(it) => it.parent(),

src/syntax_text.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl SyntaxText {
105105
}
106106
}
107107

108-
fn tokens_with_ranges(&self) -> impl Iterator<Item = (SyntaxToken, TextRange)> {
108+
fn tokens_with_ranges(&self) -> impl Iterator<Item = (SyntaxToken, TextRange)> + use<> {
109109
let text_range = self.range;
110110
self.node.descendants_with_tokens().filter_map(|element| element.into_token()).filter_map(
111111
move |token| {

0 commit comments

Comments
 (0)