mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
Add unions to AST
This commit is contained in:
parent
a029ea343f
commit
1db878fd38
@ -196,6 +196,16 @@ impl<'a> Visitor for AstValidator<'a> {
|
||||
// Ensure that `path` attributes on modules are recorded as used (c.f. #35584).
|
||||
attr::first_attr_value_str_by_name(&item.attrs, "path");
|
||||
}
|
||||
ItemKind::Union(ref vdata, _) => {
|
||||
if !vdata.is_struct() {
|
||||
self.err_handler().span_err(item.span,
|
||||
"tuple and unit unions are not permitted");
|
||||
}
|
||||
if vdata.fields().len() == 0 {
|
||||
self.err_handler().span_err(item.span,
|
||||
"unions cannot have zero fields");
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
|
@ -1886,7 +1886,7 @@ pub enum ItemKind {
|
||||
/// A union definition (`union` or `pub union`).
|
||||
///
|
||||
/// E.g. `union Foo<A, B> { x: A, y: B }`
|
||||
Union(VariantData, Generics), // FIXME: not yet implemented
|
||||
Union(VariantData, Generics),
|
||||
/// A Trait declaration (`trait` or `pub trait`).
|
||||
///
|
||||
/// E.g. `trait Foo { .. }` or `trait Foo<T> { .. }`
|
||||
|
@ -107,6 +107,13 @@ macro_rules! help {
|
||||
})
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! unimplemented_unions {
|
||||
() => ({
|
||||
panic!("unions are not fully implemented");
|
||||
})
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! register_diagnostics {
|
||||
($($code:tt),*) => (
|
||||
|
Loading…
Reference in New Issue
Block a user