Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/syntax/src/ast/node_ext.rs')
-rw-r--r--crates/syntax/src/ast/node_ext.rs11
1 files changed, 7 insertions, 4 deletions
diff --git a/crates/syntax/src/ast/node_ext.rs b/crates/syntax/src/ast/node_ext.rs
index 901d17bb14..b872221bf7 100644
--- a/crates/syntax/src/ast/node_ext.rs
+++ b/crates/syntax/src/ast/node_ext.rs
@@ -813,13 +813,16 @@ pub enum TypeBoundKind {
}
impl ast::TypeBound {
- pub fn kind(&self) -> TypeBoundKind {
+ pub fn kind(&self) -> Option<TypeBoundKind> {
if let Some(path_type) = support::children(self.syntax()).next() {
- TypeBoundKind::PathType(self.for_binder(), path_type)
+ Some(TypeBoundKind::PathType(self.for_binder(), path_type))
+ } else if let Some(for_binder) = support::children::<ast::ForType>(&self.syntax).next() {
+ let Some(ast::Type::PathType(path_type)) = for_binder.ty() else { return None };
+ Some(TypeBoundKind::PathType(for_binder.for_binder(), path_type))
} else if let Some(args) = self.use_bound_generic_args() {
- TypeBoundKind::Use(args)
+ Some(TypeBoundKind::Use(args))
} else if let Some(lifetime) = self.lifetime() {
- TypeBoundKind::Lifetime(lifetime)
+ Some(TypeBoundKind::Lifetime(lifetime))
} else {
unreachable!()
}