Introduce type aliases in syntax tree
diff --git a/syntax/ident.rs b/syntax/ident.rs
index cec424c..41eef3b 100644
--- a/syntax/ident.rs
+++ b/syntax/ident.rs
@@ -42,6 +42,7 @@
check(cx, &arg.ident);
}
}
+ Api::TypeAlias(_alias) => unimplemented!(),
}
}
}
diff --git a/syntax/mod.rs b/syntax/mod.rs
index fd8db73..3eb6c6e 100644
--- a/syntax/mod.rs
+++ b/syntax/mod.rs
@@ -20,7 +20,7 @@
use proc_macro2::{Ident, Span};
use syn::punctuated::Punctuated;
use syn::token::{Brace, Bracket, Paren};
-use syn::{Lifetime, LitStr, Token};
+use syn::{Lifetime, LitStr, Token, Type as RustType};
pub use self::atom::Atom;
pub use self::doc::Doc;
@@ -35,6 +35,7 @@
CxxFunction(ExternFn),
RustType(ExternType),
RustFunction(ExternFn),
+ TypeAlias(TypeAlias),
}
pub struct ExternType {
@@ -68,6 +69,14 @@
pub semi_token: Token![;],
}
+pub struct TypeAlias {
+ pub type_token: Token![type],
+ pub ident: Ident,
+ pub eq_token: Token![=],
+ pub ty: RustType,
+ pub semi_token: Token![;],
+}
+
pub struct Signature {
pub fn_token: Token![fn],
pub receiver: Option<Receiver>,
diff --git a/syntax/tokens.rs b/syntax/tokens.rs
index 934c85b..6dd6073 100644
--- a/syntax/tokens.rs
+++ b/syntax/tokens.rs
@@ -1,6 +1,7 @@
use crate::syntax::atom::Atom::*;
use crate::syntax::{
- Derive, Enum, ExternFn, ExternType, Receiver, Ref, Signature, Slice, Struct, Ty1, Type, Var,
+ Derive, Enum, ExternFn, ExternType, Receiver, Ref, Signature, Slice, Struct, Ty1, Type,
+ TypeAlias, Var,
};
use proc_macro2::{Ident, Span, TokenStream};
use quote::{quote_spanned, ToTokens};
@@ -86,6 +87,14 @@
}
}
+impl ToTokens for TypeAlias {
+ fn to_tokens(&self, tokens: &mut TokenStream) {
+ // Notional token range for error reporting purposes.
+ self.type_token.to_tokens(tokens);
+ self.ident.to_tokens(tokens);
+ }
+}
+
impl ToTokens for Struct {
fn to_tokens(&self, tokens: &mut TokenStream) {
// Notional token range for error reporting purposes.
diff --git a/syntax/types.rs b/syntax/types.rs
index 5800513..2ab8cbd 100644
--- a/syntax/types.rs
+++ b/syntax/types.rs
@@ -96,6 +96,7 @@
visit(&mut all, ret);
}
}
+ Api::TypeAlias(_alias) => unimplemented!(),
}
}