Preserve lit token of array length
diff --git a/syntax/impls.rs b/syntax/impls.rs
index ef3ba8f..f533093 100644
--- a/syntax/impls.rs
+++ b/syntax/impls.rs
@@ -183,12 +183,14 @@
inner,
semi_token: _,
len,
+ len_token: _,
} = self;
let Array {
bracket: _,
inner: inner2,
semi_token: _,
len: len2,
+ len_token: _,
} = other;
inner == inner2 && len == len2
}
@@ -201,6 +203,7 @@
inner,
semi_token: _,
len,
+ len_token: _,
} = self;
inner.hash(state);
len.hash(state);
diff --git a/syntax/mod.rs b/syntax/mod.rs
index 45a4aa5..e61e384 100644
--- a/syntax/mod.rs
+++ b/syntax/mod.rs
@@ -30,7 +30,7 @@
use proc_macro2::{Ident, Span};
use syn::punctuated::Punctuated;
use syn::token::{Brace, Bracket, Paren};
-use syn::{Expr, Generics, Lifetime, Token, Type as RustType};
+use syn::{Expr, Generics, Lifetime, LitInt, Token, Type as RustType};
pub use self::atom::Atom;
pub use self::derive::Derive;
@@ -196,6 +196,7 @@
pub inner: Type,
pub semi_token: Token![;],
pub len: usize,
+ pub len_token: LitInt,
}
#[derive(Copy, Clone, PartialEq)]
diff --git a/syntax/parse.rs b/syntax/parse.rs
index 80ecc71..597ccfd 100644
--- a/syntax/parse.rs
+++ b/syntax/parse.rs
@@ -657,8 +657,8 @@
));
}
match &lit.lit {
- Lit::Int(v) => {
- let v = match v.base10_parse::<usize>() {
+ Lit::Int(len_token) => {
+ let v = match len_token.base10_parse::<usize>() {
Ok(n_v) => n_v,
Err(_) => {
return Err(Error::new_spanned(
@@ -672,6 +672,7 @@
inner,
semi_token: ty.semi_token,
len: v,
+ len_token: len_token.clone(),
})))
}
_ => Err(Error::new_spanned(ty, "length literal must be a integer")),
diff --git a/syntax/tokens.rs b/syntax/tokens.rs
index 27c2693..30a63d8 100644
--- a/syntax/tokens.rs
+++ b/syntax/tokens.rs
@@ -74,7 +74,7 @@
self.bracket.surround(tokens, |tokens| {
self.inner.to_tokens(tokens);
self.semi_token.to_tokens(tokens);
- self.len.to_tokens(tokens);
+ self.len_token.to_tokens(tokens);
});
}
}