mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
Simplify
This commit is contained in:
parent
5c5bde47fb
commit
c476742f47
3 changed files with 3 additions and 20 deletions
|
@ -275,7 +275,7 @@ pub enum SelfParamKind {
|
||||||
impl ast::SelfParam {
|
impl ast::SelfParam {
|
||||||
pub fn kind(&self) -> SelfParamKind {
|
pub fn kind(&self) -> SelfParamKind {
|
||||||
if self.amp_token().is_some() {
|
if self.amp_token().is_some() {
|
||||||
if self.amp_mut_token().is_some() {
|
if self.mut_token().is_some() {
|
||||||
SelfParamKind::MutRef
|
SelfParamKind::MutRef
|
||||||
} else {
|
} else {
|
||||||
SelfParamKind::Ref
|
SelfParamKind::Ref
|
||||||
|
@ -284,24 +284,6 @@ impl ast::SelfParam {
|
||||||
SelfParamKind::Owned
|
SelfParamKind::Owned
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// the "mut" in "mut self", not the one in "&mut self"
|
|
||||||
pub fn mut_token(&self) -> Option<SyntaxToken> {
|
|
||||||
self.syntax()
|
|
||||||
.children_with_tokens()
|
|
||||||
.filter_map(|it| it.into_token())
|
|
||||||
.take_while(|it| it.kind() != T![&])
|
|
||||||
.find(|it| it.kind() == T![mut])
|
|
||||||
}
|
|
||||||
|
|
||||||
/// the "mut" in "&mut self", not the one in "mut self"
|
|
||||||
pub fn amp_mut_token(&self) -> Option<SyntaxToken> {
|
|
||||||
self.syntax()
|
|
||||||
.children_with_tokens()
|
|
||||||
.filter_map(|it| it.into_token())
|
|
||||||
.skip_while(|it| it.kind() != T![&])
|
|
||||||
.find(|it| it.kind() == T![mut])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||||
|
|
|
@ -2307,6 +2307,7 @@ impl ast::TypeAscriptionOwner for SelfParam {}
|
||||||
impl ast::AttrsOwner for SelfParam {}
|
impl ast::AttrsOwner for SelfParam {}
|
||||||
impl SelfParam {
|
impl SelfParam {
|
||||||
pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) }
|
pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) }
|
||||||
|
pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
|
||||||
pub fn lifetime_token(&self) -> Option<SyntaxToken> {
|
pub fn lifetime_token(&self) -> Option<SyntaxToken> {
|
||||||
support::token(&self.syntax, T![lifetime])
|
support::token(&self.syntax, T![lifetime])
|
||||||
}
|
}
|
||||||
|
|
|
@ -568,7 +568,7 @@ pub(crate) const AST_SRC: AstSrc = AstSrc {
|
||||||
params: [Param],
|
params: [Param],
|
||||||
T![')']
|
T![')']
|
||||||
}
|
}
|
||||||
struct SelfParam: TypeAscriptionOwner, AttrsOwner { T![&], T![lifetime], T![self] }
|
struct SelfParam: TypeAscriptionOwner, AttrsOwner { T![&], T![mut], T![lifetime], T![self] }
|
||||||
struct Param: TypeAscriptionOwner, AttrsOwner {
|
struct Param: TypeAscriptionOwner, AttrsOwner {
|
||||||
Pat,
|
Pat,
|
||||||
T![...]
|
T![...]
|
||||||
|
|
Loading…
Reference in a new issue