Skip to content

Commit 4652f80

Browse files
author
bors-servo
authored
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.
2 parents 6a480ff + 12452f5 commit 4652f80

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/codegen/helpers.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
use ir::context::BindgenContext;
44
use ir::layout::Layout;
55
use quote;
6-
use std::mem;
76
use proc_macro2::{Term, Span};
87

98
pub mod attributes {
@@ -92,12 +91,9 @@ pub fn blob(layout: Layout) -> quote::Tokens {
9291

9392
/// Integer type of the same size as the given `Layout`.
9493
pub fn integer_type(layout: Layout) -> Option<quote::Tokens> {
95-
// This guard can be weakened when Rust implements u128.
96-
if layout.size > mem::size_of::<u64>() {
97-
None
98-
} else {
99-
Some(blob(layout))
100-
}
94+
let name = Layout::known_type_for_size(layout.size)?;
95+
let name = Term::new(name, Span::call_site());
96+
Some(quote! { #name })
10197
}
10298

10399
/// Generates a bitfield allocation unit type for a type with the given `Layout`.

0 commit comments

Comments
 (0)