5606: Finalize impl Grammar r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
bors[bot] 2020-07-30 16:29:24 +00:00 committed by GitHub
commit 0f5805541b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
74 changed files with 199 additions and 193 deletions

View file

@ -41,7 +41,7 @@ impl<'a> SubstituteTypeParams<'a> {
source_scope: &'a SemanticsScope<'a>, source_scope: &'a SemanticsScope<'a>,
// FIXME: there's implicit invariant that `trait_` and `source_scope` match... // FIXME: there's implicit invariant that `trait_` and `source_scope` match...
trait_: hir::Trait, trait_: hir::Trait,
impl_def: ast::ImplDef, impl_def: ast::Impl,
) -> SubstituteTypeParams<'a> { ) -> SubstituteTypeParams<'a> {
let substs = get_syntactic_substs(impl_def).unwrap_or_default(); let substs = get_syntactic_substs(impl_def).unwrap_or_default();
let generic_def: hir::GenericDef = trait_.into(); 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 // 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) // trait ref, and then go from the types in the substs back to the syntax)
fn get_syntactic_substs(impl_def: ast::ImplDef) -> Option<Vec<ast::TypeRef>> { fn get_syntactic_substs(impl_def: ast::Impl) -> Option<Vec<ast::TypeRef>> {
let target_trait = impl_def.target_trait()?; let target_trait = impl_def.target_trait()?;
let path_type = match target_trait { let path_type = match target_trait {
ast::TypeRef::PathType(path) => path, ast::TypeRef::PathType(path) => path,

View file

@ -111,7 +111,7 @@ fn add_missing_impl_members_inner(
label: &'static str, label: &'static str,
) -> Option<()> { ) -> Option<()> {
let _p = ra_prof::profile("add_missing_impl_members_inner"); let _p = ra_prof::profile("add_missing_impl_members_inner");
let impl_def = ctx.find_node_at_offset::<ast::ImplDef>()?; let impl_def = ctx.find_node_at_offset::<ast::Impl>()?;
let impl_item_list = impl_def.assoc_item_list()?; let impl_item_list = impl_def.assoc_item_list()?;
let trait_ = resolve_target_trait(&ctx.sema, &impl_def)?; let trait_ = resolve_target_trait(&ctx.sema, &impl_def)?;

View file

@ -1,7 +1,7 @@
use ra_syntax::{ use ra_syntax::{
ast::{self, NameOwner, VisibilityOwner}, ast::{self, NameOwner, VisibilityOwner},
AstNode, AstNode,
SyntaxKind::{CONST, ENUM, FN, MODULE, STATIC, STRUCT, TRAIT_DEF, VISIBILITY}, SyntaxKind::{CONST, ENUM, FN, MODULE, STATIC, STRUCT, TRAIT, VISIBILITY},
T, T,
}; };
use test_utils::mark; use test_utils::mark;
@ -36,7 +36,7 @@ fn add_vis(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
let (offset, target) = if let Some(keyword) = item_keyword { let (offset, target) = if let Some(keyword) = item_keyword {
let parent = keyword.parent(); let parent = keyword.parent();
let def_kws = vec![CONST, STATIC, FN, MODULE, STRUCT, ENUM, TRAIT_DEF]; let def_kws = vec![CONST, STATIC, FN, MODULE, STRUCT, ENUM, TRAIT];
// Parent is not a definition, can't add visibility // Parent is not a definition, can't add visibility
if !def_kws.iter().any(|&def_kw| def_kw == parent.kind()) { if !def_kws.iter().any(|&def_kw| def_kw == parent.kind()) {
return None; return None;

View file

@ -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 // FIXME: change the new fn checking to a more semantic approach when that's more
// viable (e.g. we process proc macros, etc) // viable (e.g. we process proc macros, etc)
fn find_struct_impl(ctx: &AssistContext, strukt: &ast::Struct) -> Option<Option<ast::ImplDef>> { fn find_struct_impl(ctx: &AssistContext, strukt: &ast::Struct) -> Option<Option<ast::Impl>> {
let db = ctx.db(); let db = ctx.db();
let module = strukt.syntax().ancestors().find(|node| { let module = strukt.syntax().ancestors().find(|node| {
ast::Module::can_cast(node.kind()) || ast::SourceFile::can_cast(node.kind()) 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<Option<
let struct_def = ctx.sema.to_def(strukt)?; let struct_def = ctx.sema.to_def(strukt)?;
let block = module.descendants().filter_map(ast::ImplDef::cast).find_map(|impl_blk| { let block = module.descendants().filter_map(ast::Impl::cast).find_map(|impl_blk| {
let blk = ctx.sema.to_def(&impl_blk)?; let blk = ctx.sema.to_def(&impl_blk)?;
// FIXME: handle e.g. `struct S<T>; impl<U> S<U> {}` // FIXME: handle e.g. `struct S<T>; impl<U> S<U> {}`
@ -158,7 +158,7 @@ fn find_struct_impl(ctx: &AssistContext, strukt: &ast::Struct) -> Option<Option<
Some(block) Some(block)
} }
fn has_new_fn(imp: &ast::ImplDef) -> bool { fn has_new_fn(imp: &ast::Impl) -> bool {
if let Some(il) = imp.assoc_item_list() { if let Some(il) = imp.assoc_item_list() {
for item in il.assoc_items() { for item in il.assoc_items() {
if let ast::AssocItem::Fn(f) = item { if let ast::AssocItem::Fn(f) = item {

View file

@ -40,7 +40,7 @@ pub(crate) fn introduce_named_lifetime(acc: &mut Assists, ctx: &AssistContext) -
.filter(|lifetime| lifetime.text() == "'_")?; .filter(|lifetime| lifetime.text() == "'_")?;
if let Some(fn_def) = lifetime_token.ancestors().find_map(ast::Fn::cast) { if let Some(fn_def) = lifetime_token.ancestors().find_map(ast::Fn::cast) {
generate_fn_def_assist(acc, &fn_def, lifetime_token.text_range()) 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()) generate_impl_def_assist(acc, &impl_def, lifetime_token.text_range())
} else { } else {
None None
@ -93,7 +93,7 @@ fn generate_fn_def_assist(
/// Generate the assist for the impl def case /// Generate the assist for the impl def case
fn generate_impl_def_assist( fn generate_impl_def_assist(
acc: &mut Assists, acc: &mut Assists,
impl_def: &ast::ImplDef, impl_def: &ast::Impl,
lifetime_loc: TextRange, lifetime_loc: TextRange,
) -> Option<()> { ) -> Option<()> {
let new_lifetime_param = generate_unique_lifetime_param_name(&impl_def.generic_param_list())?; let new_lifetime_param = generate_unique_lifetime_param_name(&impl_def.generic_param_list())?;

View file

@ -38,8 +38,8 @@ pub(crate) fn move_bounds_to_where_clause(acc: &mut Assists, ctx: &AssistContext
let anchor = match_ast! { let anchor = match_ast! {
match parent { match parent {
ast::Fn(it) => it.body()?.syntax().clone().into(), ast::Fn(it) => it.body()?.syntax().clone().into(),
ast::TraitDef(it) => it.assoc_item_list()?.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::Enum(it) => it.variant_list()?.syntax().clone().into(),
ast::Struct(it) => { ast::Struct(it) => {
it.syntax().children_with_tokens() it.syntax().children_with_tokens()

View file

@ -56,7 +56,7 @@ pub(crate) fn render_snippet(_cap: SnippetCap, node: &SyntaxNode, cursor: Cursor
pub fn get_missing_assoc_items( pub fn get_missing_assoc_items(
sema: &Semantics<RootDatabase>, sema: &Semantics<RootDatabase>,
impl_def: &ast::ImplDef, impl_def: &ast::Impl,
) -> Vec<hir::AssocItem> { ) -> Vec<hir::AssocItem> {
// Names must be unique between constants and functions. However, type aliases // Names must be unique between constants and functions. However, type aliases
// may share the same name as a function or constant. // 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( pub(crate) fn resolve_target_trait(
sema: &Semantics<RootDatabase>, sema: &Semantics<RootDatabase>,
impl_def: &ast::ImplDef, impl_def: &ast::Impl,
) -> Option<hir::Trait> { ) -> Option<hir::Trait> {
let ast_path = impl_def let ast_path = impl_def
.target_trait() .target_trait()

View file

@ -99,8 +99,8 @@ impl HasSource for Static {
} }
} }
impl HasSource for Trait { impl HasSource for Trait {
type Ast = ast::TraitDef; type Ast = ast::Trait;
fn source(self, db: &dyn HirDatabase) -> InFile<ast::TraitDef> { fn source(self, db: &dyn HirDatabase) -> InFile<ast::Trait> {
self.id.lookup(db.upcast()).source(db.upcast()) self.id.lookup(db.upcast()).source(db.upcast())
} }
} }
@ -120,14 +120,14 @@ impl HasSource for MacroDef {
} }
} }
impl HasSource for ImplDef { impl HasSource for ImplDef {
type Ast = ast::ImplDef; type Ast = ast::Impl;
fn source(self, db: &dyn HirDatabase) -> InFile<ast::ImplDef> { fn source(self, db: &dyn HirDatabase) -> InFile<ast::Impl> {
self.id.lookup(db.upcast()).source(db.upcast()) self.id.lookup(db.upcast()).source(db.upcast())
} }
} }
impl HasSource for TypeParam { impl HasSource for TypeParam {
type Ast = Either<ast::TraitDef, ast::TypeParam>; type Ast = Either<ast::Trait, ast::TypeParam>;
fn source(self, db: &dyn HirDatabase) -> InFile<Self::Ast> { fn source(self, db: &dyn HirDatabase) -> InFile<Self::Ast> {
let child_source = self.id.parent.child_source(db.upcast()); let child_source = self.id.parent.child_source(db.upcast());
child_source.map(|it| it[self.id.local_id].clone()) child_source.map(|it| it[self.id.local_id].clone())

View file

@ -583,8 +583,8 @@ to_def_impls![
(crate::Struct, ast::Struct, struct_to_def), (crate::Struct, ast::Struct, struct_to_def),
(crate::Enum, ast::Enum, enum_to_def), (crate::Enum, ast::Enum, enum_to_def),
(crate::Union, ast::Union, union_to_def), (crate::Union, ast::Union, union_to_def),
(crate::Trait, ast::TraitDef, trait_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::TypeAlias, ast::TypeAlias, type_alias_to_def),
(crate::Const, ast::Const, const_to_def), (crate::Const, ast::Const, const_to_def),
(crate::Static, ast::Static, static_to_def), (crate::Static, ast::Static, static_to_def),

View file

@ -65,10 +65,10 @@ impl SourceToDefCtx<'_, '_> {
Some(ModuleId { krate: parent_module.krate, local_id: child_id }) Some(ModuleId { krate: parent_module.krate, local_id: child_id })
} }
pub(super) fn trait_to_def(&mut self, src: InFile<ast::TraitDef>) -> Option<TraitId> { pub(super) fn trait_to_def(&mut self, src: InFile<ast::Trait>) -> Option<TraitId> {
self.to_def(src, keys::TRAIT) self.to_def(src, keys::TRAIT)
} }
pub(super) fn impl_to_def(&mut self, src: InFile<ast::ImplDef>) -> Option<ImplId> { pub(super) fn impl_to_def(&mut self, src: InFile<ast::Impl>) -> Option<ImplId> {
self.to_def(src, keys::IMPL) self.to_def(src, keys::IMPL)
} }
pub(super) fn fn_to_def(&mut self, src: InFile<ast::Fn>) -> Option<FunctionId> { pub(super) fn fn_to_def(&mut self, src: InFile<ast::Fn>) -> Option<FunctionId> {
@ -154,11 +154,11 @@ impl SourceToDefCtx<'_, '_> {
let def = self.module_to_def(container.with_value(it))?; let def = self.module_to_def(container.with_value(it))?;
def.into() def.into()
}, },
ast::TraitDef(it) => { ast::Trait(it) => {
let def = self.trait_to_def(container.with_value(it))?; let def = self.trait_to_def(container.with_value(it))?;
def.into() def.into()
}, },
ast::ImplDef(it) => { ast::Impl(it) => {
let def = self.impl_to_def(container.with_value(it))?; let def = self.impl_to_def(container.with_value(it))?;
def.into() def.into()
}, },
@ -207,9 +207,9 @@ impl SourceToDefCtx<'_, '_> {
ast::Fn(it) => self.fn_to_def(container.with_value(it))?.into(), ast::Fn(it) => self.fn_to_def(container.with_value(it))?.into(),
ast::Struct(it) => self.struct_to_def(container.with_value(it))?.into(), ast::Struct(it) => self.struct_to_def(container.with_value(it))?.into(),
ast::Enum(it) => self.enum_to_def(container.with_value(it))?.into(), ast::Enum(it) => self.enum_to_def(container.with_value(it))?.into(),
ast::TraitDef(it) => self.trait_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::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, _ => continue,
} }
}; };

View file

@ -664,12 +664,12 @@ impl ExprCollector<'_> {
let id = self.find_inner_item(&def)?; let id = self.find_inner_item(&def)?;
(UnionLoc { container, id }.intern(self.db).into(), def.name()) (UnionLoc { container, id }.intern(self.db).into(), def.name())
} }
ast::Item::TraitDef(def) => { ast::Item::Trait(def) => {
let id = self.find_inner_item(&def)?; let id = self.find_inner_item(&def)?;
(TraitLoc { container, id }.intern(self.db).into(), def.name()) (TraitLoc { container, id }.intern(self.db).into(), def.name())
} }
ast::Item::ExternBlock(_) => return None, // FIXME: collect from extern blocks ast::Item::ExternBlock(_) => return None, // FIXME: collect from extern blocks
ast::Item::ImplDef(_) ast::Item::Impl(_)
| ast::Item::Use(_) | ast::Item::Use(_)
| ast::Item::ExternCrate(_) | ast::Item::ExternCrate(_)
| ast::Item::Module(_) | ast::Item::Module(_)

View file

@ -66,7 +66,7 @@ pub enum WherePredicateTarget {
TypeParam(LocalTypeParamId), TypeParam(LocalTypeParamId),
} }
type SourceMap = ArenaMap<LocalTypeParamId, Either<ast::TraitDef, ast::TypeParam>>; type SourceMap = ArenaMap<LocalTypeParamId, Either<ast::Trait, ast::TypeParam>>;
impl GenericParams { impl GenericParams {
pub(crate) fn generic_params_query( pub(crate) fn generic_params_query(
@ -317,7 +317,7 @@ impl GenericParams {
impl HasChildSource for GenericDefId { impl HasChildSource for GenericDefId {
type ChildId = LocalTypeParamId; type ChildId = LocalTypeParamId;
type Value = Either<ast::TraitDef, ast::TypeParam>; type Value = Either<ast::Trait, ast::TypeParam>;
fn child_source(&self, db: &dyn DefDatabase) -> InFile<SourceMap> { fn child_source(&self, db: &dyn DefDatabase) -> InFile<SourceMap> {
let (_, sm) = GenericParams::new(db, *self); let (_, sm) = GenericParams::new(db, *self);
sm sm

View file

@ -419,8 +419,8 @@ mod_items! {
Enum in enums -> ast::Enum, Enum in enums -> ast::Enum,
Const in consts -> ast::Const, Const in consts -> ast::Const,
Static in statics -> ast::Static, Static in statics -> ast::Static,
Trait in traits -> ast::TraitDef, Trait in traits -> ast::Trait,
Impl in impls -> ast::ImplDef, Impl in impls -> ast::Impl,
TypeAlias in type_aliases -> ast::TypeAlias, TypeAlias in type_aliases -> ast::TypeAlias,
Mod in mods -> ast::Module, Mod in mods -> ast::Module,
MacroCall in macro_calls -> ast::MacroCall, MacroCall in macro_calls -> ast::MacroCall,
@ -571,7 +571,7 @@ pub struct Trait {
pub generic_params: GenericParamsId, pub generic_params: GenericParamsId,
pub auto: bool, pub auto: bool,
pub items: Box<[AssocItem]>, pub items: Box<[AssocItem]>,
pub ast_id: FileAstId<ast::TraitDef>, pub ast_id: FileAstId<ast::Trait>,
} }
#[derive(Debug, Clone, Eq, PartialEq)] #[derive(Debug, Clone, Eq, PartialEq)]
@ -581,7 +581,7 @@ pub struct Impl {
pub target_type: TypeRef, pub target_type: TypeRef,
pub is_negative: bool, pub is_negative: bool,
pub items: Box<[AssocItem]>, pub items: Box<[AssocItem]>,
pub ast_id: FileAstId<ast::ImplDef>, pub ast_id: FileAstId<ast::Impl>,
} }
#[derive(Debug, Clone, PartialEq, Eq)] #[derive(Debug, Clone, PartialEq, Eq)]

View file

@ -95,7 +95,7 @@ impl Ctx {
// These are handled in their respective `lower_X` method (since we can't just blindly // These are handled in their respective `lower_X` method (since we can't just blindly
// walk them). // walk them).
ast::Item::TraitDef(_) | ast::Item::ImplDef(_) | ast::Item::ExternBlock(_) => {} ast::Item::Trait(_) | ast::Item::Impl(_) | ast::Item::ExternBlock(_) => {}
// These don't have inner items. // These don't have inner items.
ast::Item::Module(_) | ast::Item::ExternCrate(_) | ast::Item::Use(_) => {} ast::Item::Module(_) | ast::Item::ExternCrate(_) | ast::Item::Use(_) => {}
@ -111,8 +111,8 @@ impl Ctx {
ast::Item::Static(ast) => self.lower_static(ast).map(Into::into), ast::Item::Static(ast) => self.lower_static(ast).map(Into::into),
ast::Item::Const(ast) => Some(self.lower_const(ast).into()), ast::Item::Const(ast) => Some(self.lower_const(ast).into()),
ast::Item::Module(ast) => self.lower_module(ast).map(Into::into), ast::Item::Module(ast) => self.lower_module(ast).map(Into::into),
ast::Item::TraitDef(ast) => self.lower_trait(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( ast::Item::Use(ast) => Some(ModItems(
self.lower_use(ast).into_iter().map(Into::into).collect::<SmallVec<_>>(), self.lower_use(ast).into_iter().map(Into::into).collect::<SmallVec<_>>(),
)), )),
@ -413,7 +413,7 @@ impl Ctx {
Some(id(self.data().mods.alloc(res))) Some(id(self.data().mods.alloc(res)))
} }
fn lower_trait(&mut self, trait_def: &ast::TraitDef) -> Option<FileItemTreeId<Trait>> { fn lower_trait(&mut self, trait_def: &ast::Trait) -> Option<FileItemTreeId<Trait>> {
let name = trait_def.name()?.as_name(); let name = trait_def.name()?.as_name();
let visibility = self.lower_visibility(trait_def); let visibility = self.lower_visibility(trait_def);
let generic_params = let generic_params =
@ -445,7 +445,7 @@ impl Ctx {
Some(id(self.data().traits.alloc(res))) Some(id(self.data().traits.alloc(res)))
} }
fn lower_impl(&mut self, impl_def: &ast::ImplDef) -> Option<FileItemTreeId<Impl>> { fn lower_impl(&mut self, impl_def: &ast::Impl) -> Option<FileItemTreeId<Impl>> {
let generic_params = let generic_params =
self.lower_generic_params_and_inner_items(GenericsOwner::Impl, impl_def); 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)); let target_trait = impl_def.target_trait().map(|tr| self.lower_type_ref(&tr));
@ -698,7 +698,7 @@ enum GenericsOwner<'a> {
Enum, Enum,
Union, Union,
/// The `TraitDef` is needed to fill the source map for the implicit `Self` parameter. /// The `TraitDef` is needed to fill the source map for the implicit `Self` parameter.
Trait(&'a ast::TraitDef), Trait(&'a ast::Trait),
TypeAlias, TypeAlias,
Impl, Impl,
} }

View file

@ -234,7 +234,7 @@ fn smoke() {
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("ext_crate"))] }, input: None }]) }] #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("ext_crate"))] }, input: None }]) }]
ExternCrate { path: ModPath { kind: Plain, segments: [Name(Text("krate"))] }, alias: None, visibility: RawVisibilityId("pub(self)"), is_macro_use: false, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::ExternCrate>(1) } ExternCrate { path: ModPath { kind: Plain, segments: [Name(Text("krate"))] }, alias: None, visibility: RawVisibilityId("pub(self)"), is_macro_use: false, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::ExternCrate>(1) }
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("on_trait"))] }, input: None }]) }] #[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::<TypeAlias>(0)), Const(Idx::<Const>(0)), Function(Idx::<Function>(0)), Function(Idx::<Function>(1))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::TraitDef>(2) } Trait { name: Name(Text("Tr")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(0), auto: false, items: [TypeAlias(Idx::<TypeAlias>(0)), Const(Idx::<Const>(0)), Function(Idx::<Function>(0)), Function(Idx::<Function>(1))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Trait>(2) }
> #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_ty"))] }, input: None }]) }] > #[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::<ra_syntax::ast::generated::nodes::TypeAlias>(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, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::TypeAlias>(8) }
> #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_const"))] }, input: None }]) }] > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_const"))] }, input: None }]) }]
@ -274,7 +274,7 @@ fn simple_inner_items() {
inner attrs: Attrs { entries: None } inner attrs: Attrs { entries: None }
top-level items: 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::<Function>(1))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::ImplDef>(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::<Function>(1))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Impl>(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::<ra_syntax::ast::generated::nodes::Fn>(1) } > 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::<ra_syntax::ast::generated::nodes::Fn>(1) }
inner items: inner items:
@ -327,7 +327,7 @@ fn trait_attrs() {
top-level items: top-level items:
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("trait_attr"))] }, input: None }]) }] #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("trait_attr"))] }, input: None }]) }]
Trait { name: Name(Text("Tr")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(0), auto: false, items: [Function(Idx::<Function>(0)), Function(Idx::<Function>(1))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::TraitDef>(0) } Trait { name: Name(Text("Tr")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(0), auto: false, items: [Function(Idx::<Function>(0)), Function(Idx::<Function>(1))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Trait>(0) }
> #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_a"))] }, input: None }]) }] > #[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::<ra_syntax::ast::generated::nodes::Fn>(1) } > 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::<ra_syntax::ast::generated::nodes::Fn>(1) }
> #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_b"))] }, input: None }]) }] > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_b"))] }, input: None }]) }]
@ -353,7 +353,7 @@ fn impl_attrs() {
top-level items: top-level items:
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("impl_attr"))] }, input: None }]) }] #[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::<Function>(0)), Function(Idx::<Function>(1))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::ImplDef>(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::<Function>(0)), Function(Idx::<Function>(1))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Impl>(0) }
> #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_a"))] }, input: None }]) }] > #[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::<ra_syntax::ast::generated::nodes::Fn>(1) } > 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::<ra_syntax::ast::generated::nodes::Fn>(1) }
> #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_b"))] }, input: None }]) }] > #[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 } inner attrs: Attrs { entries: None }
top-level items: 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::<MacroCall>(0))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::ImplDef>(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::<MacroCall>(0))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Impl>(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::<ra_syntax::ast::generated::nodes::MacroCall>(1) } > MacroCall { name: None, path: ModPath { kind: Plain, segments: [Name(Text("items"))] }, is_export: false, is_local_inner: false, is_builtin: false, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::MacroCall>(1) }
"#]], "#]],
); );

View file

@ -18,8 +18,8 @@ pub const FUNCTION: Key<ast::Fn, FunctionId> = Key::new();
pub const CONST: Key<ast::Const, ConstId> = Key::new(); pub const CONST: Key<ast::Const, ConstId> = Key::new();
pub const STATIC: Key<ast::Static, StaticId> = Key::new(); pub const STATIC: Key<ast::Static, StaticId> = Key::new();
pub const TYPE_ALIAS: Key<ast::TypeAlias, TypeAliasId> = Key::new(); pub const TYPE_ALIAS: Key<ast::TypeAlias, TypeAliasId> = Key::new();
pub const IMPL: Key<ast::ImplDef, ImplId> = Key::new(); pub const IMPL: Key<ast::Impl, ImplId> = Key::new();
pub const TRAIT: Key<ast::TraitDef, TraitId> = Key::new(); pub const TRAIT: Key<ast::Trait, TraitId> = Key::new();
pub const STRUCT: Key<ast::Struct, StructId> = Key::new(); pub const STRUCT: Key<ast::Struct, StructId> = Key::new();
pub const UNION: Key<ast::Union, UnionId> = Key::new(); pub const UNION: Key<ast::Union, UnionId> = Key::new();
pub const ENUM: Key<ast::Enum, EnumId> = Key::new(); pub const ENUM: Key<ast::Enum, EnumId> = Key::new();

View file

@ -3,7 +3,7 @@
//! This module adds the completion items related to implementing associated //! This module adds the completion items related to implementing associated
//! items within a `impl Trait for Struct` block. The current context node //! items within a `impl Trait for Struct` block. The current context node
//! must be within either a `FN`, `TYPE_ALIAS`, or `CONST` 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 //! # Examples
//! //!
@ -34,7 +34,7 @@
use hir::{self, Docs, HasSource}; use hir::{self, Docs, HasSource};
use ra_assists::utils::get_missing_assoc_items; use ra_assists::utils::get_missing_assoc_items;
use ra_syntax::{ use ra_syntax::{
ast::{self, edit, ImplDef}, ast::{self, edit, Impl},
AstNode, SyntaxKind, SyntaxNode, TextRange, T, AstNode, SyntaxKind, SyntaxNode, TextRange, T,
}; };
use ra_text_edit::TextEdit; 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() { let (trigger, impl_def_offset) = ctx.token.ancestors().find_map(|p| match p.kind() {
SyntaxKind::FN | SyntaxKind::TYPE_ALIAS | SyntaxKind::CONST | SyntaxKind::BLOCK_EXPR => { SyntaxKind::FN | SyntaxKind::TYPE_ALIAS | SyntaxKind::CONST | SyntaxKind::BLOCK_EXPR => {
Some((p, 2)) Some((p, 2))
@ -114,7 +114,7 @@ fn completion_match(ctx: &CompletionContext) -> Option<(SyntaxNode, ImplDef)> {
})?; })?;
let impl_def = (0..impl_def_offset - 1) let impl_def = (0..impl_def_offset - 1)
.try_fold(trigger.parent()?, |t, _| t.parent()) .try_fold(trigger.parent()?, |t, _| t.parent())
.and_then(ast::ImplDef::cast)?; .and_then(ast::Impl::cast)?;
Some((trigger, impl_def)) Some((trigger, impl_def))
} }

View file

@ -40,7 +40,7 @@ pub(crate) struct CompletionContext<'a> {
pub(super) record_lit_syntax: Option<ast::RecordExpr>, pub(super) record_lit_syntax: Option<ast::RecordExpr>,
pub(super) record_pat_syntax: Option<ast::RecordPat>, pub(super) record_pat_syntax: Option<ast::RecordPat>,
pub(super) record_field_syntax: Option<ast::RecordExprField>, pub(super) record_field_syntax: Option<ast::RecordExprField>,
pub(super) impl_def: Option<ast::ImplDef>, pub(super) impl_def: Option<ast::Impl>,
/// FIXME: `ActiveParameter` is string-based, which is very very wrong /// FIXME: `ActiveParameter` is string-based, which is very very wrong
pub(super) active_parameter: Option<ActiveParameter>, pub(super) active_parameter: Option<ActiveParameter>,
pub(super) is_param: bool, pub(super) is_param: bool,
@ -325,7 +325,7 @@ impl<'a> CompletionContext<'a> {
.sema .sema
.ancestors_with_macros(self.token.parent()) .ancestors_with_macros(self.token.parent())
.take_while(|it| it.kind() != SOURCE_FILE && it.kind() != MODULE) .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 let top_node = name_ref
.syntax() .syntax()

View file

@ -15,7 +15,7 @@ pub(crate) fn has_trait_parent(element: SyntaxElement) -> bool {
not_same_range_ancestor(element) not_same_range_ancestor(element)
.filter(|it| it.kind() == ASSOC_ITEM_LIST) .filter(|it| it.kind() == ASSOC_ITEM_LIST)
.and_then(|it| it.parent()) .and_then(|it| it.parent())
.filter(|it| it.kind() == TRAIT_DEF) .filter(|it| it.kind() == TRAIT)
.is_some() .is_some()
} }
#[test] #[test]
@ -27,7 +27,7 @@ pub(crate) fn has_impl_parent(element: SyntaxElement) -> bool {
not_same_range_ancestor(element) not_same_range_ancestor(element)
.filter(|it| it.kind() == ASSOC_ITEM_LIST) .filter(|it| it.kind() == ASSOC_ITEM_LIST)
.and_then(|it| it.parent()) .and_then(|it| it.parent())
.filter(|it| it.kind() == IMPL_DEF) .filter(|it| it.kind() == IMPL)
.is_some() .is_some()
} }
#[test] #[test]
@ -113,7 +113,7 @@ fn test_if_is_prev() {
} }
pub(crate) fn has_trait_as_prev_sibling(element: SyntaxElement) -> bool { pub(crate) fn has_trait_as_prev_sibling(element: SyntaxElement) -> bool {
previous_sibling_or_ancestor_sibling(element).filter(|it| it.kind() == TRAIT_DEF).is_some() previous_sibling_or_ancestor_sibling(element).filter(|it| it.kind() == TRAIT).is_some()
} }
#[test] #[test]
fn test_has_trait_as_prev_sibling() { fn test_has_trait_as_prev_sibling() {
@ -121,7 +121,7 @@ fn test_has_trait_as_prev_sibling() {
} }
pub(crate) fn has_impl_as_prev_sibling(element: SyntaxElement) -> bool { 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] #[test]
fn test_has_impl_as_prev_sibling() { fn test_has_impl_as_prev_sibling() {

View file

@ -382,7 +382,7 @@ pub(crate) fn docs_from_symbol(db: &RootDatabase, symbol: &FileSymbol) -> Option
ast::Fn(it) => it.doc_comment_text(), ast::Fn(it) => it.doc_comment_text(),
ast::Struct(it) => it.doc_comment_text(), ast::Struct(it) => it.doc_comment_text(),
ast::Enum(it) => it.doc_comment_text(), ast::Enum(it) => it.doc_comment_text(),
ast::TraitDef(it) => it.doc_comment_text(), ast::Trait(it) => it.doc_comment_text(),
ast::Module(it) => it.doc_comment_text(), ast::Module(it) => it.doc_comment_text(),
ast::TypeAlias(it) => it.doc_comment_text(), ast::TypeAlias(it) => it.doc_comment_text(),
ast::Const(it) => it.doc_comment_text(), ast::Const(it) => it.doc_comment_text(),
@ -407,7 +407,7 @@ pub(crate) fn description_from_symbol(db: &RootDatabase, symbol: &FileSymbol) ->
ast::Fn(it) => it.short_label(), ast::Fn(it) => it.short_label(),
ast::Struct(it) => it.short_label(), ast::Struct(it) => it.short_label(),
ast::Enum(it) => it.short_label(), ast::Enum(it) => it.short_label(),
ast::TraitDef(it) => it.short_label(), ast::Trait(it) => it.short_label(),
ast::Module(it) => it.short_label(), ast::Module(it) => it.short_label(),
ast::TypeAlias(it) => it.short_label(), ast::TypeAlias(it) => it.short_label(),
ast::Const(it) => it.short_label(), ast::Const(it) => it.short_label(),

View file

@ -31,7 +31,7 @@ impl ShortLabel for ast::Enum {
} }
} }
impl ShortLabel for ast::TraitDef { impl ShortLabel for ast::Trait {
fn short_label(&self) -> Option<String> { fn short_label(&self) -> Option<String> {
if self.unsafe_token().is_some() { if self.unsafe_token().is_some() {
short_label_from_node(self, "unsafe trait ") short_label_from_node(self, "unsafe trait ")

View file

@ -130,7 +130,7 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
ast::Union(it) => decl(it), ast::Union(it) => decl(it),
ast::Enum(it) => decl(it), ast::Enum(it) => decl(it),
ast::Variant(it) => decl(it), ast::Variant(it) => decl(it),
ast::TraitDef(it) => decl(it), ast::Trait(it) => decl(it),
ast::Module(it) => decl(it), ast::Module(it) => decl(it),
ast::TypeAlias(it) => { ast::TypeAlias(it) => {
let ty = it.type_ref(); let ty = it.type_ref();
@ -139,7 +139,7 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
ast::RecordField(it) => decl_with_ascription(it), ast::RecordField(it) => decl_with_ascription(it),
ast::Const(it) => decl_with_ascription(it), ast::Const(it) => decl_with_ascription(it),
ast::Static(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_type = it.target_type()?;
let target_trait = it.target_trait(); let target_trait = it.target_trait();
let label = match target_trait { let label = match target_trait {
@ -372,7 +372,7 @@ fn very_obsolete() {}
label: "impl E", label: "impl E",
navigation_range: 239..240, navigation_range: 239..240,
node_range: 234..243, node_range: 234..243,
kind: IMPL_DEF, kind: IMPL,
detail: None, detail: None,
deprecated: false, deprecated: false,
}, },
@ -381,7 +381,7 @@ fn very_obsolete() {}
label: "impl fmt::Debug for E", label: "impl fmt::Debug for E",
navigation_range: 265..266, navigation_range: 265..266,
node_range: 245..269, node_range: 245..269,
kind: IMPL_DEF, kind: IMPL,
detail: None, detail: None,
deprecated: false, deprecated: false,
}, },

View file

@ -28,7 +28,7 @@ pub(crate) fn goto_implementation(
nominal_def.syntax().text_range(), nominal_def.syntax().text_range(),
impls_for_def(&sema, &nominal_def, krate)?, impls_for_def(&sema, &nominal_def, krate)?,
)); ));
} else if let Some(trait_def) = find_node_at_offset::<ast::TraitDef>(&syntax, position.offset) { } else if let Some(trait_def) = find_node_at_offset::<ast::Trait>(&syntax, position.offset) {
return Some(RangeInfo::new( return Some(RangeInfo::new(
trait_def.syntax().text_range(), trait_def.syntax().text_range(),
impls_for_trait(&sema, &trait_def, krate)?, impls_for_trait(&sema, &trait_def, krate)?,
@ -62,7 +62,7 @@ fn impls_for_def(
fn impls_for_trait( fn impls_for_trait(
sema: &Semantics<RootDatabase>, sema: &Semantics<RootDatabase>,
node: &ast::TraitDef, node: &ast::Trait,
krate: Crate, krate: Crate,
) -> Option<Vec<NavigationTarget>> { ) -> Option<Vec<NavigationTarget>> {
let tr = sema.to_def(node)?; let tr = sema.to_def(node)?;

View file

@ -1678,7 +1678,7 @@ fn main() { let s<|>t = foo(); }
6..9, 6..9,
), ),
name: "Foo", name: "Foo",
kind: TRAIT_DEF, kind: TRAIT,
container_name: None, container_name: None,
description: Some( description: Some(
"trait Foo", "trait Foo",
@ -1718,7 +1718,7 @@ fn main() { let s<|>t = foo(); }
6..9, 6..9,
), ),
name: "Foo", name: "Foo",
kind: TRAIT_DEF, kind: TRAIT,
container_name: None, container_name: None,
description: Some( description: Some(
"trait Foo", "trait Foo",
@ -1777,7 +1777,7 @@ fn main() { let s<|>t = foo(); }
6..9, 6..9,
), ),
name: "Foo", name: "Foo",
kind: TRAIT_DEF, kind: TRAIT,
container_name: None, container_name: None,
description: Some( description: Some(
"trait Foo", "trait Foo",
@ -1796,7 +1796,7 @@ fn main() { let s<|>t = foo(); }
19..22, 19..22,
), ),
name: "Bar", name: "Bar",
kind: TRAIT_DEF, kind: TRAIT,
container_name: None, container_name: None,
description: Some( description: Some(
"trait Bar", "trait Bar",
@ -1839,7 +1839,7 @@ fn main() { let s<|>t = foo(); }
6..9, 6..9,
), ),
name: "Foo", name: "Foo",
kind: TRAIT_DEF, kind: TRAIT,
container_name: None, container_name: None,
description: Some( description: Some(
"trait Foo", "trait Foo",
@ -1858,7 +1858,7 @@ fn main() { let s<|>t = foo(); }
22..25, 22..25,
), ),
name: "Bar", name: "Bar",
kind: TRAIT_DEF, kind: TRAIT,
container_name: None, container_name: None,
description: Some( description: Some(
"trait Bar", "trait Bar",
@ -1933,7 +1933,7 @@ fn foo(ar<|>g: &impl Foo) {}
6..9, 6..9,
), ),
name: "Foo", name: "Foo",
kind: TRAIT_DEF, kind: TRAIT,
container_name: None, container_name: None,
description: Some( description: Some(
"trait Foo", "trait Foo",
@ -1973,7 +1973,7 @@ fn foo(ar<|>g: &impl Foo + Bar<S>) {}
6..9, 6..9,
), ),
name: "Foo", name: "Foo",
kind: TRAIT_DEF, kind: TRAIT,
container_name: None, container_name: None,
description: Some( description: Some(
"trait Foo", "trait Foo",
@ -1992,7 +1992,7 @@ fn foo(ar<|>g: &impl Foo + Bar<S>) {}
19..22, 19..22,
), ),
name: "Bar", name: "Bar",
kind: TRAIT_DEF, kind: TRAIT,
container_name: None, container_name: None,
description: Some( description: Some(
"trait Bar", "trait Bar",
@ -2049,7 +2049,7 @@ fn foo(ar<|>g: &impl Foo<S>) {}
6..9, 6..9,
), ),
name: "Foo", name: "Foo",
kind: TRAIT_DEF, kind: TRAIT,
container_name: None, container_name: None,
description: Some( description: Some(
"trait Foo", "trait Foo",
@ -2130,7 +2130,7 @@ fn main() { let s<|>t = foo(); }
6..9, 6..9,
), ),
name: "Foo", name: "Foo",
kind: TRAIT_DEF, kind: TRAIT,
container_name: None, container_name: None,
description: Some( description: Some(
"trait Foo", "trait Foo",
@ -2167,7 +2167,7 @@ fn foo(ar<|>g: &dyn Foo) {}
6..9, 6..9,
), ),
name: "Foo", name: "Foo",
kind: TRAIT_DEF, kind: TRAIT,
container_name: None, container_name: None,
description: Some( description: Some(
"trait Foo", "trait Foo",
@ -2205,7 +2205,7 @@ fn foo(ar<|>g: &dyn Foo<S>) {}
6..9, 6..9,
), ),
name: "Foo", name: "Foo",
kind: TRAIT_DEF, kind: TRAIT,
container_name: None, container_name: None,
description: Some( description: Some(
"trait Foo", "trait Foo",
@ -2265,7 +2265,7 @@ fn foo(a<|>rg: &impl ImplTrait<B<dyn DynTrait<B<S>>>>) {}
6..15, 6..15,
), ),
name: "ImplTrait", name: "ImplTrait",
kind: TRAIT_DEF, kind: TRAIT,
container_name: None, container_name: None,
description: Some( description: Some(
"trait ImplTrait", "trait ImplTrait",
@ -2303,7 +2303,7 @@ fn foo(a<|>rg: &impl ImplTrait<B<dyn DynTrait<B<S>>>>) {}
28..36, 28..36,
), ),
name: "DynTrait", name: "DynTrait",
kind: TRAIT_DEF, kind: TRAIT,
container_name: None, container_name: None,
description: Some( description: Some(
"trait DynTrait", "trait DynTrait",
@ -2370,7 +2370,7 @@ fn main() { let s<|>t = test().get(); }
6..9, 6..9,
), ),
name: "Foo", name: "Foo",
kind: TRAIT_DEF, kind: TRAIT,
container_name: None, container_name: None,
description: Some( description: Some(
"trait Foo", "trait Foo",

View file

@ -192,15 +192,14 @@ fn text_edit_from_self_param(
self_param: &ast::SelfParam, self_param: &ast::SelfParam,
new_name: &str, new_name: &str,
) -> Option<TextEdit> { ) -> Option<TextEdit> {
fn target_type_name(impl_def: &ast::ImplDef) -> Option<String> { fn target_type_name(impl_def: &ast::Impl) -> Option<String> {
if let Some(ast::TypeRef::PathType(p)) = impl_def.target_type() { if let Some(ast::TypeRef::PathType(p)) = impl_def.target_type() {
return Some(p.path()?.segment()?.name_ref()?.text().to_string()); return Some(p.path()?.segment()?.name_ref()?.text().to_string());
} }
None None
} }
let impl_def = let impl_def = find_node_at_offset::<ast::Impl>(syn, self_param.syntax().text_range().start())?;
find_node_at_offset::<ast::ImplDef>(syn, self_param.syntax().text_range().start())?;
let type_name = target_type_name(&impl_def)?; let type_name = target_type_name(&impl_def)?;
let mut replacement_text = String::from(new_name); let mut replacement_text = String::from(new_name);

View file

@ -647,7 +647,7 @@ fn highlight_element(
fn is_child_of_impl(element: &SyntaxElement) -> bool { fn is_child_of_impl(element: &SyntaxElement) -> bool {
match element.parent() { match element.parent() {
Some(e) => e.kind() == IMPL_DEF, Some(e) => e.kind() == IMPL,
_ => false, _ => false,
} }
} }
@ -708,7 +708,7 @@ fn highlight_name_by_syntax(name: ast::Name) -> Highlight {
STRUCT => HighlightTag::Struct, STRUCT => HighlightTag::Struct,
ENUM => HighlightTag::Enum, ENUM => HighlightTag::Enum,
UNION => HighlightTag::Union, UNION => HighlightTag::Union,
TRAIT_DEF => HighlightTag::Trait, TRAIT => HighlightTag::Trait,
TYPE_ALIAS => HighlightTag::TypeAlias, TYPE_ALIAS => HighlightTag::TypeAlias,
TYPE_PARAM => HighlightTag::TypeParam, TYPE_PARAM => HighlightTag::TypeParam,
RECORD_FIELD => HighlightTag::Field, RECORD_FIELD => HighlightTag::Field,

View file

@ -162,7 +162,7 @@ pub fn classify_name(sema: &Semantics<RootDatabase>, name: &ast::Name) -> Option
let def: hir::Enum = sema.to_def(&it)?; let def: hir::Enum = sema.to_def(&it)?;
Some(NameClass::Definition(Definition::ModuleDef(def.into()))) Some(NameClass::Definition(Definition::ModuleDef(def.into())))
}, },
ast::TraitDef(it) => { ast::Trait(it) => {
let def: hir::Trait = sema.to_def(&it)?; let def: hir::Trait = sema.to_def(&it)?;
Some(NameClass::Definition(Definition::ModuleDef(def.into()))) Some(NameClass::Definition(Definition::ModuleDef(def.into())))
}, },

View file

@ -344,7 +344,7 @@ impl Query {
} }
fn is_type(kind: SyntaxKind) -> bool { fn is_type(kind: SyntaxKind) -> bool {
matches!(kind, STRUCT | ENUM | TRAIT_DEF | TYPE_ALIAS) matches!(kind, STRUCT | ENUM | TRAIT | TYPE_ALIAS)
} }
/// The actual data that is stored in the index. It should be as compact as /// The actual data that is stored in the index. It should be as compact as
@ -400,7 +400,7 @@ fn to_symbol(node: &SyntaxNode) -> Option<(SmolStr, SyntaxNodePtr, TextRange)> {
ast::Fn(it) => decl(it), ast::Fn(it) => decl(it),
ast::Struct(it) => decl(it), ast::Struct(it) => decl(it),
ast::Enum(it) => decl(it), ast::Enum(it) => decl(it),
ast::TraitDef(it) => decl(it), ast::Trait(it) => decl(it),
ast::Module(it) => decl(it), ast::Module(it) => decl(it),
ast::TypeAlias(it) => decl(it), ast::TypeAlias(it) => decl(it),
ast::Const(it) => decl(it), ast::Const(it) => decl(it),

View file

@ -150,8 +150,8 @@ pub(crate) fn reparser(
EXTERN_ITEM_LIST => items::extern_item_list, EXTERN_ITEM_LIST => items::extern_item_list,
TOKEN_TREE if first_child? == T!['{'] => items::token_tree, TOKEN_TREE if first_child? == T!['{'] => items::token_tree,
ASSOC_ITEM_LIST => match parent? { ASSOC_ITEM_LIST => match parent? {
IMPL_DEF => items::impl_item_list, IMPL => items::impl_item_list,
TRAIT_DEF => items::trait_item_list, TRAIT => items::trait_item_list,
_ => return None, _ => return None,
}, },
ITEM_LIST => items::mod_item_list, ITEM_LIST => items::mod_item_list,

View file

@ -193,7 +193,7 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Resul
// unsafe auto trait T {} // unsafe auto trait T {}
T![trait] => { T![trait] => {
traits::trait_def(p); traits::trait_def(p);
m.complete(p, TRAIT_DEF); m.complete(p, TRAIT);
} }
// test unsafe_impl // test unsafe_impl
@ -221,7 +221,7 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Resul
// unsafe default impl Foo {} // unsafe default impl Foo {}
T![impl] => { T![impl] => {
traits::impl_def(p); traits::impl_def(p);
m.complete(p, IMPL_DEF); m.complete(p, IMPL);
} }
// test existential_type // test existential_type

View file

@ -133,8 +133,8 @@ pub enum SyntaxKind {
USE, USE,
STATIC, STATIC,
CONST, CONST,
TRAIT_DEF, TRAIT,
IMPL_DEF, IMPL,
TYPE_ALIAS, TYPE_ALIAS,
MACRO_CALL, MACRO_CALL,
TOKEN_TREE, TOKEN_TREE,

View file

@ -100,17 +100,18 @@ impl Fn {
pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
} }
#[derive(Debug, Clone, PartialEq, Eq, Hash)] #[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ImplDef { pub struct Impl {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
impl ast::AttrsOwner for ImplDef {} impl ast::AttrsOwner for Impl {}
impl ast::VisibilityOwner for ImplDef {} impl ast::VisibilityOwner for Impl {}
impl ast::GenericParamsOwner for ImplDef {} impl ast::GenericParamsOwner for Impl {}
impl ImplDef { impl Impl {
pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) } pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) }
pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) } pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) }
pub fn impl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![impl]) } pub fn impl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![impl]) }
pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) } pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) }
pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) } pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) }
pub fn assoc_item_list(&self) -> Option<AssocItemList> { support::child(&self.syntax) } pub fn assoc_item_list(&self) -> Option<AssocItemList> { support::child(&self.syntax) }
@ -169,15 +170,15 @@ impl Struct {
pub fn field_list(&self) -> Option<FieldList> { support::child(&self.syntax) } pub fn field_list(&self) -> Option<FieldList> { support::child(&self.syntax) }
} }
#[derive(Debug, Clone, PartialEq, Eq, Hash)] #[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct TraitDef { pub struct Trait {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
impl ast::AttrsOwner for TraitDef {} impl ast::AttrsOwner for Trait {}
impl ast::NameOwner for TraitDef {} impl ast::NameOwner for Trait {}
impl ast::VisibilityOwner for TraitDef {} impl ast::VisibilityOwner for Trait {}
impl ast::GenericParamsOwner for TraitDef {} impl ast::GenericParamsOwner for Trait {}
impl ast::TypeBoundsOwner for TraitDef {} impl ast::TypeBoundsOwner for Trait {}
impl TraitDef { impl Trait {
pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) } pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) }
pub fn auto_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![auto]) } pub fn auto_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![auto]) }
pub fn trait_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![trait]) } pub fn trait_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![trait]) }
@ -1278,12 +1279,12 @@ pub enum Item {
ExternBlock(ExternBlock), ExternBlock(ExternBlock),
ExternCrate(ExternCrate), ExternCrate(ExternCrate),
Fn(Fn), Fn(Fn),
ImplDef(ImplDef), Impl(Impl),
MacroCall(MacroCall), MacroCall(MacroCall),
Module(Module), Module(Module),
Static(Static), Static(Static),
Struct(Struct), Struct(Struct),
TraitDef(TraitDef), Trait(Trait),
TypeAlias(TypeAlias), TypeAlias(TypeAlias),
Union(Union), Union(Union),
Use(Use), Use(Use),
@ -1477,8 +1478,8 @@ impl AstNode for Fn {
} }
fn syntax(&self) -> &SyntaxNode { &self.syntax } fn syntax(&self) -> &SyntaxNode { &self.syntax }
} }
impl AstNode for ImplDef { impl AstNode for Impl {
fn can_cast(kind: SyntaxKind) -> bool { kind == IMPL_DEF } fn can_cast(kind: SyntaxKind) -> bool { kind == IMPL }
fn cast(syntax: SyntaxNode) -> Option<Self> { fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) { if Self::can_cast(syntax.kind()) {
Some(Self { syntax }) Some(Self { syntax })
@ -1532,8 +1533,8 @@ impl AstNode for Struct {
} }
fn syntax(&self) -> &SyntaxNode { &self.syntax } fn syntax(&self) -> &SyntaxNode { &self.syntax }
} }
impl AstNode for TraitDef { impl AstNode for Trait {
fn can_cast(kind: SyntaxKind) -> bool { kind == TRAIT_DEF } fn can_cast(kind: SyntaxKind) -> bool { kind == TRAIT }
fn cast(syntax: SyntaxNode) -> Option<Self> { fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) { if Self::can_cast(syntax.kind()) {
Some(Self { syntax }) Some(Self { syntax })
@ -2790,8 +2791,8 @@ impl From<ExternCrate> for Item {
impl From<Fn> for Item { impl From<Fn> for Item {
fn from(node: Fn) -> Item { Item::Fn(node) } fn from(node: Fn) -> Item { Item::Fn(node) }
} }
impl From<ImplDef> for Item { impl From<Impl> for Item {
fn from(node: ImplDef) -> Item { Item::ImplDef(node) } fn from(node: Impl) -> Item { Item::Impl(node) }
} }
impl From<MacroCall> for Item { impl From<MacroCall> for Item {
fn from(node: MacroCall) -> Item { Item::MacroCall(node) } fn from(node: MacroCall) -> Item { Item::MacroCall(node) }
@ -2805,8 +2806,8 @@ impl From<Static> for Item {
impl From<Struct> for Item { impl From<Struct> for Item {
fn from(node: Struct) -> Item { Item::Struct(node) } fn from(node: Struct) -> Item { Item::Struct(node) }
} }
impl From<TraitDef> for Item { impl From<Trait> for Item {
fn from(node: TraitDef) -> Item { Item::TraitDef(node) } fn from(node: Trait) -> Item { Item::Trait(node) }
} }
impl From<TypeAlias> for Item { impl From<TypeAlias> for Item {
fn from(node: TypeAlias) -> Item { Item::TypeAlias(node) } fn from(node: TypeAlias) -> Item { Item::TypeAlias(node) }
@ -2820,8 +2821,8 @@ impl From<Use> for Item {
impl AstNode for Item { impl AstNode for Item {
fn can_cast(kind: SyntaxKind) -> bool { fn can_cast(kind: SyntaxKind) -> bool {
match kind { 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_DEF | TYPE_ALIAS | UNION | USE => true, | STATIC | STRUCT | TRAIT | TYPE_ALIAS | UNION | USE => true,
_ => false, _ => false,
} }
} }
@ -2832,12 +2833,12 @@ impl AstNode for Item {
EXTERN_BLOCK => Item::ExternBlock(ExternBlock { syntax }), EXTERN_BLOCK => Item::ExternBlock(ExternBlock { syntax }),
EXTERN_CRATE => Item::ExternCrate(ExternCrate { syntax }), EXTERN_CRATE => Item::ExternCrate(ExternCrate { syntax }),
FN => Item::Fn(Fn { syntax }), FN => Item::Fn(Fn { syntax }),
IMPL_DEF => Item::ImplDef(ImplDef { syntax }), IMPL => Item::Impl(Impl { syntax }),
MACRO_CALL => Item::MacroCall(MacroCall { syntax }), MACRO_CALL => Item::MacroCall(MacroCall { syntax }),
MODULE => Item::Module(Module { syntax }), MODULE => Item::Module(Module { syntax }),
STATIC => Item::Static(Static { syntax }), STATIC => Item::Static(Static { syntax }),
STRUCT => Item::Struct(Struct { syntax }), STRUCT => Item::Struct(Struct { syntax }),
TRAIT_DEF => Item::TraitDef(TraitDef { syntax }), TRAIT => Item::Trait(Trait { syntax }),
TYPE_ALIAS => Item::TypeAlias(TypeAlias { syntax }), TYPE_ALIAS => Item::TypeAlias(TypeAlias { syntax }),
UNION => Item::Union(Union { syntax }), UNION => Item::Union(Union { syntax }),
USE => Item::Use(Use { syntax }), USE => Item::Use(Use { syntax }),
@ -2852,12 +2853,12 @@ impl AstNode for Item {
Item::ExternBlock(it) => &it.syntax, Item::ExternBlock(it) => &it.syntax,
Item::ExternCrate(it) => &it.syntax, Item::ExternCrate(it) => &it.syntax,
Item::Fn(it) => &it.syntax, Item::Fn(it) => &it.syntax,
Item::ImplDef(it) => &it.syntax, Item::Impl(it) => &it.syntax,
Item::MacroCall(it) => &it.syntax, Item::MacroCall(it) => &it.syntax,
Item::Module(it) => &it.syntax, Item::Module(it) => &it.syntax,
Item::Static(it) => &it.syntax, Item::Static(it) => &it.syntax,
Item::Struct(it) => &it.syntax, Item::Struct(it) => &it.syntax,
Item::TraitDef(it) => &it.syntax, Item::Trait(it) => &it.syntax,
Item::TypeAlias(it) => &it.syntax, Item::TypeAlias(it) => &it.syntax,
Item::Union(it) => &it.syntax, Item::Union(it) => &it.syntax,
Item::Use(it) => &it.syntax, Item::Use(it) => &it.syntax,
@ -3491,7 +3492,7 @@ impl std::fmt::Display for Fn {
std::fmt::Display::fmt(self.syntax(), f) 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 { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f) std::fmt::Display::fmt(self.syntax(), f)
} }
@ -3516,7 +3517,7 @@ impl std::fmt::Display for Struct {
std::fmt::Display::fmt(self.syntax(), f) std::fmt::Display::fmt(self.syntax(), f)
} }
} }
impl std::fmt::Display for TraitDef { impl std::fmt::Display for Trait {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f) std::fmt::Display::fmt(self.syntax(), f)
} }

View file

@ -141,7 +141,7 @@ impl ast::UseTreeList {
} }
} }
impl ast::ImplDef { impl ast::Impl {
pub fn target_type(&self) -> Option<ast::TypeRef> { pub fn target_type(&self) -> Option<ast::TypeRef> {
match self.target() { match self.target() {
(Some(t), None) | (_, Some(t)) => Some(t), (Some(t), None) | (_, Some(t)) => Some(t),
@ -481,10 +481,10 @@ impl ast::DocCommentsOwner for ast::RecordField {}
impl ast::DocCommentsOwner for ast::TupleField {} impl ast::DocCommentsOwner for ast::TupleField {}
impl ast::DocCommentsOwner for ast::Enum {} impl ast::DocCommentsOwner for ast::Enum {}
impl ast::DocCommentsOwner for ast::Variant {} impl ast::DocCommentsOwner for ast::Variant {}
impl ast::DocCommentsOwner for ast::TraitDef {} impl ast::DocCommentsOwner for ast::Trait {}
impl ast::DocCommentsOwner for ast::Module {} impl ast::DocCommentsOwner for ast::Module {}
impl ast::DocCommentsOwner for ast::Static {} impl ast::DocCommentsOwner for ast::Static {}
impl ast::DocCommentsOwner for ast::Const {} impl ast::DocCommentsOwner for ast::Const {}
impl ast::DocCommentsOwner for ast::TypeAlias {} impl ast::DocCommentsOwner for ast::TypeAlias {}
impl ast::DocCommentsOwner for ast::ImplDef {} impl ast::DocCommentsOwner for ast::Impl {}
impl ast::DocCommentsOwner for ast::MacroCall {} impl ast::DocCommentsOwner for ast::MacroCall {}

View file

@ -146,7 +146,7 @@ fn n_attached_trivias<'a>(
trivias: impl Iterator<Item = (SyntaxKind, &'a str)>, trivias: impl Iterator<Item = (SyntaxKind, &'a str)>,
) -> usize { ) -> usize {
match kind { match kind {
MACRO_CALL | CONST | TYPE_ALIAS | STRUCT | ENUM | VARIANT | FN | TRAIT_DEF | MODULE MACRO_CALL | CONST | TYPE_ALIAS | STRUCT | ENUM | VARIANT | FN | TRAIT | MODULE
| RECORD_FIELD | STATIC => { | RECORD_FIELD | STATIC => {
let mut res = 0; let mut res = 0;
let mut trivias = trivias.enumerate().peekable(); let mut trivias = trivias.enumerate().peekable();

View file

@ -204,7 +204,7 @@ fn validate_visibility(vis: ast::Visibility, errors: &mut Vec<SyntaxError>) {
_ => return, _ => 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, Some(it) => it,
None => return, None => return,
}; };

View file

@ -1,5 +1,5 @@
SOURCE_FILE@0..183 SOURCE_FILE@0..183
IMPL_DEF@0..182 IMPL@0..182
IMPL_KW@0..4 "impl" IMPL_KW@0..4 "impl"
WHITESPACE@4..5 " " WHITESPACE@4..5 " "
PATH_TYPE@5..13 PATH_TYPE@5..13

View file

@ -75,7 +75,7 @@ SOURCE_FILE@0..112
ERROR@54..55 ERROR@54..55
COMMA@54..55 "," COMMA@54..55 ","
WHITESPACE@55..56 " " WHITESPACE@55..56 " "
IMPL_DEF@56..60 IMPL@56..60
IMPL_KW@56..60 "impl" IMPL_KW@56..60 "impl"
EXPR_STMT@60..61 EXPR_STMT@60..61
ERROR@60..61 ERROR@60..61
@ -133,7 +133,7 @@ SOURCE_FILE@0..112
ERROR@96..97 ERROR@96..97
COMMA@96..97 "," COMMA@96..97 ","
WHITESPACE@97..98 " " WHITESPACE@97..98 " "
TRAIT_DEF@98..104 TRAIT@98..104
TRAIT_KW@98..103 "trait" TRAIT_KW@98..103 "trait"
ERROR@103..104 ERROR@103..104
COMMA@103..104 "," COMMA@103..104 ","

View file

@ -1,5 +1,5 @@
SOURCE_FILE@0..38 SOURCE_FILE@0..38
IMPL_DEF@0..14 IMPL@0..14
IMPL_KW@0..4 "impl" IMPL_KW@0..4 "impl"
GENERIC_PARAM_LIST@4..14 GENERIC_PARAM_LIST@4..14
L_ANGLE@4..5 "<" L_ANGLE@4..5 "<"
@ -17,7 +17,7 @@ SOURCE_FILE@0..38
IDENT@8..13 "Clone" IDENT@8..13 "Clone"
R_ANGLE@13..14 ">" R_ANGLE@13..14 ">"
WHITESPACE@14..15 "\n" WHITESPACE@14..15 "\n"
IMPL_DEF@15..37 IMPL@15..37
IMPL_KW@15..19 "impl" IMPL_KW@15..19 "impl"
GENERIC_PARAM_LIST@19..22 GENERIC_PARAM_LIST@19..22
L_ANGLE@19..20 "<" L_ANGLE@19..20 "<"

View file

@ -1,5 +1,5 @@
SOURCE_FILE@0..118 SOURCE_FILE@0..118
IMPL_DEF@0..117 IMPL@0..117
IMPL_KW@0..4 "impl" IMPL_KW@0..4 "impl"
WHITESPACE@4..5 " " WHITESPACE@4..5 " "
PATH_TYPE@5..6 PATH_TYPE@5..6

View file

@ -1,5 +1,5 @@
SOURCE_FILE@0..39 SOURCE_FILE@0..39
TRAIT_DEF@0..38 TRAIT@0..38
TRAIT_KW@0..5 "trait" TRAIT_KW@0..5 "trait"
WHITESPACE@5..6 " " WHITESPACE@5..6 " "
NAME@6..7 NAME@6..7

View file

@ -17,7 +17,7 @@ SOURCE_FILE@0..30
LIFETIME@16..21 "\'loop" LIFETIME@16..21 "\'loop"
COLON@21..22 ":" COLON@21..22 ":"
WHITESPACE@22..23 " " WHITESPACE@22..23 " "
IMPL_DEF@23..27 IMPL@23..27
IMPL_KW@23..27 "impl" IMPL_KW@23..27 "impl"
WHITESPACE@27..28 "\n" WHITESPACE@27..28 "\n"
R_CURLY@28..29 "}" R_CURLY@28..29 "}"

View file

@ -1,5 +1,5 @@
SOURCE_FILE@0..87 SOURCE_FILE@0..87
IMPL_DEF@0..12 IMPL@0..12
IMPL_KW@0..4 "impl" IMPL_KW@0..4 "impl"
WHITESPACE@4..5 " " WHITESPACE@4..5 " "
PATH_TYPE@5..9 PATH_TYPE@5..9
@ -12,7 +12,7 @@ SOURCE_FILE@0..87
L_CURLY@10..11 "{" L_CURLY@10..11 "{"
R_CURLY@11..12 "}" R_CURLY@11..12 "}"
WHITESPACE@12..13 "\n" WHITESPACE@12..13 "\n"
IMPL_DEF@13..33 IMPL@13..33
IMPL_KW@13..17 "impl" IMPL_KW@13..17 "impl"
WHITESPACE@17..18 " " WHITESPACE@17..18 " "
PATH_TYPE@18..24 PATH_TYPE@18..24
@ -33,10 +33,10 @@ SOURCE_FILE@0..87
L_CURLY@31..32 "{" L_CURLY@31..32 "{"
R_CURLY@32..33 "}" R_CURLY@32..33 "}"
WHITESPACE@33..34 "\n" WHITESPACE@33..34 "\n"
IMPL_DEF@34..38 IMPL@34..38
IMPL_KW@34..38 "impl" IMPL_KW@34..38 "impl"
WHITESPACE@38..39 " " WHITESPACE@38..39 " "
IMPL_DEF@39..54 IMPL@39..54
IMPL_KW@39..43 "impl" IMPL_KW@39..43 "impl"
WHITESPACE@43..44 " " WHITESPACE@43..44 " "
PATH_TYPE@44..51 PATH_TYPE@44..51
@ -49,7 +49,7 @@ SOURCE_FILE@0..87
L_CURLY@52..53 "{" L_CURLY@52..53 "{"
R_CURLY@53..54 "}" R_CURLY@53..54 "}"
WHITESPACE@54..55 "\n" WHITESPACE@54..55 "\n"
IMPL_DEF@55..70 IMPL@55..70
IMPL_KW@55..59 "impl" IMPL_KW@55..59 "impl"
WHITESPACE@59..60 " " WHITESPACE@59..60 " "
PATH_TYPE@60..66 PATH_TYPE@60..66
@ -60,7 +60,7 @@ SOURCE_FILE@0..87
WHITESPACE@66..67 " " WHITESPACE@66..67 " "
FOR_KW@67..70 "for" FOR_KW@67..70 "for"
WHITESPACE@70..71 " " WHITESPACE@70..71 " "
IMPL_DEF@71..86 IMPL@71..86
IMPL_KW@71..75 "impl" IMPL_KW@71..75 "impl"
WHITESPACE@75..76 " " WHITESPACE@75..76 " "
PATH_TYPE@76..83 PATH_TYPE@76..83

View file

@ -1,5 +1,5 @@
SOURCE_FILE@0..62 SOURCE_FILE@0..62
TRAIT_DEF@0..61 TRAIT@0..61
TRAIT_KW@0..5 "trait" TRAIT_KW@0..5 "trait"
WHITESPACE@5..6 " " WHITESPACE@5..6 " "
NAME@6..7 NAME@6..7

View file

@ -1,5 +1,5 @@
SOURCE_FILE@0..83 SOURCE_FILE@0..83
IMPL_DEF@0..82 IMPL@0..82
IMPL_KW@0..4 "impl" IMPL_KW@0..4 "impl"
WHITESPACE@4..5 " " WHITESPACE@4..5 " "
PATH_TYPE@5..6 PATH_TYPE@5..6

View file

@ -1,5 +1,5 @@
SOURCE_FILE@0..128 SOURCE_FILE@0..128
IMPL_DEF@0..127 IMPL@0..127
IMPL_KW@0..4 "impl" IMPL_KW@0..4 "impl"
WHITESPACE@4..5 " " WHITESPACE@4..5 " "
PATH_TYPE@5..6 PATH_TYPE@5..6

View file

@ -1,5 +1,5 @@
SOURCE_FILE@0..18 SOURCE_FILE@0..18
TRAIT_DEF@0..17 TRAIT@0..17
UNSAFE_KW@0..6 "unsafe" UNSAFE_KW@0..6 "unsafe"
WHITESPACE@6..7 " " WHITESPACE@6..7 " "
TRAIT_KW@7..12 "trait" TRAIT_KW@7..12 "trait"

View file

@ -1,5 +1,5 @@
SOURCE_FILE@0..69 SOURCE_FILE@0..69
IMPL_DEF@0..68 IMPL@0..68
IMPL_KW@0..4 "impl" IMPL_KW@0..4 "impl"
WHITESPACE@4..5 " " WHITESPACE@4..5 " "
PATH_TYPE@5..6 PATH_TYPE@5..6

View file

@ -1,5 +1,5 @@
SOURCE_FILE@0..89 SOURCE_FILE@0..89
IMPL_DEF@0..88 IMPL@0..88
IMPL_KW@0..4 "impl" IMPL_KW@0..4 "impl"
WHITESPACE@4..5 " " WHITESPACE@4..5 " "
PATH_TYPE@5..6 PATH_TYPE@5..6

View file

@ -1,5 +1,5 @@
SOURCE_FILE@0..101 SOURCE_FILE@0..101
TRAIT_DEF@0..41 TRAIT@0..41
TRAIT_KW@0..5 "trait" TRAIT_KW@0..5 "trait"
WHITESPACE@5..6 " " WHITESPACE@5..6 " "
NAME@6..7 NAME@6..7
@ -52,7 +52,7 @@ SOURCE_FILE@0..101
L_CURLY@39..40 "{" L_CURLY@39..40 "{"
R_CURLY@40..41 "}" R_CURLY@40..41 "}"
WHITESPACE@41..42 "\n" WHITESPACE@41..42 "\n"
TRAIT_DEF@42..100 TRAIT@42..100
TRAIT_KW@42..47 "trait" TRAIT_KW@42..47 "trait"
WHITESPACE@47..48 " " WHITESPACE@47..48 " "
NAME@48..49 NAME@48..49

View file

@ -1,5 +1,5 @@
SOURCE_FILE@0..27 SOURCE_FILE@0..27
IMPL_DEF@0..26 IMPL@0..26
UNSAFE_KW@0..6 "unsafe" UNSAFE_KW@0..6 "unsafe"
WHITESPACE@6..7 " " WHITESPACE@6..7 " "
DEFAULT_KW@7..14 "default" DEFAULT_KW@7..14 "default"

View file

@ -1,5 +1,5 @@
SOURCE_FILE@0..22 SOURCE_FILE@0..22
TRAIT_DEF@0..21 TRAIT@0..21
TRAIT_KW@0..5 "trait" TRAIT_KW@0..5 "trait"
WHITESPACE@5..6 " " WHITESPACE@5..6 " "
NAME@6..7 NAME@6..7

View file

@ -1,5 +1,5 @@
SOURCE_FILE@0..20 SOURCE_FILE@0..20
IMPL_DEF@0..19 IMPL@0..19
IMPL_KW@0..4 "impl" IMPL_KW@0..4 "impl"
WHITESPACE@4..5 " " WHITESPACE@4..5 " "
BANG@5..6 "!" BANG@5..6 "!"

View file

@ -1,5 +1,5 @@
SOURCE_FILE@0..12 SOURCE_FILE@0..12
IMPL_DEF@0..11 IMPL@0..11
IMPL_KW@0..4 "impl" IMPL_KW@0..4 "impl"
WHITESPACE@4..5 " " WHITESPACE@4..5 " "
PATH_TYPE@5..8 PATH_TYPE@5..8

View file

@ -1,5 +1,5 @@
SOURCE_FILE@0..19 SOURCE_FILE@0..19
IMPL_DEF@0..18 IMPL@0..18
UNSAFE_KW@0..6 "unsafe" UNSAFE_KW@0..6 "unsafe"
WHITESPACE@6..7 " " WHITESPACE@6..7 " "
IMPL_KW@7..11 "impl" IMPL_KW@7..11 "impl"

View file

@ -1,5 +1,5 @@
SOURCE_FILE@0..16 SOURCE_FILE@0..16
TRAIT_DEF@0..15 TRAIT@0..15
AUTO_KW@0..4 "auto" AUTO_KW@0..4 "auto"
WHITESPACE@4..5 " " WHITESPACE@4..5 " "
TRAIT_KW@5..10 "trait" TRAIT_KW@5..10 "trait"

View file

@ -1,5 +1,5 @@
SOURCE_FILE@0..23 SOURCE_FILE@0..23
TRAIT_DEF@0..22 TRAIT@0..22
UNSAFE_KW@0..6 "unsafe" UNSAFE_KW@0..6 "unsafe"
WHITESPACE@6..7 " " WHITESPACE@6..7 " "
AUTO_KW@7..11 "auto" AUTO_KW@7..11 "auto"

View file

@ -1,5 +1,5 @@
SOURCE_FILE@0..20 SOURCE_FILE@0..20
IMPL_DEF@0..19 IMPL@0..19
DEFAULT_KW@0..7 "default" DEFAULT_KW@0..7 "default"
WHITESPACE@7..8 " " WHITESPACE@7..8 " "
IMPL_KW@8..12 "impl" IMPL_KW@8..12 "impl"

View file

@ -8,7 +8,7 @@ SOURCE_FILE@0..94
L_CURLY@6..7 "{" L_CURLY@6..7 "{"
R_CURLY@7..8 "}" R_CURLY@7..8 "}"
WHITESPACE@8..9 "\n" WHITESPACE@8..9 "\n"
IMPL_DEF@9..93 IMPL@9..93
IMPL_KW@9..13 "impl" IMPL_KW@9..13 "impl"
WHITESPACE@13..14 " " WHITESPACE@13..14 " "
PATH_TYPE@14..15 PATH_TYPE@14..15

View file

@ -1,5 +1,5 @@
SOURCE_FILE@0..69 SOURCE_FILE@0..69
IMPL_DEF@0..68 IMPL@0..68
IMPL_KW@0..4 "impl" IMPL_KW@0..4 "impl"
WHITESPACE@4..5 " " WHITESPACE@4..5 " "
PATH_TYPE@5..6 PATH_TYPE@5..6

View file

@ -1,5 +1,5 @@
SOURCE_FILE@0..29 SOURCE_FILE@0..29
IMPL_DEF@0..28 IMPL@0..28
IMPL_KW@0..4 "impl" IMPL_KW@0..4 "impl"
GENERIC_PARAM_LIST@4..18 GENERIC_PARAM_LIST@4..18
L_ANGLE@4..5 "<" L_ANGLE@4..5 "<"

View file

@ -1,5 +1,5 @@
SOURCE_FILE@0..83 SOURCE_FILE@0..83
TRAIT_DEF@0..18 TRAIT@0..18
TRAIT_KW@0..5 "trait" TRAIT_KW@0..5 "trait"
WHITESPACE@5..6 " " WHITESPACE@5..6 " "
NAME@6..7 NAME@6..7
@ -31,7 +31,7 @@ SOURCE_FILE@0..83
R_ANGLE@16..17 ">" R_ANGLE@16..17 ">"
SEMICOLON@17..18 ";" SEMICOLON@17..18 ";"
WHITESPACE@18..19 "\n" WHITESPACE@18..19 "\n"
TRAIT_DEF@19..51 TRAIT@19..51
TRAIT_KW@19..24 "trait" TRAIT_KW@19..24 "trait"
WHITESPACE@24..25 " " WHITESPACE@24..25 " "
NAME@25..26 NAME@25..26
@ -82,7 +82,7 @@ SOURCE_FILE@0..83
IDENT@46..50 "Copy" IDENT@46..50 "Copy"
SEMICOLON@50..51 ";" SEMICOLON@50..51 ";"
WHITESPACE@51..52 "\n" WHITESPACE@51..52 "\n"
TRAIT_DEF@52..82 TRAIT@52..82
TRAIT_KW@52..57 "trait" TRAIT_KW@52..57 "trait"
WHITESPACE@57..58 " " WHITESPACE@57..58 " "
NAME@58..59 NAME@58..59

View file

@ -1,5 +1,5 @@
SOURCE_FILE@0..50 SOURCE_FILE@0..50
IMPL_DEF@0..49 IMPL@0..49
IMPL_KW@0..4 "impl" IMPL_KW@0..4 "impl"
WHITESPACE@4..5 " " WHITESPACE@4..5 " "
PATH_TYPE@5..6 PATH_TYPE@5..6

View file

@ -1,5 +1,5 @@
SOURCE_FILE@0..27 SOURCE_FILE@0..27
IMPL_DEF@0..26 IMPL@0..26
DEFAULT_KW@0..7 "default" DEFAULT_KW@0..7 "default"
WHITESPACE@7..8 " " WHITESPACE@7..8 " "
UNSAFE_KW@8..14 "unsafe" UNSAFE_KW@8..14 "unsafe"

View file

@ -1,5 +1,5 @@
SOURCE_FILE@0..96 SOURCE_FILE@0..96
TRAIT_DEF@0..36 TRAIT@0..36
TRAIT_KW@0..5 "trait" TRAIT_KW@0..5 "trait"
WHITESPACE@5..6 " " WHITESPACE@5..6 " "
NAME@6..14 NAME@6..14
@ -20,7 +20,7 @@ SOURCE_FILE@0..96
WHITESPACE@34..35 "\n" WHITESPACE@34..35 "\n"
R_CURLY@35..36 "}" R_CURLY@35..36 "}"
WHITESPACE@36..38 "\n\n" WHITESPACE@36..38 "\n\n"
TRAIT_DEF@38..95 TRAIT@38..95
TRAIT_KW@38..43 "trait" TRAIT_KW@38..43 "trait"
WHITESPACE@43..44 " " WHITESPACE@43..44 " "
NAME@44..57 NAME@44..57

View file

@ -8,7 +8,7 @@ SOURCE_FILE@0..199
IDENT@69..72 "Foo" IDENT@69..72 "Foo"
SEMICOLON@72..73 ";" SEMICOLON@72..73 ";"
WHITESPACE@73..75 "\n\n" WHITESPACE@73..75 "\n\n"
IMPL_DEF@75..141 IMPL@75..141
IMPL_KW@75..79 "impl" IMPL_KW@75..79 "impl"
WHITESPACE@79..80 " " WHITESPACE@79..80 " "
PATH_TYPE@80..83 PATH_TYPE@80..83

View file

@ -89,7 +89,7 @@ SOURCE_FILE@0..686
WHITESPACE@461..463 "\n\n" WHITESPACE@461..463 "\n\n"
COMMENT@463..523 "// https://github.com ..." COMMENT@463..523 "// https://github.com ..."
WHITESPACE@523..524 "\n" WHITESPACE@523..524 "\n"
IMPL_DEF@524..685 IMPL@524..685
IMPL_KW@524..528 "impl" IMPL_KW@524..528 "impl"
WHITESPACE@528..529 " " WHITESPACE@528..529 " "
PATH_TYPE@529..537 PATH_TYPE@529..537

View file

@ -186,7 +186,7 @@ SOURCE_FILE@0..519
L_CURLY@170..171 "{" L_CURLY@170..171 "{"
R_CURLY@171..172 "}" R_CURLY@171..172 "}"
WHITESPACE@172..174 "\n\n" WHITESPACE@172..174 "\n\n"
TRAIT_DEF@174..236 TRAIT@174..236
TRAIT_KW@174..179 "trait" TRAIT_KW@174..179 "trait"
WHITESPACE@179..180 " " WHITESPACE@179..180 " "
NAME@180..183 NAME@180..183
@ -251,7 +251,7 @@ SOURCE_FILE@0..519
WHITESPACE@234..235 "\n" WHITESPACE@234..235 "\n"
R_CURLY@235..236 "}" R_CURLY@235..236 "}"
WHITESPACE@236..238 "\n\n" WHITESPACE@236..238 "\n\n"
IMPL_DEF@238..519 IMPL@238..519
IMPL_KW@238..242 "impl" IMPL_KW@238..242 "impl"
WHITESPACE@242..243 " " WHITESPACE@242..243 " "
PATH_TYPE@243..244 PATH_TYPE@243..244

View file

@ -1,5 +1,5 @@
SOURCE_FILE@0..170 SOURCE_FILE@0..170
TRAIT_DEF@0..169 TRAIT@0..169
TRAIT_KW@0..5 "trait" TRAIT_KW@0..5 "trait"
WHITESPACE@5..6 " " WHITESPACE@5..6 " "
NAME@6..7 NAME@6..7

View file

@ -1,5 +1,5 @@
SOURCE_FILE@0..137 SOURCE_FILE@0..137
IMPL_DEF@0..136 IMPL@0..136
IMPL_KW@0..4 "impl" IMPL_KW@0..4 "impl"
WHITESPACE@4..5 " " WHITESPACE@4..5 " "
PATH_TYPE@5..6 PATH_TYPE@5..6

View file

@ -1,5 +1,5 @@
SOURCE_FILE@0..46 SOURCE_FILE@0..46
IMPL_DEF@0..45 IMPL@0..45
IMPL_KW@0..4 "impl" IMPL_KW@0..4 "impl"
WHITESPACE@4..5 " " WHITESPACE@4..5 " "
PATH_TYPE@5..6 PATH_TYPE@5..6

View file

@ -924,7 +924,7 @@ pub(crate) fn handle_code_lens(
.filter(|it| { .filter(|it| {
matches!( matches!(
it.kind, it.kind,
SyntaxKind::TRAIT_DEF SyntaxKind::TRAIT
| SyntaxKind::STRUCT | SyntaxKind::STRUCT
| SyntaxKind::ENUM | SyntaxKind::ENUM
| SyntaxKind::UNION | SyntaxKind::UNION

View file

@ -35,14 +35,14 @@ pub(crate) fn symbol_kind(syntax_kind: SyntaxKind) -> lsp_types::SymbolKind {
SyntaxKind::STRUCT => lsp_types::SymbolKind::Struct, SyntaxKind::STRUCT => lsp_types::SymbolKind::Struct,
SyntaxKind::ENUM => lsp_types::SymbolKind::Enum, SyntaxKind::ENUM => lsp_types::SymbolKind::Enum,
SyntaxKind::VARIANT => lsp_types::SymbolKind::EnumMember, SyntaxKind::VARIANT => lsp_types::SymbolKind::EnumMember,
SyntaxKind::TRAIT_DEF => lsp_types::SymbolKind::Interface, SyntaxKind::TRAIT => lsp_types::SymbolKind::Interface,
SyntaxKind::MACRO_CALL => lsp_types::SymbolKind::Function, SyntaxKind::MACRO_CALL => lsp_types::SymbolKind::Function,
SyntaxKind::MODULE => lsp_types::SymbolKind::Module, SyntaxKind::MODULE => lsp_types::SymbolKind::Module,
SyntaxKind::TYPE_ALIAS => lsp_types::SymbolKind::TypeParameter, SyntaxKind::TYPE_ALIAS => lsp_types::SymbolKind::TypeParameter,
SyntaxKind::RECORD_FIELD => lsp_types::SymbolKind::Field, SyntaxKind::RECORD_FIELD => lsp_types::SymbolKind::Field,
SyntaxKind::STATIC => lsp_types::SymbolKind::Constant, SyntaxKind::STATIC => lsp_types::SymbolKind::Constant,
SyntaxKind::CONST => 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, _ => lsp_types::SymbolKind::Variable,
} }
} }

View file

@ -103,8 +103,8 @@ pub(crate) const KINDS_SRC: KindsSrc = KindsSrc {
"USE", "USE",
"STATIC", "STATIC",
"CONST", "CONST",
"TRAIT_DEF", "TRAIT",
"IMPL_DEF", "IMPL",
"TYPE_ALIAS", "TYPE_ALIAS",
"MACRO_CALL", "MACRO_CALL",
"TOKEN_TREE", "TOKEN_TREE",

View file

@ -9,12 +9,12 @@ Item =
| ExternBlock | ExternBlock
| ExternCrate | ExternCrate
| Fn | Fn
| ImplDef | Impl
| MacroCall | MacroCall
| Module | Module
| Static | Static
| Struct | Struct
| TraitDef | Trait
| TypeAlias | TypeAlias
| Union | Union
| Use | Use
@ -66,8 +66,11 @@ SelfParam =
) )
Param = Param =
Attr* Pat (':' ascribed_type:TypeRef) Attr* (
| '...' Pat (':' ascribed_type:TypeRef)
| ascribed_type:TypeRef
| '...'
)
RetType = RetType =
'->' TypeRef '->' TypeRef
@ -120,7 +123,7 @@ Static =
Attr* Visibility? 'static'? 'mut'? Name ':' ascribed_type:TypeRef Attr* Visibility? 'static'? 'mut'? Name ':' ascribed_type:TypeRef
'=' body:Expr ';' '=' body:Expr ';'
TraitDef = Trait =
Attr* Visibility? 'unsafe'? 'auto'? 'trait' Name GenericParamList Attr* Visibility? 'unsafe'? 'auto'? 'trait' Name GenericParamList
(':' TypeBoundList?)? WhereClause (':' TypeBoundList?)? WhereClause
AssocItemList AssocItemList
@ -128,9 +131,12 @@ TraitDef =
AssocItemList = AssocItemList =
'{' AssocItem* '}' '{' AssocItem* '}'
ImplDef = Impl =
Attr* Visibility? 'const'? 'default'? 'unsafe'? 'impl' GenericParamList? '!'? 'for' Attr* Visibility?
WhereClause? 'default'? 'unsafe'? 'impl' 'const'? GenericParamList? (
TypeRef
| '!'? TypeRef 'for' TypeRef
) WhereClause?
AssocItemList AssocItemList
ParenType = ParenType =