diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-05-01 20:24:25 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-05-01 20:24:25 +0100 |
commit | 21588e15dfa8b117b503769119320e718bade351 (patch) | |
tree | c10be6c66f2d6220d98c316c44bb3f9677ad1a1d /crates/ra_syntax/src/ast/generated | |
parent | 302777f0041540bf6790fde2acc3bb5b04e72427 (diff) | |
parent | 3bb46042fb5b8ee421e350c54079cb68b4edc996 (diff) |
Merge #4246
4246: Validate uses of self and super r=matklad a=djrenren
This change follows on the validation of the `crate` keyword in paths. It verifies the following things:
`super`:
- May only be preceded by other `super` segments
- If in a `UseItem` then all semantically preceding paths also consist only of `super`
`self`
- May only be the start of a path
Just a note, a couple times while working on this I found myself really wanting a Visitor of some sort so that I could traverse descendants while skipping sub-trees that are unimportant. Iterators don't really work for this, so as you can see I reached for recursion. Considering paths are generally small a fancy debounced visitor probably isn't important but figured I'd say something in case we had something like this lying around and I wasn't using it.
Co-authored-by: John Renner <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src/ast/generated')
-rw-r--r-- | crates/ra_syntax/src/ast/generated/nodes.rs | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs index 81260680f..3f16592b6 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs | |||
@@ -1241,6 +1241,8 @@ pub struct PathSegment { | |||
1241 | impl PathSegment { | 1241 | impl PathSegment { |
1242 | pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) } | 1242 | pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) } |
1243 | pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) } | 1243 | pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) } |
1244 | pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) } | ||
1245 | pub fn super_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![super]) } | ||
1244 | pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) } | 1246 | pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) } |
1245 | pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } | 1247 | pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } |
1246 | pub fn type_arg_list(&self) -> Option<TypeArgList> { support::child(&self.syntax) } | 1248 | pub fn type_arg_list(&self) -> Option<TypeArgList> { support::child(&self.syntax) } |