diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2018-07-06 13:29:46 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-06 13:29:46 -0400 |
commit | 4652f8008912482f72d9a74fad356ea1e9f1e048 (patch) | |
tree | c5da785fa1ac44a33ba73e8de66c6756f2cc5659 | |
parent | 6a480ffeb8d30a2ea58dc7e605a0274ca29e28cb (diff) | |
parent | 12452f549cf66e0466b13459405a791512ea114b (diff) |
Auto merge of #1339 - emilio:bitfield-int, r=fitzgen
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 servo/servo#21093, though
as mentioned there I couldn't find a repro on my machine.
-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`. |