summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/codegen/helpers.rs42
-rw-r--r--src/codegen/mod.rs6
2 files changed, 4 insertions, 44 deletions
diff --git a/src/codegen/helpers.rs b/src/codegen/helpers.rs
index e2fc1120..e82d5c59 100644
--- a/src/codegen/helpers.rs
+++ b/src/codegen/helpers.rs
@@ -3,7 +3,6 @@
use aster;
use ir::layout::Layout;
use syntax::ast;
-use syntax::codemap::respan;
use syntax::ptr::P;
@@ -68,46 +67,7 @@ impl BlobTyBuilder {
if data_len == 1 {
inner_ty
} else {
- ArrayTyBuilder::new().with_len(data_len).build(inner_ty)
+ aster::ty::TyBuilder::new().array(data_len).build(inner_ty)
}
}
}
-
-pub struct ArrayTyBuilder {
- len: usize,
-}
-
-impl ArrayTyBuilder {
- pub fn new() -> Self {
- ArrayTyBuilder {
- len: 0,
- }
- }
-
- pub fn with_len(mut self, len: usize) -> Self {
- self.len = len;
- self
- }
-
- pub fn build(self, ty: P<ast::Ty>) -> P<ast::Ty> {
- use syntax::codemap::DUMMY_SP;
- let size =
- ast::LitKind::Int(self.len as u64,
- ast::LitIntType::Unsigned(ast::UintTy::Us));
- let size = ast::ExprKind::Lit(P(respan(DUMMY_SP, size)));
- let array_kind = ast::TyKind::FixedLengthVec(ty,
- P(ast::Expr {
- id: ast::DUMMY_NODE_ID,
- node: size,
- span: DUMMY_SP,
- attrs: ast::ThinVec::new(),
- })
- );
-
- P(ast::Ty {
- id: ast::DUMMY_NODE_ID,
- node: array_kind,
- span: DUMMY_SP,
- })
- }
-}
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs
index d95364a2..7350bb49 100644
--- a/src/codegen/mod.rs
+++ b/src/codegen/mod.rs
@@ -1,6 +1,6 @@
mod helpers;
-use self::helpers::{attributes, ArrayTyBuilder, BlobTyBuilder};
+use self::helpers::{attributes, BlobTyBuilder};
use ir::context::BindgenContext;
use ir::item::{Item, ItemId, ItemCanonicalName, ItemCanonicalPath};
@@ -1317,7 +1317,7 @@ impl ToRustTy for Type {
// can't do better right now. We should be able to use
// i128/u128 when they're available.
IntKind::U128 |
- IntKind::I128 => ArrayTyBuilder::new().with_len(2).build(aster::ty::TyBuilder::new().u64()),
+ IntKind::I128 => aster::ty::TyBuilder::new().array(2).u64(),
}
}
TypeKind::Float(fk) => {
@@ -1336,7 +1336,7 @@ impl ToRustTy for Type {
}
TypeKind::Array(item, len) => {
let inner = item.to_rust_ty(ctx);
- ArrayTyBuilder::new().with_len(len).build(inner)
+ aster::ty::TyBuilder::new().array(len).build(inner)
}
TypeKind::Enum(..) => {
let path = item.canonical_path(ctx);