mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 04:19:13 +00:00
Fix Return Type Syntax to include ..
(i.e. method(..)
and not method()
) as specified in the RFC
This commit is contained in:
parent
7106cd3be5
commit
21e6058ab7
12 changed files with 183 additions and 16 deletions
|
@ -114,6 +114,8 @@ impl AssocTypeArg {
|
|||
#[inline]
|
||||
pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) }
|
||||
#[inline]
|
||||
pub fn return_type_syntax(&self) -> Option<ReturnTypeSyntax> { support::child(&self.syntax) }
|
||||
#[inline]
|
||||
pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
|
||||
#[inline]
|
||||
pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
|
||||
|
@ -1221,6 +1223,8 @@ impl PathSegment {
|
|||
#[inline]
|
||||
pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) }
|
||||
#[inline]
|
||||
pub fn return_type_syntax(&self) -> Option<ReturnTypeSyntax> { support::child(&self.syntax) }
|
||||
#[inline]
|
||||
pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
|
||||
#[inline]
|
||||
pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) }
|
||||
|
@ -1485,6 +1489,19 @@ impl ReturnExpr {
|
|||
pub fn return_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![return]) }
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct ReturnTypeSyntax {
|
||||
pub(crate) syntax: SyntaxNode,
|
||||
}
|
||||
impl ReturnTypeSyntax {
|
||||
#[inline]
|
||||
pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
|
||||
#[inline]
|
||||
pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
|
||||
#[inline]
|
||||
pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) }
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct SelfParam {
|
||||
pub(crate) syntax: SyntaxNode,
|
||||
|
@ -3697,6 +3714,20 @@ impl AstNode for ReturnExpr {
|
|||
#[inline]
|
||||
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
||||
}
|
||||
impl AstNode for ReturnTypeSyntax {
|
||||
#[inline]
|
||||
fn can_cast(kind: SyntaxKind) -> bool { kind == RETURN_TYPE_SYNTAX }
|
||||
#[inline]
|
||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||
if Self::can_cast(syntax.kind()) {
|
||||
Some(Self { syntax })
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
||||
}
|
||||
impl AstNode for SelfParam {
|
||||
#[inline]
|
||||
fn can_cast(kind: SyntaxKind) -> bool { kind == SELF_PARAM }
|
||||
|
@ -6609,6 +6640,11 @@ impl std::fmt::Display for ReturnExpr {
|
|||
std::fmt::Display::fmt(self.syntax(), f)
|
||||
}
|
||||
}
|
||||
impl std::fmt::Display for ReturnTypeSyntax {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
std::fmt::Display::fmt(self.syntax(), f)
|
||||
}
|
||||
}
|
||||
impl std::fmt::Display for SelfParam {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
std::fmt::Display::fmt(self.syntax(), f)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue