Skip to content

Commit 1ae4721

Browse files
committed
Finalize union grammar
1 parent 8ddbf06 commit 1ae4721

File tree

23 files changed

+51
-51
lines changed

23 files changed

+51
-51
lines changed

crates/ra_hir/src/has_source.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ impl HasSource for Struct {
6363
}
6464
}
6565
impl HasSource for Union {
66-
type Ast = ast::UnionDef;
67-
fn source(self, db: &dyn HirDatabase) -> InFile<ast::UnionDef> {
66+
type Ast = ast::Union;
67+
fn source(self, db: &dyn HirDatabase) -> InFile<ast::Union> {
6868
self.id.lookup(db.upcast()).source(db.upcast())
6969
}
7070
}

crates/ra_hir/src/semantics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ to_def_impls![
582582
(crate::Module, ast::Module, module_to_def),
583583
(crate::Struct, ast::StructDef, struct_to_def),
584584
(crate::Enum, ast::EnumDef, enum_to_def),
585-
(crate::Union, ast::UnionDef, union_to_def),
585+
(crate::Union, ast::Union, union_to_def),
586586
(crate::Trait, ast::TraitDef, trait_to_def),
587587
(crate::ImplDef, ast::ImplDef, impl_to_def),
588588
(crate::TypeAlias, ast::TypeAlias, type_alias_to_def),

crates/ra_hir/src/semantics/source_to_def.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl SourceToDefCtx<'_, '_> {
8080
pub(super) fn enum_to_def(&mut self, src: InFile<ast::EnumDef>) -> Option<EnumId> {
8181
self.to_def(src, keys::ENUM)
8282
}
83-
pub(super) fn union_to_def(&mut self, src: InFile<ast::UnionDef>) -> Option<UnionId> {
83+
pub(super) fn union_to_def(&mut self, src: InFile<ast::Union>) -> Option<UnionId> {
8484
self.to_def(src, keys::UNION)
8585
}
8686
pub(super) fn static_to_def(&mut self, src: InFile<ast::StaticDef>) -> Option<StaticId> {
@@ -174,7 +174,7 @@ impl SourceToDefCtx<'_, '_> {
174174
let def = self.enum_to_def(container.with_value(it))?;
175175
def.into()
176176
},
177-
ast::UnionDef(it) => {
177+
ast::Union(it) => {
178178
let def = self.union_to_def(container.with_value(it))?;
179179
VariantId::from(def).into()
180180
},

crates/ra_hir_def/src/body/lower.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ impl ExprCollector<'_> {
660660
let id = self.find_inner_item(&def)?;
661661
(EnumLoc { container, id }.intern(self.db).into(), def.name())
662662
}
663-
ast::Item::UnionDef(def) => {
663+
ast::Item::Union(def) => {
664664
let id = self.find_inner_item(&def)?;
665665
(UnionLoc { container, id }.intern(self.db).into(), def.name())
666666
}

crates/ra_hir_def/src/item_tree.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ mod_items! {
415415
ExternCrate in extern_crates -> ast::ExternCrate,
416416
Function in functions -> ast::Fn,
417417
Struct in structs -> ast::StructDef,
418-
Union in unions -> ast::UnionDef,
418+
Union in unions -> ast::Union,
419419
Enum in enums -> ast::EnumDef,
420420
Const in consts -> ast::ConstDef,
421421
Static in statics -> ast::StaticDef,
@@ -534,7 +534,7 @@ pub struct Union {
534534
pub visibility: RawVisibilityId,
535535
pub generic_params: GenericParamsId,
536536
pub fields: Fields,
537-
pub ast_id: FileAstId<ast::UnionDef>,
537+
pub ast_id: FileAstId<ast::Union>,
538538
}
539539

540540
#[derive(Debug, Clone, Eq, PartialEq)]

crates/ra_hir_def/src/item_tree/lower.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl Ctx {
7979
// Collect inner items for 1-to-1-lowered items.
8080
match item {
8181
ast::Item::StructDef(_)
82-
| ast::Item::UnionDef(_)
82+
| ast::Item::Union(_)
8383
| ast::Item::EnumDef(_)
8484
| ast::Item::Fn(_)
8585
| ast::Item::TypeAlias(_)
@@ -104,7 +104,7 @@ impl Ctx {
104104
let attrs = Attrs::new(item, &self.hygiene);
105105
let items = match item {
106106
ast::Item::StructDef(ast) => self.lower_struct(ast).map(Into::into),
107-
ast::Item::UnionDef(ast) => self.lower_union(ast).map(Into::into),
107+
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),
110110
ast::Item::TypeAlias(ast) => self.lower_type_alias(ast).map(Into::into),
@@ -233,7 +233,7 @@ impl Ctx {
233233
res
234234
}
235235

236-
fn lower_union(&mut self, union: &ast::UnionDef) -> Option<FileItemTreeId<Union>> {
236+
fn lower_union(&mut self, union: &ast::Union) -> Option<FileItemTreeId<Union>> {
237237
let visibility = self.lower_visibility(union);
238238
let name = union.name()?.as_name();
239239
let generic_params = self.lower_generic_params(GenericsOwner::Union, union);

crates/ra_hir_def/src/item_tree/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ fn smoke() {
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 }]) }]
255-
Union { name: Name(Text("Un")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), fields: Record(IdRange::<ra_hir_def::item_tree::Field>(3..4)), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::UnionDef>(7) }
255+
Union { name: Name(Text("Un")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), fields: Record(IdRange::<ra_hir_def::item_tree::Field>(3..4)), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Union>(7) }
256256
"##]],
257257
);
258258
}

crates/ra_hir_def/src/keys.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub const TYPE_ALIAS: Key<ast::TypeAlias, TypeAliasId> = Key::new();
2121
pub const IMPL: Key<ast::ImplDef, ImplId> = Key::new();
2222
pub const TRAIT: Key<ast::TraitDef, TraitId> = Key::new();
2323
pub const STRUCT: Key<ast::StructDef, StructId> = Key::new();
24-
pub const UNION: Key<ast::UnionDef, UnionId> = Key::new();
24+
pub const UNION: Key<ast::Union, UnionId> = Key::new();
2525
pub const ENUM: Key<ast::EnumDef, EnumId> = Key::new();
2626

2727
pub const ENUM_VARIANT: Key<ast::EnumVariant, EnumVariantId> = Key::new();

crates/ra_hir_expand/src/builtin_derive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ fn parse_adt(tt: &tt::Subtree) -> Result<BasicAdtInfo, mbe::ExpandError> {
7474
match node {
7575
ast::StructDef(it) => (it.name(), it.generic_param_list()),
7676
ast::EnumDef(it) => (it.name(), it.generic_param_list()),
77-
ast::UnionDef(it) => (it.name(), it.generic_param_list()),
77+
ast::Union(it) => (it.name(), it.generic_param_list()),
7878
_ => {
7979
debug!("unexpected node is {:?}", node);
8080
return Err(mbe::ExpandError::ConversionError)

crates/ra_ide/src/display/short_label.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ impl ShortLabel for ast::StructDef {
1919
}
2020
}
2121

22-
impl ShortLabel for ast::UnionDef {
22+
impl ShortLabel for ast::Union {
2323
fn short_label(&self) -> Option<String> {
2424
short_label_from_node(self, "union ")
2525
}

0 commit comments

Comments
 (0)