aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/ast.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src/ast.rs')
-rw-r--r--crates/ra_syntax/src/ast.rs199
1 files changed, 84 insertions, 115 deletions
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs
index 9ab59738f..285dda1e0 100644
--- a/crates/ra_syntax/src/ast.rs
+++ b/crates/ra_syntax/src/ast.rs
@@ -1,119 +1,88 @@
1mod generated; 1mod generated;
2 2
3use std::marker::PhantomData; 3use std::marker::PhantomData;
4use std::string::String as RustString;
5 4
6use itertools::Itertools; 5use itertools::Itertools;
7 6
8pub use self::generated::*; 7pub use self::generated::*;
9use crate::{ 8use crate::{
10 yellow::{RefRoot, SyntaxNodeChildren}, 9 yellow::{SyntaxNode, SyntaxNodeChildren, TreePtr, RaTypes},
11 SmolStr, 10 SmolStr,
12 SyntaxKind::*, 11 SyntaxKind::*,
13 SyntaxNodeRef,
14}; 12};
15 13
16/// The main trait to go from untyped `SyntaxNode` to a typed ast. The 14/// The main trait to go from untyped `SyntaxNode` to a typed ast. The
17/// conversion itself has zero runtime cost: ast and syntax nodes have exactly 15/// conversion itself has zero runtime cost: ast and syntax nodes have exactly
18/// the same representation: a pointer to the tree root and a pointer to the 16/// the same representation: a pointer to the tree root and a pointer to the
19/// node itself. 17/// node itself.
20pub trait AstNode<'a>: Clone + Copy + 'a { 18pub trait AstNode: rowan::TransparentNewType<Repr = rowan::SyntaxNode<RaTypes>> {
21 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> 19 fn cast(syntax: &SyntaxNode) -> Option<&Self>
22 where 20 where
23 Self: Sized; 21 Self: Sized;
24 fn syntax(self) -> SyntaxNodeRef<'a>; 22 fn syntax(&self) -> &SyntaxNode;
23 fn to_owned(&self) -> TreePtr<Self>;
25} 24}
26 25
27pub trait NameOwner<'a>: AstNode<'a> { 26pub trait NameOwner: AstNode {
28 fn name(self) -> Option<Name<'a>> { 27 fn name(&self) -> Option<&Name> {
29 child_opt(self) 28 child_opt(self)
30 } 29 }
31} 30}
32 31
33pub trait VisibilityOwner<'a>: AstNode<'a> { 32pub trait VisibilityOwner: AstNode {
34 fn visibility(self) -> Option<Visibility<'a>> { 33 fn visibility(&self) -> Option<&Visibility> {
35 child_opt(self) 34 child_opt(self)
36 } 35 }
37} 36}
38 37
39pub trait LoopBodyOwner<'a>: AstNode<'a> { 38pub trait LoopBodyOwner: AstNode {
40 fn loop_body(self) -> Option<Block<'a>> { 39 fn loop_body(&self) -> Option<&Block> {
41 child_opt(self) 40 child_opt(self)
42 } 41 }
43} 42}
44 43
45pub trait ArgListOwner<'a>: AstNode<'a> { 44pub trait ArgListOwner: AstNode {
46 fn arg_list(self) -> Option<ArgList<'a>> { 45 fn arg_list(&self) -> Option<&ArgList> {
47 child_opt(self) 46 child_opt(self)
48 } 47 }
49} 48}
50 49
51pub trait FnDefOwner<'a>: AstNode<'a> { 50pub trait FnDefOwner: AstNode {
52 fn functions(self) -> AstChildren<'a, FnDef<'a>> { 51 fn functions(&self) -> AstChildren<FnDef> {
53 children(self) 52 children(self)
54 } 53 }
55} 54}
56 55
57// ModuleItem 56pub trait ModuleItemOwner: AstNode {
58#[derive(Debug, Clone, Copy, PartialEq, Eq)] 57 fn items(&self) -> AstChildren<ModuleItem> {
59pub enum ItemOrMacro<'a> {
60 Item(ModuleItem<'a>),
61 Macro(MacroCall<'a>),
62}
63
64impl<'a> AstNode<'a> for ItemOrMacro<'a> {
65 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
66 let res = if let Some(item) = ModuleItem::cast(syntax) {
67 ItemOrMacro::Item(item)
68 } else if let Some(macro_call) = MacroCall::cast(syntax) {
69 ItemOrMacro::Macro(macro_call)
70 } else {
71 return None;
72 };
73 Some(res)
74 }
75 fn syntax(self) -> SyntaxNodeRef<'a> {
76 match self {
77 ItemOrMacro::Item(it) => it.syntax(),
78 ItemOrMacro::Macro(it) => it.syntax(),
79 }
80 }
81}
82
83pub trait ModuleItemOwner<'a>: AstNode<'a> {
84 fn items(self) -> AstChildren<'a, ModuleItem<'a>> {
85 children(self)
86 }
87
88 fn items_with_macros(self) -> AstChildren<'a, ItemOrMacro<'a>> {
89 children(self) 58 children(self)
90 } 59 }
91} 60}
92 61
93pub trait TypeParamsOwner<'a>: AstNode<'a> { 62pub trait TypeParamsOwner: AstNode {
94 fn type_param_list(self) -> Option<TypeParamList<'a>> { 63 fn type_param_list(&self) -> Option<&TypeParamList> {
95 child_opt(self) 64 child_opt(self)
96 } 65 }
97 66
98 fn where_clause(self) -> Option<WhereClause<'a>> { 67 fn where_clause(&self) -> Option<&WhereClause> {
99 child_opt(self) 68 child_opt(self)
100 } 69 }
101} 70}
102 71
103pub trait AttrsOwner<'a>: AstNode<'a> { 72pub trait AttrsOwner: AstNode {
104 fn attrs(self) -> AstChildren<'a, Attr<'a>> { 73 fn attrs(&self) -> AstChildren<Attr> {
105 children(self) 74 children(self)
106 } 75 }
107} 76}
108 77
109pub trait DocCommentsOwner<'a>: AstNode<'a> { 78pub trait DocCommentsOwner: AstNode {
110 fn doc_comments(self) -> AstChildren<'a, Comment<'a>> { 79 fn doc_comments(&self) -> AstChildren<Comment> {
111 children(self) 80 children(self)
112 } 81 }
113 82
114 /// Returns the textual content of a doc comment block as a single string. 83 /// Returns the textual content of a doc comment block as a single string.
115 /// That is, strips leading `///` and joins lines 84 /// That is, strips leading `///` and joins lines
116 fn doc_comment_text(self) -> RustString { 85 fn doc_comment_text(&self) -> std::string::String {
117 self.doc_comments() 86 self.doc_comments()
118 .filter(|comment| comment.is_doc_comment()) 87 .filter(|comment| comment.is_doc_comment())
119 .map(|comment| { 88 .map(|comment| {
@@ -130,13 +99,13 @@ pub trait DocCommentsOwner<'a>: AstNode<'a> {
130 } 99 }
131} 100}
132 101
133impl<'a> FnDef<'a> { 102impl FnDef {
134 pub fn has_atom_attr(&self, atom: &str) -> bool { 103 pub fn has_atom_attr(&self, atom: &str) -> bool {
135 self.attrs().filter_map(|x| x.as_atom()).any(|x| x == atom) 104 self.attrs().filter_map(|x| x.as_atom()).any(|x| x == atom)
136 } 105 }
137} 106}
138 107
139impl<'a> Attr<'a> { 108impl Attr {
140 pub fn as_atom(&self) -> Option<SmolStr> { 109 pub fn as_atom(&self) -> Option<SmolStr> {
141 let tt = self.value()?; 110 let tt = self.value()?;
142 let (_bra, attr, _ket) = tt.syntax().children().collect_tuple()?; 111 let (_bra, attr, _ket) = tt.syntax().children().collect_tuple()?;
@@ -147,7 +116,7 @@ impl<'a> Attr<'a> {
147 } 116 }
148 } 117 }
149 118
150 pub fn as_call(&self) -> Option<(SmolStr, TokenTree<'a>)> { 119 pub fn as_call(&self) -> Option<(SmolStr, &TokenTree)> {
151 let tt = self.value()?; 120 let tt = self.value()?;
152 let (_bra, attr, args, _ket) = tt.syntax().children().collect_tuple()?; 121 let (_bra, attr, args, _ket) = tt.syntax().children().collect_tuple()?;
153 let args = TokenTree::cast(args)?; 122 let args = TokenTree::cast(args)?;
@@ -159,37 +128,37 @@ impl<'a> Attr<'a> {
159 } 128 }
160} 129}
161 130
162impl<'a> Lifetime<'a> { 131impl Lifetime {
163 pub fn text(&self) -> SmolStr { 132 pub fn text(&self) -> SmolStr {
164 self.syntax().leaf_text().unwrap().clone() 133 self.syntax().leaf_text().unwrap().clone()
165 } 134 }
166} 135}
167 136
168impl<'a> Char<'a> { 137impl Char {
169 pub fn text(&self) -> &SmolStr { 138 pub fn text(&self) -> &SmolStr {
170 &self.syntax().leaf_text().unwrap() 139 &self.syntax().leaf_text().unwrap()
171 } 140 }
172} 141}
173 142
174impl<'a> Byte<'a> { 143impl Byte {
175 pub fn text(&self) -> &SmolStr { 144 pub fn text(&self) -> &SmolStr {
176 &self.syntax().leaf_text().unwrap() 145 &self.syntax().leaf_text().unwrap()
177 } 146 }
178} 147}
179 148
180impl<'a> ByteString<'a> { 149impl ByteString {
181 pub fn text(&self) -> &SmolStr { 150 pub fn text(&self) -> &SmolStr {
182 &self.syntax().leaf_text().unwrap() 151 &self.syntax().leaf_text().unwrap()
183 } 152 }
184} 153}
185 154
186impl<'a> String<'a> { 155impl String {
187 pub fn text(&self) -> &SmolStr { 156 pub fn text(&self) -> &SmolStr {
188 &self.syntax().leaf_text().unwrap() 157 &self.syntax().leaf_text().unwrap()
189 } 158 }
190} 159}
191 160
192impl<'a> Comment<'a> { 161impl Comment {
193 pub fn text(&self) -> &SmolStr { 162 pub fn text(&self) -> &SmolStr {
194 self.syntax().leaf_text().unwrap() 163 self.syntax().leaf_text().unwrap()
195 } 164 }
@@ -251,7 +220,7 @@ impl CommentFlavor {
251 } 220 }
252} 221}
253 222
254impl<'a> Whitespace<'a> { 223impl Whitespace {
255 pub fn text(&self) -> &SmolStr { 224 pub fn text(&self) -> &SmolStr {
256 &self.syntax().leaf_text().unwrap() 225 &self.syntax().leaf_text().unwrap()
257 } 226 }
@@ -265,36 +234,36 @@ impl<'a> Whitespace<'a> {
265 } 234 }
266} 235}
267 236
268impl<'a> Name<'a> { 237impl Name {
269 pub fn text(&self) -> SmolStr { 238 pub fn text(&self) -> SmolStr {
270 let ident = self.syntax().first_child().unwrap(); 239 let ident = self.syntax().first_child().unwrap();
271 ident.leaf_text().unwrap().clone() 240 ident.leaf_text().unwrap().clone()
272 } 241 }
273} 242}
274 243
275impl<'a> NameRef<'a> { 244impl NameRef {
276 pub fn text(&self) -> SmolStr { 245 pub fn text(&self) -> SmolStr {
277 let ident = self.syntax().first_child().unwrap(); 246 let ident = self.syntax().first_child().unwrap();
278 ident.leaf_text().unwrap().clone() 247 ident.leaf_text().unwrap().clone()
279 } 248 }
280} 249}
281 250
282impl<'a> ImplBlock<'a> { 251impl ImplBlock {
283 pub fn target_type(self) -> Option<TypeRef<'a>> { 252 pub fn target_type(&self) -> Option<&TypeRef> {
284 match self.target() { 253 match self.target() {
285 (Some(t), None) | (_, Some(t)) => Some(t), 254 (Some(t), None) | (_, Some(t)) => Some(t),
286 _ => None, 255 _ => None,
287 } 256 }
288 } 257 }
289 258
290 pub fn target_trait(self) -> Option<TypeRef<'a>> { 259 pub fn target_trait(&self) -> Option<&TypeRef> {
291 match self.target() { 260 match self.target() {
292 (Some(t), Some(_)) => Some(t), 261 (Some(t), Some(_)) => Some(t),
293 _ => None, 262 _ => None,
294 } 263 }
295 } 264 }
296 265
297 fn target(self) -> (Option<TypeRef<'a>>, Option<TypeRef<'a>>) { 266 fn target(&self) -> (Option<&TypeRef>, Option<&TypeRef>) {
298 let mut types = children(self); 267 let mut types = children(self);
299 let first = types.next(); 268 let first = types.next();
300 let second = types.next(); 269 let second = types.next();
@@ -302,8 +271,8 @@ impl<'a> ImplBlock<'a> {
302 } 271 }
303} 272}
304 273
305impl<'a> Module<'a> { 274impl Module {
306 pub fn has_semi(self) -> bool { 275 pub fn has_semi(&self) -> bool {
307 match self.syntax().last_child() { 276 match self.syntax().last_child() {
308 None => false, 277 None => false,
309 Some(node) => node.kind() == SEMI, 278 Some(node) => node.kind() == SEMI,
@@ -311,8 +280,8 @@ impl<'a> Module<'a> {
311 } 280 }
312} 281}
313 282
314impl<'a> LetStmt<'a> { 283impl LetStmt {
315 pub fn has_semi(self) -> bool { 284 pub fn has_semi(&self) -> bool {
316 match self.syntax().last_child() { 285 match self.syntax().last_child() {
317 None => false, 286 None => false,
318 Some(node) => node.kind() == SEMI, 287 Some(node) => node.kind() == SEMI,
@@ -320,35 +289,35 @@ impl<'a> LetStmt<'a> {
320 } 289 }
321} 290}
322 291
323impl<'a> IfExpr<'a> { 292impl IfExpr {
324 pub fn then_branch(self) -> Option<Block<'a>> { 293 pub fn then_branch(&self) -> Option<&Block> {
325 self.blocks().nth(0) 294 self.blocks().nth(0)
326 } 295 }
327 pub fn else_branch(self) -> Option<Block<'a>> { 296 pub fn else_branch(&self) -> Option<&Block> {
328 self.blocks().nth(1) 297 self.blocks().nth(1)
329 } 298 }
330 fn blocks(self) -> AstChildren<'a, Block<'a>> { 299 fn blocks(&self) -> AstChildren<Block> {
331 children(self) 300 children(self)
332 } 301 }
333} 302}
334 303
335#[derive(Debug, Clone, Copy, PartialEq, Eq)] 304#[derive(Debug, Clone, Copy, PartialEq, Eq)]
336pub enum PathSegmentKind<'a> { 305pub enum PathSegmentKind<'a> {
337 Name(NameRef<'a>), 306 Name(&'a NameRef),
338 SelfKw, 307 SelfKw,
339 SuperKw, 308 SuperKw,
340 CrateKw, 309 CrateKw,
341} 310}
342 311
343impl<'a> PathSegment<'a> { 312impl PathSegment {
344 pub fn parent_path(self) -> Path<'a> { 313 pub fn parent_path(&self) -> &Path {
345 self.syntax() 314 self.syntax()
346 .parent() 315 .parent()
347 .and_then(Path::cast) 316 .and_then(Path::cast)
348 .expect("segments are always nested in paths") 317 .expect("segments are always nested in paths")
349 } 318 }
350 319
351 pub fn kind(self) -> Option<PathSegmentKind<'a>> { 320 pub fn kind(&self) -> Option<PathSegmentKind> {
352 let res = if let Some(name_ref) = self.name_ref() { 321 let res = if let Some(name_ref) = self.name_ref() {
353 PathSegmentKind::Name(name_ref) 322 PathSegmentKind::Name(name_ref)
354 } else { 323 } else {
@@ -363,20 +332,20 @@ impl<'a> PathSegment<'a> {
363 } 332 }
364} 333}
365 334
366impl<'a> Path<'a> { 335impl Path {
367 pub fn parent_path(self) -> Option<Path<'a>> { 336 pub fn parent_path(&self) -> Option<&Path> {
368 self.syntax().parent().and_then(Path::cast) 337 self.syntax().parent().and_then(Path::cast)
369 } 338 }
370} 339}
371 340
372impl<'a> UseTree<'a> { 341impl UseTree {
373 pub fn has_star(self) -> bool { 342 pub fn has_star(&self) -> bool {
374 self.syntax().children().any(|it| it.kind() == STAR) 343 self.syntax().children().any(|it| it.kind() == STAR)
375 } 344 }
376} 345}
377 346
378impl<'a> UseTreeList<'a> { 347impl UseTreeList {
379 pub fn parent_use_tree(self) -> UseTree<'a> { 348 pub fn parent_use_tree(&self) -> &UseTree {
380 self.syntax() 349 self.syntax()
381 .parent() 350 .parent()
382 .and_then(UseTree::cast) 351 .and_then(UseTree::cast)
@@ -384,22 +353,22 @@ impl<'a> UseTreeList<'a> {
384 } 353 }
385} 354}
386 355
387fn child_opt<'a, P: AstNode<'a>, C: AstNode<'a>>(parent: P) -> Option<C> { 356fn child_opt<P: AstNode, C: AstNode>(parent: &P) -> Option<&C> {
388 children(parent).next() 357 children(parent).next()
389} 358}
390 359
391fn children<'a, P: AstNode<'a>, C: AstNode<'a>>(parent: P) -> AstChildren<'a, C> { 360fn children<P: AstNode, C: AstNode>(parent: &P) -> AstChildren<C> {
392 AstChildren::new(parent.syntax()) 361 AstChildren::new(parent.syntax())
393} 362}
394 363
395#[derive(Debug)] 364#[derive(Debug)]
396pub struct AstChildren<'a, N> { 365pub struct AstChildren<'a, N> {
397 inner: SyntaxNodeChildren<RefRoot<'a>>, 366 inner: SyntaxNodeChildren<'a>,
398 ph: PhantomData<N>, 367 ph: PhantomData<N>,
399} 368}
400 369
401impl<'a, N> AstChildren<'a, N> { 370impl<'a, N> AstChildren<'a, N> {
402 fn new(parent: SyntaxNodeRef<'a>) -> Self { 371 fn new(parent: &'a SyntaxNode) -> Self {
403 AstChildren { 372 AstChildren {
404 inner: parent.children(), 373 inner: parent.children(),
405 ph: PhantomData, 374 ph: PhantomData,
@@ -407,9 +376,9 @@ impl<'a, N> AstChildren<'a, N> {
407 } 376 }
408} 377}
409 378
410impl<'a, N: AstNode<'a>> Iterator for AstChildren<'a, N> { 379impl<'a, N: AstNode + 'a> Iterator for AstChildren<'a, N> {
411 type Item = N; 380 type Item = &'a N;
412 fn next(&mut self) -> Option<N> { 381 fn next(&mut self) -> Option<&'a N> {
413 loop { 382 loop {
414 if let Some(n) = N::cast(self.inner.next()?) { 383 if let Some(n) = N::cast(self.inner.next()?) {
415 return Some(n); 384 return Some(n);
@@ -420,13 +389,13 @@ impl<'a, N: AstNode<'a>> Iterator for AstChildren<'a, N> {
420 389
421#[derive(Debug, Clone, PartialEq, Eq)] 390#[derive(Debug, Clone, PartialEq, Eq)]
422pub enum StructFlavor<'a> { 391pub enum StructFlavor<'a> {
423 Tuple(PosFieldList<'a>), 392 Tuple(&'a PosFieldList),
424 Named(NamedFieldDefList<'a>), 393 Named(&'a NamedFieldDefList),
425 Unit, 394 Unit,
426} 395}
427 396
428impl<'a> StructFlavor<'a> { 397impl StructFlavor<'_> {
429 fn from_node<N: AstNode<'a>>(node: N) -> StructFlavor<'a> { 398 fn from_node<N: AstNode>(node: &N) -> StructFlavor {
430 if let Some(nfdl) = child_opt::<_, NamedFieldDefList>(node) { 399 if let Some(nfdl) = child_opt::<_, NamedFieldDefList>(node) {
431 StructFlavor::Named(nfdl) 400 StructFlavor::Named(nfdl)
432 } else if let Some(pfl) = child_opt::<_, PosFieldList>(node) { 401 } else if let Some(pfl) = child_opt::<_, PosFieldList>(node) {
@@ -437,31 +406,31 @@ impl<'a> StructFlavor<'a> {
437 } 406 }
438} 407}
439 408
440impl<'a> StructDef<'a> { 409impl StructDef {
441 pub fn flavor(self) -> StructFlavor<'a> { 410 pub fn flavor(&self) -> StructFlavor {
442 StructFlavor::from_node(self) 411 StructFlavor::from_node(self)
443 } 412 }
444} 413}
445 414
446impl<'a> EnumVariant<'a> { 415impl EnumVariant {
447 pub fn flavor(self) -> StructFlavor<'a> { 416 pub fn flavor(&self) -> StructFlavor {
448 StructFlavor::from_node(self) 417 StructFlavor::from_node(self)
449 } 418 }
450} 419}
451 420
452impl<'a> PointerType<'a> { 421impl PointerType {
453 pub fn is_mut(&self) -> bool { 422 pub fn is_mut(&self) -> bool {
454 self.syntax().children().any(|n| n.kind() == MUT_KW) 423 self.syntax().children().any(|n| n.kind() == MUT_KW)
455 } 424 }
456} 425}
457 426
458impl<'a> ReferenceType<'a> { 427impl ReferenceType {
459 pub fn is_mut(&self) -> bool { 428 pub fn is_mut(&self) -> bool {
460 self.syntax().children().any(|n| n.kind() == MUT_KW) 429 self.syntax().children().any(|n| n.kind() == MUT_KW)
461 } 430 }
462} 431}
463 432
464impl<'a> RefExpr<'a> { 433impl RefExpr {
465 pub fn is_mut(&self) -> bool { 434 pub fn is_mut(&self) -> bool {
466 self.syntax().children().any(|n| n.kind() == MUT_KW) 435 self.syntax().children().any(|n| n.kind() == MUT_KW)
467 } 436 }
@@ -477,7 +446,7 @@ pub enum PrefixOp {
477 Neg, 446 Neg,
478} 447}
479 448
480impl<'a> PrefixExpr<'a> { 449impl PrefixExpr {
481 pub fn op(&self) -> Option<PrefixOp> { 450 pub fn op(&self) -> Option<PrefixOp> {
482 match self.syntax().first_child()?.kind() { 451 match self.syntax().first_child()?.kind() {
483 STAR => Some(PrefixOp::Deref), 452 STAR => Some(PrefixOp::Deref),
@@ -552,7 +521,7 @@ pub enum BinOp {
552 BitXorAssign, 521 BitXorAssign,
553} 522}
554 523
555impl<'a> BinExpr<'a> { 524impl BinExpr {
556 pub fn op(&self) -> Option<BinOp> { 525 pub fn op(&self) -> Option<BinOp> {
557 self.syntax() 526 self.syntax()
558 .children() 527 .children()
@@ -592,15 +561,15 @@ impl<'a> BinExpr<'a> {
592 .next() 561 .next()
593 } 562 }
594 563
595 pub fn lhs(self) -> Option<Expr<'a>> { 564 pub fn lhs(&self) -> Option<&Expr> {
596 children(self).nth(0) 565 children(self).nth(0)
597 } 566 }
598 567
599 pub fn rhs(self) -> Option<Expr<'a>> { 568 pub fn rhs(&self) -> Option<&Expr> {
600 children(self).nth(1) 569 children(self).nth(1)
601 } 570 }
602 571
603 pub fn sub_exprs(self) -> (Option<Expr<'a>>, Option<Expr<'a>>) { 572 pub fn sub_exprs(&self) -> (Option<&Expr>, Option<&Expr>) {
604 let mut children = children(self); 573 let mut children = children(self);
605 let first = children.next(); 574 let first = children.next();
606 let second = children.next(); 575 let second = children.next();
@@ -618,7 +587,7 @@ pub enum SelfParamFlavor {
618 MutRef, 587 MutRef,
619} 588}
620 589
621impl<'a> SelfParam<'a> { 590impl SelfParam {
622 pub fn flavor(&self) -> SelfParamFlavor { 591 pub fn flavor(&self) -> SelfParamFlavor {
623 let borrowed = self.syntax().children().any(|n| n.kind() == AMP); 592 let borrowed = self.syntax().children().any(|n| n.kind() == AMP);
624 if borrowed { 593 if borrowed {
@@ -641,7 +610,7 @@ impl<'a> SelfParam<'a> {
641 610
642#[test] 611#[test]
643fn test_doc_comment_of_items() { 612fn test_doc_comment_of_items() {
644 let file = SourceFileNode::parse( 613 let file = SourceFile::parse(
645 r#" 614 r#"
646 //! doc 615 //! doc
647 // non-doc 616 // non-doc