diff --git a/crates/ra_assists/src/utils/insert_use.rs b/crates/ra_assists/src/utils/insert_use.rs index 8c4f33e59a..c05027eff1 100644 --- a/crates/ra_assists/src/utils/insert_use.rs +++ b/crates/ra_assists/src/utils/insert_use.rs @@ -215,7 +215,7 @@ fn walk_use_tree_for_best_action( let prev_len = current_path_segments.len(); let tree_list = current_use_tree.use_tree_list(); - let alias = current_use_tree.alias(); + let alias = current_use_tree.rename(); let path = match current_use_tree.path() { Some(path) => path, diff --git a/crates/ra_hir_def/src/item_tree/lower.rs b/crates/ra_hir_def/src/item_tree/lower.rs index 4fc21a642c..6c58c63781 100644 --- a/crates/ra_hir_def/src/item_tree/lower.rs +++ b/crates/ra_hir_def/src/item_tree/lower.rs @@ -501,7 +501,7 @@ impl Ctx { extern_crate: &ast::ExternCrateItem, ) -> Option> { let path = ModPath::from_name_ref(&extern_crate.name_ref()?); - let alias = extern_crate.alias().map(|a| { + let alias = extern_crate.rename().map(|a| { a.name().map(|it| it.as_name()).map_or(ImportAlias::Underscore, ImportAlias::Alias) }); let visibility = self.lower_visibility(extern_crate); diff --git a/crates/ra_hir_def/src/path/lower/lower_use.rs b/crates/ra_hir_def/src/path/lower/lower_use.rs index 7cc655487e..794be45e89 100644 --- a/crates/ra_hir_def/src/path/lower/lower_use.rs +++ b/crates/ra_hir_def/src/path/lower/lower_use.rs @@ -31,7 +31,7 @@ pub(crate) fn lower_use_tree( lower_use_tree(prefix.clone(), child_tree, hygiene, cb); } } else { - let alias = tree.alias().map(|a| { + let alias = tree.rename().map(|a| { a.name().map(|it| it.as_name()).map_or(ImportAlias::Underscore, ImportAlias::Alias) }); let is_glob = tree.star_token().is_some(); diff --git a/crates/ra_ide_db/src/defs.rs b/crates/ra_ide_db/src/defs.rs index f391a8e432..1464c5f2a2 100644 --- a/crates/ra_ide_db/src/defs.rs +++ b/crates/ra_ide_db/src/defs.rs @@ -119,7 +119,7 @@ pub fn classify_name(sema: &Semantics, name: &ast::Name) -> Option match_ast! { match parent { - ast::Alias(it) => { + ast::Rename(it) => { let use_tree = it.syntax().parent().and_then(ast::UseTree::cast)?; let path = use_tree.path()?; let path_segment = path.segment()?; diff --git a/crates/ra_parser/src/grammar.rs b/crates/ra_parser/src/grammar.rs index 3350e23b9f..7dfac2813e 100644 --- a/crates/ra_parser/src/grammar.rs +++ b/crates/ra_parser/src/grammar.rs @@ -224,7 +224,7 @@ fn opt_alias(p: &mut Parser) { if !p.eat(T![_]) { name(p); } - m.complete(p, ALIAS); + m.complete(p, RENAME); } } diff --git a/crates/ra_parser/src/syntax_kind/generated.rs b/crates/ra_parser/src/syntax_kind/generated.rs index 56dadc6af0..f14b60b654 100644 --- a/crates/ra_parser/src/syntax_kind/generated.rs +++ b/crates/ra_parser/src/syntax_kind/generated.rs @@ -221,7 +221,7 @@ pub enum SyntaxKind { PATH, PATH_SEGMENT, LITERAL, - ALIAS, + RENAME, VISIBILITY, WHERE_CLAUSE, WHERE_PRED, diff --git a/crates/ra_syntax/src/ast/edit.rs b/crates/ra_syntax/src/ast/edit.rs index 01a310f66d..99f4726bcc 100644 --- a/crates/ra_syntax/src/ast/edit.rs +++ b/crates/ra_syntax/src/ast/edit.rs @@ -318,7 +318,7 @@ impl ast::UseTree { None => return self.clone(), }; let use_tree = - make::use_tree(suffix, self.use_tree_list(), self.alias(), self.star_token().is_some()); + make::use_tree(suffix, self.use_tree_list(), self.rename(), self.star_token().is_some()); let nested = make::use_tree_list(iter::once(use_tree)); return make::use_tree(prefix.clone(), Some(nested), None, false); diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs index fbf3b457a9..01e8111b04 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs @@ -75,7 +75,7 @@ impl ExternCrateItem { pub fn crate_token(&self) -> Option { support::token(&self.syntax, T![crate]) } pub fn name_ref(&self) -> Option { support::child(&self.syntax) } pub fn self_token(&self) -> Option { support::token(&self.syntax, T![self]) } - pub fn alias(&self) -> Option { support::child(&self.syntax) } + pub fn rename(&self) -> Option { support::child(&self.syntax) } pub fn semicolon_token(&self) -> Option { support::token(&self.syntax, T![;]) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] @@ -1178,7 +1178,7 @@ impl UseTree { pub fn coloncolon_token(&self) -> Option { support::token(&self.syntax, T![::]) } pub fn star_token(&self) -> Option { support::token(&self.syntax, T![*]) } pub fn use_tree_list(&self) -> Option { support::child(&self.syntax) } - pub fn alias(&self) -> Option { support::child(&self.syntax) } + pub fn rename(&self) -> Option { support::child(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct UseTreeList { @@ -1190,11 +1190,11 @@ impl UseTreeList { pub fn r_curly_token(&self) -> Option { support::token(&self.syntax, T!['}']) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct Alias { +pub struct Rename { pub(crate) syntax: SyntaxNode, } -impl ast::NameOwner for Alias {} -impl Alias { +impl ast::NameOwner for Rename {} +impl Rename { pub fn as_token(&self) -> Option { support::token(&self.syntax, T![as]) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] @@ -2683,8 +2683,8 @@ impl AstNode for UseTreeList { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for Alias { - fn can_cast(kind: SyntaxKind) -> bool { kind == ALIAS } +impl AstNode for Rename { + fn can_cast(kind: SyntaxKind) -> bool { kind == RENAME } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -4040,7 +4040,7 @@ impl std::fmt::Display for UseTreeList { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for Alias { +impl std::fmt::Display for Rename { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) } diff --git a/crates/ra_syntax/src/ast/make.rs b/crates/ra_syntax/src/ast/make.rs index 192c610f1c..2b05ed2d4a 100644 --- a/crates/ra_syntax/src/ast/make.rs +++ b/crates/ra_syntax/src/ast/make.rs @@ -37,7 +37,7 @@ fn path_from_text(text: &str) -> ast::Path { pub fn use_tree( path: ast::Path, use_tree_list: Option, - alias: Option, + alias: Option, add_star: bool, ) -> ast::UseTree { let mut buf = "use ".to_string(); diff --git a/xtask/src/ast_src.rs b/xtask/src/ast_src.rs index d2a408e775..bcd92c3bcb 100644 --- a/xtask/src/ast_src.rs +++ b/xtask/src/ast_src.rs @@ -194,7 +194,7 @@ pub(crate) const KINDS_SRC: KindsSrc = KindsSrc { "PATH", "PATH_SEGMENT", "LITERAL", - "ALIAS", + "RENAME", "VISIBILITY", "WHERE_CLAUSE", "WHERE_PRED", diff --git a/xtask/src/codegen/rust.ungram b/xtask/src/codegen/rust.ungram index 470ac8c8ff..76c070402f 100644 --- a/xtask/src/codegen/rust.ungram +++ b/xtask/src/codegen/rust.ungram @@ -396,16 +396,16 @@ UseItem = Attr* Visibility? 'use' UseTree ';' UseTree = - Path ('::' ('*' | UseTreeList)) Alias? + Path ('::' ('*' | UseTreeList)) Rename? UseTreeList = '{' UseTree* '}' -Alias = +Rename = 'as' Name ExternCrateItem = - Attr* Visibility? 'extern' 'crate' (NameRef | 'self') Alias? ';' + Attr* Visibility? 'extern' 'crate' (NameRef | 'self') Rename? ';' Path = (qualifier:Path '::')? segment:PathSegment