Skip to content

Commit 11f54f6

Browse files
committed
servo: Merge #19316 - Fix Stylo tests to pass on both Stable and Nightly Rust (from servo:stylo-size-of); r=emilio
This is on top of servo/servo#19285. Rust Nightly has new enum memory layout optimizations: rust-lang/rust#45225 Source-Repo: https://github.com/servo/servo Source-Revision: 17e97b9320fdb7cdb33bbc5f4d0fde0653bbf2e4 UltraBlame original commit: 6de571030d5d998dcadbd3dac602fa006395165c
1 parent fd96606 commit 11f54f6

File tree

7 files changed

+25
-7
lines changed

7 files changed

+25
-7
lines changed

servo/components/style/build.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,16 @@ fn generate_properties() {
7676
.arg(&script)
7777
.arg(product)
7878
.arg("style-crate")
79+
.envs(if std::mem::size_of::<Option<bool>>() == 1 {
80+
81+
82+
83+
84+
85+
vec![("RUSTC_HAS_PR45225", "1")]
86+
} else {
87+
vec![]
88+
})
7989
.status()
8090
.unwrap();
8191
if !status.success() {

servo/components/style/properties/build.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ def main():
3232

3333
properties = data.PropertiesData(product=product)
3434
template = os.path.join(BASE, "properties.mako.rs")
35-
rust = render(template, product=product, data=properties, __file__=template)
35+
rust = render(template, product=product, data=properties, __file__=template,
36+
RUSTC_HAS_PR45225=os.environ.get("RUSTC_HAS_PR45225"))
3637
if output == "style-crate":
3738
write(os.environ["OUT_DIR"], "properties.rs", rust)
3839
if product == "gecko":

servo/components/style/properties/data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def casted_constant_name(self, value, cast_type):
140140
def arg_to_bool(arg):
141141
if isinstance(arg, bool):
142142
return arg
143-
assert arg in ["True", "False"]
143+
assert arg in ["True", "False"], "Unexpected value for boolean arguement: " + repr(arg)
144144
return arg == "True"
145145

146146

servo/components/style/properties/longhand/inherited_svg.mako.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ ${helpers.predefined_type(
6666
"stroke-width", "SVGWidth",
6767
"::values::computed::NonNegativeLength::new(1.).into()",
6868
products="gecko",
69-
boxed="True",
69+
boxed=not RUSTC_HAS_PR45225,
7070
animation_value_type="::values::computed::SVGWidth",
7171
spec="https://www.w3.org/TR/SVG2/painting.html#StrokeWidth")}
7272

@@ -101,7 +101,7 @@ ${helpers.predefined_type(
101101
"stroke-dashoffset", "SVGLength",
102102
"Au(0).into()",
103103
products="gecko",
104-
boxed="True",
104+
boxed=not RUSTC_HAS_PR45225,
105105
animation_value_type="ComputedValue",
106106
spec="https://www.w3.org/TR/SVG2/painting.html#StrokeDashing")}
107107

servo/components/style/properties/longhand/pointing.mako.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ ${helpers.predefined_type(
177177
"Either::Second(Auto)",
178178
spec="https://drafts.csswg.org/css-ui/#caret-color",
179179
animation_value_type="Either<AnimatedColor, Auto>",
180-
boxed=True,
180+
boxed=not RUSTC_HAS_PR45225,
181181
ignored_when_colors_disabled=True,
182182
products="gecko",
183183
)}

servo/tests/unit/stylo/build.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ use std::io::{BufRead, BufReader, Write};
1111
use std::path::Path;
1212

1313
fn main() {
14+
if std::mem::size_of::<Option<bool>>() == 1 {
15+
16+
println!("cargo:rustc-cfg=rustc_has_pr45225")
17+
}
18+
1419
let root_path = Path::new("../../../");
1520
let bindings_file = root_path.join("components/style/gecko/generated/bindings.rs");
1621
let glue_file = root_path.join("ports/geckolib/glue.rs");

servo/tests/unit/stylo/size_of.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,7 @@ size_of_test!(test_size_of_specified_image, specified::image::Image, 40);
5757

5858

5959

60-
size_of_test!(test_size_of_computed_image_layer, computed::image::ImageLayer, 48);
61-
size_of_test!(test_size_of_specified_image_layer, specified::image::ImageLayer, 48);
60+
size_of_test!(test_size_of_computed_image_layer, computed::image::ImageLayer,
61+
if cfg!(rustc_has_pr45225) { 40 } else { 48 });
62+
size_of_test!(test_size_of_specified_image_layer, specified::image::ImageLayer,
63+
if cfg!(rustc_has_pr45225) { 40 } else { 48 });

0 commit comments

Comments
 (0)