Skip to content

Commit 97df465

Browse files
bors[bot]matklad
andauthored
Merge #5602
5602: Rename StructDef -> Struct r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
2 parents 0c89443 + 216a534 commit 97df465

File tree

63 files changed

+163
-163
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+163
-163
lines changed

crates/ra_assists/src/handlers/change_visibility.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use ra_syntax::{
22
ast::{self, NameOwner, VisibilityOwner},
33
AstNode,
4-
SyntaxKind::{CONST_DEF, ENUM_DEF, FN, MODULE, STATIC_DEF, STRUCT_DEF, TRAIT_DEF, VISIBILITY},
4+
SyntaxKind::{CONST_DEF, ENUM_DEF, FN, MODULE, STATIC_DEF, STRUCT, TRAIT_DEF, VISIBILITY},
55
T,
66
};
77
use test_utils::mark;
@@ -36,7 +36,7 @@ fn add_vis(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
3636

3737
let (offset, target) = if let Some(keyword) = item_keyword {
3838
let parent = keyword.parent();
39-
let def_kws = vec![CONST_DEF, STATIC_DEF, FN, MODULE, STRUCT_DEF, ENUM_DEF, TRAIT_DEF];
39+
let def_kws = vec![CONST_DEF, STATIC_DEF, FN, MODULE, STRUCT, ENUM_DEF, TRAIT_DEF];
4040
// Parent is not a definition, can't add visibility
4141
if !def_kws.iter().any(|&def_kw| def_kw == parent.kind()) {
4242
return None;

crates/ra_assists/src/handlers/generate_new.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
3131
//
3232
// ```
3333
pub(crate) fn generate_new(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
34-
let strukt = ctx.find_node_at_offset::<ast::StructDef>()?;
34+
let strukt = ctx.find_node_at_offset::<ast::Struct>()?;
3535

3636
// We want to only apply this to non-union structs with named fields
3737
let field_list = match strukt.kind() {
@@ -91,7 +91,7 @@ pub(crate) fn generate_new(acc: &mut Assists, ctx: &AssistContext) -> Option<()>
9191

9292
// Generates the surrounding `impl Type { <code> }` including type and lifetime
9393
// parameters
94-
fn generate_impl_text(strukt: &ast::StructDef, code: &str) -> String {
94+
fn generate_impl_text(strukt: &ast::Struct, code: &str) -> String {
9595
let type_params = strukt.generic_param_list();
9696
let mut buf = String::with_capacity(code.len());
9797
buf.push_str("\n\nimpl");
@@ -122,7 +122,7 @@ fn generate_impl_text(strukt: &ast::StructDef, code: &str) -> String {
122122
//
123123
// FIXME: change the new fn checking to a more semantic approach when that's more
124124
// viable (e.g. we process proc macros, etc)
125-
fn find_struct_impl(ctx: &AssistContext, strukt: &ast::StructDef) -> Option<Option<ast::ImplDef>> {
125+
fn find_struct_impl(ctx: &AssistContext, strukt: &ast::Struct) -> Option<Option<ast::ImplDef>> {
126126
let db = ctx.db();
127127
let module = strukt.syntax().ancestors().find(|node| {
128128
ast::Module::can_cast(node.kind()) || ast::SourceFile::can_cast(node.kind())

crates/ra_assists/src/handlers/move_bounds.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub(crate) fn move_bounds_to_where_clause(acc: &mut Assists, ctx: &AssistContext
4141
ast::TraitDef(it) => it.assoc_item_list()?.syntax().clone().into(),
4242
ast::ImplDef(it) => it.assoc_item_list()?.syntax().clone().into(),
4343
ast::EnumDef(it) => it.variant_list()?.syntax().clone().into(),
44-
ast::StructDef(it) => {
44+
ast::Struct(it) => {
4545
it.syntax().children_with_tokens()
4646
.find(|it| it.kind() == RECORD_FIELD_LIST || it.kind() == T![;])?
4747
},

crates/ra_hir/src/has_source.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ impl HasSource for Field {
5757
}
5858
}
5959
impl HasSource for Struct {
60-
type Ast = ast::StructDef;
61-
fn source(self, db: &dyn HirDatabase) -> InFile<ast::StructDef> {
60+
type Ast = ast::Struct;
61+
fn source(self, db: &dyn HirDatabase) -> InFile<ast::Struct> {
6262
self.id.lookup(db.upcast()).source(db.upcast())
6363
}
6464
}

crates/ra_hir/src/semantics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ macro_rules! to_def_impls {
580580

581581
to_def_impls![
582582
(crate::Module, ast::Module, module_to_def),
583-
(crate::Struct, ast::StructDef, struct_to_def),
583+
(crate::Struct, ast::Struct, struct_to_def),
584584
(crate::Enum, ast::EnumDef, enum_to_def),
585585
(crate::Union, ast::Union, union_to_def),
586586
(crate::Trait, ast::TraitDef, trait_to_def),

crates/ra_hir/src/semantics/source_to_def.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl SourceToDefCtx<'_, '_> {
7474
pub(super) fn fn_to_def(&mut self, src: InFile<ast::Fn>) -> Option<FunctionId> {
7575
self.to_def(src, keys::FUNCTION)
7676
}
77-
pub(super) fn struct_to_def(&mut self, src: InFile<ast::StructDef>) -> Option<StructId> {
77+
pub(super) fn struct_to_def(&mut self, src: InFile<ast::Struct>) -> Option<StructId> {
7878
self.to_def(src, keys::STRUCT)
7979
}
8080
pub(super) fn enum_to_def(&mut self, src: InFile<ast::EnumDef>) -> Option<EnumId> {
@@ -166,7 +166,7 @@ impl SourceToDefCtx<'_, '_> {
166166
let def = self.fn_to_def(container.with_value(it))?;
167167
DefWithBodyId::from(def).into()
168168
},
169-
ast::StructDef(it) => {
169+
ast::Struct(it) => {
170170
let def = self.struct_to_def(container.with_value(it))?;
171171
VariantId::from(def).into()
172172
},
@@ -205,7 +205,7 @@ impl SourceToDefCtx<'_, '_> {
205205
let res: GenericDefId = match_ast! {
206206
match (container.value) {
207207
ast::Fn(it) => self.fn_to_def(container.with_value(it))?.into(),
208-
ast::StructDef(it) => self.struct_to_def(container.with_value(it))?.into(),
208+
ast::Struct(it) => self.struct_to_def(container.with_value(it))?.into(),
209209
ast::EnumDef(it) => self.enum_to_def(container.with_value(it))?.into(),
210210
ast::TraitDef(it) => self.trait_to_def(container.with_value(it))?.into(),
211211
ast::TypeAlias(it) => self.type_alias_to_def(container.with_value(it))?.into(),

crates/ra_hir_def/src/body/lower.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ impl ExprCollector<'_> {
652652
let id = self.find_inner_item(&def)?;
653653
(StaticLoc { container, id }.intern(self.db).into(), def.name())
654654
}
655-
ast::Item::StructDef(def) => {
655+
ast::Item::Struct(def) => {
656656
let id = self.find_inner_item(&def)?;
657657
(StructLoc { container, id }.intern(self.db).into(), def.name())
658658
}

crates/ra_hir_def/src/item_tree.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ mod_items! {
414414
Import in imports -> ast::Use,
415415
ExternCrate in extern_crates -> ast::ExternCrate,
416416
Function in functions -> ast::Fn,
417-
Struct in structs -> ast::StructDef,
417+
Struct in structs -> ast::Struct,
418418
Union in unions -> ast::Union,
419419
Enum in enums -> ast::EnumDef,
420420
Const in consts -> ast::ConstDef,
@@ -514,7 +514,7 @@ pub struct Struct {
514514
pub visibility: RawVisibilityId,
515515
pub generic_params: GenericParamsId,
516516
pub fields: Fields,
517-
pub ast_id: FileAstId<ast::StructDef>,
517+
pub ast_id: FileAstId<ast::Struct>,
518518
pub kind: StructDefKind,
519519
}
520520

crates/ra_hir_def/src/item_tree/lower.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ impl Ctx {
7878

7979
// Collect inner items for 1-to-1-lowered items.
8080
match item {
81-
ast::Item::StructDef(_)
81+
ast::Item::Struct(_)
8282
| ast::Item::Union(_)
8383
| ast::Item::EnumDef(_)
8484
| ast::Item::Fn(_)
@@ -103,7 +103,7 @@ impl Ctx {
103103

104104
let attrs = Attrs::new(item, &self.hygiene);
105105
let items = match item {
106-
ast::Item::StructDef(ast) => self.lower_struct(ast).map(Into::into),
106+
ast::Item::Struct(ast) => self.lower_struct(ast).map(Into::into),
107107
ast::Item::Union(ast) => self.lower_union(ast).map(Into::into),
108108
ast::Item::EnumDef(ast) => self.lower_enum(ast).map(Into::into),
109109
ast::Item::Fn(ast) => self.lower_function(ast).map(Into::into),
@@ -165,7 +165,7 @@ impl Ctx {
165165
}
166166
}
167167

168-
fn lower_struct(&mut self, strukt: &ast::StructDef) -> Option<FileItemTreeId<Struct>> {
168+
fn lower_struct(&mut self, strukt: &ast::Struct) -> Option<FileItemTreeId<Struct>> {
169169
let visibility = self.lower_visibility(strukt);
170170
let name = strukt.name()?.as_name();
171171
let generic_params = self.lower_generic_params(GenericsOwner::Struct, strukt);

crates/ra_hir_def/src/item_tree/tests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,11 @@ fn smoke() {
244244
> #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_dfl_method"))] }, input: None }]) }]
245245
> Function { name: Name(Text("dfl_method")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: true, is_unsafe: false, params: [Reference(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Self"))] }, generic_args: [None] }), Mut)], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(11) }
246246
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("struct0"))] }, input: None }]) }]
247-
Struct { name: Name(Text("Struct0")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(1), fields: Unit, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::StructDef>(3), kind: Unit }
247+
Struct { name: Name(Text("Struct0")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(1), fields: Unit, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Struct>(3), kind: Unit }
248248
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("struct1"))] }, input: None }]) }]
249-
Struct { name: Name(Text("Struct1")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(2), fields: Tuple(IdRange::<ra_hir_def::item_tree::Field>(0..1)), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::StructDef>(4), kind: Tuple }
249+
Struct { name: Name(Text("Struct1")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(2), fields: Tuple(IdRange::<ra_hir_def::item_tree::Field>(0..1)), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Struct>(4), kind: Tuple }
250250
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("struct2"))] }, input: None }]) }]
251-
Struct { name: Name(Text("Struct2")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(3), fields: Record(IdRange::<ra_hir_def::item_tree::Field>(1..2)), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::StructDef>(5), kind: Record }
251+
Struct { name: Name(Text("Struct2")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(3), fields: Record(IdRange::<ra_hir_def::item_tree::Field>(1..2)), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Struct>(5), kind: Record }
252252
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("en"))] }, input: None }]) }]
253253
Enum { name: Name(Text("En")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), variants: IdRange::<ra_hir_def::item_tree::Variant>(0..1), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::EnumDef>(6) }
254254
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("un"))] }, input: None }]) }]

0 commit comments

Comments
 (0)