Unnamed repository; edit this file 'description' to name the repository.
Rename `*Owner` traits to `Has*`
Lukas Wirth 2021-09-27
parent a28c5d7 · commit b6ed91a
-rw-r--r--crates/hir/src/display.rs2
-rw-r--r--crates/hir/src/lib.rs2
-rw-r--r--crates/hir/src/semantics.rs4
-rw-r--r--crates/hir/src/semantics/source_to_def.rs2
-rw-r--r--crates/hir_def/src/adt.rs2
-rw-r--r--crates/hir_def/src/attr.rs74
-rw-r--r--crates/hir_def/src/body.rs6
-rw-r--r--crates/hir_def/src/body/lower.rs4
-rw-r--r--crates/hir_def/src/child_by_source.rs2
-rw-r--r--crates/hir_def/src/generics.rs6
-rw-r--r--crates/hir_def/src/item_tree.rs2
-rw-r--r--crates/hir_def/src/item_tree/lower.rs12
-rw-r--r--crates/hir_def/src/path/lower.rs2
-rw-r--r--crates/hir_expand/src/builtin_derive.rs2
-rw-r--r--crates/hir_expand/src/builtin_macro.rs2
-rw-r--r--crates/hir_expand/src/db.rs2
-rw-r--r--crates/hir_expand/src/hygiene.rs2
-rw-r--r--crates/hir_expand/src/lib.rs2
-rw-r--r--crates/hir_ty/src/diagnostics/decl_check.rs2
-rw-r--r--crates/hir_ty/src/tests.rs2
-rw-r--r--crates/ide/src/annotations.rs4
-rw-r--r--crates/ide/src/display/navigation_target.rs10
-rw-r--r--crates/ide/src/file_structure.rs8
-rw-r--r--crates/ide/src/fn_references.rs2
-rwxr-xr-xcrates/ide/src/folding_ranges.rs2
-rw-r--r--crates/ide/src/highlight_related.rs2
-rw-r--r--crates/ide/src/inlay_hints.rs2
-rw-r--r--crates/ide/src/references.rs2
-rw-r--r--crates/ide/src/runnables.rs6
-rw-r--r--crates/ide_assists/src/handlers/add_lifetime_to_type.rs2
-rw-r--r--crates/ide_assists/src/handlers/add_missing_match_arms.rs2
-rw-r--r--crates/ide_assists/src/handlers/change_visibility.rs2
-rw-r--r--crates/ide_assists/src/handlers/convert_bool_then.rs2
-rw-r--r--crates/ide_assists/src/handlers/convert_into_to_from.rs2
-rw-r--r--crates/ide_assists/src/handlers/convert_iter_for_each_to_for.rs2
-rw-r--r--crates/ide_assists/src/handlers/convert_tuple_struct_to_named_struct.rs2
-rw-r--r--crates/ide_assists/src/handlers/convert_while_to_loop.rs2
-rw-r--r--crates/ide_assists/src/handlers/destructure_tuple_binding.rs2
-rw-r--r--crates/ide_assists/src/handlers/extract_function.rs2
-rw-r--r--crates/ide_assists/src/handlers/extract_struct_from_enum_variant.rs4
-rw-r--r--crates/ide_assists/src/handlers/extract_type_alias.rs2
-rw-r--r--crates/ide_assists/src/handlers/fix_visibility.rs4
-rw-r--r--crates/ide_assists/src/handlers/generate_default_from_enum_variant.rs2
-rw-r--r--crates/ide_assists/src/handlers/generate_default_from_new.rs2
-rw-r--r--crates/ide_assists/src/handlers/generate_deref.rs2
-rw-r--r--crates/ide_assists/src/handlers/generate_derive.rs2
-rw-r--r--crates/ide_assists/src/handlers/generate_enum_is_method.rs4
-rw-r--r--crates/ide_assists/src/handlers/generate_enum_projection_method.rs4
-rw-r--r--crates/ide_assists/src/handlers/generate_from_impl_for_enum.rs2
-rw-r--r--crates/ide_assists/src/handlers/generate_function.rs2
-rw-r--r--crates/ide_assists/src/handlers/generate_getter.rs2
-rw-r--r--crates/ide_assists/src/handlers/generate_impl.rs2
-rw-r--r--crates/ide_assists/src/handlers/generate_is_empty_from_len.rs2
-rw-r--r--crates/ide_assists/src/handlers/generate_new.rs2
-rw-r--r--crates/ide_assists/src/handlers/generate_setter.rs2
-rw-r--r--crates/ide_assists/src/handlers/inline_call.rs2
-rw-r--r--crates/ide_assists/src/handlers/inline_local_variable.rs2
-rw-r--r--crates/ide_assists/src/handlers/introduce_named_lifetime.rs2
-rw-r--r--crates/ide_assists/src/handlers/move_bounds.rs2
-rw-r--r--crates/ide_assists/src/handlers/move_module_to_file.rs2
-rw-r--r--crates/ide_assists/src/handlers/qualify_path.rs2
-rw-r--r--crates/ide_assists/src/handlers/remove_unused_param.rs2
-rw-r--r--crates/ide_assists/src/handlers/reorder_impl.rs2
-rw-r--r--crates/ide_assists/src/handlers/replace_derive_with_manual_impl.rs2
-rw-r--r--crates/ide_assists/src/handlers/replace_if_let_with_match.rs2
-rw-r--r--crates/ide_assists/src/handlers/sort_items.rs4
-rw-r--r--crates/ide_assists/src/handlers/toggle_ignore.rs2
-rw-r--r--crates/ide_assists/src/handlers/unmerge_use.rs2
-rw-r--r--crates/ide_assists/src/utils.rs2
-rw-r--r--crates/ide_assists/src/utils/gen_trait_fn_body.rs2
-rw-r--r--crates/ide_assists/src/utils/suggest_name.rs2
-rw-r--r--crates/ide_completion/src/completions/fn_param.rs2
-rw-r--r--crates/ide_completion/src/context.rs2
-rw-r--r--crates/ide_completion/src/patterns.rs2
-rw-r--r--crates/ide_completion/src/render/const_.rs2
-rw-r--r--crates/ide_completion/src/render/type_alias.rs2
-rw-r--r--crates/ide_db/src/call_info.rs2
-rw-r--r--crates/ide_db/src/helpers.rs2
-rw-r--r--crates/ide_db/src/helpers/import_assets.rs2
-rw-r--r--crates/ide_db/src/helpers/insert_use.rs4
-rw-r--r--crates/ide_db/src/helpers/merge_imports.rs2
-rw-r--r--crates/ide_db/src/rename.rs4
-rw-r--r--crates/ide_db/src/symbol_index.rs4
-rw-r--r--crates/ide_db/src/traits.rs2
-rw-r--r--crates/ide_diagnostics/src/handlers/replace_filter_map_next_with_find_map.rs2
-rw-r--r--crates/ide_diagnostics/src/handlers/unlinked_file.rs2
-rw-r--r--crates/ide_ssr/src/matching.rs4
-rw-r--r--crates/mbe/src/benchmark.rs2
-rw-r--r--crates/mbe/src/tests.rs2
-rw-r--r--crates/syntax/src/ast.rs6
-rw-r--r--crates/syntax/src/ast/edit_in_place.rs10
-rw-r--r--crates/syntax/src/ast/expr_ext.rs2
-rw-r--r--crates/syntax/src/ast/generated/nodes.rs368
-rw-r--r--crates/syntax/src/ast/node_ext.rs48
-rw-r--r--crates/syntax/src/ast/traits.rs18
-rw-r--r--crates/syntax/src/display.rs4
-rw-r--r--crates/syntax/src/lib.rs2
-rw-r--r--crates/syntax/src/tests.rs2
-rw-r--r--crates/syntax/src/tests/sourcegen_ast.rs16
-rw-r--r--crates/syntax/src/validation.rs2
-rw-r--r--crates/syntax/src/validation/block.rs2
101 files changed, 393 insertions, 397 deletions
diff --git a/crates/hir/src/display.rs b/crates/hir/src/display.rs
index 4ef7d399de..aa4f25a3b4 100644
--- a/crates/hir/src/display.rs
+++ b/crates/hir/src/display.rs
@@ -12,7 +12,7 @@ use hir_ty::{
},
Interner, TraitRefExt, WhereClause,
};
-use syntax::ast::{self, NameOwner};
+use syntax::ast::{self, HasName};
use crate::{
Adt, Const, ConstParam, Enum, Field, Function, GenericParam, HasCrate, HasVisibility,
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs
index 99ab630a30..879124502a 100644
--- a/crates/hir/src/lib.rs
+++ b/crates/hir/src/lib.rs
@@ -72,7 +72,7 @@ use once_cell::unsync::Lazy;
use rustc_hash::FxHashSet;
use stdx::{format_to, impl_from};
use syntax::{
- ast::{self, AttrsOwner, NameOwner},
+ ast::{self, HasAttrs as _, HasName},
AstNode, AstPtr, SmolStr, SyntaxKind, SyntaxNodePtr,
};
use tt::{Ident, Leaf, Literal, TokenTree};
diff --git a/crates/hir/src/semantics.rs b/crates/hir/src/semantics.rs
index 9de2c32111..ff3384cbe9 100644
--- a/crates/hir/src/semantics.rs
+++ b/crates/hir/src/semantics.rs
@@ -17,7 +17,7 @@ use rustc_hash::{FxHashMap, FxHashSet};
use smallvec::{smallvec, SmallVec};
use syntax::{
algo::skip_trivia_token,
- ast::{self, GenericParamsOwner, LoopBodyOwner},
+ ast::{self, HasGenericParams, HasLoopBody},
match_ast, AstNode, Direction, SyntaxNode, SyntaxNodePtr, SyntaxToken, TextRange, TextSize,
};
@@ -682,7 +682,7 @@ impl<'db> SemanticsImpl<'db> {
fn resolve_lifetime_param(&self, lifetime: &ast::Lifetime) -> Option<LifetimeParam> {
let text = lifetime.text();
let lifetime_param = lifetime.syntax().ancestors().find_map(|syn| {
- let gpl = ast::AnyGenericParamsOwner::cast(syn)?.generic_param_list()?;
+ let gpl = ast::AnyHasGenericParams::cast(syn)?.generic_param_list()?;
gpl.lifetime_params()
.find(|tp| tp.lifetime().as_ref().map(|lt| lt.text()).as_ref() == Some(&text))
})?;
diff --git a/crates/hir/src/semantics/source_to_def.rs b/crates/hir/src/semantics/source_to_def.rs
index 723c7a1727..20e2481af6 100644
--- a/crates/hir/src/semantics/source_to_def.rs
+++ b/crates/hir/src/semantics/source_to_def.rs
@@ -100,7 +100,7 @@ use rustc_hash::FxHashMap;
use smallvec::SmallVec;
use stdx::impl_from;
use syntax::{
- ast::{self, NameOwner},
+ ast::{self, HasName},
match_ast, AstNode, SyntaxNode,
};
diff --git a/crates/hir_def/src/adt.rs b/crates/hir_def/src/adt.rs
index 402fb1d8dc..6ba70a2df6 100644
--- a/crates/hir_def/src/adt.rs
+++ b/crates/hir_def/src/adt.rs
@@ -9,7 +9,7 @@ use hir_expand::{
InFile,
};
use la_arena::{Arena, ArenaMap};
-use syntax::ast::{self, NameOwner, VisibilityOwner};
+use syntax::ast::{self, HasName, HasVisibility};
use tt::{Delimiter, DelimiterKind, Leaf, Subtree, TokenTree};
use crate::{
diff --git a/crates/hir_def/src/attr.rs b/crates/hir_def/src/attr.rs
index 95516e2e83..03fe46e267 100644
--- a/crates/hir_def/src/attr.rs
+++ b/crates/hir_def/src/attr.rs
@@ -17,7 +17,7 @@ use la_arena::ArenaMap;
use mbe::{syntax_node_to_token_tree, DelimiterKind};
use smallvec::{smallvec, SmallVec};
use syntax::{
- ast::{self, AstNode, AttrsOwner, IsString},
+ ast::{self, AstNode, HasAttrs, IsString},
match_ast, AstPtr, AstToken, SmolStr, SyntaxNode, TextRange, TextSize,
};
use tt::Subtree;
@@ -101,11 +101,7 @@ impl ops::Deref for AttrsWithOwner {
impl RawAttrs {
pub(crate) const EMPTY: Self = Self { entries: None };
- pub(crate) fn new(
- db: &dyn DefDatabase,
- owner: &dyn ast::AttrsOwner,
- hygiene: &Hygiene,
- ) -> Self {
+ pub(crate) fn new(db: &dyn DefDatabase, owner: &dyn ast::HasAttrs, hygiene: &Hygiene) -> Self {
let entries = collect_attrs(owner)
.flat_map(|(id, attr)| match attr {
Either::Left(attr) => {
@@ -122,7 +118,7 @@ impl RawAttrs {
Self { entries: if entries.is_empty() { None } else { Some(entries) } }
}
- fn from_attrs_owner(db: &dyn DefDatabase, owner: InFile<&dyn ast::AttrsOwner>) -> Self {
+ fn from_attrs_owner(db: &dyn DefDatabase, owner: InFile<&dyn ast::HasAttrs>) -> Self {
let hygiene = Hygiene::new(db.upcast(), owner.file_id);
Self::new(db, owner.value, &hygiene)
}
@@ -208,7 +204,7 @@ impl Attrs {
let mut res = ArenaMap::default();
for (id, var) in src.value.iter() {
- let attrs = RawAttrs::from_attrs_owner(db, src.with_value(var as &dyn ast::AttrsOwner))
+ let attrs = RawAttrs::from_attrs_owner(db, src.with_value(var as &dyn ast::HasAttrs))
.filter(db, krate);
res.insert(id, attrs)
@@ -226,7 +222,7 @@ impl Attrs {
let mut res = ArenaMap::default();
for (id, fld) in src.value.iter() {
- let owner: &dyn AttrsOwner = match fld {
+ let owner: &dyn HasAttrs = match fld {
Either::Left(tuple) => tuple,
Either::Right(record) => record,
};
@@ -312,7 +308,7 @@ impl AttrsWithOwner {
Some(it) => {
let raw_attrs = RawAttrs::from_attrs_owner(
db,
- it.as_ref().map(|it| it as &dyn ast::AttrsOwner),
+ it.as_ref().map(|it| it as &dyn ast::HasAttrs),
);
match mod_data.definition_source(db) {
InFile { file_id, value: ModuleSource::SourceFile(file) } => raw_attrs
@@ -323,9 +319,9 @@ impl AttrsWithOwner {
None => RawAttrs::from_attrs_owner(
db,
mod_data.definition_source(db).as_ref().map(|src| match src {
- ModuleSource::SourceFile(file) => file as &dyn ast::AttrsOwner,
- ModuleSource::Module(module) => module as &dyn ast::AttrsOwner,
- ModuleSource::BlockExpr(block) => block as &dyn ast::AttrsOwner,
+ ModuleSource::SourceFile(file) => file as &dyn ast::HasAttrs,
+ ModuleSource::Module(module) => module as &dyn ast::HasAttrs,
+ ModuleSource::BlockExpr(block) => block as &dyn ast::HasAttrs,
}),
),
}
@@ -398,9 +394,9 @@ impl AttrsWithOwner {
None => {
let InFile { file_id, value } = mod_data.definition_source(db);
let attrs_owner = match &value {
- ModuleSource::SourceFile(file) => file as &dyn ast::AttrsOwner,
- ModuleSource::Module(module) => module as &dyn ast::AttrsOwner,
- ModuleSource::BlockExpr(block) => block as &dyn ast::AttrsOwner,
+ ModuleSource::SourceFile(file) => file as &dyn ast::HasAttrs,
+ ModuleSource::Module(module) => module as &dyn ast::HasAttrs,
+ ModuleSource::BlockExpr(block) => block as &dyn ast::HasAttrs,
};
return AttrSourceMap::new(InFile::new(file_id, attrs_owner));
}
@@ -411,51 +407,51 @@ impl AttrsWithOwner {
let file_id = id.parent.file_id(db);
let root = db.parse_or_expand(file_id).unwrap();
let owner = match &map[id.local_id] {
- Either::Left(it) => ast::AnyAttrsOwner::new(it.to_node(&root)),
- Either::Right(it) => ast::AnyAttrsOwner::new(it.to_node(&root)),
+ Either::Left(it) => ast::AnyHasAttrs::new(it.to_node(&root)),
+ Either::Right(it) => ast::AnyHasAttrs::new(it.to_node(&root)),
};
InFile::new(file_id, owner)
}
AttrDefId::AdtId(adt) => match adt {
- AdtId::StructId(id) => id.lookup(db).source(db).map(ast::AnyAttrsOwner::new),
- AdtId::UnionId(id) => id.lookup(db).source(db).map(ast::AnyAttrsOwner::new),
- AdtId::EnumId(id) => id.lookup(db).source(db).map(ast::AnyAttrsOwner::new),
+ AdtId::StructId(id) => id.lookup(db).source(db).map(ast::AnyHasAttrs::new),
+ AdtId::UnionId(id) => id.lookup(db).source(db).map(ast::AnyHasAttrs::new),
+ AdtId::EnumId(id) => id.lookup(db).source(db).map(ast::AnyHasAttrs::new),
},
- AttrDefId::FunctionId(id) => id.lookup(db).source(db).map(ast::AnyAttrsOwner::new),
+ AttrDefId::FunctionId(id) => id.lookup(db).source(db).map(ast::AnyHasAttrs::new),
AttrDefId::EnumVariantId(id) => {
let map = db.variants_attrs_source_map(id.parent);
let file_id = id.parent.lookup(db).id.file_id();
let root = db.parse_or_expand(file_id).unwrap();
- InFile::new(file_id, ast::AnyAttrsOwner::new(map[id.local_id].to_node(&root)))
+ InFile::new(file_id, ast::AnyHasAttrs::new(map[id.local_id].to_node(&root)))
}
- AttrDefId::StaticId(id) => id.lookup(db).source(db).map(ast::AnyAttrsOwner::new),
- AttrDefId::ConstId(id) => id.lookup(db).source(db).map(ast::AnyAttrsOwner::new),
- AttrDefId::TraitId(id) => id.lookup(db).source(db).map(ast::AnyAttrsOwner::new),
- AttrDefId::TypeAliasId(id) => id.lookup(db).source(db).map(ast::AnyAttrsOwner::new),
+ AttrDefId::StaticId(id) => id.lookup(db).source(db).map(ast::AnyHasAttrs::new),
+ AttrDefId::ConstId(id) => id.lookup(db).source(db).map(ast::AnyHasAttrs::new),
+ AttrDefId::TraitId(id) => id.lookup(db).source(db).map(ast::AnyHasAttrs::new),
+ AttrDefId::TypeAliasId(id) => id.lookup(db).source(db).map(ast::AnyHasAttrs::new),
AttrDefId::MacroDefId(id) => id.ast_id().either(
- |it| it.with_value(ast::AnyAttrsOwner::new(it.to_node(db.upcast()))),
- |it| it.with_value(ast::AnyAttrsOwner::new(it.to_node(db.upcast()))),
+ |it| it.with_value(ast::AnyHasAttrs::new(it.to_node(db.upcast()))),
+ |it| it.with_value(ast::AnyHasAttrs::new(it.to_node(db.upcast()))),
),
- AttrDefId::ImplId(id) => id.lookup(db).source(db).map(ast::AnyAttrsOwner::new),
+ AttrDefId::ImplId(id) => id.lookup(db).source(db).map(ast::AnyHasAttrs::new),
AttrDefId::GenericParamId(id) => match id {
GenericParamId::TypeParamId(id) => {
id.parent.child_source(db).map(|source| match &source[id.local_id] {
- Either::Left(id) => ast::AnyAttrsOwner::new(id.clone()),
- Either::Right(id) => ast::AnyAttrsOwner::new(id.clone()),
+ Either::Left(id) => ast::AnyHasAttrs::new(id.clone()),
+ Either::Right(id) => ast::AnyHasAttrs::new(id.clone()),
})
}
GenericParamId::LifetimeParamId(id) => id
.parent
.child_source(db)
- .map(|source| ast::AnyAttrsOwner::new(source[id.local_id].clone())),
+ .map(|source| ast::AnyHasAttrs::new(source[id.local_id].clone())),
GenericParamId::ConstParamId(id) => id
.parent
.child_source(db)
- .map(|source| ast::AnyAttrsOwner::new(source[id.local_id].clone())),
+ .map(|source| ast::AnyHasAttrs::new(source[id.local_id].clone())),
},
};
- AttrSourceMap::new(owner.as_ref().map(|node| node as &dyn AttrsOwner))
+ AttrSourceMap::new(owner.as_ref().map(|node| node as &dyn HasAttrs))
}
pub fn docs_with_rangemap(
@@ -555,7 +551,7 @@ pub struct AttrSourceMap {
}
impl AttrSourceMap {
- fn new(owner: InFile<&dyn ast::AttrsOwner>) -> Self {
+ fn new(owner: InFile<&dyn ast::HasAttrs>) -> Self {
let mut attrs = Vec::new();
let mut doc_comments = Vec::new();
for (_, attr) in collect_attrs(owner.value) {
@@ -812,10 +808,10 @@ impl<'a> AttrQuery<'a> {
fn attrs_from_ast<N>(src: AstId<N>, db: &dyn DefDatabase) -> RawAttrs
where
- N: ast::AttrsOwner,
+ N: ast::HasAttrs,
{
let src = InFile::new(src.file_id, src.to_node(db.upcast()));
- RawAttrs::from_attrs_owner(db, src.as_ref().map(|it| it as &dyn ast::AttrsOwner))
+ RawAttrs::from_attrs_owner(db, src.as_ref().map(|it| it as &dyn ast::HasAttrs))
}
fn attrs_from_item_tree<N: ItemTreeNode>(id: ItemTreeId<N>, db: &dyn DefDatabase) -> RawAttrs {
@@ -825,7 +821,7 @@ fn attrs_from_item_tree<N: ItemTreeNode>(id: ItemTreeId<N>, db: &dyn DefDatabase
}
fn collect_attrs(
- owner: &dyn ast::AttrsOwner,
+ owner: &dyn ast::HasAttrs,
) -> impl Iterator<Item = (AttrId, Either<ast::Attr, ast::Comment>)> {
let (inner_attrs, inner_docs) = inner_attributes(owner.syntax())
.map_or((None, None), |(attrs, docs)| (Some(attrs), Some(docs)));
diff --git a/crates/hir_def/src/body.rs b/crates/hir_def/src/body.rs
index 5320a96bc5..0eff093beb 100644
--- a/crates/hir_def/src/body.rs
+++ b/crates/hir_def/src/body.rs
@@ -70,11 +70,11 @@ impl CfgExpander {
CfgExpander { cfg_options, hygiene, krate }
}
- pub(crate) fn parse_attrs(&self, db: &dyn DefDatabase, owner: &dyn ast::AttrsOwner) -> Attrs {
+ pub(crate) fn parse_attrs(&self, db: &dyn DefDatabase, owner: &dyn ast::HasAttrs) -> Attrs {
RawAttrs::new(db, owner, &self.hygiene).filter(db, self.krate)
}
- pub(crate) fn is_cfg_enabled(&self, db: &dyn DefDatabase, owner: &dyn ast::AttrsOwner) -> bool {
+ pub(crate) fn is_cfg_enabled(&self, db: &dyn DefDatabase, owner: &dyn ast::HasAttrs) -> bool {
let attrs = self.parse_attrs(db, owner);
attrs.is_cfg_enabled(&self.cfg_options)
}
@@ -179,7 +179,7 @@ impl Expander {
InFile { file_id: self.current_file_id, value }
}
- pub(crate) fn parse_attrs(&self, db: &dyn DefDatabase, owner: &dyn ast::AttrsOwner) -> Attrs {
+ pub(crate) fn parse_attrs(&self, db: &dyn DefDatabase, owner: &dyn ast::HasAttrs) -> Attrs {
self.cfg_expander.parse_attrs(db, owner)
}
diff --git a/crates/hir_def/src/body/lower.rs b/crates/hir_def/src/body/lower.rs
index 6a6d992af3..804d98ce38 100644
--- a/crates/hir_def/src/body/lower.rs
+++ b/crates/hir_def/src/body/lower.rs
@@ -14,7 +14,7 @@ use la_arena::Arena;
use profile::Count;
use syntax::{
ast::{
- self, ArgListOwner, ArrayExprKind, AstChildren, LiteralKind, LoopBodyOwner, NameOwner,
+ self, ArrayExprKind, AstChildren, HasArgList, HasLoopBody, HasName, LiteralKind,
SlicePatComponents,
},
AstNode, AstPtr, SyntaxNodePtr,
@@ -912,7 +912,7 @@ impl ExprCollector<'_> {
/// Returns `None` (and emits diagnostics) when `owner` if `#[cfg]`d out, and `Some(())` when
/// not.
- fn check_cfg(&mut self, owner: &dyn ast::AttrsOwner) -> Option<()> {
+ fn check_cfg(&mut self, owner: &dyn ast::HasAttrs) -> Option<()> {
match self.expander.parse_attrs(self.db, owner).cfg() {
Some(cfg) => {
if self.expander.cfg_options().check(&cfg) != Some(false) {
diff --git a/crates/hir_def/src/child_by_source.rs b/crates/hir_def/src/child_by_source.rs
index e4580a0ca3..6d63570428 100644
--- a/crates/hir_def/src/child_by_source.rs
+++ b/crates/hir_def/src/child_by_source.rs
@@ -7,7 +7,7 @@
use either::Either;
use hir_expand::HirFileId;
use itertools::Itertools;
-use syntax::ast::AttrsOwner;
+use syntax::ast::HasAttrs;
use crate::{
db::DefDatabase,
diff --git a/crates/hir_def/src/generics.rs b/crates/hir_def/src/generics.rs
index 5425ea8bea..ef86ab8a84 100644
--- a/crates/hir_def/src/generics.rs
+++ b/crates/hir_def/src/generics.rs
@@ -10,7 +10,7 @@ use hir_expand::{
HirFileId, InFile,
};
use la_arena::{Arena, ArenaMap};
-use syntax::ast::{self, GenericParamsOwner, NameOwner, TypeBoundsOwner};
+use syntax::ast::{self, HasGenericParams, HasName, HasTypeBounds};
use crate::{
body::LowerCtx,
@@ -236,7 +236,7 @@ impl GenericParams {
&mut self,
lower_ctx: &LowerCtx,
sm: &mut SourceMap,
- node: &dyn GenericParamsOwner,
+ node: &dyn HasGenericParams,
) {
if let Some(params) = node.generic_param_list() {
self.fill_params(lower_ctx, sm, params)
@@ -249,7 +249,7 @@ impl GenericParams {
pub(crate) fn fill_bounds(
&mut self,
lower_ctx: &LowerCtx,
- node: &dyn ast::TypeBoundsOwner,
+ node: &dyn ast::HasTypeBounds,
target: Either<TypeRef, LifetimeRef>,
) {
for bound in
diff --git a/crates/hir_def/src/item_tree.rs b/crates/hir_def/src/item_tree.rs
index 26621b8c7e..df46ceeaee 100644
--- a/crates/hir_def/src/item_tree.rs
+++ b/crates/hir_def/src/item_tree.rs
@@ -44,7 +44,7 @@ use std::{
sync::Arc,
};
-use ast::{AstNode, NameOwner, StructKind};
+use ast::{AstNode, HasName, StructKind};
use base_db::CrateId;
use either::Either;
use hir_expand::{
diff --git a/crates/hir_def/src/item_tree/lower.rs b/crates/hir_def/src/item_tree/lower.rs
index 7bed19a792..0af4ae0f90 100644
--- a/crates/hir_def/src/item_tree/lower.rs
+++ b/crates/hir_def/src/item_tree/lower.rs
@@ -4,7 +4,7 @@ use std::{collections::hash_map::Entry, mem, sync::Arc};
use hir_expand::{ast_id_map::AstIdMap, hygiene::Hygiene, name::known, HirFileId};
use syntax::{
- ast::{self, ModuleItemOwner},
+ ast::{self, HasModuleItem},
SyntaxNode, WalkEvent,
};
@@ -40,7 +40,7 @@ impl<'a> Ctx<'a> {
}
}
- pub(super) fn lower_module_items(mut self, item_owner: &dyn ModuleItemOwner) -> ItemTree {
+ pub(super) fn lower_module_items(mut self, item_owner: &dyn HasModuleItem) -> ItemTree {
self.tree.top_level =
item_owner.items().flat_map(|item| self.lower_mod_item(&item, false)).collect();
self.tree
@@ -644,7 +644,7 @@ impl<'a> Ctx<'a> {
fn lower_generic_params_and_inner_items(
&mut self,
owner: GenericsOwner<'_>,
- node: &impl ast::GenericParamsOwner,
+ node: &impl ast::HasGenericParams,
) -> Interned<GenericParams> {
// Generics are part of item headers and may contain inner items we need to collect.
if let Some(params) = node.generic_param_list() {
@@ -660,7 +660,7 @@ impl<'a> Ctx<'a> {
fn lower_generic_params(
&mut self,
owner: GenericsOwner<'_>,
- node: &impl ast::GenericParamsOwner,
+ node: &impl ast::HasGenericParams,
) -> Interned<GenericParams> {
let mut sm = &mut Default::default();
let mut generics = GenericParams::default();
@@ -706,7 +706,7 @@ impl<'a> Ctx<'a> {
Interned::new(generics)
}
- fn lower_type_bounds(&mut self, node: &impl ast::TypeBoundsOwner) -> Vec<Interned<TypeBound>> {
+ fn lower_type_bounds(&mut self, node: &impl ast::HasTypeBounds) -> Vec<Interned<TypeBound>> {
match node.type_bound_list() {
Some(bound_list) => bound_list
.bounds()
@@ -716,7 +716,7 @@ impl<'a> Ctx<'a> {
}
}
- fn lower_visibility(&mut self, item: &impl ast::VisibilityOwner) -> RawVisibilityId {
+ fn lower_visibility(&mut self, item: &impl ast::HasVisibility) -> RawVisibilityId {
let vis = match self.forced_visibility {
Some(vis) => return vis,
None => RawVisibility::from_ast_with_hygiene(self.db, item.visibility(), &self.hygiene),
diff --git a/crates/hir_def/src/path/lower.rs b/crates/hir_def/src/path/lower.rs
index 82bdcd5a86..99e7cdc999 100644
--- a/crates/hir_def/src/path/lower.rs
+++ b/crates/hir_def/src/path/lower.rs
@@ -6,7 +6,7 @@ use crate::intern::Interned;
use either::Either;
use hir_expand::name::{name, AsName};
-use syntax::ast::{self, AstNode, TypeBoundsOwner};
+use syntax::ast::{self, AstNode, HasTypeBounds};
use super::AssociatedTypeBinding;
use crate::{
diff --git a/crates/hir_expand/src/builtin_derive.rs b/crates/hir_expand/src/builtin_derive.rs
index c5738a2a0e..eeebe87acd 100644
--- a/crates/hir_expand/src/builtin_derive.rs
+++ b/crates/hir_expand/src/builtin_derive.rs
@@ -4,7 +4,7 @@ use tracing::debug;
use mbe::ExpandResult;
use syntax::{
- ast::{self, AstNode, GenericParamsOwner, ModuleItemOwner, NameOwner},
+ ast::{self, AstNode, HasGenericParams, HasModuleItem, HasName},
match_ast,
};
diff --git a/crates/hir_expand/src/builtin_macro.rs b/crates/hir_expand/src/builtin_macro.rs
index 74f9b23d73..9293b45064 100644
--- a/crates/hir_expand/src/builtin_macro.rs
+++ b/crates/hir_expand/src/builtin_macro.rs
@@ -558,7 +558,7 @@ mod tests {
use base_db::{fixture::WithFixture, SourceDatabase};
use expect_test::{expect, Expect};
- use syntax::ast::NameOwner;
+ use syntax::ast::HasName;
use crate::{
name::AsName, test_db::TestDB, AstNode, EagerCallInfo, ExpandTo, MacroCallId,
diff --git a/crates/hir_expand/src/db.rs b/crates/hir_expand/src/db.rs
index 09ff972960..fd1d8d2e60 100644
--- a/crates/hir_expand/src/db.rs
+++ b/crates/hir_expand/src/db.rs
@@ -8,7 +8,7 @@ use mbe::{syntax_node_to_token_tree, ExpandError, ExpandResult};
use rustc_hash::FxHashSet;
use syntax::{
algo::diff,
- ast::{self, AttrsOwner, NameOwner},
+ ast::{self, HasAttrs, HasName},
AstNode, GreenNode, Parse, SyntaxNode, SyntaxToken, T,
};
diff --git a/crates/hir_expand/src/hygiene.rs b/crates/hir_expand/src/hygiene.rs
index a1c519b804..5b3ccdeb60 100644
--- a/crates/hir_expand/src/hygiene.rs
+++ b/crates/hir_expand/src/hygiene.rs
@@ -9,7 +9,7 @@ use db::TokenExpander;
use either::Either;
use mbe::Origin;
use syntax::{
- ast::{self, AttrsOwner},
+ ast::{self, HasAttrs},
AstNode, SyntaxKind, SyntaxNode, TextRange, TextSize,
};
diff --git a/crates/hir_expand/src/lib.rs b/crates/hir_expand/src/lib.rs
index bdc3023e9c..fc1ac17213 100644
--- a/crates/hir_expand/src/lib.rs
+++ b/crates/hir_expand/src/lib.rs
@@ -25,7 +25,7 @@ use std::{hash::Hash, iter, sync::Arc};
use base_db::{impl_intern_key, salsa, CrateId, FileId, FileRange};
use syntax::{
algo::skip_trivia_token,
- ast::{self, AstNode, AttrsOwner},
+ ast::{self, AstNode, HasAttrs},
Direction, SyntaxNode, SyntaxToken, TextRange, TextSize,
};
diff --git a/crates/hir_ty/src/diagnostics/decl_check.rs b/crates/hir_ty/src/diagnostics/decl_check.rs
index ea9b54af63..6fbb9c93b4 100644
--- a/crates/hir_ty/src/diagnostics/decl_check.rs
+++ b/crates/hir_ty/src/diagnostics/decl_check.rs
@@ -22,7 +22,7 @@ use hir_def::{
use hir_expand::name::{AsName, Name};
use stdx::{always, never};
use syntax::{
- ast::{self, NameOwner},
+ ast::{self, HasName},
AstNode, AstPtr,
};
diff --git a/crates/hir_ty/src/tests.rs b/crates/hir_ty/src/tests.rs
index af6e773217..cf6833e56a 100644
--- a/crates/hir_ty/src/tests.rs
+++ b/crates/hir_ty/src/tests.rs
@@ -26,7 +26,7 @@ use hir_expand::{db::AstDatabase, InFile};
use once_cell::race::OnceBool;
use stdx::format_to;
use syntax::{
- ast::{self, AstNode, NameOwner},
+ ast::{self, AstNode, HasName},
SyntaxNode,
};
use tracing_subscriber::{layer::SubscriberExt, EnvFilter, Registry};
diff --git a/crates/ide/src/annotations.rs b/crates/ide/src/annotations.rs
index 67f1f6dbdb..472b396ac5 100644
--- a/crates/ide/src/annotations.rs
+++ b/crates/ide/src/annotations.rs
@@ -5,7 +5,7 @@ use ide_db::{
helpers::visit_file_defs,
RootDatabase,
};
-use syntax::{ast::NameOwner, AstNode, TextRange};
+use syntax::{ast::HasName, AstNode, TextRange};
use crate::{
fn_references::find_all_methods,
@@ -99,7 +99,7 @@ pub(crate) fn annotations(
});
}
- fn name_range<T: NameOwner>(node: &InFile<T>, file_id: FileId) -> Option<TextRange> {
+ fn name_range<T: HasName>(node: &InFile<T>, file_id: FileId) -> Option<TextRange> {
if node.file_id == file_id.into() {
node.value.name().map(|it| it.syntax().text_range())
} else {
diff --git a/crates/ide/src/display/navigation_target.rs b/crates/ide/src/display/navigation_target.rs
index 6978e4b88f..65c29f6805 100644
--- a/crates/ide/src/display/navigation_target.rs
+++ b/crates/ide/src/display/navigation_target.rs
@@ -14,7 +14,7 @@ use ide_db::{
};
use ide_db::{defs::Definition, RootDatabase};
use syntax::{
- ast::{self, NameOwner},
+ ast::{self, HasName},
match_ast, AstNode, SmolStr, TextRange,
};
@@ -133,7 +133,7 @@ impl NavigationTarget {
/// Allows `NavigationTarget` to be created from a `NameOwner`
pub(crate) fn from_named(
db: &RootDatabase,
- node: InFile<&dyn ast::NameOwner>,
+ node: InFile<&dyn ast::HasName>,
kind: SymbolKind,
) -> NavigationTarget {
let name = node.value.name().map(|it| it.text().into()).unwrap_or_else(|| "_".into());
@@ -257,13 +257,13 @@ impl ToNavFromAst for hir::Trait {
impl<D> TryToNav for D
where
D: HasSource + ToNavFromAst + Copy + HasAttrs + HirDisplay,
- D::Ast: ast::NameOwner,
+ D::Ast: ast::HasName,
{
fn try_to_nav(&self, db: &RootDatabase) -> Option<NavigationTarget> {
let src = self.source(db)?;
let mut res = NavigationTarget::from_named(
db,
- src.as_ref().map(|it| it as &dyn ast::NameOwner),
+ src.as_ref().map(|it| it as &dyn ast::HasName),
D::KIND,
);
res.docs = self.docs(db);
@@ -343,7 +343,7 @@ impl TryToNav for hir::Field {
impl TryToNav for hir::MacroDef {
fn try_to_nav(&self, db: &RootDatabase) -> Option<NavigationTarget> {
let src = self.source(db)?;
- let name_owner: &dyn ast::NameOwner = match &src.value {
+ let name_owner: &dyn ast::HasName = match &src.value {
Either::Left(it) => it,
Either::Right(it) => it,
};
diff --git a/crates/ide/src/file_structure.rs b/crates/ide/src/file_structure.rs
index 19071d6be9..409f3901f5 100644
--- a/crates/ide/src/file_structure.rs
+++ b/crates/ide/src/file_structure.rs
@@ -1,6 +1,6 @@
use ide_db::SymbolKind;
use syntax::{
- ast::{self, AttrsOwner, GenericParamsOwner, NameOwner},
+ ast::{self, HasAttrs, HasGenericParams, HasName},
match_ast, AstNode, AstToken, NodeOrToken, SourceFile, SyntaxNode, SyntaxToken, TextRange,
WalkEvent,
};
@@ -74,11 +74,11 @@ pub(crate) fn file_structure(file: &SourceFile) -> Vec<StructureNode> {
}
fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
- fn decl<N: NameOwner + AttrsOwner>(node: N, kind: StructureNodeKind) -> Option<StructureNode> {
+ fn decl<N: HasName + HasAttrs>(node: N, kind: StructureNodeKind) -> Option<StructureNode> {
decl_with_detail(&node, None, kind)
}
- fn decl_with_type_ref<N: NameOwner + AttrsOwner>(
+ fn decl_with_type_ref<N: HasName + HasAttrs>(
node: &N,
type_ref: Option<ast::Type>,
kind: StructureNodeKind,
@@ -91,7 +91,7 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
decl_with_detail(node, detail, kind)
}
- fn decl_with_detail<N: NameOwner + AttrsOwner>(
+ fn decl_with_detail<N: HasName + HasAttrs>(
node: &N,
detail: Option<String>,
kind: StructureNodeKind,
diff --git a/crates/ide/src/fn_references.rs b/crates/ide/src/fn_references.rs
index 1a99a1f371..63fb322cea 100644
--- a/crates/ide/src/fn_references.rs
+++ b/crates/ide/src/fn_references.rs
@@ -4,7 +4,7 @@
use hir::Semantics;
use ide_assists::utils::test_related_attribute;
use ide_db::RootDatabase;
-use syntax::{ast, ast::NameOwner, AstNode, SyntaxNode};
+use syntax::{ast, ast::HasName, AstNode, SyntaxNode};
use crate::{FileId, FileRange};
diff --git a/crates/ide/src/folding_ranges.rs b/crates/ide/src/folding_ranges.rs
index 6f69421002..66126c8d55 100755
--- a/crates/ide/src/folding_ranges.rs
+++ b/crates/ide/src/folding_ranges.rs
@@ -152,7 +152,7 @@ fn fold_kind(kind: SyntaxKind) -> Option<FoldKind> {
fn contiguous_range_for_item_group<N>(first: N, visited: &mut FxHashSet<N>) -> Option<TextRange>
where
- N: ast::VisibilityOwner + Clone + Hash + Eq,
+ N: ast::HasVisibility + Clone + Hash + Eq,
{
if !visited.insert(first.clone()) {
return None;
diff --git a/crates/ide/src/highlight_related.rs b/crates/ide/src/highlight_related.rs
index 6aef3a9429..6b557bc92d 100644
--- a/crates/ide/src/highlight_related.rs
+++ b/crates/ide/src/highlight_related.rs
@@ -8,7 +8,7 @@ use ide_db::{
};
use rustc_hash::FxHashSet;
use syntax::{
- ast::{self, LoopBodyOwner},
+ ast::{self, HasLoopBody},
match_ast, AstNode,
SyntaxKind::IDENT,
SyntaxNode, SyntaxToken, TextRange, TextSize, T,
diff --git a/crates/ide/src/inlay_hints.rs b/crates/ide/src/inlay_hints.rs
index 79e68aa1dd..401feffff4 100644
--- a/crates/ide/src/inlay_hints.rs
+++ b/crates/ide/src/inlay_hints.rs
@@ -4,7 +4,7 @@ use ide_db::RootDatabase;
use ide_db::{base_db::FileRange, helpers::FamousDefs};
use stdx::to_lower_snake_case;
use syntax::{
- ast::{self, ArgListOwner, AstNode, NameOwner},
+ ast::{self, AstNode, HasArgList, HasName},
match_ast, Direction, NodeOrToken, SmolStr, SyntaxKind, TextRange, T,
};
diff --git a/crates/ide/src/references.rs b/crates/ide/src/references.rs
index c39d00b6e7..3ebec4dd8f 100644
--- a/crates/ide/src/references.rs
+++ b/crates/ide/src/references.rs
@@ -22,7 +22,7 @@ use ide_db::{
use rustc_hash::FxHashMap;
use syntax::{
algo::find_node_at_offset,
- ast::{self, NameOwner},
+ ast::{self, HasName},
match_ast, AstNode, SyntaxNode, TextRange, TextSize, T,
};
diff --git a/crates/ide/src/runnables.rs b/crates/ide/src/runnables.rs
index 376384670a..5d0cf7bba4 100644
--- a/crates/ide/src/runnables.rs
+++ b/crates/ide/src/runnables.rs
@@ -1,6 +1,6 @@
use std::fmt;
-use ast::NameOwner;
+use ast::HasName;
use cfg::CfgExpr;
use either::Either;
use hir::{AsAssocItem, HasAttrs, HasSource, HirDisplay, InFile, Semantics};
@@ -14,7 +14,7 @@ use ide_db::{
use itertools::Itertools;
use rustc_hash::{FxHashMap, FxHashSet};
use stdx::{always, format_to};
-use syntax::ast::{self, AstNode, AttrsOwner};
+use syntax::ast::{self, AstNode, HasAttrs as _};
use crate::{
display::{ToNav, TryToNav},
@@ -328,7 +328,7 @@ pub(crate) fn runnable_fn(sema: &Semantics<RootDatabase>, def: hir::Function) ->
let nav = NavigationTarget::from_named(
sema.db,
- func.as_ref().map(|it| it as &dyn ast::NameOwner),
+ func.as_ref().map(|it| it as &dyn ast::HasName),
SymbolKind::Function,
);
let cfg = def.attrs(sema.db).cfg();
diff --git a/crates/ide_assists/src/handlers/add_lifetime_to_type.rs b/crates/ide_assists/src/handlers/add_lifetime_to_type.rs
index 7030d0f978..14cdc1cf86 100644
--- a/crates/ide_assists/src/handlers/add_lifetime_to_type.rs
+++ b/crates/ide_assists/src/handlers/add_lifetime_to_type.rs
@@ -1,4 +1,4 @@
-use syntax::ast::{self, AstNode, GenericParamsOwner, NameOwner};
+use syntax::ast::{self, AstNode, HasGenericParams, HasName};
use crate::{AssistContext, AssistId, AssistKind, Assists};
diff --git a/crates/ide_assists/src/handlers/add_missing_match_arms.rs b/crates/ide_assists/src/handlers/add_missing_match_arms.rs
index cdbd8ac183..c856ab45d7 100644
--- a/crates/ide_assists/src/handlers/add_missing_match_arms.rs
+++ b/crates/ide_assists/src/handlers/add_missing_match_arms.rs
@@ -5,7 +5,7 @@ use hir::{Adt, HasSource, ModuleDef, Semantics};
use ide_db::helpers::{mod_path_to_ast, FamousDefs};
use ide_db::RootDatabase;
use itertools::Itertools;
-use syntax::ast::{self, make, AstNode, MatchArm, NameOwner, Pat};
+use syntax::ast::{self, make, AstNode, HasName, MatchArm, Pat};
use crate::{
utils::{self, render_snippet, Cursor},
diff --git a/crates/ide_assists/src/handlers/change_visibility.rs b/crates/ide_assists/src/handlers/change_visibility.rs
index ed936667f8..5f15e923ad 100644
--- a/crates/ide_assists/src/handlers/change_visibility.rs
+++ b/crates/ide_assists/src/handlers/change_visibility.rs
@@ -1,5 +1,5 @@
use syntax::{
- ast::{self, NameOwner, VisibilityOwner},
+ ast::{self, HasName, HasVisibility},
AstNode,
SyntaxKind::{
CONST, ENUM, FN, MACRO_DEF, MODULE, STATIC, STRUCT, TRAIT, TYPE_ALIAS, USE, VISIBILITY,
diff --git a/crates/ide_assists/src/handlers/convert_bool_then.rs b/crates/ide_assists/src/handlers/convert_bool_then.rs
index e7939269ad..2e24c22c9f 100644
--- a/crates/ide_assists/src/handlers/convert_bool_then.rs
+++ b/crates/ide_assists/src/handlers/convert_bool_then.rs
@@ -9,7 +9,7 @@ use ide_db::{
};
use itertools::Itertools;
use syntax::{
- ast::{self, edit::AstNodeEdit, make, ArgListOwner},
+ ast::{self, edit::AstNodeEdit, make, HasArgList},
ted, AstNode, SyntaxNode,
};
diff --git a/crates/ide_assists/src/handlers/convert_into_to_from.rs b/crates/ide_assists/src/handlers/convert_into_to_from.rs
index 2d8b936cd6..29555a5111 100644
--- a/crates/ide_assists/src/handlers/convert_into_to_from.rs
+++ b/crates/ide_assists/src/handlers/convert_into_to_from.rs
@@ -2,7 +2,7 @@ use ide_db::{
helpers::{mod_path_to_ast, FamousDefs},
traits::resolve_target_trait,
};
-use syntax::ast::{self, AstNode, NameOwner};
+use syntax::ast::{self, AstNode, HasName};
use crate::{AssistContext, AssistId, AssistKind, Assists};
diff --git a/crates/ide_assists/src/handlers/convert_iter_for_each_to_for.rs b/crates/ide_assists/src/handlers/convert_iter_for_each_to_for.rs
index aef03e3238..8744115f29 100644
--- a/crates/ide_assists/src/handlers/convert_iter_for_each_to_for.rs
+++ b/crates/ide_assists/src/handlers/convert_iter_for_each_to_for.rs
@@ -2,7 +2,7 @@ use hir::known;
use ide_db::helpers::FamousDefs;
use stdx::format_to;
use syntax::{
- ast::{self, edit_in_place::Indent, make, ArgListOwner, LoopBodyOwner},
+ ast::{self, edit_in_place::Indent, make, HasArgList, HasLoopBody},
AstNode,
};
diff --git a/crates/ide_assists/src/handlers/convert_tuple_struct_to_named_struct.rs b/crates/ide_assists/src/handlers/convert_tuple_struct_to_named_struct.rs
index bb0382e15f..9b8e548e8f 100644
--- a/crates/ide_assists/src/handlers/convert_tuple_struct_to_named_struct.rs
+++ b/crates/ide_assists/src/handlers/convert_tuple_struct_to_named_struct.rs
@@ -1,7 +1,7 @@
use either::Either;
use ide_db::defs::{Definition, NameRefClass};
use syntax::{
- ast::{self, AstNode, GenericParamsOwner, VisibilityOwner},
+ ast::{self, AstNode, HasGenericParams, HasVisibility},
match_ast, SyntaxNode,
};
diff --git a/crates/ide_assists/src/handlers/convert_while_to_loop.rs b/crates/ide_assists/src/handlers/convert_while_to_loop.rs
index cbddc106ff..2ecf646252 100644
--- a/crates/ide_assists/src/handlers/convert_while_to_loop.rs
+++ b/crates/ide_assists/src/handlers/convert_while_to_loop.rs
@@ -4,7 +4,7 @@ use syntax::{
ast::{
self,
edit::{AstNodeEdit, IndentLevel},
- make, LoopBodyOwner,
+ make, HasLoopBody,
},
AstNode, T,
};
diff --git a/crates/ide_assists/src/handlers/destructure_tuple_binding.rs b/crates/ide_assists/src/handlers/destructure_tuple_binding.rs
index a421f57754..a57b3c3904 100644
--- a/crates/ide_assists/src/handlers/destructure_tuple_binding.rs
+++ b/crates/ide_assists/src/handlers/destructure_tuple_binding.rs
@@ -5,7 +5,7 @@ use ide_db::{
};
use itertools::Itertools;
use syntax::{
- ast::{self, AstNode, FieldExpr, IdentPat, MethodCallExpr, NameOwner},
+ ast::{self, AstNode, FieldExpr, HasName, IdentPat, MethodCallExpr},
TextRange,
};
diff --git a/crates/ide_assists/src/handlers/extract_function.rs b/crates/ide_assists/src/handlers/extract_function.rs
index 733bb34788..4b11c5da19 100644
--- a/crates/ide_assists/src/handlers/extract_function.rs
+++ b/crates/ide_assists/src/handlers/extract_function.rs
@@ -636,7 +636,7 @@ impl FunctionBody {
let mut ancestors = self.parent()?.ancestors();
let infer_expr_opt = |expr| sema.type_of_expr(&expr?).map(TypeInfo::adjusted);
let mut parent_loop = None;
- let mut set_parent_loop = |loop_: &dyn ast::LoopBodyOwner| {
+ let mut set_parent_loop = |loop_: &dyn ast::HasLoopBody| {
if loop_
.loop_body()
.map_or(false, |it| it.syntax().text_range().contains_range(self.text_range()))
diff --git a/crates/ide_assists/src/handlers/extract_struct_from_enum_variant.rs b/crates/ide_assists/src/handlers/extract_struct_from_enum_variant.rs
index 3bc347b1e2..d481b8c298 100644
--- a/crates/ide_assists/src/handlers/extract_struct_from_enum_variant.rs
+++ b/crates/ide_assists/src/handlers/extract_struct_from_enum_variant.rs
@@ -15,8 +15,8 @@ use itertools::Itertools;
use rustc_hash::FxHashSet;
use syntax::{
ast::{
- self, edit::IndentLevel, edit_in_place::Indent, make, AstNode, AttrsOwner,
- GenericParamsOwner, NameOwner, TypeBoundsOwner, VisibilityOwner,
+ self, edit::IndentLevel, edit_in_place::Indent, make, AstNode, HasAttrs, HasGenericParams,
+ HasName, HasTypeBounds, HasVisibility,
},
match_ast,
ted::{self, Position},
diff --git a/crates/ide_assists/src/handlers/extract_type_alias.rs b/crates/ide_assists/src/handlers/extract_type_alias.rs
index a2dd23b58b..f0c4d521db 100644
--- a/crates/ide_assists/src/handlers/extract_type_alias.rs
+++ b/crates/ide_assists/src/handlers/extract_type_alias.rs
@@ -2,7 +2,7 @@ use either::Either;
use ide_db::helpers::node_ext::walk_ty;
use itertools::Itertools;
use syntax::{
- ast::{self, edit::IndentLevel, AstNode, GenericParamsOwner, NameOwner},
+ ast::{self, edit::IndentLevel, AstNode, HasGenericParams, HasName},
match_ast,
};
diff --git a/crates/ide_assists/src/handlers/fix_visibility.rs b/crates/ide_assists/src/handlers/fix_visibility.rs
index 08d665f8ee..80da4a35ad 100644
--- a/crates/ide_assists/src/handlers/fix_visibility.rs
+++ b/crates/ide_assists/src/handlers/fix_visibility.rs
@@ -1,7 +1,7 @@
use hir::{db::HirDatabase, HasSource, HasVisibility, PathResolution};
use ide_db::base_db::FileId;
use syntax::{
- ast::{self, VisibilityOwner},
+ ast::{self, HasVisibility as _},
AstNode, TextRange, TextSize,
};
@@ -147,7 +147,7 @@ fn target_data_for_def(
) -> Option<(TextSize, Option<ast::Visibility>, TextRange, FileId)>
where
S: HasSource<Ast = Ast>,
- Ast: AstNode + ast::VisibilityOwner,
+ Ast: AstNode + ast::HasVisibility,
{
let source = x.source(db)?;
let in_file_syntax = source.syntax();
diff --git a/crates/ide_assists/src/handlers/generate_default_from_enum_variant.rs b/crates/ide_assists/src/handlers/generate_default_from_enum_variant.rs
index e55c385029..e67789a662 100644
--- a/crates/ide_assists/src/handlers/generate_default_from_enum_variant.rs
+++ b/crates/ide_assists/src/handlers/generate_default_from_enum_variant.rs
@@ -1,5 +1,5 @@
use ide_db::{helpers::FamousDefs, RootDatabase};
-use syntax::ast::{self, AstNode, NameOwner};
+use syntax::ast::{self, AstNode, HasName};
use crate::{AssistContext, AssistId, AssistKind, Assists};
diff --git a/crates/ide_assists/src/handlers/generate_default_from_new.rs b/crates/ide_assists/src/handlers/generate_default_from_new.rs
index b54ec59da1..680ec0d1cd 100644
--- a/crates/ide_assists/src/handlers/generate_default_from_new.rs
+++ b/crates/ide_assists/src/handlers/generate_default_from_new.rs
@@ -2,7 +2,7 @@ use ide_db::helpers::FamousDefs;
use itertools::Itertools;
use stdx::format_to;
use syntax::{
- ast::{self, GenericParamsOwner, Impl, NameOwner, TypeBoundsOwner},
+ ast::{self, HasGenericParams, HasName, HasTypeBounds, Impl},
AstNode,
};
diff --git a/crates/ide_assists/src/handlers/generate_deref.rs b/crates/ide_assists/src/handlers/generate_deref.rs
index 4e10fdb854..2208c23c15 100644
--- a/crates/ide_assists/src/handlers/generate_deref.rs
+++ b/crates/ide_assists/src/handlers/generate_deref.rs
@@ -2,7 +2,7 @@ use std::fmt::Display;
use ide_db::{helpers::FamousDefs, RootDatabase};
use syntax::{
- ast::{self, NameOwner},
+ ast::{self, HasName},
AstNode, SyntaxNode,
};
diff --git a/crates/ide_assists/src/handlers/generate_derive.rs b/crates/ide_assists/src/handlers/generate_derive.rs
index adae8ab7e9..28483f795e 100644
--- a/crates/ide_assists/src/handlers/generate_derive.rs
+++ b/crates/ide_assists/src/handlers/generate_derive.rs
@@ -1,5 +1,5 @@
use syntax::{
- ast::{self, AstNode, AttrsOwner},
+ ast::{self, AstNode, HasAttrs},
SyntaxKind::{COMMENT, WHITESPACE},
TextSize,
};
diff --git a/crates/ide_assists/src/handlers/generate_enum_is_method.rs b/crates/ide_assists/src/handlers/generate_enum_is_method.rs
index 94216f2dff..c2a6e438b1 100644
--- a/crates/ide_assists/src/handlers/generate_enum_is_method.rs
+++ b/crates/ide_assists/src/handlers/generate_enum_is_method.rs
@@ -1,6 +1,6 @@
use stdx::to_lower_snake_case;
-use syntax::ast::VisibilityOwner;
-use syntax::ast::{self, AstNode, NameOwner};
+use syntax::ast::HasVisibility;
+use syntax::ast::{self, AstNode, HasName};
use crate::{
utils::{add_method_to_adt, find_struct_impl},
diff --git a/crates/ide_assists/src/handlers/generate_enum_projection_method.rs b/crates/ide_assists/src/handlers/generate_enum_projection_method.rs
index 986fb23155..a9116be67c 100644
--- a/crates/ide_assists/src/handlers/generate_enum_projection_method.rs
+++ b/crates/ide_assists/src/handlers/generate_enum_projection_method.rs
@@ -1,7 +1,7 @@
use itertools::Itertools;
use stdx::to_lower_snake_case;
-use syntax::ast::VisibilityOwner;
-use syntax::ast::{self, AstNode, NameOwner};
+use syntax::ast::HasVisibility;
+use syntax::ast::{self, AstNode, HasName};
use crate::{
utils::{add_method_to_adt, find_struct_impl},
diff --git a/crates/ide_assists/src/handlers/generate_from_impl_for_enum.rs b/crates/ide_assists/src/handlers/generate_from_impl_for_enum.rs
index 8727be07dd..96b751f099 100644
--- a/crates/ide_assists/src/handlers/generate_from_impl_for_enum.rs
+++ b/crates/ide_assists/src/handlers/generate_from_impl_for_enum.rs
@@ -1,6 +1,6 @@
use ide_db::helpers::FamousDefs;
use ide_db::RootDatabase;
-use syntax::ast::{self, AstNode, NameOwner};
+use syntax::ast::{self, AstNode, HasName};
use crate::{utils::generate_trait_impl_text, AssistContext, AssistId, AssistKind, Assists};
diff --git a/crates/ide_assists/src/handlers/generate_function.rs b/crates/ide_assists/src/handlers/generate_function.rs
index 0255e508b4..8a115087da 100644
--- a/crates/ide_assists/src/handlers/generate_function.rs
+++ b/crates/ide_assists/src/handlers/generate_function.rs
@@ -11,7 +11,7 @@ use syntax::{
ast::{
self,
edit::{AstNodeEdit, IndentLevel},
- make, ArgListOwner, AstNode, CallExpr, ModuleItemOwner,
+ make, AstNode, CallExpr, HasArgList, HasModuleItem,
},
SyntaxKind, SyntaxNode, TextRange, TextSize,
};
diff --git a/crates/ide_assists/src/handlers/generate_getter.rs b/crates/ide_assists/src/handlers/generate_getter.rs
index 739f3e592f..186e01fa9d 100644
--- a/crates/ide_assists/src/handlers/generate_getter.rs
+++ b/crates/ide_assists/src/handlers/generate_getter.rs
@@ -1,5 +1,5 @@
use stdx::{format_to, to_lower_snake_case};
-use syntax::ast::{self, AstNode, NameOwner, VisibilityOwner};
+use syntax::ast::{self, AstNode, HasName, HasVisibility};
use crate::{
utils::useless_type_special_case,
diff --git a/crates/ide_assists/src/handlers/generate_impl.rs b/crates/ide_assists/src/handlers/generate_impl.rs
index fd2e250bc3..58fea103f8 100644
--- a/crates/ide_assists/src/handlers/generate_impl.rs
+++ b/crates/ide_assists/src/handlers/generate_impl.rs
@@ -1,4 +1,4 @@
-use syntax::ast::{self, AstNode, NameOwner};
+use syntax::ast::{self, AstNode, HasName};
use crate::{utils::generate_impl_text, AssistContext, AssistId, AssistKind, Assists};
diff --git a/crates/ide_assists/src/handlers/generate_is_empty_from_len.rs b/crates/ide_assists/src/handlers/generate_is_empty_from_len.rs
index 910010a044..d831289775 100644
--- a/crates/ide_assists/src/handlers/generate_is_empty_from_len.rs
+++ b/crates/ide_assists/src/handlers/generate_is_empty_from_len.rs
@@ -1,6 +1,6 @@
use hir::{known, HasSource, Name};
use syntax::{
- ast::{self, NameOwner},
+ ast::{self, HasName},
AstNode,
};
diff --git a/crates/ide_assists/src/handlers/generate_new.rs b/crates/ide_assists/src/handlers/generate_new.rs
index b65e8387b0..6a1f710f6d 100644
--- a/crates/ide_assists/src/handlers/generate_new.rs
+++ b/crates/ide_assists/src/handlers/generate_new.rs
@@ -1,6 +1,6 @@
use itertools::Itertools;
use stdx::format_to;
-use syntax::ast::{self, AstNode, NameOwner, StructKind, VisibilityOwner};
+use syntax::ast::{self, AstNode, HasName, HasVisibility, StructKind};
use crate::{
utils::{find_impl_block_start, find_struct_impl, generate_impl_text},
diff --git a/crates/ide_assists/src/handlers/generate_setter.rs b/crates/ide_assists/src/handlers/generate_setter.rs
index 5bdf6b3f44..5005ac9f5c 100644
--- a/crates/ide_assists/src/handlers/generate_setter.rs
+++ b/crates/ide_assists/src/handlers/generate_setter.rs
@@ -1,5 +1,5 @@
use stdx::{format_to, to_lower_snake_case};
-use syntax::ast::{self, AstNode, NameOwner, VisibilityOwner};
+use syntax::ast::{self, AstNode, HasName, HasVisibility};
use crate::{
utils::{find_impl_block_end, find_struct_impl, generate_impl_text},
diff --git a/crates/ide_assists/src/handlers/inline_call.rs b/crates/ide_assists/src/handlers/inline_call.rs
index bd566ec820..14313fefa7 100644
--- a/crates/ide_assists/src/handlers/inline_call.rs
+++ b/crates/ide_assists/src/handlers/inline_call.rs
@@ -11,7 +11,7 @@ use ide_db::{
};
use itertools::{izip, Itertools};
use syntax::{
- ast::{self, edit_in_place::Indent, ArgListOwner},
+ ast::{self, edit_in_place::Indent, HasArgList},
ted, AstNode, SyntaxNode,
};
diff --git a/crates/ide_assists/src/handlers/inline_local_variable.rs b/crates/ide_assists/src/handlers/inline_local_variable.rs
index 337cd6cb5a..f01dff0965 100644
--- a/crates/ide_assists/src/handlers/inline_local_variable.rs
+++ b/crates/ide_assists/src/handlers/inline_local_variable.rs
@@ -7,7 +7,7 @@ use ide_db::{
RootDatabase,
};
use syntax::{
- ast::{self, AstNode, AstToken, NameOwner},
+ ast::{self, AstNode, AstToken, HasName},
SyntaxElement, TextRange,
};
diff --git a/crates/ide_assists/src/handlers/introduce_named_lifetime.rs b/crates/ide_assists/src/handlers/introduce_named_lifetime.rs
index 8077f73d1e..ec6be2e816 100644
--- a/crates/ide_assists/src/handlers/introduce_named_lifetime.rs
+++ b/crates/ide_assists/src/handlers/introduce_named_lifetime.rs
@@ -1,6 +1,6 @@
use rustc_hash::FxHashSet;
use syntax::{
- ast::{self, edit_in_place::GenericParamsOwnerEdit, make, GenericParamsOwner},
+ ast::{self, edit_in_place::GenericParamsOwnerEdit, make, HasGenericParams},
ted::{self, Position},
AstNode, TextRange,
};
diff --git a/crates/ide_assists/src/handlers/move_bounds.rs b/crates/ide_assists/src/handlers/move_bounds.rs
index d89d11bdf4..01c6eea225 100644
--- a/crates/ide_assists/src/handlers/move_bounds.rs
+++ b/crates/ide_assists/src/handlers/move_bounds.rs
@@ -1,5 +1,5 @@
use syntax::{
- ast::{self, edit_in_place::GenericParamsOwnerEdit, make, AstNode, NameOwner, TypeBoundsOwner},
+ ast::{self, edit_in_place::GenericParamsOwnerEdit, make, AstNode, HasName, HasTypeBounds},
match_ast,
};
diff --git a/crates/ide_assists/src/handlers/move_module_to_file.rs b/crates/ide_assists/src/handlers/move_module_to_file.rs
index cfc54be8d1..30dc7c5fa4 100644
--- a/crates/ide_assists/src/handlers/move_module_to_file.rs
+++ b/crates/ide_assists/src/handlers/move_module_to_file.rs
@@ -5,7 +5,7 @@ use ide_db::base_db::AnchoredPathBuf;
use itertools::Itertools;
use stdx::format_to;
use syntax::{
- ast::{self, edit::AstNodeEdit, NameOwner},
+ ast::{self, edit::AstNodeEdit, HasName},
AstNode, TextRange,
};
diff --git a/crates/ide_assists/src/handlers/qualify_path.rs b/crates/ide_assists/src/handlers/qualify_path.rs
index 2510eae971..8a2ec8ba80 100644
--- a/crates/ide_assists/src/handlers/qualify_path.rs
+++ b/crates/ide_assists/src/handlers/qualify_path.rs
@@ -8,7 +8,7 @@ use ide_db::helpers::{
use ide_db::RootDatabase;
use syntax::{
ast,
- ast::{make, ArgListOwner},
+ ast::{make, HasArgList},
AstNode,
};
diff --git a/crates/ide_assists/src/handlers/remove_unused_param.rs b/crates/ide_assists/src/handlers/remove_unused_param.rs
index 75b9f827d7..545809a71d 100644
--- a/crates/ide_assists/src/handlers/remove_unused_param.rs
+++ b/crates/ide_assists/src/handlers/remove_unused_param.rs
@@ -1,7 +1,7 @@
use ide_db::{base_db::FileId, defs::Definition, search::FileReference};
use syntax::{
algo::find_node_at_range,
- ast::{self, ArgListOwner},
+ ast::{self, HasArgList},
AstNode, SourceFile, SyntaxKind, SyntaxNode, TextRange, T,
};
diff --git a/crates/ide_assists/src/handlers/reorder_impl.rs b/crates/ide_assists/src/handlers/reorder_impl.rs
index d398373c34..8ae12ab1f4 100644
--- a/crates/ide_assists/src/handlers/reorder_impl.rs
+++ b/crates/ide_assists/src/handlers/reorder_impl.rs
@@ -4,7 +4,7 @@ use rustc_hash::FxHashMap;
use hir::{PathResolution, Semantics};
use ide_db::RootDatabase;
use syntax::{
- ast::{self, NameOwner},
+ ast::{self, HasName},
ted, AstNode,
};
diff --git a/crates/ide_assists/src/handlers/replace_derive_with_manual_impl.rs b/crates/ide_assists/src/handlers/replace_derive_with_manual_impl.rs
index d6319ea5c1..c0b7db332e 100644
--- a/crates/ide_assists/src/handlers/replace_derive_with_manual_impl.rs
+++ b/crates/ide_assists/src/handlers/replace_derive_with_manual_impl.rs
@@ -3,7 +3,7 @@ use ide_db::helpers::{import_assets::NameToImport, mod_path_to_ast};
use ide_db::items_locator;
use itertools::Itertools;
use syntax::{
- ast::{self, make, AstNode, NameOwner},
+ ast::{self, make, AstNode, HasName},
SyntaxKind::{IDENT, WHITESPACE},
};
diff --git a/crates/ide_assists/src/handlers/replace_if_let_with_match.rs b/crates/ide_assists/src/handlers/replace_if_let_with_match.rs
index 1873653306..3a89c2b996 100644
--- a/crates/ide_assists/src/handlers/replace_if_let_with_match.rs
+++ b/crates/ide_assists/src/handlers/replace_if_let_with_match.rs
@@ -6,7 +6,7 @@ use syntax::{
ast::{
self,
edit::{AstNodeEdit, IndentLevel},
- make, NameOwner,
+ make, HasName,
},
AstNode, TextRange,
};
diff --git a/crates/ide_assists/src/handlers/sort_items.rs b/crates/ide_assists/src/handlers/sort_items.rs
index f318c048b1..a9d4f4299e 100644
--- a/crates/ide_assists/src/handlers/sort_items.rs
+++ b/crates/ide_assists/src/handlers/sort_items.rs
@@ -3,7 +3,7 @@ use std::cmp::Ordering;
use itertools::Itertools;
use syntax::{
- ast::{self, NameOwner},
+ ast::{self, HasName},
ted, AstNode, TextRange,
};
@@ -195,7 +195,7 @@ fn add_sort_variants_assist(acc: &mut Assists, variant_list: ast::VariantList) -
)
}
-fn sort_by_name<T: NameOwner + Clone>(initial: &[T]) -> Vec<T> {
+fn sort_by_name<T: HasName + Clone>(initial: &[T]) -> Vec<T> {
initial
.iter()
.cloned()
diff --git a/crates/ide_assists/src/handlers/toggle_ignore.rs b/crates/ide_assists/src/handlers/toggle_ignore.rs
index 4da6089cac..feaa24c1fe 100644
--- a/crates/ide_assists/src/handlers/toggle_ignore.rs
+++ b/crates/ide_assists/src/handlers/toggle_ignore.rs
@@ -1,5 +1,5 @@
use syntax::{
- ast::{self, AttrsOwner},
+ ast::{self, HasAttrs},
AstNode, AstToken,
};
diff --git a/crates/ide_assists/src/handlers/unmerge_use.rs b/crates/ide_assists/src/handlers/unmerge_use.rs
index 22853b7e36..71a816e19f 100644
--- a/crates/ide_assists/src/handlers/unmerge_use.rs
+++ b/crates/ide_assists/src/handlers/unmerge_use.rs
@@ -1,6 +1,6 @@
use itertools::Itertools;
use syntax::{
- ast::{self, make, VisibilityOwner},
+ ast::{self, make, HasVisibility},
ted::{self, Position},
AstNode, SyntaxKind,
};
diff --git a/crates/ide_assists/src/utils.rs b/crates/ide_assists/src/utils.rs
index aa0956d0f6..9bc70bc3fe 100644
--- a/crates/ide_assists/src/utils.rs
+++ b/crates/ide_assists/src/utils.rs
@@ -14,7 +14,7 @@ use syntax::{
self,
edit::{self, AstNodeEdit},
edit_in_place::AttrsOwnerEdit,
- make, ArgListOwner, AttrsOwner, GenericParamsOwner, NameOwner, TypeBoundsOwner,
+ make, HasArgList, HasAttrs, HasGenericParams, HasName, HasTypeBounds,
},
ted, AstNode, Direction, SmolStr,
SyntaxKind::*,
diff --git a/crates/ide_assists/src/utils/gen_trait_fn_body.rs b/crates/ide_assists/src/utils/gen_trait_fn_body.rs
index eb4a23a8da..6915460209 100644
--- a/crates/ide_assists/src/utils/gen_trait_fn_body.rs
+++ b/crates/ide_assists/src/utils/gen_trait_fn_body.rs
@@ -1,7 +1,7 @@
//! This module contains functions to generate default trait impl function bodies where possible.
use syntax::{
- ast::{self, edit::AstNodeEdit, make, AstNode, BinaryOp, CmpOp, LogicOp, NameOwner},
+ ast::{self, edit::AstNodeEdit, make, AstNode, BinaryOp, CmpOp, HasName, LogicOp},
ted,
};
diff --git a/crates/ide_assists/src/utils/suggest_name.rs b/crates/ide_assists/src/utils/suggest_name.rs
index 17db6d3c19..35e2300196 100644
--- a/crates/ide_assists/src/utils/suggest_name.rs
+++ b/crates/ide_assists/src/utils/suggest_name.rs
@@ -5,7 +5,7 @@ use ide_db::RootDatabase;
use itertools::Itertools;
use stdx::to_lower_snake_case;
use syntax::{
- ast::{self, NameOwner},
+ ast::{self, HasName},
match_ast, AstNode, SmolStr,
};
diff --git a/crates/ide_completion/src/completions/fn_param.rs b/crates/ide_completion/src/completions/fn_param.rs
index 28da6d69c8..a9f1944e28 100644
--- a/crates/ide_completion/src/completions/fn_param.rs
+++ b/crates/ide_completion/src/completions/fn_param.rs
@@ -2,7 +2,7 @@
use rustc_hash::FxHashMap;
use syntax::{
- ast::{self, ModuleItemOwner},
+ ast::{self, HasModuleItem},
match_ast, AstNode,
};
diff --git a/crates/ide_completion/src/context.rs b/crates/ide_completion/src/context.rs
index 7d5c36d01f..9d3e894a3d 100644
--- a/crates/ide_completion/src/context.rs
+++ b/crates/ide_completion/src/context.rs
@@ -9,7 +9,7 @@ use ide_db::{
};
use syntax::{
algo::find_node_at_offset,
- ast::{self, NameOrNameRef, NameOwner},
+ ast::{self, HasName, NameOrNameRef},
match_ast, AstNode, NodeOrToken,
SyntaxKind::{self, *},
SyntaxNode, SyntaxToken, TextRange, TextSize, T,
diff --git a/crates/ide_completion/src/patterns.rs b/crates/ide_completion/src/patterns.rs
index 05792dd47e..381a6a83aa 100644
--- a/crates/ide_completion/src/patterns.rs
+++ b/crates/ide_completion/src/patterns.rs
@@ -8,7 +8,7 @@ use hir::Semantics;
use ide_db::RootDatabase;
use syntax::{
algo::non_trivia_sibling,
- ast::{self, ArgListOwner, LoopBodyOwner},
+ ast::{self, HasArgList, HasLoopBody},
match_ast, AstNode, Direction, SyntaxElement,
SyntaxKind::*,
SyntaxNode, SyntaxToken, TextRange, TextSize, T,
diff --git a/crates/ide_completion/src/render/const_.rs b/crates/ide_completion/src/render/const_.rs
index 4609f2e967..166ae3c16b 100644
--- a/crates/ide_completion/src/render/const_.rs
+++ b/crates/ide_completion/src/render/const_.rs
@@ -3,7 +3,7 @@
use hir::{AsAssocItem, HasSource};
use ide_db::SymbolKind;
use syntax::{
- ast::{Const, NameOwner},
+ ast::{Const, HasName},
display::const_label,
};
diff --git a/crates/ide_completion/src/render/type_alias.rs b/crates/ide_completion/src/render/type_alias.rs
index 6021448e78..c1e6182643 100644
--- a/crates/ide_completion/src/render/type_alias.rs
+++ b/crates/ide_completion/src/render/type_alias.rs
@@ -3,7 +3,7 @@
use hir::{AsAssocItem, HasSource};
use ide_db::SymbolKind;
use syntax::{
- ast::{NameOwner, TypeAlias},
+ ast::{HasName, TypeAlias},
display::type_label,
};
diff --git a/crates/ide_db/src/call_info.rs b/crates/ide_db/src/call_info.rs
index 3d32fddd93..e1d85f0411 100644
--- a/crates/ide_db/src/call_info.rs
+++ b/crates/ide_db/src/call_info.rs
@@ -5,7 +5,7 @@ use hir::{HasAttrs, HirDisplay, Semantics, Type};
use stdx::format_to;
use syntax::{
algo,
- ast::{self, ArgListOwner, NameOwner},
+ ast::{self, HasArgList, HasName},
match_ast, AstNode, Direction, SyntaxNode, SyntaxToken, TextRange, TextSize,
};
diff --git a/crates/ide_db/src/helpers.rs b/crates/ide_db/src/helpers.rs
index a52c4046bf..a8087d47fe 100644
--- a/crates/ide_db/src/helpers.rs
+++ b/crates/ide_db/src/helpers.rs
@@ -13,7 +13,7 @@ use base_db::FileId;
use either::Either;
use hir::{ItemInNs, MacroDef, ModuleDef, Name, Semantics};
use syntax::{
- ast::{self, make, LoopBodyOwner},
+ ast::{self, make, HasLoopBody},
AstNode, Direction, SyntaxElement, SyntaxKind, SyntaxToken, TokenAtOffset, WalkEvent, T,
};
diff --git a/crates/ide_db/src/helpers/import_assets.rs b/crates/ide_db/src/helpers/import_assets.rs
index a672c10917..d6bb19d129 100644
--- a/crates/ide_db/src/helpers/import_assets.rs
+++ b/crates/ide_db/src/helpers/import_assets.rs
@@ -6,7 +6,7 @@ use hir::{
use itertools::Itertools;
use rustc_hash::FxHashSet;
use syntax::{
- ast::{self, NameOwner},
+ ast::{self, HasName},
utils::path_to_string_stripping_turbo_fish,
AstNode, SyntaxNode,
};
diff --git a/crates/ide_db/src/helpers/insert_use.rs b/crates/ide_db/src/helpers/insert_use.rs
index a8ac0a9006..a5d1932775 100644
--- a/crates/ide_db/src/helpers/insert_use.rs
+++ b/crates/ide_db/src/helpers/insert_use.rs
@@ -7,7 +7,7 @@ use std::cmp::Ordering;
use hir::Semantics;
use syntax::{
algo,
- ast::{self, make, AstNode, AttrsOwner, ModuleItemOwner, PathSegmentKind, VisibilityOwner},
+ ast::{self, make, AstNode, HasAttrs, HasModuleItem, HasVisibility, PathSegmentKind},
match_ast, ted, AstToken, Direction, NodeOrToken, SyntaxNode, SyntaxToken,
};
@@ -51,7 +51,7 @@ pub enum ImportScope {
impl ImportScope {
fn from(syntax: SyntaxNode) -> Option<Self> {
- fn contains_cfg_attr(attrs: &dyn AttrsOwner) -> bool {
+ fn contains_cfg_attr(attrs: &dyn HasAttrs) -> bool {
attrs
.attrs()
.any(|attr| attr.as_simple_call().map_or(false, |(ident, _)| ident == "cfg"))
diff --git a/crates/ide_db/src/helpers/merge_imports.rs b/crates/ide_db/src/helpers/merge_imports.rs
index 6f130e99b4..8189d6e53f 100644
--- a/crates/ide_db/src/helpers/merge_imports.rs
+++ b/crates/ide_db/src/helpers/merge_imports.rs
@@ -3,7 +3,7 @@ use std::cmp::Ordering;
use itertools::{EitherOrBoth, Itertools};
use syntax::{
- ast::{self, make, AstNode, AttrsOwner, PathSegmentKind, VisibilityOwner},
+ ast::{self, make, AstNode, HasAttrs, HasVisibility, PathSegmentKind},
ted,
};
diff --git a/crates/ide_db/src/rename.rs b/crates/ide_db/src/rename.rs
index a5dca509fe..0ca0dc8c6b 100644
--- a/crates/ide_db/src/rename.rs
+++ b/crates/ide_db/src/rename.rs
@@ -27,7 +27,7 @@ use either::Either;
use hir::{AsAssocItem, FieldSource, HasSource, InFile, ModuleSource, Semantics};
use stdx::never;
use syntax::{
- ast::{self, NameOwner},
+ ast::{self, HasName},
lex_single_syntax_kind, AstNode, SyntaxKind, TextRange, T,
};
use text_edit::{TextEdit, TextEditBuilder};
@@ -156,7 +156,7 @@ impl Definition {
fn name_range<D>(def: D, sema: &Semantics<RootDatabase>) -> Option<FileRange>
where
D: HasSource,
- D::Ast: ast::NameOwner,
+ D::Ast: ast::HasName,
{
let src = def.source(sema.db)?;
let name = src.value.name()?;
diff --git a/crates/ide_db/src/symbol_index.rs b/crates/ide_db/src/symbol_index.rs
index fb3568b107..54ceafa67f 100644
--- a/crates/ide_db/src/symbol_index.rs
+++ b/crates/ide_db/src/symbol_index.rs
@@ -37,7 +37,7 @@ use hir::db::DefDatabase;
use rayon::prelude::*;
use rustc_hash::{FxHashMap, FxHashSet};
use syntax::{
- ast::{self, NameOwner},
+ ast::{self, HasName},
match_ast, AstNode, Parse, SmolStr, SourceFile,
SyntaxKind::*,
SyntaxNode, SyntaxNodePtr, TextRange, WalkEvent,
@@ -427,7 +427,7 @@ fn source_file_to_file_symbols(source_file: &SourceFile, file_id: FileId) -> Vec
}
fn to_symbol(node: &SyntaxNode) -> Option<(SmolStr, SyntaxNodePtr, TextRange)> {
- fn decl<N: NameOwner>(node: N) -> Option<(SmolStr, SyntaxNodePtr, TextRange)> {
+ fn decl<N: HasName>(node: N) -> Option<(SmolStr, SyntaxNodePtr, TextRange)> {
let name = node.name()?;
let name_range = name.syntax().text_range();
let name = name.text().into();
diff --git a/crates/ide_db/src/traits.rs b/crates/ide_db/src/traits.rs
index 66ae81c73e..def7a8acaa 100644
--- a/crates/ide_db/src/traits.rs
+++ b/crates/ide_db/src/traits.rs
@@ -4,7 +4,7 @@ use crate::RootDatabase;
use hir::Semantics;
use rustc_hash::FxHashSet;
use syntax::{
- ast::{self, NameOwner},
+ ast::{self, HasName},
AstNode,
};
diff --git a/crates/ide_diagnostics/src/handlers/replace_filter_map_next_with_find_map.rs b/crates/ide_diagnostics/src/handlers/replace_filter_map_next_with_find_map.rs
index c47ceab33d..9826e1c707 100644
--- a/crates/ide_diagnostics/src/handlers/replace_filter_map_next_with_find_map.rs
+++ b/crates/ide_diagnostics/src/handlers/replace_filter_map_next_with_find_map.rs
@@ -1,7 +1,7 @@
use hir::{db::AstDatabase, InFile};
use ide_db::source_change::SourceChange;
use syntax::{
- ast::{self, ArgListOwner},
+ ast::{self, HasArgList},
AstNode, TextRange,
};
use text_edit::TextEdit;
diff --git a/crates/ide_diagnostics/src/handlers/unlinked_file.rs b/crates/ide_diagnostics/src/handlers/unlinked_file.rs
index 9eafd42d86..cc10a63f87 100644
--- a/crates/ide_diagnostics/src/handlers/unlinked_file.rs
+++ b/crates/ide_diagnostics/src/handlers/unlinked_file.rs
@@ -7,7 +7,7 @@ use ide_db::{
RootDatabase,
};
use syntax::{
- ast::{self, ModuleItemOwner, NameOwner},
+ ast::{self, HasModuleItem, HasName},
AstNode, TextRange, TextSize,
};
use text_edit::TextEdit;
diff --git a/crates/ide_ssr/src/matching.rs b/crates/ide_ssr/src/matching.rs
index 6812947218..88c1d80608 100644
--- a/crates/ide_ssr/src/matching.rs
+++ b/crates/ide_ssr/src/matching.rs
@@ -527,7 +527,7 @@ impl<'db, 'sema> Matcher<'db, 'sema> {
pattern_ufcs: &UfcsCallInfo,
code: &ast::MethodCallExpr,
) -> Result<(), MatchFailed> {
- use ast::ArgListOwner;
+ use ast::HasArgList;
let code_resolved_function = self
.sema
.resolve_method_call(code)
@@ -587,7 +587,7 @@ impl<'db, 'sema> Matcher<'db, 'sema> {
pattern_ufcs: &UfcsCallInfo,
code: &ast::CallExpr,
) -> Result<(), MatchFailed> {
- use ast::ArgListOwner;
+ use ast::HasArgList;
// Check that the first argument is the expected type.
if let (Some(pattern_type), Some(expr)) = (
&pattern_ufcs.qualifier_type,
diff --git a/crates/mbe/src/benchmark.rs b/crates/mbe/src/benchmark.rs
index ffa316dd24..cd5d76be3c 100644
--- a/crates/mbe/src/benchmark.rs
+++ b/crates/mbe/src/benchmark.rs
@@ -2,7 +2,7 @@
use rustc_hash::FxHashMap;
use syntax::{
- ast::{self, NameOwner},
+ ast::{self, HasName},
AstNode, SmolStr,
};
use test_utils::{bench, bench_fixture, skip_slow_tests};
diff --git a/crates/mbe/src/tests.rs b/crates/mbe/src/tests.rs
index e6ac9754da..26924fa8f3 100644
--- a/crates/mbe/src/tests.rs
+++ b/crates/mbe/src/tests.rs
@@ -238,7 +238,7 @@ fn debug_dump_ignore_spaces(node: &syntax::SyntaxNode) -> String {
#[test]
fn test_node_to_tt_censor() {
- use syntax::ast::{AttrsOwner, ModuleItemOwner};
+ use syntax::ast::{HasAttrs, HasModuleItem};
let source = r##"
#[attr0]
diff --git a/crates/syntax/src/ast.rs b/crates/syntax/src/ast.rs
index e07b22a550..e57c3d2fe4 100644
--- a/crates/syntax/src/ast.rs
+++ b/crates/syntax/src/ast.rs
@@ -30,8 +30,8 @@ pub use self::{
QuoteOffsets, Radix,
},
traits::{
- ArgListOwner, AttrsOwner, CommentIter, DocCommentsOwner, GenericParamsOwner, LoopBodyOwner,
- ModuleItemOwner, NameOwner, TypeBoundsOwner, VisibilityOwner,
+ CommentIter, HasArgList, HasAttrs, HasDocComments, HasGenericParams, HasLoopBody,
+ HasModuleItem, HasName, HasTypeBounds, HasVisibility,
},
};
@@ -118,7 +118,7 @@ mod support {
#[test]
fn assert_ast_is_object_safe() {
- fn _f(_: &dyn AstNode, _: &dyn NameOwner) {}
+ fn _f(_: &dyn AstNode, _: &dyn HasName) {}
}
#[test]
diff --git a/crates/syntax/src/ast/edit_in_place.rs b/crates/syntax/src/ast/edit_in_place.rs
index d6775c89ba..4b354f7b32 100644
--- a/crates/syntax/src/ast/edit_in_place.rs
+++ b/crates/syntax/src/ast/edit_in_place.rs
@@ -7,16 +7,16 @@ use rowan::SyntaxElement;
use crate::{
algo::neighbor,
- ast::{self, edit::IndentLevel, make, GenericParamsOwner},
+ ast::{self, edit::IndentLevel, make, HasGenericParams},
ted::{self, Position},
AstNode, AstToken, Direction,
SyntaxKind::{ATTR, COMMENT, WHITESPACE},
SyntaxNode,
};
-use super::NameOwner;
+use super::HasName;
-pub trait GenericParamsOwnerEdit: ast::GenericParamsOwner {
+pub trait GenericParamsOwnerEdit: ast::HasGenericParams {
fn get_or_create_generic_param_list(&self) -> ast::GenericParamList;
fn get_or_create_where_clause(&self) -> ast::WhereClause;
}
@@ -194,7 +194,7 @@ fn create_generic_param_list(position: Position) -> ast::GenericParamList {
gpl
}
-pub trait AttrsOwnerEdit: ast::AttrsOwner {
+pub trait AttrsOwnerEdit: ast::HasAttrs {
fn remove_attrs_and_docs(&self) {
remove_attrs_and_docs(self.syntax());
@@ -218,7 +218,7 @@ pub trait AttrsOwnerEdit: ast::AttrsOwner {
}
}
-impl<T: ast::AttrsOwner> AttrsOwnerEdit for T {}
+impl<T: ast::HasAttrs> AttrsOwnerEdit for T {}
impl ast::GenericParamList {
pub fn add_generic_param(&self, generic_param: ast::GenericParam) {
diff --git a/crates/syntax/src/ast/expr_ext.rs b/crates/syntax/src/ast/expr_ext.rs
index 4f92cc0671..7363ad905a 100644
--- a/crates/syntax/src/ast/expr_ext.rs
+++ b/crates/syntax/src/ast/expr_ext.rs
@@ -13,7 +13,7 @@ use crate::{
SyntaxToken, T,
};
-impl ast::AttrsOwner for ast::Expr {}
+impl ast::HasAttrs for ast::Expr {}
impl ast::Expr {
pub fn is_block_like(&self) -> bool {
diff --git a/crates/syntax/src/ast/generated/nodes.rs b/crates/syntax/src/ast/generated/nodes.rs
index 9fbd4aea19..5d92a0f9e5 100644
--- a/crates/syntax/src/ast/generated/nodes.rs
+++ b/crates/syntax/src/ast/generated/nodes.rs
@@ -104,7 +104,7 @@ impl TypeArg {
pub struct AssocTypeArg {
pub(crate) syntax: SyntaxNode,
}
-impl ast::TypeBoundsOwner for AssocTypeArg {}
+impl ast::HasTypeBounds for AssocTypeArg {}
impl AssocTypeArg {
pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
pub fn generic_param_list(&self) -> Option<GenericParamList> { support::child(&self.syntax) }
@@ -145,7 +145,7 @@ impl TypeBoundList {
pub struct MacroCall {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for MacroCall {}
+impl ast::HasAttrs for MacroCall {}
impl MacroCall {
pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) }
@@ -179,7 +179,7 @@ impl TokenTree {
pub struct MacroItems {
pub(crate) syntax: SyntaxNode,
}
-impl ast::ModuleItemOwner for MacroItems {}
+impl ast::HasModuleItem for MacroItems {}
impl MacroItems {}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct MacroStmts {
@@ -193,8 +193,8 @@ impl MacroStmts {
pub struct SourceFile {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for SourceFile {}
-impl ast::ModuleItemOwner for SourceFile {}
+impl ast::HasAttrs for SourceFile {}
+impl ast::HasModuleItem for SourceFile {}
impl SourceFile {
pub fn shebang_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![shebang]) }
}
@@ -202,9 +202,9 @@ impl SourceFile {
pub struct Const {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for Const {}
-impl ast::NameOwner for Const {}
-impl ast::VisibilityOwner for Const {}
+impl ast::HasAttrs for Const {}
+impl ast::HasName for Const {}
+impl ast::HasVisibility for Const {}
impl Const {
pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) }
pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
@@ -219,10 +219,10 @@ impl Const {
pub struct Enum {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for Enum {}
-impl ast::NameOwner for Enum {}
-impl ast::VisibilityOwner for Enum {}
-impl ast::GenericParamsOwner for Enum {}
+impl ast::HasAttrs for Enum {}
+impl ast::HasName for Enum {}
+impl ast::HasVisibility for Enum {}
+impl ast::HasGenericParams for Enum {}
impl Enum {
pub fn enum_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![enum]) }
pub fn variant_list(&self) -> Option<VariantList> { support::child(&self.syntax) }
@@ -231,7 +231,7 @@ impl Enum {
pub struct ExternBlock {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for ExternBlock {}
+impl ast::HasAttrs for ExternBlock {}
impl ExternBlock {
pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) }
pub fn extern_item_list(&self) -> Option<ExternItemList> { support::child(&self.syntax) }
@@ -240,8 +240,8 @@ impl ExternBlock {
pub struct ExternCrate {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for ExternCrate {}
-impl ast::VisibilityOwner for ExternCrate {}
+impl ast::HasAttrs for ExternCrate {}
+impl ast::HasVisibility for ExternCrate {}
impl ExternCrate {
pub fn extern_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![extern]) }
pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) }
@@ -253,10 +253,10 @@ impl ExternCrate {
pub struct Fn {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for Fn {}
-impl ast::NameOwner for Fn {}
-impl ast::VisibilityOwner for Fn {}
-impl ast::GenericParamsOwner for Fn {}
+impl ast::HasAttrs for Fn {}
+impl ast::HasName for Fn {}
+impl ast::HasVisibility for Fn {}
+impl ast::HasGenericParams for Fn {}
impl Fn {
pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) }
pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
@@ -273,9 +273,9 @@ impl Fn {
pub struct Impl {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for Impl {}
-impl ast::VisibilityOwner for Impl {}
-impl ast::GenericParamsOwner for Impl {}
+impl ast::HasAttrs for Impl {}
+impl ast::HasVisibility for Impl {}
+impl ast::HasGenericParams for Impl {}
impl Impl {
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]) }
@@ -289,9 +289,9 @@ impl Impl {
pub struct MacroRules {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for MacroRules {}
-impl ast::NameOwner for MacroRules {}
-impl ast::VisibilityOwner for MacroRules {}
+impl ast::HasAttrs for MacroRules {}
+impl ast::HasName for MacroRules {}
+impl ast::HasVisibility for MacroRules {}
impl MacroRules {
pub fn macro_rules_token(&self) -> Option<SyntaxToken> {
support::token(&self.syntax, T![macro_rules])
@@ -303,9 +303,9 @@ impl MacroRules {
pub struct MacroDef {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for MacroDef {}
-impl ast::NameOwner for MacroDef {}
-impl ast::VisibilityOwner for MacroDef {}
+impl ast::HasAttrs for MacroDef {}
+impl ast::HasName for MacroDef {}
+impl ast::HasVisibility for MacroDef {}
impl MacroDef {
pub fn macro_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![macro]) }
pub fn args(&self) -> Option<TokenTree> { support::child(&self.syntax) }
@@ -315,9 +315,9 @@ impl MacroDef {
pub struct Module {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for Module {}
-impl ast::NameOwner for Module {}
-impl ast::VisibilityOwner for Module {}
+impl ast::HasAttrs for Module {}
+impl ast::HasName for Module {}
+impl ast::HasVisibility for Module {}
impl Module {
pub fn mod_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mod]) }
pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) }
@@ -327,9 +327,9 @@ impl Module {
pub struct Static {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for Static {}
-impl ast::NameOwner for Static {}
-impl ast::VisibilityOwner for Static {}
+impl ast::HasAttrs for Static {}
+impl ast::HasName for Static {}
+impl ast::HasVisibility for Static {}
impl Static {
pub fn static_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![static]) }
pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
@@ -343,10 +343,10 @@ impl Static {
pub struct Struct {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for Struct {}
-impl ast::NameOwner for Struct {}
-impl ast::VisibilityOwner for Struct {}
-impl ast::GenericParamsOwner for Struct {}
+impl ast::HasAttrs for Struct {}
+impl ast::HasName for Struct {}
+impl ast::HasVisibility for Struct {}
+impl ast::HasGenericParams for Struct {}
impl Struct {
pub fn struct_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![struct]) }
pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
@@ -356,11 +356,11 @@ impl Struct {
pub struct Trait {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for Trait {}
-impl ast::NameOwner for Trait {}
-impl ast::VisibilityOwner for Trait {}
-impl ast::GenericParamsOwner for Trait {}
-impl ast::TypeBoundsOwner for Trait {}
+impl ast::HasAttrs for Trait {}
+impl ast::HasName for Trait {}
+impl ast::HasVisibility for Trait {}
+impl ast::HasGenericParams for Trait {}
+impl ast::HasTypeBounds for Trait {}
impl Trait {
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]) }
@@ -371,11 +371,11 @@ impl Trait {
pub struct TypeAlias {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for TypeAlias {}
-impl ast::NameOwner for TypeAlias {}
-impl ast::VisibilityOwner for TypeAlias {}
-impl ast::GenericParamsOwner for TypeAlias {}
-impl ast::TypeBoundsOwner for TypeAlias {}
+impl ast::HasAttrs for TypeAlias {}
+impl ast::HasName for TypeAlias {}
+impl ast::HasVisibility for TypeAlias {}
+impl ast::HasGenericParams for TypeAlias {}
+impl ast::HasTypeBounds for TypeAlias {}
impl TypeAlias {
pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) }
pub fn type_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![type]) }
@@ -387,10 +387,10 @@ impl TypeAlias {
pub struct Union {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for Union {}
-impl ast::NameOwner for Union {}
-impl ast::VisibilityOwner for Union {}
-impl ast::GenericParamsOwner for Union {}
+impl ast::HasAttrs for Union {}
+impl ast::HasName for Union {}
+impl ast::HasVisibility for Union {}
+impl ast::HasGenericParams for Union {}
impl Union {
pub fn union_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![union]) }
pub fn record_field_list(&self) -> Option<RecordFieldList> { support::child(&self.syntax) }
@@ -399,8 +399,8 @@ impl Union {
pub struct Use {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for Use {}
-impl ast::VisibilityOwner for Use {}
+impl ast::HasAttrs for Use {}
+impl ast::HasVisibility for Use {}
impl Use {
pub fn use_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![use]) }
pub fn use_tree(&self) -> Option<UseTree> { support::child(&self.syntax) }
@@ -421,8 +421,8 @@ impl Visibility {
pub struct ItemList {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for ItemList {}
-impl ast::ModuleItemOwner for ItemList {}
+impl ast::HasAttrs for ItemList {}
+impl ast::HasModuleItem for ItemList {}
impl ItemList {
pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
@@ -431,7 +431,7 @@ impl ItemList {
pub struct Rename {
pub(crate) syntax: SyntaxNode,
}
-impl ast::NameOwner for Rename {}
+impl ast::HasName for Rename {}
impl Rename {
pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) }
pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) }
@@ -475,7 +475,7 @@ impl WhereClause {
pub struct BlockExpr {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for BlockExpr {}
+impl ast::HasAttrs for BlockExpr {}
impl BlockExpr {
pub fn label(&self) -> Option<Label> { support::child(&self.syntax) }
pub fn try_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![try]) }
@@ -488,8 +488,8 @@ impl BlockExpr {
pub struct SelfParam {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for SelfParam {}
-impl ast::NameOwner for SelfParam {}
+impl ast::HasAttrs for SelfParam {}
+impl ast::HasName for SelfParam {}
impl SelfParam {
pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) }
pub fn lifetime(&self) -> Option<Lifetime> { support::child(&self.syntax) }
@@ -501,7 +501,7 @@ impl SelfParam {
pub struct Param {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for Param {}
+impl ast::HasAttrs for Param {}
impl Param {
pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
@@ -530,9 +530,9 @@ impl TupleFieldList {
pub struct RecordField {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for RecordField {}
-impl ast::NameOwner for RecordField {}
-impl ast::VisibilityOwner for RecordField {}
+impl ast::HasAttrs for RecordField {}
+impl ast::HasName for RecordField {}
+impl ast::HasVisibility for RecordField {}
impl RecordField {
pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
@@ -541,8 +541,8 @@ impl RecordField {
pub struct TupleField {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for TupleField {}
-impl ast::VisibilityOwner for TupleField {}
+impl ast::HasAttrs for TupleField {}
+impl ast::HasVisibility for TupleField {}
impl TupleField {
pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
}
@@ -559,9 +559,9 @@ impl VariantList {
pub struct Variant {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for Variant {}
-impl ast::NameOwner for Variant {}
-impl ast::VisibilityOwner for Variant {}
+impl ast::HasAttrs for Variant {}
+impl ast::HasName for Variant {}
+impl ast::HasVisibility for Variant {}
impl Variant {
pub fn field_list(&self) -> Option<FieldList> { support::child(&self.syntax) }
pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
@@ -571,7 +571,7 @@ impl Variant {
pub struct AssocItemList {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for AssocItemList {}
+impl ast::HasAttrs for AssocItemList {}
impl AssocItemList {
pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
pub fn assoc_items(&self) -> AstChildren<AssocItem> { support::children(&self.syntax) }
@@ -581,7 +581,7 @@ impl AssocItemList {
pub struct ExternItemList {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for ExternItemList {}
+impl ast::HasAttrs for ExternItemList {}
impl ExternItemList {
pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
pub fn extern_items(&self) -> AstChildren<ExternItem> { support::children(&self.syntax) }
@@ -591,8 +591,8 @@ impl ExternItemList {
pub struct ConstParam {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for ConstParam {}
-impl ast::NameOwner for ConstParam {}
+impl ast::HasAttrs for ConstParam {}
+impl ast::HasName for ConstParam {}
impl ConstParam {
pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
@@ -604,8 +604,8 @@ impl ConstParam {
pub struct LifetimeParam {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for LifetimeParam {}
-impl ast::TypeBoundsOwner for LifetimeParam {}
+impl ast::HasAttrs for LifetimeParam {}
+impl ast::HasTypeBounds for LifetimeParam {}
impl LifetimeParam {
pub fn lifetime(&self) -> Option<Lifetime> { support::child(&self.syntax) }
}
@@ -613,9 +613,9 @@ impl LifetimeParam {
pub struct TypeParam {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for TypeParam {}
-impl ast::NameOwner for TypeParam {}
-impl ast::TypeBoundsOwner for TypeParam {}
+impl ast::HasAttrs for TypeParam {}
+impl ast::HasName for TypeParam {}
+impl ast::HasTypeBounds for TypeParam {}
impl TypeParam {
pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
pub fn default_type(&self) -> Option<Type> { support::child(&self.syntax) }
@@ -624,7 +624,7 @@ impl TypeParam {
pub struct WherePred {
pub(crate) syntax: SyntaxNode,
}
-impl ast::TypeBoundsOwner for WherePred {}
+impl ast::HasTypeBounds for WherePred {}
impl WherePred {
pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) }
pub fn generic_param_list(&self) -> Option<GenericParamList> { support::child(&self.syntax) }
@@ -653,7 +653,7 @@ impl ExprStmt {
pub struct LetStmt {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for LetStmt {}
+impl ast::HasAttrs for LetStmt {}
impl LetStmt {
pub fn let_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![let]) }
pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
@@ -667,7 +667,7 @@ impl LetStmt {
pub struct ArrayExpr {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for ArrayExpr {}
+impl ast::HasAttrs for ArrayExpr {}
impl ArrayExpr {
pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
pub fn exprs(&self) -> AstChildren<Expr> { support::children(&self.syntax) }
@@ -679,7 +679,7 @@ impl ArrayExpr {
pub struct AwaitExpr {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for AwaitExpr {}
+impl ast::HasAttrs for AwaitExpr {}
impl AwaitExpr {
pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
pub fn dot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![.]) }
@@ -689,13 +689,13 @@ impl AwaitExpr {
pub struct BinExpr {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for BinExpr {}
+impl ast::HasAttrs for BinExpr {}
impl BinExpr {}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct BoxExpr {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for BoxExpr {}
+impl ast::HasAttrs for BoxExpr {}
impl BoxExpr {
pub fn box_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![box]) }
pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
@@ -704,7 +704,7 @@ impl BoxExpr {
pub struct BreakExpr {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for BreakExpr {}
+impl ast::HasAttrs for BreakExpr {}
impl BreakExpr {
pub fn break_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![break]) }
pub fn lifetime(&self) -> Option<Lifetime> { support::child(&self.syntax) }
@@ -714,8 +714,8 @@ impl BreakExpr {
pub struct CallExpr {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for CallExpr {}
-impl ast::ArgListOwner for CallExpr {}
+impl ast::HasAttrs for CallExpr {}
+impl ast::HasArgList for CallExpr {}
impl CallExpr {
pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
}
@@ -723,7 +723,7 @@ impl CallExpr {
pub struct CastExpr {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for CastExpr {}
+impl ast::HasAttrs for CastExpr {}
impl CastExpr {
pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) }
@@ -733,7 +733,7 @@ impl CastExpr {
pub struct ClosureExpr {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for ClosureExpr {}
+impl ast::HasAttrs for ClosureExpr {}
impl ClosureExpr {
pub fn static_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![static]) }
pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) }
@@ -746,7 +746,7 @@ impl ClosureExpr {
pub struct ContinueExpr {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for ContinueExpr {}
+impl ast::HasAttrs for ContinueExpr {}
impl ContinueExpr {
pub fn continue_token(&self) -> Option<SyntaxToken> {
support::token(&self.syntax, T![continue])
@@ -757,7 +757,7 @@ impl ContinueExpr {
pub struct FieldExpr {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for FieldExpr {}
+impl ast::HasAttrs for FieldExpr {}
impl FieldExpr {
pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
pub fn dot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![.]) }
@@ -767,8 +767,8 @@ impl FieldExpr {
pub struct ForExpr {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for ForExpr {}
-impl ast::LoopBodyOwner for ForExpr {}
+impl ast::HasAttrs for ForExpr {}
+impl ast::HasLoopBody for ForExpr {}
impl ForExpr {
pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) }
pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
@@ -779,7 +779,7 @@ impl ForExpr {
pub struct IfExpr {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for IfExpr {}
+impl ast::HasAttrs for IfExpr {}
impl IfExpr {
pub fn if_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![if]) }
pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) }
@@ -789,7 +789,7 @@ impl IfExpr {
pub struct IndexExpr {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for IndexExpr {}
+impl ast::HasAttrs for IndexExpr {}
impl IndexExpr {
pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
@@ -798,14 +798,14 @@ impl IndexExpr {
pub struct Literal {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for Literal {}
+impl ast::HasAttrs for Literal {}
impl Literal {}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct LoopExpr {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for LoopExpr {}
-impl ast::LoopBodyOwner for LoopExpr {}
+impl ast::HasAttrs for LoopExpr {}
+impl ast::HasLoopBody for LoopExpr {}
impl LoopExpr {
pub fn loop_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![loop]) }
}
@@ -813,7 +813,7 @@ impl LoopExpr {
pub struct MatchExpr {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for MatchExpr {}
+impl ast::HasAttrs for MatchExpr {}
impl MatchExpr {
pub fn match_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![match]) }
pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
@@ -823,8 +823,8 @@ impl MatchExpr {
pub struct MethodCallExpr {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for MethodCallExpr {}
-impl ast::ArgListOwner for MethodCallExpr {}
+impl ast::HasAttrs for MethodCallExpr {}
+impl ast::HasArgList for MethodCallExpr {}
impl MethodCallExpr {
pub fn receiver(&self) -> Option<Expr> { support::child(&self.syntax) }
pub fn dot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![.]) }
@@ -835,7 +835,7 @@ impl MethodCallExpr {
pub struct ParenExpr {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for ParenExpr {}
+impl ast::HasAttrs for ParenExpr {}
impl ParenExpr {
pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
@@ -845,7 +845,7 @@ impl ParenExpr {
pub struct PathExpr {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for PathExpr {}
+impl ast::HasAttrs for PathExpr {}
impl PathExpr {
pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
}
@@ -853,7 +853,7 @@ impl PathExpr {
pub struct PrefixExpr {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for PrefixExpr {}
+impl ast::HasAttrs for PrefixExpr {}
impl PrefixExpr {
pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
}
@@ -861,7 +861,7 @@ impl PrefixExpr {
pub struct RangeExpr {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for RangeExpr {}
+impl ast::HasAttrs for RangeExpr {}
impl RangeExpr {}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct RecordExpr {
@@ -877,7 +877,7 @@ impl RecordExpr {
pub struct RefExpr {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for RefExpr {}
+impl ast::HasAttrs for RefExpr {}
impl RefExpr {
pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) }
pub fn raw_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![raw]) }
@@ -889,7 +889,7 @@ impl RefExpr {
pub struct ReturnExpr {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for ReturnExpr {}
+impl ast::HasAttrs for ReturnExpr {}
impl ReturnExpr {
pub fn return_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![return]) }
pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
@@ -898,7 +898,7 @@ impl ReturnExpr {
pub struct TryExpr {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for TryExpr {}
+impl ast::HasAttrs for TryExpr {}
impl TryExpr {
pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
pub fn question_mark_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![?]) }
@@ -907,7 +907,7 @@ impl TryExpr {
pub struct TupleExpr {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for TupleExpr {}
+impl ast::HasAttrs for TupleExpr {}
impl TupleExpr {
pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
pub fn fields(&self) -> AstChildren<Expr> { support::children(&self.syntax) }
@@ -917,8 +917,8 @@ impl TupleExpr {
pub struct WhileExpr {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for WhileExpr {}
-impl ast::LoopBodyOwner for WhileExpr {}
+impl ast::HasAttrs for WhileExpr {}
+impl ast::HasLoopBody for WhileExpr {}
impl WhileExpr {
pub fn while_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![while]) }
pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) }
@@ -927,7 +927,7 @@ impl WhileExpr {
pub struct YieldExpr {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for YieldExpr {}
+impl ast::HasAttrs for YieldExpr {}
impl YieldExpr {
pub fn yield_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![yield]) }
pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
@@ -936,7 +936,7 @@ impl YieldExpr {
pub struct StmtList {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for StmtList {}
+impl ast::HasAttrs for StmtList {}
impl StmtList {
pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
pub fn statements(&self) -> AstChildren<Stmt> { support::children(&self.syntax) }
@@ -955,7 +955,7 @@ impl Label {
pub struct RecordExprFieldList {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for RecordExprFieldList {}
+impl ast::HasAttrs for RecordExprFieldList {}
impl RecordExprFieldList {
pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
pub fn fields(&self) -> AstChildren<RecordExprField> { support::children(&self.syntax) }
@@ -967,7 +967,7 @@ impl RecordExprFieldList {
pub struct RecordExprField {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for RecordExprField {}
+impl ast::HasAttrs for RecordExprField {}
impl RecordExprField {
pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
@@ -996,7 +996,7 @@ impl Condition {
pub struct MatchArmList {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for MatchArmList {}
+impl ast::HasAttrs for MatchArmList {}
impl MatchArmList {
pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
pub fn arms(&self) -> AstChildren<MatchArm> { support::children(&self.syntax) }
@@ -1006,7 +1006,7 @@ impl MatchArmList {
pub struct MatchArm {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for MatchArm {}
+impl ast::HasAttrs for MatchArm {}
impl MatchArm {
pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
pub fn guard(&self) -> Option<MatchGuard> { support::child(&self.syntax) }
@@ -1155,8 +1155,8 @@ impl TypeBound {
pub struct IdentPat {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for IdentPat {}
-impl ast::NameOwner for IdentPat {}
+impl ast::HasAttrs for IdentPat {}
+impl ast::HasName for IdentPat {}
impl IdentPat {
pub fn ref_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ref]) }
pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
@@ -1296,7 +1296,7 @@ impl RecordPatFieldList {
pub struct RecordPatField {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for RecordPatField {}
+impl ast::HasAttrs for RecordPatField {}
impl RecordPatField {
pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
@@ -1379,7 +1379,7 @@ pub enum Item {
Union(Union),
Use(Use),
}
-impl ast::AttrsOwner for Item {}
+impl ast::HasAttrs for Item {}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum Stmt {
ExprStmt(ExprStmt),
@@ -1416,10 +1416,10 @@ pub enum Adt {
Struct(Struct),
Union(Union),
}
-impl ast::AttrsOwner for Adt {}
-impl ast::GenericParamsOwner for Adt {}
-impl ast::NameOwner for Adt {}
-impl ast::VisibilityOwner for Adt {}
+impl ast::HasAttrs for Adt {}
+impl ast::HasGenericParams for Adt {}
+impl ast::HasName for Adt {}
+impl ast::HasVisibility for Adt {}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum AssocItem {
Const(Const),
@@ -1427,7 +1427,7 @@ pub enum AssocItem {
MacroCall(MacroCall),
TypeAlias(TypeAlias),
}
-impl ast::AttrsOwner for AssocItem {}
+impl ast::HasAttrs for AssocItem {}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ExternItem {
Fn(Fn),
@@ -1435,54 +1435,54 @@ pub enum ExternItem {
Static(Static),
TypeAlias(TypeAlias),
}
-impl ast::AttrsOwner for ExternItem {}
+impl ast::HasAttrs for ExternItem {}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum GenericParam {
ConstParam(ConstParam),
LifetimeParam(LifetimeParam),
TypeParam(TypeParam),
}
-impl ast::AttrsOwner for GenericParam {}
+impl ast::HasAttrs for GenericParam {}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
-pub struct AnyArgListOwner {
+pub struct AnyHasArgList {
pub(crate) syntax: SyntaxNode,
}
-impl ast::ArgListOwner for AnyArgListOwner {}
+impl ast::HasArgList for AnyHasArgList {}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
-pub struct AnyAttrsOwner {
+pub struct AnyHasAttrs {
pub(crate) syntax: SyntaxNode,
}
-impl ast::AttrsOwner for AnyAttrsOwner {}
+impl ast::HasAttrs for AnyHasAttrs {}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
-pub struct AnyGenericParamsOwner {
+pub struct AnyHasGenericParams {
pub(crate) syntax: SyntaxNode,
}
-impl ast::GenericParamsOwner for AnyGenericParamsOwner {}
+impl ast::HasGenericParams for AnyHasGenericParams {}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
-pub struct AnyLoopBodyOwner {
+pub struct AnyHasLoopBody {
pub(crate) syntax: SyntaxNode,
}
-impl ast::LoopBodyOwner for AnyLoopBodyOwner {}
+impl ast::HasLoopBody for AnyHasLoopBody {}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
-pub struct AnyModuleItemOwner {
+pub struct AnyHasModuleItem {
pub(crate) syntax: SyntaxNode,
}
-impl ast::ModuleItemOwner for AnyModuleItemOwner {}
+impl ast::HasModuleItem for AnyHasModuleItem {}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
-pub struct AnyNameOwner {
+pub struct AnyHasName {
pub(crate) syntax: SyntaxNode,
}
-impl ast::NameOwner for AnyNameOwner {}
+impl ast::HasName for AnyHasName {}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
-pub struct AnyTypeBoundsOwner {
+pub struct AnyHasTypeBounds {
pub(crate) syntax: SyntaxNode,
}
-impl ast::TypeBoundsOwner for AnyTypeBoundsOwner {}
+impl ast::HasTypeBounds for AnyHasTypeBounds {}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
-pub struct AnyVisibilityOwner {
+pub struct AnyHasVisibility {
pub(crate) syntax: SyntaxNode,
}
-impl ast::VisibilityOwner for AnyVisibilityOwner {}
+impl ast::HasVisibility for AnyHasVisibility {}
impl AstNode for Name {
fn can_cast(kind: SyntaxKind) -> bool { kind == NAME }
fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -3597,13 +3597,13 @@ impl AstNode for GenericParam {
}
}
}
-impl AnyArgListOwner {
+impl AnyHasArgList {
#[inline]
- pub fn new<T: ast::ArgListOwner>(node: T) -> AnyArgListOwner {
- AnyArgListOwner { syntax: node.syntax().clone() }
+ pub fn new<T: ast::HasArgList>(node: T) -> AnyHasArgList {
+ AnyHasArgList { syntax: node.syntax().clone() }
}
}
-impl AstNode for AnyArgListOwner {
+impl AstNode for AnyHasArgList {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
CALL_EXPR | METHOD_CALL_EXPR => true,
@@ -3611,17 +3611,17 @@ impl AstNode for AnyArgListOwner {
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
- Self::can_cast(syntax.kind()).then(|| AnyArgListOwner { syntax })
+ Self::can_cast(syntax.kind()).then(|| AnyHasArgList { syntax })
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
-impl AnyAttrsOwner {
+impl AnyHasAttrs {
#[inline]
- pub fn new<T: ast::AttrsOwner>(node: T) -> AnyAttrsOwner {
- AnyAttrsOwner { syntax: node.syntax().clone() }
+ pub fn new<T: ast::HasAttrs>(node: T) -> AnyHasAttrs {
+ AnyHasAttrs { syntax: node.syntax().clone() }
}
}
-impl AstNode for AnyAttrsOwner {
+impl AstNode for AnyHasAttrs {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
MACRO_CALL
@@ -3692,17 +3692,17 @@ impl AstNode for AnyAttrsOwner {
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
- Self::can_cast(syntax.kind()).then(|| AnyAttrsOwner { syntax })
+ Self::can_cast(syntax.kind()).then(|| AnyHasAttrs { syntax })
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
-impl AnyGenericParamsOwner {
+impl AnyHasGenericParams {
#[inline]
- pub fn new<T: ast::GenericParamsOwner>(node: T) -> AnyGenericParamsOwner {
- AnyGenericParamsOwner { syntax: node.syntax().clone() }
+ pub fn new<T: ast::HasGenericParams>(node: T) -> AnyHasGenericParams {
+ AnyHasGenericParams { syntax: node.syntax().clone() }
}
}
-impl AstNode for AnyGenericParamsOwner {
+impl AstNode for AnyHasGenericParams {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
ENUM | FN | IMPL | STRUCT | TRAIT | TYPE_ALIAS | UNION => true,
@@ -3710,17 +3710,17 @@ impl AstNode for AnyGenericParamsOwner {
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
- Self::can_cast(syntax.kind()).then(|| AnyGenericParamsOwner { syntax })
+ Self::can_cast(syntax.kind()).then(|| AnyHasGenericParams { syntax })
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
-impl AnyLoopBodyOwner {
+impl AnyHasLoopBody {
#[inline]
- pub fn new<T: ast::LoopBodyOwner>(node: T) -> AnyLoopBodyOwner {
- AnyLoopBodyOwner { syntax: node.syntax().clone() }
+ pub fn new<T: ast::HasLoopBody>(node: T) -> AnyHasLoopBody {
+ AnyHasLoopBody { syntax: node.syntax().clone() }
}
}
-impl AstNode for AnyLoopBodyOwner {
+impl AstNode for AnyHasLoopBody {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
FOR_EXPR | LOOP_EXPR | WHILE_EXPR => true,
@@ -3728,17 +3728,17 @@ impl AstNode for AnyLoopBodyOwner {
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
- Self::can_cast(syntax.kind()).then(|| AnyLoopBodyOwner { syntax })
+ Self::can_cast(syntax.kind()).then(|| AnyHasLoopBody { syntax })
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
-impl AnyModuleItemOwner {
+impl AnyHasModuleItem {
#[inline]
- pub fn new<T: ast::ModuleItemOwner>(node: T) -> AnyModuleItemOwner {
- AnyModuleItemOwner { syntax: node.syntax().clone() }
+ pub fn new<T: ast::HasModuleItem>(node: T) -> AnyHasModuleItem {
+ AnyHasModuleItem { syntax: node.syntax().clone() }
}
}
-impl AstNode for AnyModuleItemOwner {
+impl AstNode for AnyHasModuleItem {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
MACRO_ITEMS | SOURCE_FILE | ITEM_LIST => true,
@@ -3746,17 +3746,17 @@ impl AstNode for AnyModuleItemOwner {
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
- Self::can_cast(syntax.kind()).then(|| AnyModuleItemOwner { syntax })
+ Self::can_cast(syntax.kind()).then(|| AnyHasModuleItem { syntax })
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
-impl AnyNameOwner {
+impl AnyHasName {
#[inline]
- pub fn new<T: ast::NameOwner>(node: T) -> AnyNameOwner {
- AnyNameOwner { syntax: node.syntax().clone() }
+ pub fn new<T: ast::HasName>(node: T) -> AnyHasName {
+ AnyHasName { syntax: node.syntax().clone() }
}
}
-impl AstNode for AnyNameOwner {
+impl AstNode for AnyHasName {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
CONST | ENUM | FN | MACRO_RULES | MACRO_DEF | MODULE | STATIC | STRUCT | TRAIT
@@ -3766,17 +3766,17 @@ impl AstNode for AnyNameOwner {
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
- Self::can_cast(syntax.kind()).then(|| AnyNameOwner { syntax })
+ Self::can_cast(syntax.kind()).then(|| AnyHasName { syntax })
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
-impl AnyTypeBoundsOwner {
+impl AnyHasTypeBounds {
#[inline]
- pub fn new<T: ast::TypeBoundsOwner>(node: T) -> AnyTypeBoundsOwner {
- AnyTypeBoundsOwner { syntax: node.syntax().clone() }
+ pub fn new<T: ast::HasTypeBounds>(node: T) -> AnyHasTypeBounds {
+ AnyHasTypeBounds { syntax: node.syntax().clone() }
}
}
-impl AstNode for AnyTypeBoundsOwner {
+impl AstNode for AnyHasTypeBounds {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
ASSOC_TYPE_ARG | TRAIT | TYPE_ALIAS | LIFETIME_PARAM | TYPE_PARAM | WHERE_PRED => true,
@@ -3784,17 +3784,17 @@ impl AstNode for AnyTypeBoundsOwner {
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
- Self::can_cast(syntax.kind()).then(|| AnyTypeBoundsOwner { syntax })
+ Self::can_cast(syntax.kind()).then(|| AnyHasTypeBounds { syntax })
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
-impl AnyVisibilityOwner {
+impl AnyHasVisibility {
#[inline]
- pub fn new<T: ast::VisibilityOwner>(node: T) -> AnyVisibilityOwner {
- AnyVisibilityOwner { syntax: node.syntax().clone() }
+ pub fn new<T: ast::HasVisibility>(node: T) -> AnyHasVisibility {
+ AnyHasVisibility { syntax: node.syntax().clone() }
}
}
-impl AstNode for AnyVisibilityOwner {
+impl AstNode for AnyHasVisibility {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
CONST | ENUM | EXTERN_CRATE | FN | IMPL | MACRO_RULES | MACRO_DEF | MODULE | STATIC
@@ -3805,7 +3805,7 @@ impl AstNode for AnyVisibilityOwner {
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
- Self::can_cast(syntax.kind()).then(|| AnyVisibilityOwner { syntax })
+ Self::can_cast(syntax.kind()).then(|| AnyHasVisibility { syntax })
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
diff --git a/crates/syntax/src/ast/node_ext.rs b/crates/syntax/src/ast/node_ext.rs
index 18a324e3ea..a07f02e445 100644
--- a/crates/syntax/src/ast/node_ext.rs
+++ b/crates/syntax/src/ast/node_ext.rs
@@ -11,8 +11,8 @@ use rowan::{GreenNodeData, GreenTokenData};
use crate::{
ast::{
- self, support, AstNode, AstToken, AttrsOwner, GenericParamsOwner, ModuleItemOwner,
- NameOwner, SyntaxNode,
+ self, support, AstNode, AstToken, HasAttrs, HasGenericParams, HasModuleItem, HasName,
+ SyntaxNode,
},
NodeOrToken, SmolStr, SyntaxElement, SyntaxToken, TokenText, T,
};
@@ -50,7 +50,7 @@ fn text_of_first_token(node: &SyntaxNode) -> TokenText<'_> {
}
}
-impl ast::ModuleItemOwner for ast::StmtList {}
+impl ast::HasModuleItem for ast::StmtList {}
impl ast::BlockExpr {
// FIXME: remove all these methods, they belong to ast::StmtList
@@ -107,7 +107,7 @@ impl AstNode for Macro {
}
}
-impl NameOwner for Macro {
+impl HasName for Macro {
fn name(&self) -> Option<ast::Name> {
match self {
Macro::MacroRules(mac) => mac.name(),
@@ -116,7 +116,7 @@ impl NameOwner for Macro {
}
}
-impl AttrsOwner for Macro {}
+impl HasAttrs for Macro {}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum AttrKind {
@@ -531,7 +531,7 @@ impl ast::Variant {
impl ast::Item {
pub fn generic_param_list(&self) -> Option<ast::GenericParamList> {
- ast::AnyGenericParamsOwner::cast(self.syntax().clone())?.generic_param_list()
+ ast::AnyHasGenericParams::cast(self.syntax().clone())?.generic_param_list()
}
}
@@ -765,21 +765,21 @@ impl ast::GenericParamList {
}
}
-impl ast::DocCommentsOwner for ast::SourceFile {}
-impl ast::DocCommentsOwner for ast::Fn {}
-impl ast::DocCommentsOwner for ast::Struct {}
-impl ast::DocCommentsOwner for ast::Union {}
-impl ast::DocCommentsOwner for ast::RecordField {}
-impl ast::DocCommentsOwner for ast::TupleField {}
-impl ast::DocCommentsOwner for ast::Enum {}
-impl ast::DocCommentsOwner for ast::Variant {}
-impl ast::DocCommentsOwner for ast::Trait {}
-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::Impl {}
-impl ast::DocCommentsOwner for ast::MacroRules {}
-impl ast::DocCommentsOwner for ast::MacroDef {}
-impl ast::DocCommentsOwner for ast::Macro {}
-impl ast::DocCommentsOwner for ast::Use {}
+impl ast::HasDocComments for ast::SourceFile {}
+impl ast::HasDocComments for ast::Fn {}
+impl ast::HasDocComments for ast::Struct {}
+impl ast::HasDocComments for ast::Union {}
+impl ast::HasDocComments for ast::RecordField {}
+impl ast::HasDocComments for ast::TupleField {}
+impl ast::HasDocComments for ast::Enum {}
+impl ast::HasDocComments for ast::Variant {}
+impl ast::HasDocComments for ast::Trait {}
+impl ast::HasDocComments for ast::Module {}
+impl ast::HasDocComments for ast::Static {}
+impl ast::HasDocComments for ast::Const {}
+impl ast::HasDocComments for ast::TypeAlias {}
+impl ast::HasDocComments for ast::Impl {}
+impl ast::HasDocComments for ast::MacroRules {}
+impl ast::HasDocComments for ast::MacroDef {}
+impl ast::HasDocComments for ast::Macro {}
+impl ast::HasDocComments for ast::Use {}
diff --git a/crates/syntax/src/ast/traits.rs b/crates/syntax/src/ast/traits.rs
index ddd2136370..eae3a7e2fe 100644
--- a/crates/syntax/src/ast/traits.rs
+++ b/crates/syntax/src/ast/traits.rs
@@ -7,19 +7,19 @@ use crate::{
SyntaxToken, T,
};
-pub trait NameOwner: AstNode {
+pub trait HasName: AstNode {
fn name(&self) -> Option<ast::Name> {
support::child(self.syntax())
}
}
-pub trait VisibilityOwner: AstNode {
+pub trait HasVisibility: AstNode {
fn visibility(&self) -> Option<ast::Visibility> {
support::child(self.syntax())
}
}
-pub trait LoopBodyOwner: AstNode {
+pub trait HasLoopBody: AstNode {
fn loop_body(&self) -> Option<ast::BlockExpr> {
support::child(self.syntax())
}
@@ -29,19 +29,19 @@ pub trait LoopBodyOwner: AstNode {
}
}
-pub trait ArgListOwner: AstNode {
+pub trait HasArgList: AstNode {
fn arg_list(&self) -> Option<ast::ArgList> {
support::child(self.syntax())
}
}
-pub trait ModuleItemOwner: AstNode {
+pub trait HasModuleItem: AstNode {
fn items(&self) -> AstChildren<ast::Item> {
support::children(self.syntax())
}
}
-pub trait GenericParamsOwner: AstNode {
+pub trait HasGenericParams: AstNode {
fn generic_param_list(&self) -> Option<ast::GenericParamList> {
support::child(self.syntax())
}
@@ -51,7 +51,7 @@ pub trait GenericParamsOwner: AstNode {
}
}
-pub trait TypeBoundsOwner: AstNode {
+pub trait HasTypeBounds: AstNode {
fn type_bound_list(&self) -> Option<ast::TypeBoundList> {
support::child(self.syntax())
}
@@ -61,7 +61,7 @@ pub trait TypeBoundsOwner: AstNode {
}
}
-pub trait AttrsOwner: AstNode {
+pub trait HasAttrs: AstNode {
fn attrs(&self) -> AstChildren<ast::Attr> {
support::children(self.syntax())
}
@@ -70,7 +70,7 @@ pub trait AttrsOwner: AstNode {
}
}
-pub trait DocCommentsOwner: AttrsOwner {
+pub trait HasDocComments: HasAttrs {
fn doc_comments(&self) -> CommentIter {
CommentIter { iter: self.syntax().children_with_tokens() }
}
diff --git a/crates/syntax/src/display.rs b/crates/syntax/src/display.rs
index 2422da23f4..1498385fef 100644
--- a/crates/syntax/src/display.rs
+++ b/crates/syntax/src/display.rs
@@ -2,11 +2,11 @@
//! into types that may be used to render in a UI.
use crate::{
- ast::{self, AstNode, AttrsOwner, GenericParamsOwner, NameOwner},
+ ast::{self, AstNode, HasAttrs, HasGenericParams, HasName},
SyntaxKind::{ATTR, COMMENT},
};
-use ast::VisibilityOwner;
+use ast::HasVisibility;
use stdx::format_to;
pub fn function_declaration(node: &ast::Fn) -> String {
diff --git a/crates/syntax/src/lib.rs b/crates/syntax/src/lib.rs
index 00749d742f..132d300674 100644
--- a/crates/syntax/src/lib.rs
+++ b/crates/syntax/src/lib.rs
@@ -255,7 +255,7 @@ macro_rules! match_ast {
/// API.
#[test]
fn api_walkthrough() {
- use ast::{ModuleItemOwner, NameOwner};
+ use ast::{HasModuleItem, HasName};
let source_code = "
fn foo() {
diff --git a/crates/syntax/src/tests.rs b/crates/syntax/src/tests.rs
index ca48ca14e4..f8f7a3ad32 100644
--- a/crates/syntax/src/tests.rs
+++ b/crates/syntax/src/tests.rs
@@ -8,7 +8,7 @@ use std::{
path::{Path, PathBuf},
};
-use ast::NameOwner;
+use ast::HasName;
use expect_test::expect_file;
use rayon::prelude::*;
use test_utils::{bench, bench_fixture, project_root};
diff --git a/crates/syntax/src/tests/sourcegen_ast.rs b/crates/syntax/src/tests/sourcegen_ast.rs
index 8897c29722..564cf6663c 100644
--- a/crates/syntax/src/tests/sourcegen_ast.rs
+++ b/crates/syntax/src/tests/sourcegen_ast.rs
@@ -740,14 +740,14 @@ fn extract_enums(ast: &mut AstSrc) {
fn extract_struct_traits(ast: &mut AstSrc) {
let traits: &[(&str, &[&str])] = &[
- ("AttrsOwner", &["attrs"]),
- ("NameOwner", &["name"]),
- ("VisibilityOwner", &["visibility"]),
- ("GenericParamsOwner", &["generic_param_list", "where_clause"]),
- ("TypeBoundsOwner", &["type_bound_list", "colon_token"]),
- ("ModuleItemOwner", &["items"]),
- ("LoopBodyOwner", &["label", "loop_body"]),
- ("ArgListOwner", &["arg_list"]),
+ ("HasAttrs", &["attrs"]),
+ ("HasName", &["name"]),
+ ("HasVisibility", &["visibility"]),
+ ("HasGenericParams", &["generic_param_list", "where_clause"]),
+ ("HasTypeBounds", &["type_bound_list", "colon_token"]),
+ ("HasModuleItem", &["items"]),
+ ("HasLoopBody", &["label", "loop_body"]),
+ ("HasArgList", &["arg_list"]),
];
for node in &mut ast.nodes {
diff --git a/crates/syntax/src/validation.rs b/crates/syntax/src/validation.rs
index a7c469ffdf..b2d42f6651 100644
--- a/crates/syntax/src/validation.rs
+++ b/crates/syntax/src/validation.rs
@@ -13,7 +13,7 @@ use rustc_lexer::unescape::{
use crate::{
algo,
- ast::{self, VisibilityOwner},
+ ast::{self, HasVisibility},
match_ast, AstNode, SyntaxError,
SyntaxKind::{CONST, FN, INT_NUMBER, TYPE_ALIAS},
SyntaxNode, SyntaxToken, TextSize, T,
diff --git a/crates/syntax/src/validation/block.rs b/crates/syntax/src/validation/block.rs
index e03a77749d..9076b82503 100644
--- a/crates/syntax/src/validation/block.rs
+++ b/crates/syntax/src/validation/block.rs
@@ -1,7 +1,7 @@
//! Logic for validating block expressions i.e. `ast::BlockExpr`.
use crate::{
- ast::{self, AstNode, AttrsOwner},
+ ast::{self, AstNode, HasAttrs},
SyntaxError,
SyntaxKind::*,
};