about summary refs log tree commit diff
diff options
context:
space:
mode:
authorA4-Tacks <wdsjxhno1001@163.com>2025-09-07 15:05:11 +0800
committerA4-Tacks <wdsjxhno1001@163.com>2025-09-09 15:22:12 +0800
commit2079d1126bcfb5ed125009f3ccfc67ebd7995d56 (patch)
tree7609b12ee0801d6778c44fcee7183d39ef08b905
parentab5113a316959f2558f03a7bf590e967602f02df (diff)
downloadrust-2079d1126bcfb5ed125009f3ccfc67ebd7995d56.tar.gz
rust-2079d1126bcfb5ed125009f3ccfc67ebd7995d56.zip
Fix LifetimeParam::lifetime_bounds invalid implement
Lifetime node example:

```
LIFETIME_PARAM@15..21
  LIFETIME@15..17
    LIFETIME_IDENT@15..17 "'a"
  COLON@17..18 ":"
  WHITESPACE@18..19 " "
  TYPE_BOUND_LIST@19..21
    TYPE_BOUND@19..21
      LIFETIME@19..21
        LIFETIME_IDENT@19..21 "'b"
```
-rw-r--r--src/tools/rust-analyzer/crates/syntax/src/ast/node_ext.rs13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/tools/rust-analyzer/crates/syntax/src/ast/node_ext.rs b/src/tools/rust-analyzer/crates/syntax/src/ast/node_ext.rs
index 42b0f5cf2da..af741d100f6 100644
--- a/src/tools/rust-analyzer/crates/syntax/src/ast/node_ext.rs
+++ b/src/tools/rust-analyzer/crates/syntax/src/ast/node_ext.rs
@@ -12,8 +12,8 @@ use rowan::{GreenNodeData, GreenTokenData};
 use crate::{
     NodeOrToken, SmolStr, SyntaxElement, SyntaxToken, T, TokenText,
     ast::{
-        self, AstNode, AstToken, HasAttrs, HasGenericArgs, HasGenericParams, HasName, SyntaxNode,
-        support,
+        self, AstNode, AstToken, HasAttrs, HasGenericArgs, HasGenericParams, HasName,
+        HasTypeBounds, SyntaxNode, support,
     },
     ted,
 };
@@ -912,11 +912,10 @@ impl ast::Visibility {
 
 impl ast::LifetimeParam {
     pub fn lifetime_bounds(&self) -> impl Iterator<Item = SyntaxToken> {
-        self.syntax()
-            .children_with_tokens()
-            .filter_map(|it| it.into_token())
-            .skip_while(|x| x.kind() != T![:])
-            .filter(|it| it.kind() == T![lifetime_ident])
+        self.type_bound_list()
+            .into_iter()
+            .flat_map(|it| it.bounds())
+            .filter_map(|it| it.lifetime()?.lifetime_ident_token())
     }
 }