Skip to content

Commit f3ac19e

Browse files
Support extern types
1 parent ed09bd3 commit f3ac19e

File tree

6 files changed

+16
-591
lines changed

6 files changed

+16
-591
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/hir_def/src/item_tree/lower.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,10 @@ impl Ctx {
557557
let statik = self.lower_static(&ast)?;
558558
statik.into()
559559
}
560+
ast::ExternItem::TypeAlias(ty) => {
561+
let id = self.lower_type_alias(&ty)?;
562+
id.into()
563+
}
560564
ast::ExternItem::MacroCall(_) => return None,
561565
};
562566
self.add_attrs(id.into(), attrs);

crates/hir_def/src/nameres/tests.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ union U { to_be: bool, not_to_be: u8 }
4646
enum E { V }
4747
4848
extern {
49+
type Ext;
4950
static EXT: u8;
5051
fn ext();
5152
}
@@ -65,6 +66,7 @@ extern {
6566
Baz: t v
6667
E: t
6768
EXT: v
69+
Ext: t
6870
U: t
6971
ext: v
7072
"#]],

crates/syntax/src/ast/generated/nodes.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1380,6 +1380,7 @@ pub enum ExternItem {
13801380
Fn(Fn),
13811381
MacroCall(MacroCall),
13821382
Static(Static),
1383+
TypeAlias(TypeAlias),
13831384
}
13841385
impl ast::AttrsOwner for ExternItem {}
13851386
impl ast::NameOwner for ExternItem {}
@@ -3339,10 +3340,13 @@ impl From<MacroCall> for ExternItem {
33393340
impl From<Static> for ExternItem {
33403341
fn from(node: Static) -> ExternItem { ExternItem::Static(node) }
33413342
}
3343+
impl From<TypeAlias> for ExternItem {
3344+
fn from(node: TypeAlias) -> ExternItem { ExternItem::TypeAlias(node) }
3345+
}
33423346
impl AstNode for ExternItem {
33433347
fn can_cast(kind: SyntaxKind) -> bool {
33443348
match kind {
3345-
FN | MACRO_CALL | STATIC => true,
3349+
FN | MACRO_CALL | STATIC | TYPE_ALIAS => true,
33463350
_ => false,
33473351
}
33483352
}
@@ -3351,6 +3355,7 @@ impl AstNode for ExternItem {
33513355
FN => ExternItem::Fn(Fn { syntax }),
33523356
MACRO_CALL => ExternItem::MacroCall(MacroCall { syntax }),
33533357
STATIC => ExternItem::Static(Static { syntax }),
3358+
TYPE_ALIAS => ExternItem::TypeAlias(TypeAlias { syntax }),
33543359
_ => return None,
33553360
};
33563361
Some(res)
@@ -3360,6 +3365,7 @@ impl AstNode for ExternItem {
33603365
ExternItem::Fn(it) => &it.syntax,
33613366
ExternItem::MacroCall(it) => &it.syntax,
33623367
ExternItem::Static(it) => &it.syntax,
3368+
ExternItem::TypeAlias(it) => &it.syntax,
33633369
}
33643370
}
33653371
}

xtask/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ flate2 = "1.0"
1515
pico-args = "0.3.1"
1616
proc-macro2 = "1.0.8"
1717
quote = "1.0.2"
18-
ungrammar = "1.1.1"
18+
ungrammar = "1.1.3"
1919
walkdir = "2.3.1"
2020
write-json = "0.1.0"
2121
# Avoid adding more dependencies to this crate

0 commit comments

Comments
 (0)