mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 05:15:04 +00:00
fix: Recognize Self
as a proper keyword
This commit is contained in:
parent
8f504dc873
commit
c0d6471143
27 changed files with 98 additions and 49 deletions
|
@ -1,10 +1,10 @@
|
|||
use super::*;
|
||||
|
||||
pub(super) const PATH_FIRST: TokenSet =
|
||||
TokenSet::new(&[IDENT, T![self], T![super], T![crate], T![:], T![<]]);
|
||||
TokenSet::new(&[IDENT, T![self], T![super], T![crate], T![Self], T![:], T![<]]);
|
||||
|
||||
pub(super) fn is_path_start(p: &Parser) -> bool {
|
||||
is_use_path_start(p) || p.at(T![<])
|
||||
is_use_path_start(p) || p.at(T![<]) || p.at(T![Self])
|
||||
}
|
||||
|
||||
pub(super) fn is_use_path_start(p: &Parser) -> bool {
|
||||
|
@ -88,7 +88,7 @@ fn path_segment(p: &mut Parser, mode: Mode, first: bool) {
|
|||
}
|
||||
// test crate_path
|
||||
// use crate::foo;
|
||||
T![self] | T![super] | T![crate] => {
|
||||
T![self] | T![super] | T![crate] | T![Self] => {
|
||||
let m = p.start();
|
||||
p.bump_any();
|
||||
m.complete(p, NAME_REF);
|
||||
|
|
|
@ -14,6 +14,7 @@ pub(super) const TYPE_FIRST: TokenSet = paths::PATH_FIRST.union(TokenSet::new(&[
|
|||
T![for],
|
||||
T![impl],
|
||||
T![dyn],
|
||||
T![Self],
|
||||
]));
|
||||
|
||||
const TYPE_RECOVERY_SET: TokenSet = TokenSet::new(&[
|
||||
|
@ -46,7 +47,7 @@ fn type_with_bounds_cond(p: &mut Parser, allow_bounds: bool) {
|
|||
T![dyn] => dyn_trait_type(p),
|
||||
// Some path types are not allowed to have bounds (no plus)
|
||||
T![<] => path_type_(p, allow_bounds),
|
||||
_ if paths::is_use_path_start(p) => path_or_macro_type_(p, allow_bounds),
|
||||
_ if paths::is_path_start(p) => path_or_macro_type_(p, allow_bounds),
|
||||
_ => {
|
||||
p.err_recover("expected type", TYPE_RECOVERY_SET);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue