Skip to content

Commit d8c063c

Browse files
authored
Merge branch 'rust-analyzer:master' into hash_table
2 parents acdae5a + 0c1077e commit d8c063c

File tree

4 files changed

+22
-18
lines changed

4 files changed

+22
-18
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rowan"
3-
version = "0.16.1"
3+
version = "0.16.2"
44
authors = ["Aleksey Kladov <[email protected]>"]
55
repository = "https://github.com/rust-analyzer/rowan"
66
license = "MIT OR Apache-2.0"

src/api.rs

Lines changed: 10 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(),
@@ -472,6 +472,7 @@ impl<L: Language> SyntaxElementChildren<L> {
472472
}
473473
}
474474

475+
#[derive(Debug, Clone)]
475476
pub struct Preorder<L: Language> {
476477
raw: cursor::Preorder,
477478
_p: PhantomData<L>,
@@ -490,6 +491,7 @@ impl<L: Language> Iterator for Preorder<L> {
490491
}
491492
}
492493

494+
#[derive(Debug, Clone)]
493495
pub struct PreorderWithTokens<L: Language> {
494496
raw: cursor::PreorderWithTokens,
495497
_p: PhantomData<L>,

src/cursor.rs

Lines changed: 10 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(),
@@ -1474,6 +1474,7 @@ impl<F: Fn(SyntaxKind) -> bool> Iterator for SyntaxElementChildrenByKind<F> {
14741474
}
14751475
}
14761476

1477+
#[derive(Debug, Clone)]
14771478
pub struct Preorder {
14781479
start: SyntaxNode,
14791480
next: Option<WalkEvent<SyntaxNode>>,
@@ -1529,6 +1530,7 @@ impl Iterator for Preorder {
15291530
}
15301531
}
15311532

1533+
#[derive(Debug, Clone)]
15321534
pub struct PreorderWithTokens {
15331535
start: SyntaxElement,
15341536
next: Option<WalkEvent<SyntaxElement>>,

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)