From b302f69b7c5b1b966ec3f8637761ecb867e3bcca Mon Sep 17 00:00:00 2001 From: Charles Lew Date: Sun, 13 Sep 2020 10:24:19 +0800 Subject: Update chalk to 0.27 and adapt to chalk changes. --- crates/hir_def/src/item_tree.rs | 1 + crates/hir_def/src/item_tree/lower.rs | 6 ++++-- crates/hir_def/src/item_tree/tests.rs | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) (limited to 'crates/hir_def/src') diff --git a/crates/hir_def/src/item_tree.rs b/crates/hir_def/src/item_tree.rs index e14722cae..52abb8e7f 100644 --- a/crates/hir_def/src/item_tree.rs +++ b/crates/hir_def/src/item_tree.rs @@ -592,6 +592,7 @@ pub struct TypeAlias { pub bounds: Box<[TypeBound]>, pub generic_params: GenericParamsId, pub type_ref: Option, + pub is_extern: bool, pub ast_id: FileAstId, } diff --git a/crates/hir_def/src/item_tree/lower.rs b/crates/hir_def/src/item_tree/lower.rs index 6a503d785..d93377c3b 100644 --- a/crates/hir_def/src/item_tree/lower.rs +++ b/crates/hir_def/src/item_tree/lower.rs @@ -364,6 +364,7 @@ impl Ctx { generic_params, type_ref, ast_id, + is_extern: false, }; Some(id(self.data().type_aliases.alloc(res))) } @@ -558,8 +559,9 @@ impl Ctx { statik.into() } ast::ExternItem::TypeAlias(ty) => { - let id = self.lower_type_alias(&ty)?; - id.into() + let foreign_ty = self.lower_type_alias(&ty)?; + self.data().type_aliases[foreign_ty.index].is_extern = true; + foreign_ty.into() } ast::ExternItem::MacroCall(_) => return None, }; diff --git a/crates/hir_def/src/item_tree/tests.rs b/crates/hir_def/src/item_tree/tests.rs index 620e697d4..eed3d0d6f 100644 --- a/crates/hir_def/src/item_tree/tests.rs +++ b/crates/hir_def/src/item_tree/tests.rs @@ -236,7 +236,7 @@ fn smoke() { #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("on_trait"))] }, input: None }]) }] Trait { name: Name(Text("Tr")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(0), auto: false, items: [TypeAlias(Idx::(0)), Const(Idx::(0)), Function(Idx::(0)), Function(Idx::(1))], ast_id: FileAstId::(2) } > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_ty"))] }, input: None }]) }] - > TypeAlias { name: Name(Text("AssocTy")), visibility: RawVisibilityId("pub(self)"), bounds: [Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Tr"))] }, generic_args: [Some(GenericArgs { args: [Type(Tuple([]))], has_self_type: false, bindings: [] })] })], generic_params: GenericParamsId(4294967295), type_ref: None, ast_id: FileAstId::(8) } + > TypeAlias { name: Name(Text("AssocTy")), visibility: RawVisibilityId("pub(self)"), bounds: [Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Tr"))] }, generic_args: [Some(GenericArgs { args: [Type(Tuple([]))], has_self_type: false, bindings: [] })] })], generic_params: GenericParamsId(4294967295), type_ref: None, is_extern: false, ast_id: FileAstId::(8) } > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_const"))] }, input: None }]) }] > Const { name: Some(Name(Text("CONST"))), visibility: RawVisibilityId("pub(self)"), type_ref: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("u8"))] }, generic_args: [None] }), ast_id: FileAstId::(9) } > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_method"))] }, input: None }]) }] -- cgit v1.2.3