diff options
author | Emilio Cobos Álvarez <emilio@crisal.io> | 2018-06-25 15:29:27 +0200 |
---|---|---|
committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2018-07-05 02:36:41 +0200 |
commit | 12452f549cf66e0466b13459405a791512ea114b (patch) | |
tree | c5da785fa1ac44a33ba73e8de66c6756f2cc5659 /src/codegen/helpers.rs | |
parent | b3e41a2924bb60e0a308bd2d35c8b9c0126a7249 (diff) |
Fix integer_type to actually return integers all the time.
blob() does care about alignment, so we can get into an architecture where there
are integers where size != align.
This is a tentative fix for https://github.com/servo/servo/issues/21093, though
as mentioned there I couldn't find a repro on my machine.
Diffstat (limited to 'src/codegen/helpers.rs')
-rw-r--r-- | src/codegen/helpers.rs | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/src/codegen/helpers.rs b/src/codegen/helpers.rs index f1007c51..b7c3df7f 100644 --- a/src/codegen/helpers.rs +++ b/src/codegen/helpers.rs @@ -3,7 +3,6 @@ use ir::context::BindgenContext; use ir::layout::Layout; use quote; -use std::mem; use proc_macro2::{Term, Span}; pub mod attributes { @@ -92,12 +91,9 @@ pub fn blob(layout: Layout) -> quote::Tokens { /// Integer type of the same size as the given `Layout`. pub fn integer_type(layout: Layout) -> Option<quote::Tokens> { - // This guard can be weakened when Rust implements u128. - if layout.size > mem::size_of::<u64>() { - None - } else { - Some(blob(layout)) - } + let name = Layout::known_type_for_size(layout.size)?; + let name = Term::new(name, Span::call_site()); + Some(quote! { #name }) } /// Generates a bitfield allocation unit type for a type with the given `Layout`. |