diff --git a/crates/ra_syntax/src/ast/extensions.rs b/crates/ra_syntax/src/ast/extensions.rs index 1aacb06764..76b7655e68 100644 --- a/crates/ra_syntax/src/ast/extensions.rs +++ b/crates/ra_syntax/src/ast/extensions.rs @@ -275,7 +275,7 @@ pub enum SelfParamKind { impl ast::SelfParam { pub fn kind(&self) -> SelfParamKind { if self.amp_token().is_some() { - if self.amp_mut_token().is_some() { + if self.mut_token().is_some() { SelfParamKind::MutRef } else { SelfParamKind::Ref @@ -284,24 +284,6 @@ impl ast::SelfParam { SelfParamKind::Owned } } - - /// the "mut" in "mut self", not the one in "&mut self" - pub fn mut_token(&self) -> Option { - 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 { - 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)] diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs index 0df7cfe526..f1098755b6 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs @@ -2307,6 +2307,7 @@ impl ast::TypeAscriptionOwner for SelfParam {} impl ast::AttrsOwner for SelfParam {} impl SelfParam { pub fn amp_token(&self) -> Option { support::token(&self.syntax, T![&]) } + pub fn mut_token(&self) -> Option { support::token(&self.syntax, T![mut]) } pub fn lifetime_token(&self) -> Option { support::token(&self.syntax, T![lifetime]) } diff --git a/xtask/src/ast_src.rs b/xtask/src/ast_src.rs index 8c0b5f5a8b..69cba91684 100644 --- a/xtask/src/ast_src.rs +++ b/xtask/src/ast_src.rs @@ -568,7 +568,7 @@ pub(crate) const AST_SRC: AstSrc = AstSrc { params: [Param], 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 { Pat, T![...]