aboutsummaryrefslogtreecommitdiff
path: root/src/backends/rust/types.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/backends/rust/types.rs')
-rw-r--r--src/backends/rust/types.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/backends/rust/types.rs b/src/backends/rust/types.rs
index 5b1767d..b5f2b91 100644
--- a/src/backends/rust/types.rs
+++ b/src/backends/rust/types.rs
@@ -15,7 +15,8 @@
//! Utility functions for dealing with Rust integer types.
use crate::analyzer::ast as analyzer_ast;
-use crate::{ast, lint};
+use crate::backends::rust::ToIdent;
+use crate::{analyzer, ast};
use quote::{format_ident, quote};
/// A Rust integer type such as `u8`.
@@ -55,7 +56,7 @@ pub fn rust_type(field: &analyzer_ast::Field) -> proc_macro2::TokenStream {
quote!(#field_type)
}
ast::FieldDesc::Typedef { type_id, .. } => {
- let field_type = format_ident!("{type_id}");
+ let field_type = type_id.to_ident();
quote!(#field_type)
}
ast::FieldDesc::Array { width: Some(width), size: Some(size), .. } => {
@@ -68,12 +69,12 @@ pub fn rust_type(field: &analyzer_ast::Field) -> proc_macro2::TokenStream {
quote!(Vec<#field_type>)
}
ast::FieldDesc::Array { type_id: Some(type_id), size: Some(size), .. } => {
- let field_type = format_ident!("{type_id}");
+ let field_type = type_id.to_ident();
let size = proc_macro2::Literal::usize_unsuffixed(*size);
quote!([#field_type; #size])
}
ast::FieldDesc::Array { type_id: Some(type_id), size: None, .. } => {
- let field_type = format_ident!("{type_id}");
+ let field_type = type_id.to_ident();
quote!(Vec<#field_type>)
}
//ast::Field::Size { .. } | ast::Field::Count { .. } => quote!(),
@@ -83,7 +84,7 @@ pub fn rust_type(field: &analyzer_ast::Field) -> proc_macro2::TokenStream {
pub fn rust_borrow(
field: &analyzer_ast::Field,
- scope: &lint::Scope<'_>,
+ scope: &analyzer::Scope<'_>,
) -> proc_macro2::TokenStream {
match &field.desc {
ast::FieldDesc::Scalar { .. } => quote!(),