summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/codegen/impl_debug.rs2
-rw-r--r--src/codegen/mod.rs18
-rw-r--r--src/codegen/struct_layout.rs2
-rw-r--r--src/ir/analysis/derive_copy.rs4
-rw-r--r--src/ir/analysis/derive_debug.rs6
-rw-r--r--src/ir/analysis/derive_default.rs4
-rw-r--r--src/ir/analysis/derive_hash.rs6
-rw-r--r--src/ir/analysis/derive_partial_eq_or_partial_ord.rs6
-rw-r--r--src/ir/analysis/has_destructor.rs2
-rw-r--r--src/ir/analysis/has_float.rs4
-rw-r--r--src/ir/analysis/has_type_param_in_array.rs4
-rw-r--r--src/ir/analysis/has_vtable.rs2
-rw-r--r--src/ir/context.rs24
-rw-r--r--src/ir/function.rs4
-rw-r--r--src/ir/item.rs13
-rw-r--r--src/ir/ty.rs52
-rw-r--r--src/ir/var.rs2
17 files changed, 89 insertions, 66 deletions
diff --git a/src/codegen/impl_debug.rs b/src/codegen/impl_debug.rs
index e111ecc6..7ef108da 100644
--- a/src/codegen/impl_debug.rs
+++ b/src/codegen/impl_debug.rs
@@ -203,7 +203,7 @@ impl<'a> ImplDebug<'a> for Item {
}
TypeKind::Pointer(inner) => {
- let inner_type = ctx.resolve_type(inner.as_type_id_unchecked()).canonical_type(ctx);
+ let inner_type = ctx.resolve_type(inner).canonical_type(ctx);
match *inner_type.kind() {
TypeKind::Function(ref sig)
if !sig.can_trivially_derive_debug() => {
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs
index 8a200948..b0c1b18e 100644
--- a/src/codegen/mod.rs
+++ b/src/codegen/mod.rs
@@ -2728,7 +2728,10 @@ where
}
}
-impl TryToOpaque for ItemId {
+impl<T> TryToOpaque for T
+where
+ T: Copy + Into<ItemId>
+{
type Extra = ();
fn try_get_layout(
@@ -2736,11 +2739,14 @@ impl TryToOpaque for ItemId {
ctx: &BindgenContext,
_: &(),
) -> error::Result<Layout> {
- ctx.resolve_item(*self).try_get_layout(ctx, &())
+ ctx.resolve_item((*self).into()).try_get_layout(ctx, &())
}
}
-impl TryToRustTy for ItemId {
+impl<T> TryToRustTy for T
+where
+ T: Copy + Into<ItemId>
+{
type Extra = ();
fn try_to_rust_ty(
@@ -2748,7 +2754,7 @@ impl TryToRustTy for ItemId {
ctx: &BindgenContext,
_: &(),
) -> error::Result<quote::Tokens> {
- ctx.resolve_item(*self).try_to_rust_ty(ctx, &())
+ ctx.resolve_item((*self).into()).try_to_rust_ty(ctx, &())
}
}
@@ -2930,7 +2936,7 @@ impl TryToRustTy for Type {
}
TypeKind::Pointer(inner) |
TypeKind::Reference(inner) => {
- let is_const = self.is_const() || ctx.resolve_type(inner.as_type_id_unchecked()).is_const();
+ let is_const = self.is_const() || ctx.resolve_type(inner).is_const();
let inner = inner.into_resolver().through_type_refs().resolve(ctx);
let inner_ty = inner.expect_type();
@@ -3626,7 +3632,7 @@ mod utils {
let arg_ty = match *arg_ty.canonical_type(ctx).kind() {
TypeKind::Array(t, _) => {
t.to_rust_ty_or_opaque(ctx, &())
- .to_ptr(ctx.resolve_type(t.as_type_id_unchecked()).is_const())
+ .to_ptr(ctx.resolve_type(t).is_const())
},
TypeKind::Pointer(inner) => {
let inner = ctx.resolve_item(inner);
diff --git a/src/codegen/struct_layout.rs b/src/codegen/struct_layout.rs
index 9e08b13f..06059853 100644
--- a/src/codegen/struct_layout.rs
+++ b/src/codegen/struct_layout.rs
@@ -166,7 +166,7 @@ impl<'a> StructLayoutTracker<'a> {
//
// This means that the structs in the array are super-unsafe to
// access, since they won't be properly aligned, but *shrug*.
- if let Some(layout) = self.ctx.resolve_type(inner.as_type_id_unchecked()).layout(
+ if let Some(layout) = self.ctx.resolve_type(inner).layout(
self.ctx,
)
{
diff --git a/src/ir/analysis/derive_copy.rs b/src/ir/analysis/derive_copy.rs
index 264d227a..1a97f3c2 100644
--- a/src/ir/analysis/derive_copy.rs
+++ b/src/ir/analysis/derive_copy.rs
@@ -177,7 +177,7 @@ impl<'ctx> MonotoneFramework for CannotDeriveCopy<'ctx> {
}
TypeKind::Array(t, len) => {
- let cant_derive_copy = self.is_not_copy(t);
+ let cant_derive_copy = self.is_not_copy(t.into());
if cant_derive_copy {
trace!(
" arrays of T for which we cannot derive Copy \
@@ -198,7 +198,7 @@ impl<'ctx> MonotoneFramework for CannotDeriveCopy<'ctx> {
TypeKind::ResolvedTypeRef(t) |
TypeKind::TemplateAlias(t, _) |
TypeKind::Alias(t) => {
- let cant_derive_copy = self.is_not_copy(t);
+ let cant_derive_copy = self.is_not_copy(t.into());
if cant_derive_copy {
trace!(
" arrays of T for which we cannot derive Copy \
diff --git a/src/ir/analysis/derive_debug.rs b/src/ir/analysis/derive_debug.rs
index fd9fe2cc..8a83613b 100644
--- a/src/ir/analysis/derive_debug.rs
+++ b/src/ir/analysis/derive_debug.rs
@@ -191,7 +191,7 @@ impl<'ctx> MonotoneFramework for CannotDeriveDebug<'ctx> {
}
TypeKind::Array(t, len) => {
- if self.is_not_debug(t) {
+ if self.is_not_debug(t.into()) {
trace!(
" arrays of T for which we cannot derive Debug \
also cannot derive Debug"
@@ -211,7 +211,7 @@ impl<'ctx> MonotoneFramework for CannotDeriveDebug<'ctx> {
TypeKind::ResolvedTypeRef(t) |
TypeKind::TemplateAlias(t, _) |
TypeKind::Alias(t) => {
- if self.is_not_debug(t) {
+ if self.is_not_debug(t.into()) {
trace!(
" aliases and type refs to T which cannot derive \
Debug also cannot derive Debug"
@@ -294,7 +294,7 @@ impl<'ctx> MonotoneFramework for CannotDeriveDebug<'ctx> {
TypeKind::Pointer(inner) => {
let inner_type =
- self.ctx.resolve_type(inner.as_type_id_unchecked()).canonical_type(self.ctx);
+ self.ctx.resolve_type(inner).canonical_type(self.ctx);
if let TypeKind::Function(ref sig) = *inner_type.kind() {
if !sig.can_trivially_derive_debug() {
trace!(
diff --git a/src/ir/analysis/derive_default.rs b/src/ir/analysis/derive_default.rs
index 7acbe04a..083723c7 100644
--- a/src/ir/analysis/derive_default.rs
+++ b/src/ir/analysis/derive_default.rs
@@ -222,7 +222,7 @@ impl<'ctx> MonotoneFramework for CannotDeriveDefault<'ctx> {
}
TypeKind::Array(t, len) => {
- if self.is_not_default(t) {
+ if self.is_not_default(t.into()) {
trace!(
" arrays of T for which we cannot derive Default \
also cannot derive Default"
@@ -242,7 +242,7 @@ impl<'ctx> MonotoneFramework for CannotDeriveDefault<'ctx> {
TypeKind::ResolvedTypeRef(t) |
TypeKind::TemplateAlias(t, _) |
TypeKind::Alias(t) => {
- if self.is_not_default(t) {
+ if self.is_not_default(t.into()) {
trace!(
" aliases and type refs to T which cannot derive \
Default also cannot derive Default"
diff --git a/src/ir/analysis/derive_hash.rs b/src/ir/analysis/derive_hash.rs
index f53dbfc7..e2aae2f8 100644
--- a/src/ir/analysis/derive_hash.rs
+++ b/src/ir/analysis/derive_hash.rs
@@ -178,7 +178,7 @@ impl<'ctx> MonotoneFramework for CannotDeriveHash<'ctx> {
}
TypeKind::Array(t, len) => {
- if self.cannot_derive_hash.contains(&t) {
+ if self.cannot_derive_hash.contains(&t.into()) {
trace!(
" arrays of T for which we cannot derive Hash \
also cannot derive Hash"
@@ -197,7 +197,7 @@ impl<'ctx> MonotoneFramework for CannotDeriveHash<'ctx> {
TypeKind::Pointer(inner) => {
let inner_type =
- self.ctx.resolve_type(inner.as_type_id_unchecked()).canonical_type(self.ctx);
+ self.ctx.resolve_type(inner).canonical_type(self.ctx);
if let TypeKind::Function(ref sig) = *inner_type.kind() {
if !sig.can_trivially_derive_hash() {
trace!(
@@ -222,7 +222,7 @@ impl<'ctx> MonotoneFramework for CannotDeriveHash<'ctx> {
TypeKind::ResolvedTypeRef(t) |
TypeKind::TemplateAlias(t, _) |
TypeKind::Alias(t) => {
- if self.cannot_derive_hash.contains(&t) {
+ if self.cannot_derive_hash.contains(&t.into()) {
trace!(
" aliases and type refs to T which cannot derive \
Hash also cannot derive Hash"
diff --git a/src/ir/analysis/derive_partial_eq_or_partial_ord.rs b/src/ir/analysis/derive_partial_eq_or_partial_ord.rs
index 0e01247e..9211bb09 100644
--- a/src/ir/analysis/derive_partial_eq_or_partial_ord.rs
+++ b/src/ir/analysis/derive_partial_eq_or_partial_ord.rs
@@ -190,7 +190,7 @@ impl<'ctx> MonotoneFramework for CannotDerivePartialEqOrPartialOrd<'ctx> {
}
TypeKind::Array(t, len) => {
- if self.cannot_derive_partialeq_or_partialord.contains(&t) {
+ if self.cannot_derive_partialeq_or_partialord.contains(&t.into()) {
trace!(
" arrays of T for which we cannot derive `PartialEq`/`PartialOrd` \
also cannot derive `PartialEq`/`PartialOrd`"
@@ -209,7 +209,7 @@ impl<'ctx> MonotoneFramework for CannotDerivePartialEqOrPartialOrd<'ctx> {
TypeKind::Pointer(inner) => {
let inner_type =
- self.ctx.resolve_type(inner.as_type_id_unchecked()).canonical_type(self.ctx);
+ self.ctx.resolve_type(inner).canonical_type(self.ctx);
if let TypeKind::Function(ref sig) = *inner_type.kind() {
if !sig.can_trivially_derive_partialeq_or_partialord() {
trace!(
@@ -236,7 +236,7 @@ impl<'ctx> MonotoneFramework for CannotDerivePartialEqOrPartialOrd<'ctx> {
TypeKind::ResolvedTypeRef(t) |
TypeKind::TemplateAlias(t, _) |
TypeKind::Alias(t) => {
- if self.cannot_derive_partialeq_or_partialord.contains(&t) {
+ if self.cannot_derive_partialeq_or_partialord.contains(&t.into()) {
trace!(
" aliases and type refs to T which cannot derive \
`PartialEq`/`PartialOrd` also cannot derive `PartialEq`/`PartialOrd`"
diff --git a/src/ir/analysis/has_destructor.rs b/src/ir/analysis/has_destructor.rs
index f6400d7d..4058cd88 100644
--- a/src/ir/analysis/has_destructor.rs
+++ b/src/ir/analysis/has_destructor.rs
@@ -103,7 +103,7 @@ impl<'ctx> MonotoneFramework for HasDestructorAnalysis<'ctx> {
TypeKind::TemplateAlias(t, _) |
TypeKind::Alias(t) |
TypeKind::ResolvedTypeRef(t) => {
- if self.have_destructor.contains(&t) {
+ if self.have_destructor.contains(&t.into()) {
self.insert(id)
} else {
ConstrainResult::Same
diff --git a/src/ir/analysis/has_float.rs b/src/ir/analysis/has_float.rs
index 959a411b..218572dc 100644
--- a/src/ir/analysis/has_float.rs
+++ b/src/ir/analysis/has_float.rs
@@ -140,7 +140,7 @@ impl<'ctx> MonotoneFramework for HasFloat<'ctx> {
}
TypeKind::Array(t, _) => {
- if self.has_float.contains(&t) {
+ if self.has_float.contains(&t.into()) {
trace!(" Array with type T that has float also has float");
return self.insert(id)
}
@@ -151,7 +151,7 @@ impl<'ctx> MonotoneFramework for HasFloat<'ctx> {
TypeKind::ResolvedTypeRef(t) |
TypeKind::TemplateAlias(t, _) |
TypeKind::Alias(t) => {
- if self.has_float.contains(&t) {
+ if self.has_float.contains(&t.into()) {
trace!(" aliases and type refs to T which have float \
also have float");
self.insert(id)
diff --git a/src/ir/analysis/has_type_param_in_array.rs b/src/ir/analysis/has_type_param_in_array.rs
index 5b034cca..6a0e6707 100644
--- a/src/ir/analysis/has_type_param_in_array.rs
+++ b/src/ir/analysis/has_type_param_in_array.rs
@@ -147,7 +147,7 @@ impl<'ctx> MonotoneFramework for HasTypeParameterInArray<'ctx> {
TypeKind::Array(t, _) => {
let inner_ty =
- self.ctx.resolve_type(t.as_type_id_unchecked()).canonical_type(self.ctx);
+ self.ctx.resolve_type(t).canonical_type(self.ctx);
match *inner_ty.kind() {
TypeKind::TypeParam => {
trace!(" Array with Named type has type parameter");
@@ -165,7 +165,7 @@ impl<'ctx> MonotoneFramework for HasTypeParameterInArray<'ctx> {
TypeKind::ResolvedTypeRef(t) |
TypeKind::TemplateAlias(t, _) |
TypeKind::Alias(t) => {
- if self.has_type_parameter_in_array.contains(&t) {
+ if self.has_type_parameter_in_array.contains(&t.into()) {
trace!(
" aliases and type refs to T which have array \
also have array"
diff --git a/src/ir/analysis/has_vtable.rs b/src/ir/analysis/has_vtable.rs
index b0d48738..53a647af 100644
--- a/src/ir/analysis/has_vtable.rs
+++ b/src/ir/analysis/has_vtable.rs
@@ -98,7 +98,7 @@ impl<'ctx> MonotoneFramework for HasVtableAnalysis<'ctx> {
TypeKind::Alias(t) |
TypeKind::ResolvedTypeRef(t) |
TypeKind::Reference(t) => {
- if self.have_vtable.contains(&t) {
+ if self.have_vtable.contains(&t.into()) {
self.insert(id)
} else {
ConstrainResult::Same
diff --git a/src/ir/context.rs b/src/ir/context.rs
index 8f36a0b8..79f4012e 100644
--- a/src/ir/context.rs
+++ b/src/ir/context.rs
@@ -46,6 +46,12 @@ impl From<TypeId> for ItemId {
}
}
+impl<'a> From<&'a TypeId> for ItemId {
+ fn from(tid: &'a TypeId) -> ItemId {
+ tid.0
+ }
+}
+
impl From<ItemId> for usize {
fn from(id: ItemId) -> usize {
id.0
@@ -792,8 +798,7 @@ impl BindgenContext {
let item = self.items.get_mut(&id).unwrap();
*item.kind_mut().as_type_mut().unwrap().kind_mut() =
- TypeKind::ResolvedTypeRef(resolved);
-
+ TypeKind::ResolvedTypeRef(resolved.as_type_id_unchecked());
resolved
};
@@ -902,7 +907,7 @@ impl BindgenContext {
let new_parent = {
let item = self.items.get_mut(&id).unwrap();
*item.kind_mut().as_type_mut().unwrap().kind_mut() =
- TypeKind::ResolvedTypeRef(replacement);
+ TypeKind::ResolvedTypeRef(replacement.as_type_id_unchecked());
item.parent_id()
};
@@ -1701,7 +1706,7 @@ impl BindgenContext {
let spelling = ty.spelling();
let is_const = ty.is_const();
let layout = ty.fallible_layout().ok();
- let type_kind = TypeKind::ResolvedTypeRef(wrapped_id);
+ let type_kind = TypeKind::ResolvedTypeRef(wrapped_id.as_type_id_unchecked());
let ty = Type::new(Some(spelling), layout, type_kind, is_const);
let item = Item::new(
with_id,
@@ -2286,6 +2291,13 @@ impl ItemId {
}
}
+impl TypeId {
+ pub fn into_resolver(self) -> ItemResolver {
+ let id: ItemId = self.into();
+ id.into()
+ }
+}
+
impl From<ItemId> for ItemResolver {
fn from(id: ItemId) -> ItemResolver {
ItemResolver::new(id)
@@ -2325,14 +2337,14 @@ impl ItemResolver {
match ty_kind {
Some(&TypeKind::ResolvedTypeRef(next_id))
if self.through_type_refs => {
- id = next_id;
+ id = next_id.into();
}
// We intentionally ignore template aliases here, as they are
// more complicated, and don't represent a simple renaming of
// some type.
Some(&TypeKind::Alias(next_id))
if self.through_type_aliases => {
- id = next_id;
+ id = next_id.into();
}
_ => return item,
}
diff --git a/src/ir/function.rs b/src/ir/function.rs
index 402a0230..5fcd21ea 100644
--- a/src/ir/function.rs
+++ b/src/ir/function.rs
@@ -385,12 +385,12 @@ impl FunctionSig {
let class = Item::parse(cursor.semantic_parent(), None, ctx)
.expect("Expected to parse the class");
let ptr =
- Item::builtin_type(TypeKind::Pointer(class), is_const, ctx);
+ Item::builtin_type(TypeKind::Pointer(class.as_type_id_unchecked()), is_const, ctx);
args.insert(0, (Some("this".into()), ptr));
} else if is_virtual {
let void = Item::builtin_type(TypeKind::Void, false, ctx);
let ptr =
- Item::builtin_type(TypeKind::Pointer(void), false, ctx);
+ Item::builtin_type(TypeKind::Pointer(void.as_type_id_unchecked()), false, ctx);
args.insert(0, (Some("this".into()), ptr));
}
}
diff --git a/src/ir/item.rs b/src/ir/item.rs
index 955793c1..38d562fb 100644
--- a/src/ir/item.rs
+++ b/src/ir/item.rs
@@ -156,7 +156,9 @@ impl<'a> Iterator for ItemAncestorsIter<'a> {
}
}
-impl AsTemplateParam for ItemId {
+impl<T> AsTemplateParam for T
+where
+ T: Copy + Into<ItemId> {
type Extra = ();
fn as_template_param(
@@ -164,7 +166,7 @@ impl AsTemplateParam for ItemId {
ctx: &BindgenContext,
_: &(),
) -> Option<ItemId> {
- ctx.resolve_item(*self).as_template_param(ctx, &())
+ ctx.resolve_item((*self).into()).as_template_param(ctx, &())
}
}
@@ -952,7 +954,10 @@ impl Item {
}
}
-impl IsOpaque for ItemId {
+impl<T> IsOpaque for T
+where
+ T: Copy + Into<ItemId>
+{
type Extra = ();
fn is_opaque(&self, ctx: &BindgenContext, _: &()) -> bool {
@@ -960,7 +965,7 @@ impl IsOpaque for ItemId {
ctx.in_codegen_phase(),
"You're not supposed to call this yet"
);
- ctx.resolve_item(*self).is_opaque(ctx, &())
+ ctx.resolve_item((*self).into()).is_opaque(ctx, &())
}
}
diff --git a/src/ir/ty.rs b/src/ir/ty.rs
index 301f543d..34146658 100644
--- a/src/ir/ty.rs
+++ b/src/ir/ty.rs
@@ -1,7 +1,7 @@
//! Everything related to types in our intermediate representation.
use super::comp::CompInfo;
-use super::context::{BindgenContext, ItemId};
+use super::context::{BindgenContext, ItemId, TypeId};
use super::dot::DotAttributes;
use super::enum_ty::Enum;
use super::function::FunctionSig;
@@ -212,10 +212,10 @@ impl Type {
pub fn is_incomplete_array(&self, ctx: &BindgenContext) -> Option<ItemId> {
match self.kind {
TypeKind::Array(item, len) => {
- if len == 0 { Some(item) } else { None }
+ if len == 0 { Some(item.into()) } else { None }
}
TypeKind::ResolvedTypeRef(inner) => {
- ctx.resolve_type(inner.as_type_id_unchecked()).is_incomplete_array(ctx)
+ ctx.resolve_type(inner).is_incomplete_array(ctx)
}
_ => None,
}
@@ -238,7 +238,7 @@ impl Type {
))
}
TypeKind::ResolvedTypeRef(inner) => {
- ctx.resolve_type(inner.as_type_id_unchecked()).layout(ctx)
+ ctx.resolve_type(inner).layout(ctx)
}
_ => None,
}
@@ -275,8 +275,8 @@ impl Type {
ctx: &BindgenContext,
) -> Option<Cow<'a, str>> {
let name_info = match *self.kind() {
- TypeKind::Pointer(inner) => Some((inner, Cow::Borrowed("ptr"))),
- TypeKind::Reference(inner) => Some((inner, Cow::Borrowed("ref"))),
+ TypeKind::Pointer(inner) => Some((inner.into(), Cow::Borrowed("ptr"))),
+ TypeKind::Reference(inner) => Some((inner.into(), Cow::Borrowed("ref"))),
TypeKind::Array(inner, length) => {
Some((inner, format!("array{}", length).into()))
}
@@ -333,7 +333,7 @@ impl Type {
TypeKind::ResolvedTypeRef(inner) |
TypeKind::Alias(inner) |
TypeKind::TemplateAlias(inner, _) => {
- ctx.resolve_type(inner.as_type_id_unchecked()).safe_canonical_type(ctx)
+ ctx.resolve_type(inner).safe_canonical_type(ctx)
}
TypeKind::TemplateInstantiation(ref inst) => {
ctx.resolve_type(inst.template_definition().as_type_id_unchecked())
@@ -546,7 +546,7 @@ impl TemplateParameters for TypeKind {
) -> Option<Vec<ItemId>> {
match *self {
TypeKind::ResolvedTypeRef(id) => {
- ctx.resolve_type(id.as_type_id_unchecked()).self_template_params(ctx)
+ ctx.resolve_type(id).self_template_params(ctx)
}
TypeKind::Comp(ref comp) => comp.self_template_params(ctx),
TypeKind::TemplateAlias(_, ref args) => Some(args.clone()),
@@ -626,14 +626,14 @@ pub enum TypeKind {
Complex(FloatKind),
/// A type alias, with a name, that points to another type.
- Alias(ItemId),
+ Alias(TypeId),
/// A templated alias, pointing to an inner type, just as `Alias`, but with
/// template parameters.
- TemplateAlias(ItemId, Vec<ItemId>),
+ TemplateAlias(TypeId, Vec<ItemId>),
- /// An array of a type and a lenght.
- Array(ItemId, usize),
+ /// An array of a type and a length.
+ Array(TypeId, usize),
/// A function type, with a given signature.
Function(FunctionSig),
@@ -643,13 +643,13 @@ pub enum TypeKind {
/// A pointer to a type. The bool field represents whether it's const or
/// not.
- Pointer(ItemId),
+ Pointer(TypeId),
/// A pointer to an Apple block.
BlockPointer,
/// A reference to a type, as in: int& foo().
- Reference(ItemId),
+ Reference(TypeId),
/// An instantiation of an abstract template definition with a set of
/// concrete template arguments.
@@ -673,7 +673,7 @@ pub enum TypeKind {
///
/// These are generated after we resolve a forward declaration, or when we
/// replace one type with another.
- ResolvedTypeRef(ItemId),
+ ResolvedTypeRef(TypeId),
/// A named type, that is, a template parameter.
TypeParam,
@@ -701,12 +701,12 @@ impl Type {
TypeKind::Comp(ref ci) => ci.is_unsized(ctx, itemid),
TypeKind::Opaque => self.layout.map_or(true, |l| l.size == 0),
TypeKind::Array(inner, size) => {
- size == 0 || ctx.resolve_type(inner.as_type_id_unchecked()).is_unsized(ctx, &inner)
+ size == 0 || ctx.resolve_type(inner).is_unsized(ctx, &inner.into())
}
TypeKind::ResolvedTypeRef(inner) |
TypeKind::Alias(inner) |
TypeKind::TemplateAlias(inner, _) => {
- ctx.resolve_type(inner.as_type_id_unchecked()).is_unsized(ctx, &inner)
+ ctx.resolve_type(inner).is_unsized(ctx, &inner.into())
}
TypeKind::TemplateInstantiation(ref inst) => {
let definition = inst.template_definition();
@@ -1000,7 +1000,7 @@ impl Type {
}
};
- TypeKind::TemplateAlias(inner_type, args)
+ TypeKind::TemplateAlias(inner_type.as_type_id_unchecked(), args)
}
CXCursor_TemplateRef => {
let referenced = location.referenced().unwrap();
@@ -1116,7 +1116,7 @@ impl Type {
}
let inner =
Item::from_ty_or_ref(pointee, location, None, ctx);
- TypeKind::Pointer(inner)
+ TypeKind::Pointer(inner.as_type_id_unchecked())
}
CXType_BlockPointer => TypeKind::BlockPointer,
// XXX: RValueReference is most likely wrong, but I don't think we
@@ -1129,7 +1129,7 @@ impl Type {
None,
ctx,
);
- TypeKind::Reference(inner)
+ TypeKind::Reference(inner.as_type_id_unchecked())
}
// XXX DependentSizedArray is wrong
CXType_VariableArray |
@@ -1140,7 +1140,7 @@ impl Type {
None,
ctx,
).expect("Not able to resolve array element?");
- TypeKind::Pointer(inner)
+ TypeKind::Pointer(inner.as_type_id_unchecked())
}
CXType_IncompleteArray => {
let inner = Item::from_ty(
@@ -1149,7 +1149,7 @@ impl Type {
None,
ctx,
).expect("Not able to resolve array element?");
- TypeKind::Array(inner, 0)
+ TypeKind::Array(inner.as_type_id_unchecked(), 0)
}
CXType_FunctionNoProto |
CXType_FunctionProto => {
@@ -1161,7 +1161,7 @@ impl Type {
let inner = cursor.typedef_type().expect("Not valid Type?");
let inner =
Item::from_ty_or_ref(inner, location, None, ctx);
- TypeKind::Alias(inner)
+ TypeKind::Alias(inner.as_type_id_unchecked())
}
CXType_Enum => {
let enum_ = Enum::from_ty(ty, ctx).expect("Not an enum?");
@@ -1207,7 +1207,7 @@ impl Type {
None,
ctx,
).expect("Not able to resolve array element?");
- TypeKind::Array(inner, ty.num_elements().unwrap())
+ TypeKind::Array(inner.as_type_id_unchecked(), ty.num_elements().unwrap())
}
CXType_Elaborated => {
return Self::from_clang_ty(
@@ -1261,10 +1261,10 @@ impl Trace for Type {
TypeKind::Array(inner, _) |
TypeKind::Alias(inner) |
TypeKind::ResolvedTypeRef(inner) => {
- tracer.visit_kind(inner, EdgeKind::TypeReference);
+ tracer.visit_kind(inner.into(), EdgeKind::TypeReference);
}
TypeKind::TemplateAlias(inner, ref template_params) => {
- tracer.visit_kind(inner, EdgeKind::TypeReference);
+ tracer.visit_kind(inner.into(), EdgeKind::TypeReference);
for &item in template_params {
tracer.visit_kind(
item,
diff --git a/src/ir/var.rs b/src/ir/var.rs
index 5fafd72d..c0ecf3e4 100644
--- a/src/ir/var.rs
+++ b/src/ir/var.rs
@@ -179,7 +179,7 @@ impl ClangSubItemParser for Var {
true,
ctx,
);
- (TypeKind::Pointer(char_ty), VarType::String(val))
+ (TypeKind::Pointer(char_ty.as_type_id_unchecked()), VarType::String(val))
}
EvalResult::Int(Wrapping(value)) => {
let kind = ctx.parse_callbacks()