From 2161a1689d53be4c4c5ab9353735975e9949fb02 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 1 Sep 2018 12:30:53 +0300 Subject: [PATCH] Type aliases to scope --- crates/libeditor/src/scope/mod_scope.rs | 4 +++- crates/libsyntax2/src/ast/generated.rs | 3 +++ crates/libsyntax2/src/grammar.ron | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/libeditor/src/scope/mod_scope.rs b/crates/libeditor/src/scope/mod_scope.rs index 25faee3b8f..052f70569c 100644 --- a/crates/libeditor/src/scope/mod_scope.rs +++ b/crates/libeditor/src/scope/mod_scope.rs @@ -26,6 +26,7 @@ impl ModuleScope { ast::ModuleItem::ConstDef(item) => Entry::new(item), ast::ModuleItem::StaticDef(item) => Entry::new(item), ast::ModuleItem::TraitDef(item) => Entry::new(item), + ast::ModuleItem::TypeDef(item) => Entry::new(item), ast::ModuleItem::Module(item) => Entry::new(item), ast::ModuleItem::UseItem(item) => { if let Some(tree) = item.use_tree() { @@ -104,6 +105,7 @@ mod tests { y::z, t, }; - ", &["Foo", "Bar", "baz", "quux", "z", "t"]) + type T = (); + ", &["Foo", "Bar", "baz", "quux", "z", "t", "T"]) } } diff --git a/crates/libsyntax2/src/ast/generated.rs b/crates/libsyntax2/src/ast/generated.rs index 50dc41b273..f21e49437d 100644 --- a/crates/libsyntax2/src/ast/generated.rs +++ b/crates/libsyntax2/src/ast/generated.rs @@ -947,6 +947,7 @@ pub enum ModuleItem<'a> { EnumDef(EnumDef<'a>), FnDef(FnDef<'a>), TraitDef(TraitDef<'a>), + TypeDef(TypeDef<'a>), ImplItem(ImplItem<'a>), UseItem(UseItem<'a>), ExternCrateItem(ExternCrateItem<'a>), @@ -962,6 +963,7 @@ impl<'a> AstNode<'a> for ModuleItem<'a> { ENUM_DEF => Some(ModuleItem::EnumDef(EnumDef { syntax })), FN_DEF => Some(ModuleItem::FnDef(FnDef { syntax })), TRAIT_DEF => Some(ModuleItem::TraitDef(TraitDef { syntax })), + TYPE_DEF => Some(ModuleItem::TypeDef(TypeDef { syntax })), IMPL_ITEM => Some(ModuleItem::ImplItem(ImplItem { syntax })), USE_ITEM => Some(ModuleItem::UseItem(UseItem { syntax })), EXTERN_CRATE_ITEM => Some(ModuleItem::ExternCrateItem(ExternCrateItem { syntax })), @@ -977,6 +979,7 @@ impl<'a> AstNode<'a> for ModuleItem<'a> { ModuleItem::EnumDef(inner) => inner.syntax(), ModuleItem::FnDef(inner) => inner.syntax(), ModuleItem::TraitDef(inner) => inner.syntax(), + ModuleItem::TypeDef(inner) => inner.syntax(), ModuleItem::ImplItem(inner) => inner.syntax(), ModuleItem::UseItem(inner) => inner.syntax(), ModuleItem::ExternCrateItem(inner) => inner.syntax(), diff --git a/crates/libsyntax2/src/grammar.ron b/crates/libsyntax2/src/grammar.ron index 5225212298..fbe8397d88 100644 --- a/crates/libsyntax2/src/grammar.ron +++ b/crates/libsyntax2/src/grammar.ron @@ -332,7 +332,7 @@ Grammar( ], ), "ModuleItem": ( - enum: ["StructDef", "EnumDef", "FnDef", "TraitDef", "ImplItem", + enum: ["StructDef", "EnumDef", "FnDef", "TraitDef", "TypeDef", "ImplItem", "UseItem", "ExternCrateItem", "ConstDef", "StaticDef", "Module" ] ),