File tree Expand file tree Collapse file tree 3 files changed +18
-1
lines changed Expand file tree Collapse file tree 3 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -196,6 +196,16 @@ impl<'a> Visitor for AstValidator<'a> {
196
196
// Ensure that `path` attributes on modules are recorded as used (c.f. #35584).
197
197
attr:: first_attr_value_str_by_name ( & item. attrs , "path" ) ;
198
198
}
199
+ ItemKind :: Union ( ref vdata, _) => {
200
+ if !vdata. is_struct ( ) {
201
+ self . err_handler ( ) . span_err ( item. span ,
202
+ "tuple and unit unions are not permitted" ) ;
203
+ }
204
+ if vdata. fields ( ) . len ( ) == 0 {
205
+ self . err_handler ( ) . span_err ( item. span ,
206
+ "unions cannot have zero fields" ) ;
207
+ }
208
+ }
199
209
_ => { }
200
210
}
201
211
Original file line number Diff line number Diff line change @@ -1886,7 +1886,7 @@ pub enum ItemKind {
1886
1886
/// A union definition (`union` or `pub union`).
1887
1887
///
1888
1888
/// E.g. `union Foo<A, B> { x: A, y: B }`
1889
- Union ( VariantData , Generics ) , // FIXME: not yet implemented
1889
+ Union ( VariantData , Generics ) ,
1890
1890
/// A Trait declaration (`trait` or `pub trait`).
1891
1891
///
1892
1892
/// E.g. `trait Foo { .. }` or `trait Foo<T> { .. }`
Original file line number Diff line number Diff line change @@ -107,6 +107,13 @@ macro_rules! help {
107
107
} )
108
108
}
109
109
110
+ #[ macro_export]
111
+ macro_rules! unimplemented_unions {
112
+ ( ) => ( {
113
+ panic!( "unions are not fully implemented" ) ;
114
+ } )
115
+ }
116
+
110
117
#[ macro_export]
111
118
macro_rules! register_diagnostics {
112
119
( $( $code: tt) ,* ) => (
You can’t perform that action at this time.
0 commit comments