Skip to content

Commit

Permalink
Avoid entraining various Debug impls in release builds.
Browse files Browse the repository at this point in the history
MozReview-Commit-ID: Lp9i9EI5qdU
  • Loading branch information
bholley committed Jan 13, 2018
1 parent 6ca651c commit f858ce9
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 49 deletions.
15 changes: 3 additions & 12 deletions components/style/dom.rs
Expand Up @@ -746,18 +746,9 @@ pub trait TElement
/// element-backed pseudo-element, in which case we return the originating
/// element.
fn rule_hash_target(&self) -> Self {
if let Some(pseudo) = self.implemented_pseudo_element() {
match self.closest_non_native_anonymous_ancestor() {
Some(e) => e,
None => {
panic!(
"Trying to collect rules for a detached pseudo-element: \
{:?} {:?}",
pseudo,
self,
)
}
}
if self.implemented_pseudo_element().is_some() {
self.closest_non_native_anonymous_ancestor()
.expect("Trying to collect rules for a detached pseudo-element")
} else {
*self
}
Expand Down
14 changes: 7 additions & 7 deletions components/style/gecko/conversions.rs
Expand Up @@ -141,7 +141,7 @@ impl Angle {
nsCSSUnit::eCSSUnit_Grad => Angle::Grad(value),
nsCSSUnit::eCSSUnit_Radian => Angle::Rad(value),
nsCSSUnit::eCSSUnit_Turn => Angle::Turn(value),
_ => panic!("Unexpected unit {:?} for angle", unit),
_ => panic!("Unexpected unit for angle"),
}
}
}
Expand Down Expand Up @@ -415,7 +415,7 @@ impl nsStyleImage {
let atom = Gecko_GetImageElement(self);
Some(GenericImage::Element(Atom::from(atom)))
},
x => panic!("Unexpected image type {:?}", x)
_ => panic!("Unexpected image type")
}
}

Expand Down Expand Up @@ -503,7 +503,7 @@ impl nsStyleImage {
// FIXME: We should support ShapeExtent::Contain and ShapeExtent::Cover.
// But we can't choose those yet since Gecko does not support both values.
// https://bugzilla.mozilla.org/show_bug.cgi?id=1217664
x => panic!("Found unexpected gecko_size: {:?}", x),
_ => panic!("Found unexpected gecko_size"),
}
};

Expand Down Expand Up @@ -539,7 +539,7 @@ impl nsStyleImage {
};
EndingShape::Ellipse(length_percentage_keyword)
},
x => panic!("Found unexpected mShape: {:?}", x),
_ => panic!("Found unexpected mShape"),
};

let position = match (horizontal_style, vertical_style) {
Expand Down Expand Up @@ -842,7 +842,7 @@ pub mod basic_shape {
FillBox => GeometryBox::FillBox,
StrokeBox => GeometryBox::StrokeBox,
ViewBox => GeometryBox::ViewBox,
other => panic!("Unexpected StyleGeometryBox::{:?} while converting to GeometryBox", other),
_ => panic!("Unexpected StyleGeometryBox while converting to GeometryBox"),
}
}
}
Expand All @@ -855,7 +855,7 @@ pub mod basic_shape {
PaddingBox => ShapeBox::PaddingBox,
BorderBox => ShapeBox::BorderBox,
MarginBox => ShapeBox::MarginBox,
other => panic!("Unexpected StyleGeometryBox::{:?} while converting to ShapeBox", other),
_ => panic!("Unexpected StyleGeometryBox while converting to ShapeBox"),
}
}
}
Expand Down Expand Up @@ -1010,7 +1010,7 @@ impl TextAlign {
structs::NS_STYLE_TEXT_ALIGN_MOZ_CENTER => TextAlign::MozCenter,
structs::NS_STYLE_TEXT_ALIGN_CHAR => TextAlign::Char,
structs::NS_STYLE_TEXT_ALIGN_END => TextAlign::End,
x => panic!("Found unexpected value in style struct for text-align property: {:?}", x),
_ => panic!("Found unexpected value in style struct for text-align property"),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion components/style/gecko/wrapper.rs
Expand Up @@ -901,7 +901,7 @@ impl structs::FontSizePrefs {
structs::kGenericFont_monospace => self.mDefaultMonospaceSize,
structs::kGenericFont_cursive => self.mDefaultCursiveSize,
structs::kGenericFont_fantasy => self.mDefaultFantasySize,
x => unreachable!("Unknown generic ID {}", x),
_ => unreachable!("Unknown generic ID"),
})
}
}
Expand Down
4 changes: 2 additions & 2 deletions components/style/gecko_bindings/sugar/ns_css_value.rs
Expand Up @@ -114,7 +114,7 @@ impl nsCSSValue {
nsCSSUnit::eCSSUnit_Calc => {
LengthOrPercentage::Calc(bindings::Gecko_CSSValue_GetCalc(self).into())
},
x => panic!("The unit should not be {:?}", x),
_ => panic!("Unexpected unit"),
}
}

Expand All @@ -124,7 +124,7 @@ impl nsCSSValue {
nsCSSUnit::eCSSUnit_Pixel => {
Length::new(bindings::Gecko_CSSValue_GetNumber(self))
},
x => panic!("The unit should not be {:?}", x),
_ => panic!("Unexpected unit"),
}
}

Expand Down
29 changes: 14 additions & 15 deletions components/style/properties/gecko.mako.rs
Expand Up @@ -437,7 +437,7 @@ def set_gecko_property(ffi_name, expr):
${keyword.casted_constant_name(value, cast_type)} => Keyword::${to_camel_case(value)},
% endfor
% if keyword.gecko_inexhaustive:
x => panic!("Found unexpected value in style struct for ${ident} property: {:?}", x),
_ => panic!("Found unexpected value in style struct for ${ident} property"),
% endif
}
% else:
Expand All @@ -446,7 +446,7 @@ def set_gecko_property(ffi_name, expr):
structs::${keyword.gecko_constant(value)} => Keyword::${to_camel_case(value)},
% endfor
% if keyword.gecko_inexhaustive:
x => panic!("Found unexpected value in style struct for ${ident} property: {:?}", x),
_ => panic!("Found unexpected value in style struct for ${ident} property"),
% endif
}
% endif
Expand Down Expand Up @@ -598,8 +598,7 @@ def set_gecko_property(ffi_name, expr):
CoordDataValue::Calc(calc) =>
SvgLengthOrPercentageOrNumber::LengthOrPercentage(
LengthOrPercentage::Calc(calc.into())),
_ => unreachable!("Unexpected coordinate {:?} in ${ident}",
self.gecko.${gecko_ffi_name}.as_value()),
_ => unreachable!("Unexpected coordinate in ${ident}"),
};
SVGLength::Length(length.into())
}
Expand Down Expand Up @@ -1257,7 +1256,7 @@ fn clone_single_transform_function(
% for servo, gecko, format in transform_functions:
${computed_operation_arm(servo, gecko, format)}
% endfor
_ => panic!("{:?} is not an acceptable transform function", transform_function),
_ => panic!("unacceptable transform function"),
}
}
}
Expand Down Expand Up @@ -2377,7 +2376,7 @@ fn static_assert() {
% endfor
structs::${border_style_keyword.gecko_constant('auto')} => OutlineStyle::Auto,
% if border_style_keyword.gecko_inexhaustive:
x => panic!("Found unexpected value in style struct for outline_style property: {:?}", x),
_ => panic!("Found unexpected value in style struct for outline_style property"),
% endif
}
}
Expand Down Expand Up @@ -2900,8 +2899,8 @@ fn static_assert() {
${value}_list.push(CustomIdent(ident));
},
% endfor
x => {
panic!("Found unexpected value for font-variant-alternates: {:?}", x);
_ => {
panic!("Found unexpected value for font-variant-alternates");
}
}
}
Expand Down Expand Up @@ -3078,7 +3077,7 @@ fn static_assert() {
% for value in keyword.gecko_values():
structs::${keyword.gecko_constant(value)} => Keyword::${to_camel_case(value)},
% endfor
x => panic!("Found unexpected value for animation-${ident}: {:?}", x),
_ => panic!("Found unexpected value for animation-${ident}"),
}
}
${impl_animation_count(ident, gecko_ffi_name)}
Expand Down Expand Up @@ -3812,7 +3811,7 @@ fn static_assert() {
% endif
=> Keyword::${to_camel_case(value)},
% endfor
x => panic!("Found unexpected value in style struct for ${ident} property: {:?}", x),
_ => panic!("Found unexpected value in style struct for ${ident} property"),
}
}).collect()
)
Expand Down Expand Up @@ -3862,7 +3861,7 @@ fn static_assert() {
StyleImageLayerRepeat::Space => RepeatKeyword::Space,
StyleImageLayerRepeat::Round => RepeatKeyword::Round,
StyleImageLayerRepeat::NoRepeat => RepeatKeyword::NoRepeat,
x => panic!("Found unexpected value in style struct for ${shorthand}_repeat property: {:?}", x),
_ => panic!("Found unexpected value in style struct for ${shorthand}_repeat property"),
}
}

Expand Down Expand Up @@ -4839,7 +4838,7 @@ fn static_assert() {
structs::NS_STYLE_TEXT_EMPHASIS_STYLE_DOUBLE_CIRCLE => ShapeKeyword::DoubleCircle,
structs::NS_STYLE_TEXT_EMPHASIS_STYLE_TRIANGLE => ShapeKeyword::Triangle,
structs::NS_STYLE_TEXT_EMPHASIS_STYLE_SESAME => ShapeKeyword::Sesame,
x => panic!("Unexpected value in style struct for text-emphasis-style property: {:?}", x)
_ => panic!("Unexpected value in style struct for text-emphasis-style property")
};

T::Keyword(KeywordValue {
Expand Down Expand Up @@ -4947,7 +4946,7 @@ fn static_assert() {
structs::NS_STYLE_TEXT_OVERFLOW_ELLIPSIS => TextOverflowSide::Ellipsis,
structs::NS_STYLE_TEXT_OVERFLOW_STRING =>
TextOverflowSide::String(side.mString.to_string().into_boxed_str()),
x => panic!("Found unexpected value in style struct for text_overflow property: {:?}", x),
_ => panic!("Found unexpected value in style struct for text_overflow property"),
}
}

Expand Down Expand Up @@ -5430,7 +5429,7 @@ clip-path
structs::NS_STYLE_CURSOR_ALL_SCROLL => Keyword::Cursor(Cursor::AllScroll),
structs::NS_STYLE_CURSOR_ZOOM_IN => Keyword::Cursor(Cursor::ZoomIn),
structs::NS_STYLE_CURSOR_ZOOM_OUT => Keyword::Cursor(Cursor::ZoomOut),
x => panic!("Found unexpected value in style struct for cursor property: {:?}", x),
_ => panic!("Found unexpected value in style struct for cursor property"),
};

let images = self.gecko.mCursorImages.iter().map(|gecko_cursor_image| {
Expand Down Expand Up @@ -5693,7 +5692,7 @@ clip-path
)
}
},
x => panic!("Found unexpected value in style struct for content property: {:?}", x),
_ => panic!("Found unexpected value in style struct for content property"),
}
}).collect()
)
Expand Down
2 changes: 1 addition & 1 deletion components/style/properties/helpers.mako.rs
Expand Up @@ -558,7 +558,7 @@
% for value in values:
${to_rust_ident(value).upper()} => ${type}::${to_camel_case(value)},
% endfor
x => panic!("Found unexpected value in style struct for ${keyword.name} property: {:?}", x),
_ => panic!("Found unexpected value in style struct for ${keyword.name} property"),
}
}
}
Expand Down
10 changes: 3 additions & 7 deletions components/style/properties/helpers/animated_properties.mako.rs
Expand Up @@ -178,7 +178,7 @@ impl From<nsCSSPropertyID> for TransitionProperty {
% endfor
nsCSSPropertyID::eCSSPropertyExtra_all_properties => TransitionProperty::All,
_ => {
panic!("non-convertible nsCSSPropertyID::{:?}", property)
panic!("non-convertible nsCSSPropertyID")
}
}
}
Expand Down Expand Up @@ -552,7 +552,7 @@ impl Animate for AnimationValue {
% endif
% endfor
_ => {
panic!("Unexpected AnimationValue::animate call, got: {:?}, {:?}", self, other);
panic!("Unexpected AnimationValue::animate call");
}
};
Ok(value)
Expand Down Expand Up @@ -582,11 +582,7 @@ impl ComputeSquaredDistance for AnimationValue {
% endif
% endfor
_ => {
panic!(
"computed values should be of the same property, got: {:?}, {:?}",
self,
other
);
panic!("computed values should be of the same property");
},
}
}
Expand Down
2 changes: 1 addition & 1 deletion components/style/values/computed/font.rs
Expand Up @@ -482,7 +482,7 @@ impl SingleFontFamily {
name: (&*family.mName).into(),
syntax: FamilyNameSyntax::Quoted,
}),
x => panic!("Found unexpected font FontFamilyType: {:?}", x),
_ => panic!("Found unexpected font FontFamilyType"),
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions ports/geckolib/glue.rs
Expand Up @@ -3029,7 +3029,7 @@ macro_rules! get_longhand_from_id {
match PropertyId::from_nscsspropertyid($id) {
Ok(PropertyId::Longhand(long)) => long,
_ => {
panic!("stylo: unknown presentation property with id {:?}", $id);
panic!("stylo: unknown presentation property with id");
}
}
};
Expand All @@ -3042,7 +3042,7 @@ macro_rules! match_wrap_declared {
LonghandId::$property => PropertyDeclaration::$property($inner),
)*
_ => {
panic!("stylo: Don't know how to handle presentation property {:?}", $longhand);
panic!("stylo: Don't know how to handle presentation property");
}
}
)
Expand Down Expand Up @@ -3226,7 +3226,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetLengthValue(
structs::nsCSSUnit::eCSSUnit_Point => NoCalcLength::Absolute(AbsoluteLength::Pt(value)),
structs::nsCSSUnit::eCSSUnit_Pica => NoCalcLength::Absolute(AbsoluteLength::Pc(value)),
structs::nsCSSUnit::eCSSUnit_Quarter => NoCalcLength::Absolute(AbsoluteLength::Q(value)),
_ => unreachable!("Unknown unit {:?} passed to SetLengthValue", unit)
_ => unreachable!("Unknown unit passed to SetLengthValue")
};

let prop = match_wrap_declared! { long,
Expand Down

0 comments on commit f858ce9

Please sign in to comment.