Upgrade to rustc 1.18.0-nightly (5f13a3b54 2017-04-15)

This version enables [struct field reordering][1] which brings the size
of the types for specified values of some CSS properties under the threshold
such that they shouldn’t be boxed anymore, making unit tests fail.

Simply unboxing them moves the test failure to Stylo’s unit tests,
since the stable compiler used in that case does not do field re-ordering.
Therefore, we manually reorder a couple fields to effectively bring this
optimization to older compilers for a few specific types.

[1]: https://github.com/rust-lang/rust/pull/40377
This commit is contained in:
Simon Sapin 2017-04-15 13:42:50 +02:00
parent 7ae9c96467
commit daba02438d
11 changed files with 50 additions and 53 deletions

View file

@ -225,10 +225,10 @@ mod shorthand_serialization {
let px_30 = BorderWidth::from_length(Length::from_px(30f32));
let px_10 = BorderWidth::from_length(Length::from_px(10f32));
properties.push(PropertyDeclaration::BorderTopWidth(Box::new(px_30.clone())));
properties.push(PropertyDeclaration::BorderRightWidth(Box::new(px_30.clone())));
properties.push(PropertyDeclaration::BorderBottomWidth(Box::new(px_30.clone())));
properties.push(PropertyDeclaration::BorderLeftWidth(Box::new(px_10.clone())));
properties.push(PropertyDeclaration::BorderTopWidth(px_30.clone()));
properties.push(PropertyDeclaration::BorderRightWidth(px_30.clone()));
properties.push(PropertyDeclaration::BorderBottomWidth(px_30.clone()));
properties.push(PropertyDeclaration::BorderLeftWidth(px_10.clone()));
let blue = CSSColor {
parsed: ComputedColor::RGBA(RGBA::new(0, 0, 255, 255)),
@ -258,10 +258,10 @@ mod shorthand_serialization {
let px_30 = BorderWidth::from_length(Length::from_px(30f32));
properties.push(PropertyDeclaration::BorderTopWidth(Box::new(px_30.clone())));
properties.push(PropertyDeclaration::BorderRightWidth(Box::new(px_30.clone())));
properties.push(PropertyDeclaration::BorderBottomWidth(Box::new(px_30.clone())));
properties.push(PropertyDeclaration::BorderLeftWidth(Box::new(px_30.clone())));
properties.push(PropertyDeclaration::BorderTopWidth(px_30.clone()));
properties.push(PropertyDeclaration::BorderRightWidth(px_30.clone()));
properties.push(PropertyDeclaration::BorderBottomWidth(px_30.clone()));
properties.push(PropertyDeclaration::BorderLeftWidth(px_30.clone()));
let blue = CSSColor {
parsed: ComputedColor::RGBA(RGBA::new(0, 0, 255, 255)),
@ -302,10 +302,10 @@ mod shorthand_serialization {
let right_px = BorderWidth::from_length(Length::from_px(15f32));
let left_px = BorderWidth::from_length(Length::from_px(15f32));
properties.push(PropertyDeclaration::BorderTopWidth(Box::new(top_px)));
properties.push(PropertyDeclaration::BorderRightWidth(Box::new(right_px)));
properties.push(PropertyDeclaration::BorderBottomWidth(Box::new(bottom_px)));
properties.push(PropertyDeclaration::BorderLeftWidth(Box::new(left_px)));
properties.push(PropertyDeclaration::BorderTopWidth(top_px));
properties.push(PropertyDeclaration::BorderRightWidth(right_px));
properties.push(PropertyDeclaration::BorderBottomWidth(bottom_px));
properties.push(PropertyDeclaration::BorderLeftWidth(left_px));
let serialization = shorthand_properties_to_string(properties);
assert_eq!(serialization, "border-width: 10px 15px;");
@ -320,10 +320,10 @@ mod shorthand_serialization {
let bottom_px = BorderWidth::Thick;
let left_px = BorderWidth::from_length(Length::from_px(15f32));
properties.push(PropertyDeclaration::BorderTopWidth(Box::new(top_px)));
properties.push(PropertyDeclaration::BorderRightWidth(Box::new(right_px)));
properties.push(PropertyDeclaration::BorderBottomWidth(Box::new(bottom_px)));
properties.push(PropertyDeclaration::BorderLeftWidth(Box::new(left_px)));
properties.push(PropertyDeclaration::BorderTopWidth(top_px));
properties.push(PropertyDeclaration::BorderRightWidth(right_px));
properties.push(PropertyDeclaration::BorderBottomWidth(bottom_px));
properties.push(PropertyDeclaration::BorderLeftWidth(left_px));
let serialization = shorthand_properties_to_string(properties);
assert_eq!(serialization, "border-width: thin medium thick 15px;");
@ -411,7 +411,7 @@ mod shorthand_serialization {
authored: None
};
properties.push(PropertyDeclaration::BorderTopWidth(Box::new(width)));
properties.push(PropertyDeclaration::BorderTopWidth(width));
properties.push(PropertyDeclaration::BorderTopStyle(style));
properties.push(PropertyDeclaration::BorderTopColor(color));
@ -429,7 +429,7 @@ mod shorthand_serialization {
fn border_top_should_serialize_correctly() {
let mut properties = Vec::new();
let (width, style, color) = get_border_property_values();
properties.push(PropertyDeclaration::BorderTopWidth(Box::new(width)));
properties.push(PropertyDeclaration::BorderTopWidth(width));
properties.push(PropertyDeclaration::BorderTopStyle(style));
properties.push(PropertyDeclaration::BorderTopColor(color));
@ -441,7 +441,7 @@ mod shorthand_serialization {
fn border_right_should_serialize_correctly() {
let mut properties = Vec::new();
let (width, style, color) = get_border_property_values();
properties.push(PropertyDeclaration::BorderRightWidth(Box::new(width)));
properties.push(PropertyDeclaration::BorderRightWidth(width));
properties.push(PropertyDeclaration::BorderRightStyle(style));
properties.push(PropertyDeclaration::BorderRightColor(color));
@ -453,7 +453,7 @@ mod shorthand_serialization {
fn border_bottom_should_serialize_correctly() {
let mut properties = Vec::new();
let (width, style, color) = get_border_property_values();
properties.push(PropertyDeclaration::BorderBottomWidth(Box::new(width)));
properties.push(PropertyDeclaration::BorderBottomWidth(width));
properties.push(PropertyDeclaration::BorderBottomStyle(style));
properties.push(PropertyDeclaration::BorderBottomColor(color));
@ -465,7 +465,7 @@ mod shorthand_serialization {
fn border_left_should_serialize_correctly() {
let mut properties = Vec::new();
let (width, style, color) = get_border_property_values();
properties.push(PropertyDeclaration::BorderLeftWidth(Box::new(width)));
properties.push(PropertyDeclaration::BorderLeftWidth(width));
properties.push(PropertyDeclaration::BorderLeftStyle(style));
properties.push(PropertyDeclaration::BorderLeftColor(color));
@ -478,19 +478,19 @@ mod shorthand_serialization {
let mut properties = Vec::new();
let (width, style, color) = get_border_property_values();
properties.push(PropertyDeclaration::BorderTopWidth(Box::new(width.clone())));
properties.push(PropertyDeclaration::BorderTopWidth(width.clone()));
properties.push(PropertyDeclaration::BorderTopStyle(style.clone()));
properties.push(PropertyDeclaration::BorderTopColor(color.clone()));
properties.push(PropertyDeclaration::BorderRightWidth(Box::new(width.clone())));
properties.push(PropertyDeclaration::BorderRightWidth(width.clone()));
properties.push(PropertyDeclaration::BorderRightStyle(style.clone()));
properties.push(PropertyDeclaration::BorderRightColor(color.clone()));
properties.push(PropertyDeclaration::BorderBottomWidth(Box::new(width.clone())));
properties.push(PropertyDeclaration::BorderBottomWidth(width.clone()));
properties.push(PropertyDeclaration::BorderBottomStyle(style.clone()));
properties.push(PropertyDeclaration::BorderBottomColor(color.clone()));
properties.push(PropertyDeclaration::BorderLeftWidth(Box::new(width.clone())));
properties.push(PropertyDeclaration::BorderLeftWidth(width.clone()));
properties.push(PropertyDeclaration::BorderLeftStyle(style.clone()));
properties.push(PropertyDeclaration::BorderLeftColor(color.clone()));
@ -575,7 +575,7 @@ mod shorthand_serialization {
let width = Either::Second(Auto);
let count = Either::Second(Auto);
properties.push(PropertyDeclaration::ColumnWidth(Box::new(width)));
properties.push(PropertyDeclaration::ColumnWidth(width));
properties.push(PropertyDeclaration::ColumnCount(count));
let serialization = shorthand_properties_to_string(properties);

View file

@ -11,17 +11,17 @@ use style::values::specified::{AbsoluteLength, Length, NoCalcLength, ViewportPer
#[test]
fn has_viewport_percentage_for_specified_value() {
//TODO: test all specified value with a HasViewportPercentage impl
let pvw = PropertyDeclaration::BorderTopWidth(Box::new(
let pvw = PropertyDeclaration::BorderTopWidth(
border_top_width::SpecifiedValue::from_length(
Length::NoCalc(NoCalcLength::ViewportPercentage(ViewportPercentageLength::Vw(100.)))
)
));
);
assert!(pvw.has_viewport_percentage());
let pabs = PropertyDeclaration::BorderTopWidth(Box::new(
let pabs = PropertyDeclaration::BorderTopWidth(
border_top_width::SpecifiedValue::from_length(
Length::NoCalc(NoCalcLength::Absolute(AbsoluteLength::Px(Au(100).to_f32_px())))
)
));
);
assert!(!pabs.has_viewport_percentage());
}