mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
fix: support existential type
This commit is contained in:
parent
3f5f9f0560
commit
2ca9f71897
7 changed files with 53 additions and 6 deletions
|
@ -107,6 +107,10 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Resul
|
|||
p.bump_remap(T![default]);
|
||||
has_mods = true;
|
||||
}
|
||||
if p.at(IDENT) && p.at_contextual_kw("existential") && p.nth(1) == T![type] {
|
||||
p.bump_remap(T![existential]);
|
||||
has_mods = true;
|
||||
}
|
||||
|
||||
// items
|
||||
match p.current() {
|
||||
|
@ -165,12 +169,17 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Resul
|
|||
traits::impl_block(p);
|
||||
m.complete(p, IMPL_BLOCK);
|
||||
}
|
||||
// test existential_type
|
||||
// existential type Foo: Fn() -> usize;
|
||||
T![type] => {
|
||||
type_def(p, m);
|
||||
}
|
||||
_ => {
|
||||
if !has_visibility && !has_mods {
|
||||
return Err(m);
|
||||
} else {
|
||||
if has_mods {
|
||||
p.error("expected fn, trait or impl");
|
||||
p.error("expected existential, fn, trait or impl");
|
||||
} else {
|
||||
p.error("expected an item");
|
||||
}
|
||||
|
@ -187,7 +196,9 @@ fn items_without_modifiers(p: &mut Parser, m: Marker) -> Result<(), Marker> {
|
|||
// test extern_crate
|
||||
// extern crate foo;
|
||||
T![extern] if la == T![crate] => extern_crate_item(p, m),
|
||||
T![type] => type_def(p, m),
|
||||
T![type] => {
|
||||
type_def(p, m);
|
||||
}
|
||||
T![mod] => mod_item(p, m),
|
||||
T![struct] => {
|
||||
// test struct_items
|
||||
|
@ -308,7 +319,6 @@ fn type_def(p: &mut Parser, m: Marker) {
|
|||
// test type_item_where_clause
|
||||
// type Foo where Foo: Copy = ();
|
||||
type_params::opt_where_clause(p);
|
||||
|
||||
if p.eat(T![=]) {
|
||||
types::type_(p);
|
||||
}
|
||||
|
|
|
@ -106,6 +106,7 @@ pub enum SyntaxKind {
|
|||
TRY_KW,
|
||||
AUTO_KW,
|
||||
DEFAULT_KW,
|
||||
EXISTENTIAL_KW,
|
||||
UNION_KW,
|
||||
INT_NUMBER,
|
||||
FLOAT_NUMBER,
|
||||
|
@ -336,6 +337,7 @@ macro_rules! T {
|
|||
(try) => { $crate::SyntaxKind::TRY_KW };
|
||||
(auto) => { $crate::SyntaxKind::AUTO_KW };
|
||||
(default) => { $crate::SyntaxKind::DEFAULT_KW };
|
||||
(existential) => { $crate::SyntaxKind::EXISTENTIAL_KW };
|
||||
(union) => { $crate::SyntaxKind::UNION_KW };
|
||||
}
|
||||
|
||||
|
@ -394,6 +396,7 @@ impl SyntaxKind {
|
|||
| TRY_KW
|
||||
| AUTO_KW
|
||||
| DEFAULT_KW
|
||||
| EXISTENTIAL_KW
|
||||
| UNION_KW
|
||||
=> true,
|
||||
_ => false
|
||||
|
@ -566,6 +569,7 @@ impl SyntaxKind {
|
|||
TRY_KW => &SyntaxInfo { name: "TRY_KW" },
|
||||
AUTO_KW => &SyntaxInfo { name: "AUTO_KW" },
|
||||
DEFAULT_KW => &SyntaxInfo { name: "DEFAULT_KW" },
|
||||
EXISTENTIAL_KW => &SyntaxInfo { name: "EXISTENTIAL_KW" },
|
||||
UNION_KW => &SyntaxInfo { name: "UNION_KW" },
|
||||
INT_NUMBER => &SyntaxInfo { name: "INT_NUMBER" },
|
||||
FLOAT_NUMBER => &SyntaxInfo { name: "FLOAT_NUMBER" },
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue