Skip to content
Permalink
Browse files

style: Add check for non-Copy specified value to ensure specified_is_…

…copy always returns the right result.

Differential Revision: https://phabricator.services.mozilla.com/D2931
  • Loading branch information
upsuper authored and emilio committed Aug 18, 2018
1 parent e7945bb commit e22850dc85104d867acfab235150795d06f92efa
@@ -290,14 +290,22 @@ def specified_is_copy(self):
"AlignContent",
"AlignItems",
"AlignSelf",
"Appearance",
"BackgroundRepeat",
"BorderImageRepeat",
"BorderStyle",
"Clear",
"ColumnCount",
"Contain",
"Display",
"Float",
"FontSizeAdjust",
"FontStretch",
"FontStyle",
"FontStyleAdjust",
"FontSynthesis",
"FontWeight",
"GreaterThanOrEqualToOneNumber",
"GridAutoFlow",
"InitialLetter",
"Integer",
@@ -311,17 +319,22 @@ def specified_is_copy(self):
"NonNegativeNumber",
"Opacity",
"OutlineStyle",
"OverflowClipBox",
"OverscrollBehavior",
"Percentage",
"SVGOpacity",
"SVGPaintOrder",
"ScrollSnapType",
"TextAlign",
"TextDecorationLine",
"TouchAction",
"TransformStyle",
"XSpan",
"XTextZoom",
"ZIndex",
}
if self.name == "overflow-y":
return True
return bool(self.keyword)

def animated_type(self):
@@ -448,7 +448,7 @@ ${helpers.predefined_type(

${helpers.predefined_type(
"perspective-origin",
"position::Position",
"Position",
"computed::position::Position::center()",
boxed=True,
extra_prefixes=transform_extra_prefixes,
@@ -305,6 +305,21 @@ impl Clone for PropertyDeclaration {
}
}

// This function ensures that all properties not handled above
// do not have a specified value implements Copy. If you hit
// compile error here, you may want to add the type name into
// Longhand.specified_is_copy in data.py.
fn _static_assert_others_are_not_copy() {
struct Helper<T>(T);
trait AssertCopy { fn assert() {} }
trait AssertNotCopy { fn assert() {} }
impl<T: Copy> AssertCopy for Helper<T> {}
% for ty in set(x["type"] for x in others):
impl AssertNotCopy for Helper<${ty}> {}
Helper::<${ty}>::assert();
% endfor
}

match *self {
${" |\n".join("{}(..)".format(v["name"]) for v in copy)} => {
unsafe { debug_unreachable!() }

0 comments on commit e22850d

Please sign in to comment.
You can’t perform that action at this time.