diff --git a/crates/ra_assists/src/ast_transform.rs b/crates/ra_assists/src/ast_transform.rs index 01adb834cc..5ea4f9f5ba 100644 --- a/crates/ra_assists/src/ast_transform.rs +++ b/crates/ra_assists/src/ast_transform.rs @@ -41,7 +41,7 @@ impl<'a> SubstituteTypeParams<'a> { source_scope: &'a SemanticsScope<'a>, // FIXME: there's implicit invariant that `trait_` and `source_scope` match... trait_: hir::Trait, - impl_def: ast::ImplDef, + impl_def: ast::Impl, ) -> SubstituteTypeParams<'a> { let substs = get_syntactic_substs(impl_def).unwrap_or_default(); let generic_def: hir::GenericDef = trait_.into(); @@ -80,7 +80,7 @@ impl<'a> SubstituteTypeParams<'a> { // FIXME: It would probably be nicer if we could get this via HIR (i.e. get the // trait ref, and then go from the types in the substs back to the syntax) - fn get_syntactic_substs(impl_def: ast::ImplDef) -> Option> { + fn get_syntactic_substs(impl_def: ast::Impl) -> Option> { let target_trait = impl_def.target_trait()?; let path_type = match target_trait { ast::TypeRef::PathType(path) => path, diff --git a/crates/ra_assists/src/handlers/add_missing_impl_members.rs b/crates/ra_assists/src/handlers/add_missing_impl_members.rs index 1ab176c261..95a750aeec 100644 --- a/crates/ra_assists/src/handlers/add_missing_impl_members.rs +++ b/crates/ra_assists/src/handlers/add_missing_impl_members.rs @@ -111,7 +111,7 @@ fn add_missing_impl_members_inner( label: &'static str, ) -> Option<()> { let _p = ra_prof::profile("add_missing_impl_members_inner"); - let impl_def = ctx.find_node_at_offset::()?; + let impl_def = ctx.find_node_at_offset::()?; let impl_item_list = impl_def.assoc_item_list()?; let trait_ = resolve_target_trait(&ctx.sema, &impl_def)?; diff --git a/crates/ra_assists/src/handlers/generate_new.rs b/crates/ra_assists/src/handlers/generate_new.rs index 22b47d2547..3c67749eec 100644 --- a/crates/ra_assists/src/handlers/generate_new.rs +++ b/crates/ra_assists/src/handlers/generate_new.rs @@ -122,7 +122,7 @@ fn generate_impl_text(strukt: &ast::Struct, code: &str) -> String { // // FIXME: change the new fn checking to a more semantic approach when that's more // viable (e.g. we process proc macros, etc) -fn find_struct_impl(ctx: &AssistContext, strukt: &ast::Struct) -> Option> { +fn find_struct_impl(ctx: &AssistContext, strukt: &ast::Struct) -> Option> { let db = ctx.db(); let module = strukt.syntax().ancestors().find(|node| { ast::Module::can_cast(node.kind()) || ast::SourceFile::can_cast(node.kind()) @@ -130,7 +130,7 @@ fn find_struct_impl(ctx: &AssistContext, strukt: &ast::Struct) -> Option; impl S {}` @@ -158,7 +158,7 @@ fn find_struct_impl(ctx: &AssistContext, strukt: &ast::Struct) -> Option bool { +fn has_new_fn(imp: &ast::Impl) -> bool { if let Some(il) = imp.assoc_item_list() { for item in il.assoc_items() { if let ast::AssocItem::Fn(f) = item { diff --git a/crates/ra_assists/src/handlers/introduce_named_lifetime.rs b/crates/ra_assists/src/handlers/introduce_named_lifetime.rs index 4ad173ef00..92a1a5925c 100644 --- a/crates/ra_assists/src/handlers/introduce_named_lifetime.rs +++ b/crates/ra_assists/src/handlers/introduce_named_lifetime.rs @@ -40,7 +40,7 @@ pub(crate) fn introduce_named_lifetime(acc: &mut Assists, ctx: &AssistContext) - .filter(|lifetime| lifetime.text() == "'_")?; if let Some(fn_def) = lifetime_token.ancestors().find_map(ast::Fn::cast) { generate_fn_def_assist(acc, &fn_def, lifetime_token.text_range()) - } else if let Some(impl_def) = lifetime_token.ancestors().find_map(ast::ImplDef::cast) { + } else if let Some(impl_def) = lifetime_token.ancestors().find_map(ast::Impl::cast) { generate_impl_def_assist(acc, &impl_def, lifetime_token.text_range()) } else { None @@ -93,7 +93,7 @@ fn generate_fn_def_assist( /// Generate the assist for the impl def case fn generate_impl_def_assist( acc: &mut Assists, - impl_def: &ast::ImplDef, + impl_def: &ast::Impl, lifetime_loc: TextRange, ) -> Option<()> { let new_lifetime_param = generate_unique_lifetime_param_name(&impl_def.generic_param_list())?; diff --git a/crates/ra_assists/src/handlers/move_bounds.rs b/crates/ra_assists/src/handlers/move_bounds.rs index fd1d87423a..6d394443eb 100644 --- a/crates/ra_assists/src/handlers/move_bounds.rs +++ b/crates/ra_assists/src/handlers/move_bounds.rs @@ -39,7 +39,7 @@ pub(crate) fn move_bounds_to_where_clause(acc: &mut Assists, ctx: &AssistContext match parent { ast::Fn(it) => it.body()?.syntax().clone().into(), ast::Trait(it) => it.assoc_item_list()?.syntax().clone().into(), - ast::ImplDef(it) => it.assoc_item_list()?.syntax().clone().into(), + ast::Impl(it) => it.assoc_item_list()?.syntax().clone().into(), ast::Enum(it) => it.variant_list()?.syntax().clone().into(), ast::Struct(it) => { it.syntax().children_with_tokens() diff --git a/crates/ra_assists/src/utils.rs b/crates/ra_assists/src/utils.rs index 337e3474f8..bb16ebd4e8 100644 --- a/crates/ra_assists/src/utils.rs +++ b/crates/ra_assists/src/utils.rs @@ -56,7 +56,7 @@ pub(crate) fn render_snippet(_cap: SnippetCap, node: &SyntaxNode, cursor: Cursor pub fn get_missing_assoc_items( sema: &Semantics, - impl_def: &ast::ImplDef, + impl_def: &ast::Impl, ) -> Vec { // Names must be unique between constants and functions. However, type aliases // may share the same name as a function or constant. @@ -109,7 +109,7 @@ pub fn get_missing_assoc_items( pub(crate) fn resolve_target_trait( sema: &Semantics, - impl_def: &ast::ImplDef, + impl_def: &ast::Impl, ) -> Option { let ast_path = impl_def .target_trait() diff --git a/crates/ra_hir/src/has_source.rs b/crates/ra_hir/src/has_source.rs index 057f6e32fb..1c691d9619 100644 --- a/crates/ra_hir/src/has_source.rs +++ b/crates/ra_hir/src/has_source.rs @@ -120,8 +120,8 @@ impl HasSource for MacroDef { } } impl HasSource for ImplDef { - type Ast = ast::ImplDef; - fn source(self, db: &dyn HirDatabase) -> InFile { + type Ast = ast::Impl; + fn source(self, db: &dyn HirDatabase) -> InFile { self.id.lookup(db.upcast()).source(db.upcast()) } } diff --git a/crates/ra_hir/src/semantics.rs b/crates/ra_hir/src/semantics.rs index 5f5104dab4..6f3b3dc9ad 100644 --- a/crates/ra_hir/src/semantics.rs +++ b/crates/ra_hir/src/semantics.rs @@ -584,7 +584,7 @@ to_def_impls![ (crate::Enum, ast::Enum, enum_to_def), (crate::Union, ast::Union, union_to_def), (crate::Trait, ast::Trait, trait_to_def), - (crate::ImplDef, ast::ImplDef, impl_to_def), + (crate::ImplDef, ast::Impl, impl_to_def), (crate::TypeAlias, ast::TypeAlias, type_alias_to_def), (crate::Const, ast::Const, const_to_def), (crate::Static, ast::Static, static_to_def), diff --git a/crates/ra_hir/src/semantics/source_to_def.rs b/crates/ra_hir/src/semantics/source_to_def.rs index ae41d3ddf7..d1994e2e78 100644 --- a/crates/ra_hir/src/semantics/source_to_def.rs +++ b/crates/ra_hir/src/semantics/source_to_def.rs @@ -68,7 +68,7 @@ impl SourceToDefCtx<'_, '_> { pub(super) fn trait_to_def(&mut self, src: InFile) -> Option { self.to_def(src, keys::TRAIT) } - pub(super) fn impl_to_def(&mut self, src: InFile) -> Option { + pub(super) fn impl_to_def(&mut self, src: InFile) -> Option { self.to_def(src, keys::IMPL) } pub(super) fn fn_to_def(&mut self, src: InFile) -> Option { @@ -158,7 +158,7 @@ impl SourceToDefCtx<'_, '_> { let def = self.trait_to_def(container.with_value(it))?; def.into() }, - ast::ImplDef(it) => { + ast::Impl(it) => { let def = self.impl_to_def(container.with_value(it))?; def.into() }, @@ -209,7 +209,7 @@ impl SourceToDefCtx<'_, '_> { ast::Enum(it) => self.enum_to_def(container.with_value(it))?.into(), ast::Trait(it) => self.trait_to_def(container.with_value(it))?.into(), ast::TypeAlias(it) => self.type_alias_to_def(container.with_value(it))?.into(), - ast::ImplDef(it) => self.impl_to_def(container.with_value(it))?.into(), + ast::Impl(it) => self.impl_to_def(container.with_value(it))?.into(), _ => continue, } }; diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index 0d02421737..78f6da5b8b 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs @@ -669,7 +669,7 @@ impl ExprCollector<'_> { (TraitLoc { container, id }.intern(self.db).into(), def.name()) } ast::Item::ExternBlock(_) => return None, // FIXME: collect from extern blocks - ast::Item::ImplDef(_) + ast::Item::Impl(_) | ast::Item::Use(_) | ast::Item::ExternCrate(_) | ast::Item::Module(_) diff --git a/crates/ra_hir_def/src/item_tree.rs b/crates/ra_hir_def/src/item_tree.rs index 11002b1ad5..63b56405c5 100644 --- a/crates/ra_hir_def/src/item_tree.rs +++ b/crates/ra_hir_def/src/item_tree.rs @@ -420,7 +420,7 @@ mod_items! { Const in consts -> ast::Const, Static in statics -> ast::Static, Trait in traits -> ast::Trait, - Impl in impls -> ast::ImplDef, + Impl in impls -> ast::Impl, TypeAlias in type_aliases -> ast::TypeAlias, Mod in mods -> ast::Module, MacroCall in macro_calls -> ast::MacroCall, @@ -581,7 +581,7 @@ pub struct Impl { pub target_type: TypeRef, pub is_negative: bool, pub items: Box<[AssocItem]>, - pub ast_id: FileAstId, + pub ast_id: FileAstId, } #[derive(Debug, Clone, PartialEq, Eq)] diff --git a/crates/ra_hir_def/src/item_tree/lower.rs b/crates/ra_hir_def/src/item_tree/lower.rs index aaf3cfd3ad..b0cf94956e 100644 --- a/crates/ra_hir_def/src/item_tree/lower.rs +++ b/crates/ra_hir_def/src/item_tree/lower.rs @@ -95,7 +95,7 @@ impl Ctx { // These are handled in their respective `lower_X` method (since we can't just blindly // walk them). - ast::Item::Trait(_) | ast::Item::ImplDef(_) | ast::Item::ExternBlock(_) => {} + ast::Item::Trait(_) | ast::Item::Impl(_) | ast::Item::ExternBlock(_) => {} // These don't have inner items. ast::Item::Module(_) | ast::Item::ExternCrate(_) | ast::Item::Use(_) => {} @@ -112,7 +112,7 @@ impl Ctx { ast::Item::Const(ast) => Some(self.lower_const(ast).into()), ast::Item::Module(ast) => self.lower_module(ast).map(Into::into), ast::Item::Trait(ast) => self.lower_trait(ast).map(Into::into), - ast::Item::ImplDef(ast) => self.lower_impl(ast).map(Into::into), + ast::Item::Impl(ast) => self.lower_impl(ast).map(Into::into), ast::Item::Use(ast) => Some(ModItems( self.lower_use(ast).into_iter().map(Into::into).collect::>(), )), @@ -445,7 +445,7 @@ impl Ctx { Some(id(self.data().traits.alloc(res))) } - fn lower_impl(&mut self, impl_def: &ast::ImplDef) -> Option> { + fn lower_impl(&mut self, impl_def: &ast::Impl) -> Option> { let generic_params = self.lower_generic_params_and_inner_items(GenericsOwner::Impl, impl_def); let target_trait = impl_def.target_trait().map(|tr| self.lower_type_ref(&tr)); diff --git a/crates/ra_hir_def/src/item_tree/tests.rs b/crates/ra_hir_def/src/item_tree/tests.rs index 40a9bd53df..a81497fa8a 100644 --- a/crates/ra_hir_def/src/item_tree/tests.rs +++ b/crates/ra_hir_def/src/item_tree/tests.rs @@ -274,7 +274,7 @@ fn simple_inner_items() { inner attrs: Attrs { entries: None } top-level items: - Impl { generic_params: GenericParamsId(0), target_trait: Some(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("D"))] }, generic_args: [None] })), target_type: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Response"))] }, generic_args: [Some(GenericArgs { args: [Type(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("T"))] }, generic_args: [None] }))], has_self_type: false, bindings: [] })] }), is_negative: false, items: [Function(Idx::(1))], ast_id: FileAstId::(0) } + Impl { generic_params: GenericParamsId(0), target_trait: Some(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("D"))] }, generic_args: [None] })), target_type: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Response"))] }, generic_args: [Some(GenericArgs { args: [Type(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("T"))] }, generic_args: [None] }))], has_self_type: false, bindings: [] })] }), is_negative: false, items: [Function(Idx::(1))], ast_id: FileAstId::(0) } > Function { name: Name(Text("foo")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::(1) } inner items: @@ -353,7 +353,7 @@ fn impl_attrs() { top-level items: #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("impl_attr"))] }, input: None }]) }] - Impl { generic_params: GenericParamsId(4294967295), target_trait: None, target_type: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Ty"))] }, generic_args: [None] }), is_negative: false, items: [Function(Idx::(0)), Function(Idx::(1))], ast_id: FileAstId::(0) } + Impl { generic_params: GenericParamsId(4294967295), target_trait: None, target_type: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Ty"))] }, generic_args: [None] }), is_negative: false, items: [Function(Idx::(0)), Function(Idx::(1))], ast_id: FileAstId::(0) } > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_a"))] }, input: None }]) }] > Function { name: Name(Text("a")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::(1) } > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_b"))] }, input: None }]) }] @@ -432,7 +432,7 @@ fn assoc_item_macros() { inner attrs: Attrs { entries: None } top-level items: - Impl { generic_params: GenericParamsId(4294967295), target_trait: None, target_type: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("S"))] }, generic_args: [None] }), is_negative: false, items: [MacroCall(Idx::(0))], ast_id: FileAstId::(0) } + Impl { generic_params: GenericParamsId(4294967295), target_trait: None, target_type: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("S"))] }, generic_args: [None] }), is_negative: false, items: [MacroCall(Idx::(0))], ast_id: FileAstId::(0) } > MacroCall { name: None, path: ModPath { kind: Plain, segments: [Name(Text("items"))] }, is_export: false, is_local_inner: false, is_builtin: false, ast_id: FileAstId::(1) } "#]], ); diff --git a/crates/ra_hir_def/src/keys.rs b/crates/ra_hir_def/src/keys.rs index 0bed088751..441bdbead8 100644 --- a/crates/ra_hir_def/src/keys.rs +++ b/crates/ra_hir_def/src/keys.rs @@ -18,7 +18,7 @@ pub const FUNCTION: Key = Key::new(); pub const CONST: Key = Key::new(); pub const STATIC: Key = Key::new(); pub const TYPE_ALIAS: Key = Key::new(); -pub const IMPL: Key = Key::new(); +pub const IMPL: Key = Key::new(); pub const TRAIT: Key = Key::new(); pub const STRUCT: Key = Key::new(); pub const UNION: Key = Key::new(); diff --git a/crates/ra_ide/src/completion/complete_trait_impl.rs b/crates/ra_ide/src/completion/complete_trait_impl.rs index 87221d964e..d9a0ef167d 100644 --- a/crates/ra_ide/src/completion/complete_trait_impl.rs +++ b/crates/ra_ide/src/completion/complete_trait_impl.rs @@ -3,7 +3,7 @@ //! This module adds the completion items related to implementing associated //! items within a `impl Trait for Struct` block. The current context node //! must be within either a `FN`, `TYPE_ALIAS`, or `CONST` node -//! and an direct child of an `IMPL_DEF`. +//! and an direct child of an `IMPL`. //! //! # Examples //! @@ -34,7 +34,7 @@ use hir::{self, Docs, HasSource}; use ra_assists::utils::get_missing_assoc_items; use ra_syntax::{ - ast::{self, edit, ImplDef}, + ast::{self, edit, Impl}, AstNode, SyntaxKind, SyntaxNode, TextRange, T, }; use ra_text_edit::TextEdit; @@ -104,7 +104,7 @@ pub(crate) fn complete_trait_impl(acc: &mut Completions, ctx: &CompletionContext } } -fn completion_match(ctx: &CompletionContext) -> Option<(SyntaxNode, ImplDef)> { +fn completion_match(ctx: &CompletionContext) -> Option<(SyntaxNode, Impl)> { let (trigger, impl_def_offset) = ctx.token.ancestors().find_map(|p| match p.kind() { SyntaxKind::FN | SyntaxKind::TYPE_ALIAS | SyntaxKind::CONST | SyntaxKind::BLOCK_EXPR => { Some((p, 2)) @@ -114,7 +114,7 @@ fn completion_match(ctx: &CompletionContext) -> Option<(SyntaxNode, ImplDef)> { })?; let impl_def = (0..impl_def_offset - 1) .try_fold(trigger.parent()?, |t, _| t.parent()) - .and_then(ast::ImplDef::cast)?; + .and_then(ast::Impl::cast)?; Some((trigger, impl_def)) } diff --git a/crates/ra_ide/src/completion/completion_context.rs b/crates/ra_ide/src/completion/completion_context.rs index c8704eb3e8..2113abbb22 100644 --- a/crates/ra_ide/src/completion/completion_context.rs +++ b/crates/ra_ide/src/completion/completion_context.rs @@ -40,7 +40,7 @@ pub(crate) struct CompletionContext<'a> { pub(super) record_lit_syntax: Option, pub(super) record_pat_syntax: Option, pub(super) record_field_syntax: Option, - pub(super) impl_def: Option, + pub(super) impl_def: Option, /// FIXME: `ActiveParameter` is string-based, which is very very wrong pub(super) active_parameter: Option, pub(super) is_param: bool, @@ -325,7 +325,7 @@ impl<'a> CompletionContext<'a> { .sema .ancestors_with_macros(self.token.parent()) .take_while(|it| it.kind() != SOURCE_FILE && it.kind() != MODULE) - .find_map(ast::ImplDef::cast); + .find_map(ast::Impl::cast); let top_node = name_ref .syntax() diff --git a/crates/ra_ide/src/completion/patterns.rs b/crates/ra_ide/src/completion/patterns.rs index 6c11f5830b..a68861e1c9 100644 --- a/crates/ra_ide/src/completion/patterns.rs +++ b/crates/ra_ide/src/completion/patterns.rs @@ -27,7 +27,7 @@ pub(crate) fn has_impl_parent(element: SyntaxElement) -> bool { not_same_range_ancestor(element) .filter(|it| it.kind() == ASSOC_ITEM_LIST) .and_then(|it| it.parent()) - .filter(|it| it.kind() == IMPL_DEF) + .filter(|it| it.kind() == IMPL) .is_some() } #[test] @@ -121,7 +121,7 @@ fn test_has_trait_as_prev_sibling() { } pub(crate) fn has_impl_as_prev_sibling(element: SyntaxElement) -> bool { - previous_sibling_or_ancestor_sibling(element).filter(|it| it.kind() == IMPL_DEF).is_some() + previous_sibling_or_ancestor_sibling(element).filter(|it| it.kind() == IMPL).is_some() } #[test] fn test_has_impl_as_prev_sibling() { diff --git a/crates/ra_ide/src/file_structure.rs b/crates/ra_ide/src/file_structure.rs index 3fc9724603..7d378f2d0a 100644 --- a/crates/ra_ide/src/file_structure.rs +++ b/crates/ra_ide/src/file_structure.rs @@ -139,7 +139,7 @@ fn structure_node(node: &SyntaxNode) -> Option { ast::RecordField(it) => decl_with_ascription(it), ast::Const(it) => decl_with_ascription(it), ast::Static(it) => decl_with_ascription(it), - ast::ImplDef(it) => { + ast::Impl(it) => { let target_type = it.target_type()?; let target_trait = it.target_trait(); let label = match target_trait { @@ -372,7 +372,7 @@ fn very_obsolete() {} label: "impl E", navigation_range: 239..240, node_range: 234..243, - kind: IMPL_DEF, + kind: IMPL, detail: None, deprecated: false, }, @@ -381,7 +381,7 @@ fn very_obsolete() {} label: "impl fmt::Debug for E", navigation_range: 265..266, node_range: 245..269, - kind: IMPL_DEF, + kind: IMPL, detail: None, deprecated: false, }, diff --git a/crates/ra_ide/src/references/rename.rs b/crates/ra_ide/src/references/rename.rs index d8ffb8c84c..d330109f1c 100644 --- a/crates/ra_ide/src/references/rename.rs +++ b/crates/ra_ide/src/references/rename.rs @@ -192,15 +192,14 @@ fn text_edit_from_self_param( self_param: &ast::SelfParam, new_name: &str, ) -> Option { - fn target_type_name(impl_def: &ast::ImplDef) -> Option { + fn target_type_name(impl_def: &ast::Impl) -> Option { if let Some(ast::TypeRef::PathType(p)) = impl_def.target_type() { return Some(p.path()?.segment()?.name_ref()?.text().to_string()); } None } - let impl_def = - find_node_at_offset::(syn, self_param.syntax().text_range().start())?; + let impl_def = find_node_at_offset::(syn, self_param.syntax().text_range().start())?; let type_name = target_type_name(&impl_def)?; let mut replacement_text = String::from(new_name); diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index a66453c04b..e3a96f9d5c 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs @@ -647,7 +647,7 @@ fn highlight_element( fn is_child_of_impl(element: &SyntaxElement) -> bool { match element.parent() { - Some(e) => e.kind() == IMPL_DEF, + Some(e) => e.kind() == IMPL, _ => false, } } diff --git a/crates/ra_parser/src/grammar.rs b/crates/ra_parser/src/grammar.rs index cd4b2381d6..c2e1d701e2 100644 --- a/crates/ra_parser/src/grammar.rs +++ b/crates/ra_parser/src/grammar.rs @@ -150,7 +150,7 @@ pub(crate) fn reparser( EXTERN_ITEM_LIST => items::extern_item_list, TOKEN_TREE if first_child? == T!['{'] => items::token_tree, ASSOC_ITEM_LIST => match parent? { - IMPL_DEF => items::impl_item_list, + IMPL => items::impl_item_list, TRAIT => items::trait_item_list, _ => return None, }, diff --git a/crates/ra_parser/src/grammar/items.rs b/crates/ra_parser/src/grammar/items.rs index 5603d61a99..cca524ceaa 100644 --- a/crates/ra_parser/src/grammar/items.rs +++ b/crates/ra_parser/src/grammar/items.rs @@ -221,7 +221,7 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Resul // unsafe default impl Foo {} T![impl] => { traits::impl_def(p); - m.complete(p, IMPL_DEF); + m.complete(p, IMPL); } // test existential_type diff --git a/crates/ra_parser/src/syntax_kind/generated.rs b/crates/ra_parser/src/syntax_kind/generated.rs index 27eed00903..d1b22f08a9 100644 --- a/crates/ra_parser/src/syntax_kind/generated.rs +++ b/crates/ra_parser/src/syntax_kind/generated.rs @@ -134,7 +134,7 @@ pub enum SyntaxKind { STATIC, CONST, TRAIT, - IMPL_DEF, + IMPL, TYPE_ALIAS, MACRO_CALL, TOKEN_TREE, diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs index 3adb6b2d42..ba00742f0c 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs @@ -100,17 +100,18 @@ impl Fn { pub fn semicolon_token(&self) -> Option { support::token(&self.syntax, T![;]) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct ImplDef { +pub struct Impl { pub(crate) syntax: SyntaxNode, } -impl ast::AttrsOwner for ImplDef {} -impl ast::VisibilityOwner for ImplDef {} -impl ast::GenericParamsOwner for ImplDef {} -impl ImplDef { - pub fn const_token(&self) -> Option { support::token(&self.syntax, T![const]) } +impl ast::AttrsOwner for Impl {} +impl ast::VisibilityOwner for Impl {} +impl ast::GenericParamsOwner for Impl {} +impl Impl { pub fn default_token(&self) -> Option { support::token(&self.syntax, T![default]) } pub fn unsafe_token(&self) -> Option { support::token(&self.syntax, T![unsafe]) } pub fn impl_token(&self) -> Option { support::token(&self.syntax, T![impl]) } + pub fn const_token(&self) -> Option { support::token(&self.syntax, T![const]) } + pub fn type_ref(&self) -> Option { support::child(&self.syntax) } pub fn excl_token(&self) -> Option { support::token(&self.syntax, T![!]) } pub fn for_token(&self) -> Option { support::token(&self.syntax, T![for]) } pub fn assoc_item_list(&self) -> Option { support::child(&self.syntax) } @@ -1278,7 +1279,7 @@ pub enum Item { ExternBlock(ExternBlock), ExternCrate(ExternCrate), Fn(Fn), - ImplDef(ImplDef), + Impl(Impl), MacroCall(MacroCall), Module(Module), Static(Static), @@ -1477,8 +1478,8 @@ impl AstNode for Fn { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for ImplDef { - fn can_cast(kind: SyntaxKind) -> bool { kind == IMPL_DEF } +impl AstNode for Impl { + fn can_cast(kind: SyntaxKind) -> bool { kind == IMPL } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2790,8 +2791,8 @@ impl From for Item { impl From for Item { fn from(node: Fn) -> Item { Item::Fn(node) } } -impl From for Item { - fn from(node: ImplDef) -> Item { Item::ImplDef(node) } +impl From for Item { + fn from(node: Impl) -> Item { Item::Impl(node) } } impl From for Item { fn from(node: MacroCall) -> Item { Item::MacroCall(node) } @@ -2820,7 +2821,7 @@ impl From for Item { impl AstNode for Item { fn can_cast(kind: SyntaxKind) -> bool { match kind { - CONST | ENUM | EXTERN_BLOCK | EXTERN_CRATE | FN | IMPL_DEF | MACRO_CALL | MODULE + CONST | ENUM | EXTERN_BLOCK | EXTERN_CRATE | FN | IMPL | MACRO_CALL | MODULE | STATIC | STRUCT | TRAIT | TYPE_ALIAS | UNION | USE => true, _ => false, } @@ -2832,7 +2833,7 @@ impl AstNode for Item { EXTERN_BLOCK => Item::ExternBlock(ExternBlock { syntax }), EXTERN_CRATE => Item::ExternCrate(ExternCrate { syntax }), FN => Item::Fn(Fn { syntax }), - IMPL_DEF => Item::ImplDef(ImplDef { syntax }), + IMPL => Item::Impl(Impl { syntax }), MACRO_CALL => Item::MacroCall(MacroCall { syntax }), MODULE => Item::Module(Module { syntax }), STATIC => Item::Static(Static { syntax }), @@ -2852,7 +2853,7 @@ impl AstNode for Item { Item::ExternBlock(it) => &it.syntax, Item::ExternCrate(it) => &it.syntax, Item::Fn(it) => &it.syntax, - Item::ImplDef(it) => &it.syntax, + Item::Impl(it) => &it.syntax, Item::MacroCall(it) => &it.syntax, Item::Module(it) => &it.syntax, Item::Static(it) => &it.syntax, @@ -3491,7 +3492,7 @@ impl std::fmt::Display for Fn { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for ImplDef { +impl std::fmt::Display for Impl { 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/node_ext.rs b/crates/ra_syntax/src/ast/node_ext.rs index a8d8955de5..313f522261 100644 --- a/crates/ra_syntax/src/ast/node_ext.rs +++ b/crates/ra_syntax/src/ast/node_ext.rs @@ -141,7 +141,7 @@ impl ast::UseTreeList { } } -impl ast::ImplDef { +impl ast::Impl { pub fn target_type(&self) -> Option { match self.target() { (Some(t), None) | (_, Some(t)) => Some(t), @@ -486,5 +486,5 @@ impl ast::DocCommentsOwner for ast::Module {} impl ast::DocCommentsOwner for ast::Static {} impl ast::DocCommentsOwner for ast::Const {} impl ast::DocCommentsOwner for ast::TypeAlias {} -impl ast::DocCommentsOwner for ast::ImplDef {} +impl ast::DocCommentsOwner for ast::Impl {} impl ast::DocCommentsOwner for ast::MacroCall {} diff --git a/crates/ra_syntax/src/validation.rs b/crates/ra_syntax/src/validation.rs index a666b18db2..0325ab0b42 100644 --- a/crates/ra_syntax/src/validation.rs +++ b/crates/ra_syntax/src/validation.rs @@ -204,7 +204,7 @@ fn validate_visibility(vis: ast::Visibility, errors: &mut Vec) { _ => return, } - let impl_def = match parent.parent().and_then(|it| it.parent()).and_then(ast::ImplDef::cast) { + let impl_def = match parent.parent().and_then(|it| it.parent()).and_then(ast::Impl::cast) { Some(it) => it, None => return, }; diff --git a/crates/ra_syntax/test_data/parser/err/0018_incomplete_fn.rast b/crates/ra_syntax/test_data/parser/err/0018_incomplete_fn.rast index 1ce5f188ff..bc95b85128 100644 --- a/crates/ra_syntax/test_data/parser/err/0018_incomplete_fn.rast +++ b/crates/ra_syntax/test_data/parser/err/0018_incomplete_fn.rast @@ -1,5 +1,5 @@ SOURCE_FILE@0..183 - IMPL_DEF@0..182 + IMPL@0..182 IMPL_KW@0..4 "impl" WHITESPACE@4..5 " " PATH_TYPE@5..13 diff --git a/crates/ra_syntax/test_data/parser/err/0022_bad_exprs.rast b/crates/ra_syntax/test_data/parser/err/0022_bad_exprs.rast index a6e304b789..71fb19783a 100644 --- a/crates/ra_syntax/test_data/parser/err/0022_bad_exprs.rast +++ b/crates/ra_syntax/test_data/parser/err/0022_bad_exprs.rast @@ -75,7 +75,7 @@ SOURCE_FILE@0..112 ERROR@54..55 COMMA@54..55 "," WHITESPACE@55..56 " " - IMPL_DEF@56..60 + IMPL@56..60 IMPL_KW@56..60 "impl" EXPR_STMT@60..61 ERROR@60..61 diff --git a/crates/ra_syntax/test_data/parser/err/0026_imp_recovery.rast b/crates/ra_syntax/test_data/parser/err/0026_imp_recovery.rast index 8c8bf7b7e5..7e4b11c272 100644 --- a/crates/ra_syntax/test_data/parser/err/0026_imp_recovery.rast +++ b/crates/ra_syntax/test_data/parser/err/0026_imp_recovery.rast @@ -1,5 +1,5 @@ SOURCE_FILE@0..38 - IMPL_DEF@0..14 + IMPL@0..14 IMPL_KW@0..4 "impl" GENERIC_PARAM_LIST@4..14 L_ANGLE@4..5 "<" @@ -17,7 +17,7 @@ SOURCE_FILE@0..38 IDENT@8..13 "Clone" R_ANGLE@13..14 ">" WHITESPACE@14..15 "\n" - IMPL_DEF@15..37 + IMPL@15..37 IMPL_KW@15..19 "impl" GENERIC_PARAM_LIST@19..22 L_ANGLE@19..20 "<" diff --git a/crates/ra_syntax/test_data/parser/err/0037_visibility_in_traits.rast b/crates/ra_syntax/test_data/parser/err/0037_visibility_in_traits.rast index b1400aa5f7..faf87d6e5c 100644 --- a/crates/ra_syntax/test_data/parser/err/0037_visibility_in_traits.rast +++ b/crates/ra_syntax/test_data/parser/err/0037_visibility_in_traits.rast @@ -1,5 +1,5 @@ SOURCE_FILE@0..118 - IMPL_DEF@0..117 + IMPL@0..117 IMPL_KW@0..4 "impl" WHITESPACE@4..5 " " PATH_TYPE@5..6 diff --git a/crates/ra_syntax/test_data/parser/inline/err/0002_misplaced_label_err.rast b/crates/ra_syntax/test_data/parser/inline/err/0002_misplaced_label_err.rast index 8b0a888fd5..a4271fc87a 100644 --- a/crates/ra_syntax/test_data/parser/inline/err/0002_misplaced_label_err.rast +++ b/crates/ra_syntax/test_data/parser/inline/err/0002_misplaced_label_err.rast @@ -17,7 +17,7 @@ SOURCE_FILE@0..30 LIFETIME@16..21 "\'loop" COLON@21..22 ":" WHITESPACE@22..23 " " - IMPL_DEF@23..27 + IMPL@23..27 IMPL_KW@23..27 "impl" WHITESPACE@27..28 "\n" R_CURLY@28..29 "}" diff --git a/crates/ra_syntax/test_data/parser/inline/err/0004_impl_type.rast b/crates/ra_syntax/test_data/parser/inline/err/0004_impl_type.rast index 2d0253aa07..29d6b39740 100644 --- a/crates/ra_syntax/test_data/parser/inline/err/0004_impl_type.rast +++ b/crates/ra_syntax/test_data/parser/inline/err/0004_impl_type.rast @@ -1,5 +1,5 @@ SOURCE_FILE@0..87 - IMPL_DEF@0..12 + IMPL@0..12 IMPL_KW@0..4 "impl" WHITESPACE@4..5 " " PATH_TYPE@5..9 @@ -12,7 +12,7 @@ SOURCE_FILE@0..87 L_CURLY@10..11 "{" R_CURLY@11..12 "}" WHITESPACE@12..13 "\n" - IMPL_DEF@13..33 + IMPL@13..33 IMPL_KW@13..17 "impl" WHITESPACE@17..18 " " PATH_TYPE@18..24 @@ -33,10 +33,10 @@ SOURCE_FILE@0..87 L_CURLY@31..32 "{" R_CURLY@32..33 "}" WHITESPACE@33..34 "\n" - IMPL_DEF@34..38 + IMPL@34..38 IMPL_KW@34..38 "impl" WHITESPACE@38..39 " " - IMPL_DEF@39..54 + IMPL@39..54 IMPL_KW@39..43 "impl" WHITESPACE@43..44 " " PATH_TYPE@44..51 @@ -49,7 +49,7 @@ SOURCE_FILE@0..87 L_CURLY@52..53 "{" R_CURLY@53..54 "}" WHITESPACE@54..55 "\n" - IMPL_DEF@55..70 + IMPL@55..70 IMPL_KW@55..59 "impl" WHITESPACE@59..60 " " PATH_TYPE@60..66 @@ -60,7 +60,7 @@ SOURCE_FILE@0..87 WHITESPACE@66..67 " " FOR_KW@67..70 "for" WHITESPACE@70..71 " " - IMPL_DEF@71..86 + IMPL@71..86 IMPL_KW@71..75 "impl" WHITESPACE@75..76 " " PATH_TYPE@76..83 diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0001_trait_item_list.rast b/crates/ra_syntax/test_data/parser/inline/ok/0001_trait_item_list.rast index 955e00dde3..c7289e4008 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0001_trait_item_list.rast +++ b/crates/ra_syntax/test_data/parser/inline/ok/0001_trait_item_list.rast @@ -1,5 +1,5 @@ SOURCE_FILE@0..83 - IMPL_DEF@0..82 + IMPL@0..82 IMPL_KW@0..4 "impl" WHITESPACE@4..5 " " PATH_TYPE@5..6 diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0006_self_param.rast b/crates/ra_syntax/test_data/parser/inline/ok/0006_self_param.rast index 87c170707c..ae61cbad82 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0006_self_param.rast +++ b/crates/ra_syntax/test_data/parser/inline/ok/0006_self_param.rast @@ -1,5 +1,5 @@ SOURCE_FILE@0..128 - IMPL_DEF@0..127 + IMPL@0..127 IMPL_KW@0..4 "impl" WHITESPACE@4..5 " " PATH_TYPE@5..6 diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0018_arb_self_types.rast b/crates/ra_syntax/test_data/parser/inline/ok/0018_arb_self_types.rast index e75180900b..20b2b6c193 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0018_arb_self_types.rast +++ b/crates/ra_syntax/test_data/parser/inline/ok/0018_arb_self_types.rast @@ -1,5 +1,5 @@ SOURCE_FILE@0..69 - IMPL_DEF@0..68 + IMPL@0..68 IMPL_KW@0..4 "impl" WHITESPACE@4..5 " " PATH_TYPE@5..6 diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0021_impl_item_list.rast b/crates/ra_syntax/test_data/parser/inline/ok/0021_impl_item_list.rast index 52181ca0c3..ca0702aba5 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0021_impl_item_list.rast +++ b/crates/ra_syntax/test_data/parser/inline/ok/0021_impl_item_list.rast @@ -1,5 +1,5 @@ SOURCE_FILE@0..89 - IMPL_DEF@0..88 + IMPL@0..88 IMPL_KW@0..4 "impl" WHITESPACE@4..5 " " PATH_TYPE@5..6 diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0047_unsafe_default_impl.rast b/crates/ra_syntax/test_data/parser/inline/ok/0047_unsafe_default_impl.rast index 8a6b5a8fcf..d6dfa83b70 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0047_unsafe_default_impl.rast +++ b/crates/ra_syntax/test_data/parser/inline/ok/0047_unsafe_default_impl.rast @@ -1,5 +1,5 @@ SOURCE_FILE@0..27 - IMPL_DEF@0..26 + IMPL@0..26 UNSAFE_KW@0..6 "unsafe" WHITESPACE@6..7 " " DEFAULT_KW@7..14 "default" diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0063_impl_def_neg.rast b/crates/ra_syntax/test_data/parser/inline/ok/0063_impl_def_neg.rast index 31178f86e0..4368930cc9 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0063_impl_def_neg.rast +++ b/crates/ra_syntax/test_data/parser/inline/ok/0063_impl_def_neg.rast @@ -1,5 +1,5 @@ SOURCE_FILE@0..20 - IMPL_DEF@0..19 + IMPL@0..19 IMPL_KW@0..4 "impl" WHITESPACE@4..5 " " BANG@5..6 "!" diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0079_impl_def.rast b/crates/ra_syntax/test_data/parser/inline/ok/0079_impl_def.rast index 26825ef860..209711fc49 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0079_impl_def.rast +++ b/crates/ra_syntax/test_data/parser/inline/ok/0079_impl_def.rast @@ -1,5 +1,5 @@ SOURCE_FILE@0..12 - IMPL_DEF@0..11 + IMPL@0..11 IMPL_KW@0..4 "impl" WHITESPACE@4..5 " " PATH_TYPE@5..8 diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0087_unsafe_impl.rast b/crates/ra_syntax/test_data/parser/inline/ok/0087_unsafe_impl.rast index e3223cee58..43c09affed 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0087_unsafe_impl.rast +++ b/crates/ra_syntax/test_data/parser/inline/ok/0087_unsafe_impl.rast @@ -1,5 +1,5 @@ SOURCE_FILE@0..19 - IMPL_DEF@0..18 + IMPL@0..18 UNSAFE_KW@0..6 "unsafe" WHITESPACE@6..7 " " IMPL_KW@7..11 "impl" diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0097_default_impl.rast b/crates/ra_syntax/test_data/parser/inline/ok/0097_default_impl.rast index 8a839a4a6a..0a1b21d6e6 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0097_default_impl.rast +++ b/crates/ra_syntax/test_data/parser/inline/ok/0097_default_impl.rast @@ -1,5 +1,5 @@ SOURCE_FILE@0..20 - IMPL_DEF@0..19 + IMPL@0..19 DEFAULT_KW@0..7 "default" WHITESPACE@7..8 " " IMPL_KW@8..12 "impl" diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0118_impl_inner_attributes.rast b/crates/ra_syntax/test_data/parser/inline/ok/0118_impl_inner_attributes.rast index f2561abd69..141a7b2035 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0118_impl_inner_attributes.rast +++ b/crates/ra_syntax/test_data/parser/inline/ok/0118_impl_inner_attributes.rast @@ -8,7 +8,7 @@ SOURCE_FILE@0..94 L_CURLY@6..7 "{" R_CURLY@7..8 "}" WHITESPACE@8..9 "\n" - IMPL_DEF@9..93 + IMPL@9..93 IMPL_KW@9..13 "impl" WHITESPACE@13..14 " " PATH_TYPE@14..15 diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0132_default_fn_type.rast b/crates/ra_syntax/test_data/parser/inline/ok/0132_default_fn_type.rast index de02238df7..b8d26a53a5 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0132_default_fn_type.rast +++ b/crates/ra_syntax/test_data/parser/inline/ok/0132_default_fn_type.rast @@ -1,5 +1,5 @@ SOURCE_FILE@0..69 - IMPL_DEF@0..68 + IMPL@0..68 IMPL_KW@0..4 "impl" WHITESPACE@4..5 " " PATH_TYPE@5..6 diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0150_impl_type_params.rast b/crates/ra_syntax/test_data/parser/inline/ok/0150_impl_type_params.rast index 07e555d637..8f197a19d5 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0150_impl_type_params.rast +++ b/crates/ra_syntax/test_data/parser/inline/ok/0150_impl_type_params.rast @@ -1,5 +1,5 @@ SOURCE_FILE@0..29 - IMPL_DEF@0..28 + IMPL@0..28 IMPL_KW@0..4 "impl" GENERIC_PARAM_LIST@4..18 L_ANGLE@4..5 "<" diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_fn.rast b/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_fn.rast index 680f354458..1269621dc2 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_fn.rast +++ b/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_fn.rast @@ -1,5 +1,5 @@ SOURCE_FILE@0..50 - IMPL_DEF@0..49 + IMPL@0..49 IMPL_KW@0..4 "impl" WHITESPACE@4..5 " " PATH_TYPE@5..6 diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_impl.rast b/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_impl.rast index e0c338297e..6bfe925af2 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_impl.rast +++ b/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_impl.rast @@ -1,5 +1,5 @@ SOURCE_FILE@0..27 - IMPL_DEF@0..26 + IMPL@0..26 DEFAULT_KW@0..7 "default" WHITESPACE@7..8 " " UNSAFE_KW@8..14 "unsafe" diff --git a/crates/ra_syntax/test_data/parser/ok/0042_ufcs_call_list.rast b/crates/ra_syntax/test_data/parser/ok/0042_ufcs_call_list.rast index c4ffc0a3d8..ed29b0812c 100644 --- a/crates/ra_syntax/test_data/parser/ok/0042_ufcs_call_list.rast +++ b/crates/ra_syntax/test_data/parser/ok/0042_ufcs_call_list.rast @@ -8,7 +8,7 @@ SOURCE_FILE@0..199 IDENT@69..72 "Foo" SEMICOLON@72..73 ";" WHITESPACE@73..75 "\n\n" - IMPL_DEF@75..141 + IMPL@75..141 IMPL_KW@75..79 "impl" WHITESPACE@79..80 " " PATH_TYPE@80..83 diff --git a/crates/ra_syntax/test_data/parser/ok/0045_block_inner_attrs.rast b/crates/ra_syntax/test_data/parser/ok/0045_block_inner_attrs.rast index 5ebc53618c..139ce90469 100644 --- a/crates/ra_syntax/test_data/parser/ok/0045_block_inner_attrs.rast +++ b/crates/ra_syntax/test_data/parser/ok/0045_block_inner_attrs.rast @@ -89,7 +89,7 @@ SOURCE_FILE@0..686 WHITESPACE@461..463 "\n\n" COMMENT@463..523 "// https://github.com ..." WHITESPACE@523..524 "\n" - IMPL_DEF@524..685 + IMPL@524..685 IMPL_KW@524..528 "impl" WHITESPACE@528..529 " " PATH_TYPE@529..537 diff --git a/crates/ra_syntax/test_data/parser/ok/0051_parameter_attrs.rast b/crates/ra_syntax/test_data/parser/ok/0051_parameter_attrs.rast index 7a574ebb41..2cc8497844 100644 --- a/crates/ra_syntax/test_data/parser/ok/0051_parameter_attrs.rast +++ b/crates/ra_syntax/test_data/parser/ok/0051_parameter_attrs.rast @@ -251,7 +251,7 @@ SOURCE_FILE@0..519 WHITESPACE@234..235 "\n" R_CURLY@235..236 "}" WHITESPACE@236..238 "\n\n" - IMPL_DEF@238..519 + IMPL@238..519 IMPL_KW@238..242 "impl" WHITESPACE@242..243 " " PATH_TYPE@243..244 diff --git a/crates/ra_syntax/test_data/parser/ok/0064_impl_fn_params.rast b/crates/ra_syntax/test_data/parser/ok/0064_impl_fn_params.rast index ef0eca47cc..453757c3cd 100644 --- a/crates/ra_syntax/test_data/parser/ok/0064_impl_fn_params.rast +++ b/crates/ra_syntax/test_data/parser/ok/0064_impl_fn_params.rast @@ -1,5 +1,5 @@ SOURCE_FILE@0..137 - IMPL_DEF@0..136 + IMPL@0..136 IMPL_KW@0..4 "impl" WHITESPACE@4..5 " " PATH_TYPE@5..6 diff --git a/crates/ra_syntax/test_data/parser/ok/0066_default_const.rast b/crates/ra_syntax/test_data/parser/ok/0066_default_const.rast index 485efe20cf..6246a31a66 100644 --- a/crates/ra_syntax/test_data/parser/ok/0066_default_const.rast +++ b/crates/ra_syntax/test_data/parser/ok/0066_default_const.rast @@ -1,5 +1,5 @@ SOURCE_FILE@0..46 - IMPL_DEF@0..45 + IMPL@0..45 IMPL_KW@0..4 "impl" WHITESPACE@4..5 " " PATH_TYPE@5..6 diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs index 3889ebed18..fadcc5853b 100644 --- a/crates/rust-analyzer/src/to_proto.rs +++ b/crates/rust-analyzer/src/to_proto.rs @@ -42,7 +42,7 @@ pub(crate) fn symbol_kind(syntax_kind: SyntaxKind) -> lsp_types::SymbolKind { SyntaxKind::RECORD_FIELD => lsp_types::SymbolKind::Field, SyntaxKind::STATIC => lsp_types::SymbolKind::Constant, SyntaxKind::CONST => lsp_types::SymbolKind::Constant, - SyntaxKind::IMPL_DEF => lsp_types::SymbolKind::Object, + SyntaxKind::IMPL => lsp_types::SymbolKind::Object, _ => lsp_types::SymbolKind::Variable, } } diff --git a/xtask/src/ast_src.rs b/xtask/src/ast_src.rs index ea8bf50edc..c7087a14ec 100644 --- a/xtask/src/ast_src.rs +++ b/xtask/src/ast_src.rs @@ -104,7 +104,7 @@ pub(crate) const KINDS_SRC: KindsSrc = KindsSrc { "STATIC", "CONST", "TRAIT", - "IMPL_DEF", + "IMPL", "TYPE_ALIAS", "MACRO_CALL", "TOKEN_TREE", diff --git a/xtask/src/codegen/rust.ungram b/xtask/src/codegen/rust.ungram index b306583979..cda0e8fbb5 100644 --- a/xtask/src/codegen/rust.ungram +++ b/xtask/src/codegen/rust.ungram @@ -9,7 +9,7 @@ Item = | ExternBlock | ExternCrate | Fn -| ImplDef +| Impl | MacroCall | Module | Static @@ -131,9 +131,12 @@ Trait = AssocItemList = '{' AssocItem* '}' -ImplDef = - Attr* Visibility? 'const'? 'default'? 'unsafe'? 'impl' GenericParamList? '!'? 'for' - WhereClause? +Impl = + Attr* Visibility? + 'default'? 'unsafe'? 'impl' 'const'? GenericParamList? ( + TypeRef + | '!'? TypeRef 'for' TypeRef + ) WhereClause? AssocItemList ParenType =