aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_hir_def/src/generics.rs2
-rw-r--r--crates/ra_syntax/src/ast/generated/nodes.rs54
-rw-r--r--crates/ra_syntax/src/ast/node_ext.rs20
3 files changed, 28 insertions, 48 deletions
diff --git a/crates/ra_hir_def/src/generics.rs b/crates/ra_hir_def/src/generics.rs
index be0b45af3..699ba9c92 100644
--- a/crates/ra_hir_def/src/generics.rs
+++ b/crates/ra_hir_def/src/generics.rs
@@ -270,7 +270,7 @@ impl GenericParams {
270 bound: ast::TypeBound, 270 bound: ast::TypeBound,
271 type_ref: TypeRef, 271 type_ref: TypeRef,
272 ) { 272 ) {
273 if bound.question_token().is_some() { 273 if bound.question_mark_token().is_some() {
274 // FIXME: remove this bound 274 // FIXME: remove this bound
275 return; 275 return;
276 } 276 }
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs
index afa37f227..9064398a9 100644
--- a/crates/ra_syntax/src/ast/generated/nodes.rs
+++ b/crates/ra_syntax/src/ast/generated/nodes.rs
@@ -639,6 +639,17 @@ impl DynTraitType {
639 pub fn type_bound_list(&self) -> Option<TypeBoundList> { support::child(&self.syntax) } 639 pub fn type_bound_list(&self) -> Option<TypeBoundList> { support::child(&self.syntax) }
640} 640}
641#[derive(Debug, Clone, PartialEq, Eq, Hash)] 641#[derive(Debug, Clone, PartialEq, Eq, Hash)]
642pub struct TypeBound {
643 pub(crate) syntax: SyntaxNode,
644}
645impl TypeBound {
646 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
647 support::token(&self.syntax, T![lifetime])
648 }
649 pub fn question_mark_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![?]) }
650 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
651}
652#[derive(Debug, Clone, PartialEq, Eq, Hash)]
642pub struct TupleExpr { 653pub struct TupleExpr {
643 pub(crate) syntax: SyntaxNode, 654 pub(crate) syntax: SyntaxNode,
644} 655}
@@ -1168,17 +1179,6 @@ impl MacroStmts {
1168 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 1179 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1169} 1180}
1170#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1181#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1171pub struct TypeBound {
1172 pub(crate) syntax: SyntaxNode,
1173}
1174impl TypeBound {
1175 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
1176 support::token(&self.syntax, T![lifetime])
1177 }
1178 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
1179 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
1180}
1181#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1182pub struct WherePred { 1182pub struct WherePred {
1183 pub(crate) syntax: SyntaxNode, 1183 pub(crate) syntax: SyntaxNode,
1184} 1184}
@@ -2045,6 +2045,17 @@ impl AstNode for DynTraitType {
2045 } 2045 }
2046 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2046 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2047} 2047}
2048impl AstNode for TypeBound {
2049 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND }
2050 fn cast(syntax: SyntaxNode) -> Option<Self> {
2051 if Self::can_cast(syntax.kind()) {
2052 Some(Self { syntax })
2053 } else {
2054 None
2055 }
2056 }
2057 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2058}
2048impl AstNode for TupleExpr { 2059impl AstNode for TupleExpr {
2049 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_EXPR } 2060 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_EXPR }
2050 fn cast(syntax: SyntaxNode) -> Option<Self> { 2061 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2661,17 +2672,6 @@ impl AstNode for MacroStmts {
2661 } 2672 }
2662 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2673 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2663} 2674}
2664impl AstNode for TypeBound {
2665 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND }
2666 fn cast(syntax: SyntaxNode) -> Option<Self> {
2667 if Self::can_cast(syntax.kind()) {
2668 Some(Self { syntax })
2669 } else {
2670 None
2671 }
2672 }
2673 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2674}
2675impl AstNode for WherePred { 2675impl AstNode for WherePred {
2676 fn can_cast(kind: SyntaxKind) -> bool { kind == WHERE_PRED } 2676 fn can_cast(kind: SyntaxKind) -> bool { kind == WHERE_PRED }
2677 fn cast(syntax: SyntaxNode) -> Option<Self> { 2677 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -3746,6 +3746,11 @@ impl std::fmt::Display for DynTraitType {
3746 std::fmt::Display::fmt(self.syntax(), f) 3746 std::fmt::Display::fmt(self.syntax(), f)
3747 } 3747 }
3748} 3748}
3749impl std::fmt::Display for TypeBound {
3750 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3751 std::fmt::Display::fmt(self.syntax(), f)
3752 }
3753}
3749impl std::fmt::Display for TupleExpr { 3754impl std::fmt::Display for TupleExpr {
3750 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3755 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3751 std::fmt::Display::fmt(self.syntax(), f) 3756 std::fmt::Display::fmt(self.syntax(), f)
@@ -4026,11 +4031,6 @@ impl std::fmt::Display for MacroStmts {
4026 std::fmt::Display::fmt(self.syntax(), f) 4031 std::fmt::Display::fmt(self.syntax(), f)
4027 } 4032 }
4028} 4033}
4029impl std::fmt::Display for TypeBound {
4030 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4031 std::fmt::Display::fmt(self.syntax(), f)
4032 }
4033}
4034impl std::fmt::Display for WherePred { 4034impl std::fmt::Display for WherePred {
4035 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 4035 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4036 std::fmt::Display::fmt(self.syntax(), f) 4036 std::fmt::Display::fmt(self.syntax(), f)
diff --git a/crates/ra_syntax/src/ast/node_ext.rs b/crates/ra_syntax/src/ast/node_ext.rs
index 30c2db56b..69726fb93 100644
--- a/crates/ra_syntax/src/ast/node_ext.rs
+++ b/crates/ra_syntax/src/ast/node_ext.rs
@@ -362,26 +362,6 @@ impl ast::TypeBound {
362 unreachable!() 362 unreachable!()
363 } 363 }
364 } 364 }
365
366 pub fn const_question_token(&self) -> Option<SyntaxToken> {
367 self.syntax()
368 .children_with_tokens()
369 .filter_map(|it| it.into_token())
370 .take_while(|it| it.kind() != T![const])
371 .find(|it| it.kind() == T![?])
372 }
373
374 pub fn question_token(&self) -> Option<SyntaxToken> {
375 if self.const_token().is_some() {
376 self.syntax()
377 .children_with_tokens()
378 .filter_map(|it| it.into_token())
379 .skip_while(|it| it.kind() != T![const])
380 .find(|it| it.kind() == T![?])
381 } else {
382 support::token(&self.syntax, T![?])
383 }
384 }
385} 365}
386 366
387pub enum VisibilityKind { 367pub enum VisibilityKind {