aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-08-24 21:10:16 +0100
committerGitHub <[email protected]>2020-08-24 21:10:16 +0100
commitef9cea945d5767e7c60d5931a7649a73caea23ad (patch)
tree8a2cdf4db86466eca026b32a52822092248e95ba /crates
parented09bd3cc6a37d7d22038adf7ff815f0188a9949 (diff)
parentf3ac19e8cd8be78f1eb96893482edac038739bb1 (diff)
Merge #5861
5861: Support extern types r=matklad a=jonas-schievink This is a currently unstable feature tracked at https://github.com/rust-lang/rust/issues/43467 Co-authored-by: Jonas Schievink <[email protected]>
Diffstat (limited to 'crates')
-rw-r--r--crates/hir_def/src/item_tree/lower.rs4
-rw-r--r--crates/hir_def/src/nameres/tests.rs2
-rw-r--r--crates/syntax/src/ast/generated/nodes.rs8
3 files changed, 13 insertions, 1 deletions
diff --git a/crates/hir_def/src/item_tree/lower.rs b/crates/hir_def/src/item_tree/lower.rs
index 391ab5d39..6a503d785 100644
--- a/crates/hir_def/src/item_tree/lower.rs
+++ b/crates/hir_def/src/item_tree/lower.rs
@@ -557,6 +557,10 @@ impl Ctx {
557 let statik = self.lower_static(&ast)?; 557 let statik = self.lower_static(&ast)?;
558 statik.into() 558 statik.into()
559 } 559 }
560 ast::ExternItem::TypeAlias(ty) => {
561 let id = self.lower_type_alias(&ty)?;
562 id.into()
563 }
560 ast::ExternItem::MacroCall(_) => return None, 564 ast::ExternItem::MacroCall(_) => return None,
561 }; 565 };
562 self.add_attrs(id.into(), attrs); 566 self.add_attrs(id.into(), attrs);
diff --git a/crates/hir_def/src/nameres/tests.rs b/crates/hir_def/src/nameres/tests.rs
index 8aaf7a158..5ca30dac9 100644
--- a/crates/hir_def/src/nameres/tests.rs
+++ b/crates/hir_def/src/nameres/tests.rs
@@ -46,6 +46,7 @@ union U { to_be: bool, not_to_be: u8 }
46enum E { V } 46enum E { V }
47 47
48extern { 48extern {
49 type Ext;
49 static EXT: u8; 50 static EXT: u8;
50 fn ext(); 51 fn ext();
51} 52}
@@ -65,6 +66,7 @@ extern {
65 Baz: t v 66 Baz: t v
66 E: t 67 E: t
67 EXT: v 68 EXT: v
69 Ext: t
68 U: t 70 U: t
69 ext: v 71 ext: v
70 "#]], 72 "#]],
diff --git a/crates/syntax/src/ast/generated/nodes.rs b/crates/syntax/src/ast/generated/nodes.rs
index 6317407c6..d6af5755c 100644
--- a/crates/syntax/src/ast/generated/nodes.rs
+++ b/crates/syntax/src/ast/generated/nodes.rs
@@ -1380,6 +1380,7 @@ pub enum ExternItem {
1380 Fn(Fn), 1380 Fn(Fn),
1381 MacroCall(MacroCall), 1381 MacroCall(MacroCall),
1382 Static(Static), 1382 Static(Static),
1383 TypeAlias(TypeAlias),
1383} 1384}
1384impl ast::AttrsOwner for ExternItem {} 1385impl ast::AttrsOwner for ExternItem {}
1385impl ast::NameOwner for ExternItem {} 1386impl ast::NameOwner for ExternItem {}
@@ -3339,10 +3340,13 @@ impl From<MacroCall> for ExternItem {
3339impl From<Static> for ExternItem { 3340impl From<Static> for ExternItem {
3340 fn from(node: Static) -> ExternItem { ExternItem::Static(node) } 3341 fn from(node: Static) -> ExternItem { ExternItem::Static(node) }
3341} 3342}
3343impl From<TypeAlias> for ExternItem {
3344 fn from(node: TypeAlias) -> ExternItem { ExternItem::TypeAlias(node) }
3345}
3342impl AstNode for ExternItem { 3346impl AstNode for ExternItem {
3343 fn can_cast(kind: SyntaxKind) -> bool { 3347 fn can_cast(kind: SyntaxKind) -> bool {
3344 match kind { 3348 match kind {
3345 FN | MACRO_CALL | STATIC => true, 3349 FN | MACRO_CALL | STATIC | TYPE_ALIAS => true,
3346 _ => false, 3350 _ => false,
3347 } 3351 }
3348 } 3352 }
@@ -3351,6 +3355,7 @@ impl AstNode for ExternItem {
3351 FN => ExternItem::Fn(Fn { syntax }), 3355 FN => ExternItem::Fn(Fn { syntax }),
3352 MACRO_CALL => ExternItem::MacroCall(MacroCall { syntax }), 3356 MACRO_CALL => ExternItem::MacroCall(MacroCall { syntax }),
3353 STATIC => ExternItem::Static(Static { syntax }), 3357 STATIC => ExternItem::Static(Static { syntax }),
3358 TYPE_ALIAS => ExternItem::TypeAlias(TypeAlias { syntax }),
3354 _ => return None, 3359 _ => return None,
3355 }; 3360 };
3356 Some(res) 3361 Some(res)
@@ -3360,6 +3365,7 @@ impl AstNode for ExternItem {
3360 ExternItem::Fn(it) => &it.syntax, 3365 ExternItem::Fn(it) => &it.syntax,
3361 ExternItem::MacroCall(it) => &it.syntax, 3366 ExternItem::MacroCall(it) => &it.syntax,
3362 ExternItem::Static(it) => &it.syntax, 3367 ExternItem::Static(it) => &it.syntax,
3368 ExternItem::TypeAlias(it) => &it.syntax,
3363 } 3369 }
3364 } 3370 }
3365} 3371}