diff options
author | Emilio Cobos Álvarez <emilio@crisal.io> | 2019-07-24 11:11:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-24 11:11:17 +0200 |
commit | a3d8cf75f85fda70d36f2c74d2ecd0b414a63736 (patch) | |
tree | 94ce484c0686352ce6de7935797c0998ecb8beb8 | |
parent | 9fe3e909bea3cc24759148f27d03772a479c6ecf (diff) |
Cleanup wchar_t layout computation to happen later. (#1596)
This is a breaking cheange since WChar is exposed, but should be no behavior
change otherwise.
-rw-r--r-- | src/codegen/mod.rs | 5 | ||||
-rw-r--r-- | src/ir/context.rs | 6 | ||||
-rw-r--r-- | src/ir/int.rs | 7 |
3 files changed, 6 insertions, 12 deletions
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs index 15ace9e9..e026a3c7 100644 --- a/src/codegen/mod.rs +++ b/src/codegen/mod.rs @@ -3060,8 +3060,9 @@ impl TryToRustTy for Type { IntKind::ULong => Ok(raw_type(ctx, "c_ulong")), IntKind::LongLong => Ok(raw_type(ctx, "c_longlong")), IntKind::ULongLong => Ok(raw_type(ctx, "c_ulonglong")), - IntKind::WChar { size } => { - let ty = Layout::known_type_for_size(ctx, size) + IntKind::WChar => { + let layout = self.layout(ctx).expect("Couldn't compute wchar_t's layout?"); + let ty = Layout::known_type_for_size(ctx, layout.size) .expect("Non-representable wchar_t?"); let ident = ctx.rust_ident_raw(ty); Ok(quote! { #ident }) diff --git a/src/ir/context.rs b/src/ir/context.rs index f2b6956a..25c37874 100644 --- a/src/ir/context.rs +++ b/src/ir/context.rs @@ -2011,11 +2011,7 @@ If you encounter an error missing from this list, please file an issue or a PR!" CXType_UChar => TypeKind::Int(IntKind::UChar), CXType_Short => TypeKind::Int(IntKind::Short), CXType_UShort => TypeKind::Int(IntKind::UShort), - CXType_WChar => { - TypeKind::Int(IntKind::WChar { - size: ty.fallible_size(self).expect("Couldn't compute size of wchar_t?"), - }) - }, + CXType_WChar => TypeKind::Int(IntKind::WChar), CXType_Char16 => TypeKind::Int(IntKind::U16), CXType_Char32 => TypeKind::Int(IntKind::U32), CXType_Long => TypeKind::Int(IntKind::Long), diff --git a/src/ir/int.rs b/src/ir/int.rs index 144a7ded..dd3f0bef 100644 --- a/src/ir/int.rs +++ b/src/ir/int.rs @@ -13,10 +13,7 @@ pub enum IntKind { UChar, /// An `wchar_t`. - WChar { - /// The size of the wchar_t in bytes, which will be 2 or 4. - size: usize, - }, + WChar, /// A platform-dependent `char` type, with the signedness support. Char { @@ -97,7 +94,7 @@ impl IntKind { // to know whether it is or not right now (unlike char, there's no // WChar_S / WChar_U). Bool | UChar | UShort | UInt | ULong | ULongLong | U8 | U16 | - WChar { .. } | U32 | U64 | U128 => false, + WChar | U32 | U64 | U128 => false, SChar | Short | Int | Long | LongLong | I8 | I16 | I32 | I64 | I128 => true, |