From 12452f549cf66e0466b13459405a791512ea114b Mon Sep 17 00:00:00 2001 From: Emilio Cobos Álvarez Date: Mon, 25 Jun 2018 15:29:27 +0200 Subject: 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. --- src/codegen/helpers.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src/codegen/helpers.rs') 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 { - // This guard can be weakened when Rust implements u128. - if layout.size > mem::size_of::() { - 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`. -- cgit v1.2.3