Skip to content

Commit 2916bea

Browse files
committed
Use the upstreamed version of the array builder.
1 parent c41a1c2 commit 2916bea

File tree

2 files changed

+4
-44
lines changed

2 files changed

+4
-44
lines changed

src/codegen/helpers.rs

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
use aster;
44
use ir::layout::Layout;
55
use syntax::ast;
6-
use syntax::codemap::respan;
76
use syntax::ptr::P;
87

98

@@ -68,46 +67,7 @@ impl BlobTyBuilder {
6867
if data_len == 1 {
6968
inner_ty
7069
} else {
71-
ArrayTyBuilder::new().with_len(data_len).build(inner_ty)
70+
aster::ty::TyBuilder::new().array(data_len).build(inner_ty)
7271
}
7372
}
7473
}
75-
76-
pub struct ArrayTyBuilder {
77-
len: usize,
78-
}
79-
80-
impl ArrayTyBuilder {
81-
pub fn new() -> Self {
82-
ArrayTyBuilder {
83-
len: 0,
84-
}
85-
}
86-
87-
pub fn with_len(mut self, len: usize) -> Self {
88-
self.len = len;
89-
self
90-
}
91-
92-
pub fn build(self, ty: P<ast::Ty>) -> P<ast::Ty> {
93-
use syntax::codemap::DUMMY_SP;
94-
let size =
95-
ast::LitKind::Int(self.len as u64,
96-
ast::LitIntType::Unsigned(ast::UintTy::Us));
97-
let size = ast::ExprKind::Lit(P(respan(DUMMY_SP, size)));
98-
let array_kind = ast::TyKind::FixedLengthVec(ty,
99-
P(ast::Expr {
100-
id: ast::DUMMY_NODE_ID,
101-
node: size,
102-
span: DUMMY_SP,
103-
attrs: ast::ThinVec::new(),
104-
})
105-
);
106-
107-
P(ast::Ty {
108-
id: ast::DUMMY_NODE_ID,
109-
node: array_kind,
110-
span: DUMMY_SP,
111-
})
112-
}
113-
}

src/codegen/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
mod helpers;
22

3-
use self::helpers::{attributes, ArrayTyBuilder, BlobTyBuilder};
3+
use self::helpers::{attributes, BlobTyBuilder};
44

55
use ir::context::BindgenContext;
66
use ir::item::{Item, ItemId, ItemCanonicalName, ItemCanonicalPath};
@@ -1317,7 +1317,7 @@ impl ToRustTy for Type {
13171317
// can't do better right now. We should be able to use
13181318
// i128/u128 when they're available.
13191319
IntKind::U128 |
1320-
IntKind::I128 => ArrayTyBuilder::new().with_len(2).build(aster::ty::TyBuilder::new().u64()),
1320+
IntKind::I128 => aster::ty::TyBuilder::new().array(2).u64(),
13211321
}
13221322
}
13231323
TypeKind::Float(fk) => {
@@ -1336,7 +1336,7 @@ impl ToRustTy for Type {
13361336
}
13371337
TypeKind::Array(item, len) => {
13381338
let inner = item.to_rust_ty(ctx);
1339-
ArrayTyBuilder::new().with_len(len).build(inner)
1339+
aster::ty::TyBuilder::new().array(len).build(inner)
13401340
}
13411341
TypeKind::Enum(..) => {
13421342
let path = item.canonical_path(ctx);

0 commit comments

Comments
 (0)