11630: fix: Recognize `Self` as a proper keyword r=Veykril a=Veykril

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/11627

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
bors[bot] 2022-03-05 23:48:54 +00:00 committed by GitHub
commit 96c11f5fd6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
39 changed files with 226 additions and 74 deletions

View file

@ -302,6 +302,7 @@ fn pretty_print_macro_expansion(expn: SyntaxNode, map: Option<&TokenMap>) -> Str
(T![fn], T!['(']) => "",
(T![']'], _) if curr_kind.is_keyword() => " ",
(T![']'], T![#]) => "\n",
(T![Self], T![::]) => "",
_ if prev_kind.is_keyword() => " ",
_ => "",
};

View file

@ -53,6 +53,10 @@ pub(super) fn lower_path(mut path: ast::Path, ctx: &LowerCtx) -> Option<Path> {
}
}
}
ast::PathSegmentKind::SelfTypeKw => {
segments.push(name![Self]);
generic_args.push(None)
}
ast::PathSegmentKind::Type { type_ref, trait_ref } => {
assert!(path.qualifier().is_none()); // this can only occur at the first segment