Change debug assertions to specific ones

This commit is contained in:
janczer 2018-02-07 09:18:59 +01:00
parent 2cf0077be1
commit 661d234c3c
23 changed files with 53 additions and 53 deletions

View file

@ -219,7 +219,7 @@ impl TouchHandler {
}
fn pinch_distance_and_center(&self) -> (f32, TypedPoint2D<f32, DevicePixel>) {
debug_assert!(self.touch_count() == 2);
debug_assert_eq!(self.touch_count(), 2);
let p0 = self.active_touch_points[0].point;
let p1 = self.active_touch_points[1].point;
let center = p0.lerp(p1, 0.5);

View file

@ -499,7 +499,7 @@ fn robin_hood<'a, K: 'a, V: 'a>(bucket: FullBucketMut<'a, K, V>,
loop {
displacement += 1;
let probe = bucket.next();
debug_assert!(probe.index() != idx_end);
debug_assert_ne!(probe.index(), idx_end);
let full_bucket = match probe.peek() {
Empty(bucket) => {
@ -578,7 +578,7 @@ impl<K, V, S> HashMap<K, V, S>
Full(b) => b.into_bucket(),
};
buckets.next();
debug_assert!(buckets.index() != start_index);
debug_assert_ne!(buckets.index(), start_index);
}
}
}

View file

@ -485,7 +485,7 @@ pub enum MarginsMayCollapseFlag {
MarginsMayNotCollapse,
}
#[derive(PartialEq)]
#[derive(Debug, PartialEq)]
pub enum FormattingContextType {
None,
Block,
@ -1472,7 +1472,7 @@ impl BlockFlow {
fn assign_inline_position_for_formatting_context(&mut self,
layout_context: &LayoutContext,
content_box: LogicalRect<Au>) {
debug_assert!(self.formatting_context_type() != FormattingContextType::None);
debug_assert_ne!(self.formatting_context_type(), FormattingContextType::None);
if !self.base.restyle_damage.intersects(ServoRestyleDamage::REFLOW_OUT_OF_FLOW | ServoRestyleDamage::REFLOW) {
return

View file

@ -269,7 +269,7 @@ impl WebRenderDisplayItemConverter for DisplayItem {
},
DisplayItem::PushStackingContext(ref item) => {
let stacking_context = &item.stacking_context;
debug_assert!(stacking_context.context_type == StackingContextType::Real);
debug_assert_eq!(stacking_context.context_type, StackingContextType::Real);
let transform = stacking_context
.transform

View file

@ -767,7 +767,7 @@ impl Fragment {
let ellipsis_fragments = with_thread_local_font_context(layout_context, |font_context| {
TextRunScanner::new().scan_for_runs(font_context, unscanned_ellipsis_fragments)
});
debug_assert!(ellipsis_fragments.len() == 1);
debug_assert_eq!(ellipsis_fragments.len(), 1);
ellipsis_fragment = ellipsis_fragments.fragments.into_iter().next().unwrap();
ellipsis_fragment.flags |= FragmentFlags::IS_ELLIPSIS;
ellipsis_fragment

View file

@ -804,7 +804,7 @@ impl LineBreaker {
self.work_list.push_front(cur_fragment);
for fragment_index in (last_known_line_breaking_opportunity.get()..
self.pending_line.range.end().get()).rev() {
debug_assert!(fragment_index == (self.new_fragments.len() as isize) - 1);
debug_assert_eq!(fragment_index, (self.new_fragments.len() as isize) - 1);
self.work_list.push_front(self.new_fragments.pop().unwrap());
}

View file

@ -125,7 +125,7 @@ impl TableFlow {
}
} else {
// We discovered a new column. Initialize its data.
debug_assert!(column_index == parent_inline_sizes.len());
debug_assert_eq!(column_index, parent_inline_sizes.len());
if child_cell_inline_size.column_span > 1 {
// TODO(pcwalton): Perform the recursive algorithm specified in INTRINSIC §
// 4. For now we make this column contribute no width.
@ -635,7 +635,7 @@ impl<T> VecExt<T> for Vec<T> {
if index < self.len() {
self[index] = value
} else {
debug_assert!(index == self.len());
debug_assert_eq!(index, self.len());
self.push(value)
}
&mut self[index]
@ -643,7 +643,7 @@ impl<T> VecExt<T> for Vec<T> {
fn get_mut_or_push(&mut self, index: usize, zero: T) -> &mut T {
if index >= self.len() {
debug_assert!(index == self.len());
debug_assert_eq!(index, self.len());
self.push(zero)
}
&mut self[index]

View file

@ -771,7 +771,7 @@ fn http_network_or_cache_fetch(request: &mut Request,
// Step 11
if cors_flag || (http_request.method != Method::Get && http_request.method != Method::Head) {
debug_assert!(http_request.origin != Origin::Client);
debug_assert_ne!(http_request.origin, Origin::Client);
if let Origin::Origin(ref url_origin) = http_request.origin {
if let Some(hyper_origin) = try_immutable_origin_to_hyper_origin(url_origin) {
http_request.headers.set(hyper_origin)

View file

@ -291,7 +291,7 @@ fn split_at_utf16_code_unit_offset(s: &str, offset: u32) -> Result<(&str, Option
if c > '\u{FFFF}' {
if code_units == offset {
if opts::get().replace_surrogates {
debug_assert!(c.len_utf8() == 4);
debug_assert_eq!(c.len_utf8(), 4);
return Ok((&s[..i], Some(c), &s[i + c.len_utf8()..]))
}
panic!("\n\n\

View file

@ -1334,7 +1334,7 @@ impl TreeIterator {
}
self.depth -= 1;
}
debug_assert!(self.depth == 0);
debug_assert_eq!(self.depth, 0);
self.current = None;
Some(current)
}

View file

@ -313,7 +313,7 @@ impl WebGLTexture {
}
fn is_cube_complete(&self) -> bool {
debug_assert!(self.face_count.get() == 6);
debug_assert_eq!(self.face_count.get(), 6);
let image_info = self.base_image_info().unwrap();
if !image_info.is_defined() {

View file

@ -598,7 +598,7 @@ impl<H, T> Arc<HeaderSlice<H, [T]>> {
assert!(items.next().is_none(), "ExactSizeIterator under-reported length");
// We should have consumed the buffer exactly.
debug_assert!(current as *mut u8 == buffer.offset(size as isize));
debug_assert_eq!(current as *mut u8, buffer.offset(size as isize));
}
// Return the fat Arc.

View file

@ -472,7 +472,7 @@ impl<E: TElement> SequentialTask<E> {
/// Executes this task.
pub fn execute(self) {
use self::SequentialTask::*;
debug_assert!(thread_state::get() == ThreadState::LAYOUT);
debug_assert_eq!(thread_state::get(), ThreadState::LAYOUT);
match self {
Unused(_) => unreachable!(),
#[cfg(feature = "gecko")]
@ -560,7 +560,7 @@ impl<E: TElement> SelectorFlagsMap<E> {
/// Applies the flags. Must be called on the main thread.
fn apply_flags(&mut self) {
debug_assert!(thread_state::get() == ThreadState::LAYOUT);
debug_assert_eq!(thread_state::get(), ThreadState::LAYOUT);
self.cache.evict_all();
for (el, flags) in self.map.drain() {
unsafe { el.set_selector_flags(flags); }
@ -598,7 +598,7 @@ where
E: TElement,
{
fn drop(&mut self) {
debug_assert!(thread_state::get() == ThreadState::LAYOUT);
debug_assert_eq!(thread_state::get(), ThreadState::LAYOUT);
for task in self.0.drain(..) {
task.execute()
}
@ -751,7 +751,7 @@ impl<E: TElement> ThreadLocalStyleContext<E> {
impl<E: TElement> Drop for ThreadLocalStyleContext<E> {
fn drop(&mut self) {
debug_assert!(thread_state::get() == ThreadState::LAYOUT);
debug_assert_eq!(thread_state::get(), ThreadState::LAYOUT);
// Apply any slow selector flags that need to be set on parents.
self.selector_flags.apply_flags();

View file

@ -369,7 +369,7 @@ impl MediaExpressionValue {
match for_expr.feature.mValueType {
nsMediaFeature_ValueType::eLength => {
debug_assert!(css_value.mUnit == nsCSSUnit::eCSSUnit_Pixel);
debug_assert_eq!(css_value.mUnit, nsCSSUnit::eCSSUnit_Pixel);
let pixels = css_value.float_unchecked();
Some(MediaExpressionValue::Length(Length::from_px(pixels)))
}
@ -379,17 +379,17 @@ impl MediaExpressionValue {
Some(MediaExpressionValue::Integer(i as u32))
}
nsMediaFeature_ValueType::eFloat => {
debug_assert!(css_value.mUnit == nsCSSUnit::eCSSUnit_Number);
debug_assert_eq!(css_value.mUnit, nsCSSUnit::eCSSUnit_Number);
Some(MediaExpressionValue::Float(css_value.float_unchecked()))
}
nsMediaFeature_ValueType::eBoolInteger => {
debug_assert!(css_value.mUnit == nsCSSUnit::eCSSUnit_Integer);
debug_assert_eq!(css_value.mUnit, nsCSSUnit::eCSSUnit_Integer);
let i = css_value.integer_unchecked();
debug_assert!(i == 0 || i == 1);
Some(MediaExpressionValue::BoolInteger(i == 1))
}
nsMediaFeature_ValueType::eResolution => {
debug_assert!(css_value.mUnit == nsCSSUnit::eCSSUnit_Pixel);
debug_assert_eq!(css_value.mUnit, nsCSSUnit::eCSSUnit_Pixel);
Some(MediaExpressionValue::Resolution(Resolution::Dppx(css_value.float_unchecked())))
}
nsMediaFeature_ValueType::eEnumerated => {
@ -397,7 +397,7 @@ impl MediaExpressionValue {
Some(MediaExpressionValue::Enumerated(value))
}
nsMediaFeature_ValueType::eIdent => {
debug_assert!(css_value.mUnit == nsCSSUnit::eCSSUnit_Ident);
debug_assert_eq!(css_value.mUnit, nsCSSUnit::eCSSUnit_Ident);
let string = unsafe {
let buffer = *css_value.mValue.mString.as_ref();
debug_assert!(!buffer.is_null());
@ -774,11 +774,11 @@ impl Expression {
one.to_dpi().partial_cmp(&actual_dpi).unwrap()
}
(&Ident(ref one), &Ident(ref other)) => {
debug_assert!(self.feature.mRangeType != nsMediaFeature_RangeType::eMinMaxAllowed);
debug_assert_ne!(self.feature.mRangeType, nsMediaFeature_RangeType::eMinMaxAllowed);
return one == other;
}
(&Enumerated(one), &Enumerated(other)) => {
debug_assert!(self.feature.mRangeType != nsMediaFeature_RangeType::eMinMaxAllowed);
debug_assert_ne!(self.feature.mRangeType, nsMediaFeature_RangeType::eMinMaxAllowed);
return one == other;
}
_ => unreachable!(),

View file

@ -378,7 +378,7 @@ pub unsafe trait CoordDataMut : CoordData {
/// Gets the `Calc` value mutably, asserts in debug builds if the unit is
/// not `Calc`.
unsafe fn as_calc_mut(&mut self) -> &mut nsStyleCoord_Calc {
debug_assert!(self.unit() == nsStyleUnit::eStyleUnit_Calc);
debug_assert_eq!(self.unit(), nsStyleUnit::eStyleUnit_Calc);
&mut *(*self.union().mPointer.as_mut() as *mut nsStyleCoord_Calc)
}
@ -451,7 +451,7 @@ pub unsafe trait CoordData {
/// Pretend inner value is a calc; obtain it.
/// Ensure that the unit is Calc before calling this.
unsafe fn get_calc_value(&self) -> nsStyleCoord_CalcValue {
debug_assert!(self.unit() == nsStyleUnit::eStyleUnit_Calc);
debug_assert_eq!(self.unit(), nsStyleUnit::eStyleUnit_Calc);
(*self.as_calc())._base
}
@ -459,7 +459,7 @@ pub unsafe trait CoordData {
#[inline]
/// Pretend the inner value is a calc expression, and obtain it.
unsafe fn as_calc(&self) -> &nsStyleCoord_Calc {
debug_assert!(self.unit() == nsStyleUnit::eStyleUnit_Calc);
debug_assert_eq!(self.unit(), nsStyleUnit::eStyleUnit_Calc);
&*(*self.union().mPointer.as_ref() as *const nsStyleCoord_Calc)
}
}

View file

@ -1213,7 +1213,7 @@ fn clone_single_transform_function(
let convert_shared_list_to_operations = |value: &structs::nsCSSValue|
-> Vec<TransformOperation> {
debug_assert!(value.mUnit == structs::nsCSSUnit::eCSSUnit_SharedList);
debug_assert_eq!(value.mUnit, structs::nsCSSUnit::eCSSUnit_SharedList);
let value_list = unsafe {
value.mValue.mSharedList.as_ref()
.as_mut().expect("List pointer should be non-null").mHead.as_ref()
@ -1804,7 +1804,7 @@ fn static_assert() {
use gecko_bindings::structs::nsStyleUnit;
// z-index is never a calc(). If it were, we'd be leaking here, so
// assert that it isn't.
debug_assert!(self.gecko.mZIndex.unit() != nsStyleUnit::eStyleUnit_Calc);
debug_assert_ne!(self.gecko.mZIndex.unit(), nsStyleUnit::eStyleUnit_Calc);
unsafe {
self.gecko.mZIndex.copy_from_unchecked(&other.gecko.mZIndex);
}
@ -1837,7 +1837,7 @@ fn static_assert() {
}
pub fn set_computed_justify_items(&mut self, v: values::specified::JustifyItems) {
debug_assert!(v.0 != ::values::specified::align::AlignFlags::AUTO);
debug_assert_ne!(v.0, ::values::specified::align::AlignFlags::AUTO);
self.gecko.mJustifyItems = v.into();
}
@ -2885,7 +2885,7 @@ fn static_assert() {
I::IntoIter: ExactSizeIterator + Clone
{
let v = v.into_iter();
debug_assert!(v.len() != 0);
debug_assert_ne!(v.len(), 0);
let input_len = v.len();
self.gecko.m${type.capitalize()}s.ensure_len(input_len);
@ -2910,7 +2910,7 @@ fn static_assert() {
I::IntoIter: ExactSizeIterator + Clone
{
let v = v.into_iter();
debug_assert!(v.len() != 0);
debug_assert_ne!(v.len(), 0);
let input_len = v.len();
self.gecko.m${type.capitalize()}s.ensure_len(input_len);
@ -2966,7 +2966,7 @@ fn static_assert() {
let v = v.into_iter();
debug_assert!(v.len() != 0);
debug_assert_ne!(v.len(), 0);
let input_len = v.len();
self.gecko.mAnimations.ensure_len(input_len);
@ -3364,7 +3364,7 @@ fn static_assert() {
I::IntoIter: ExactSizeIterator
{
let v = v.into_iter();
debug_assert!(v.len() != 0);
debug_assert_ne!(v.len(), 0);
self.gecko.mAnimations.ensure_len(v.len());
self.gecko.mAnimationNameCount = v.len() as u32;
@ -3957,7 +3957,7 @@ fn static_assert() {
if ty == DimensionType::eAuto as u8 {
LengthOrPercentageOrAuto::Auto
} else {
debug_assert!(ty == DimensionType::eLengthPercentage as u8);
debug_assert_eq!(ty, DimensionType::eLengthPercentage as u8);
value.into()
}
}
@ -3965,11 +3965,11 @@ fn static_assert() {
longhands::background_size::computed_value::T(
self.gecko.${image_layers_field}.mLayers.iter().map(|ref layer| {
if DimensionType::eCover as u8 == layer.mSize.mWidthType {
debug_assert!(layer.mSize.mHeightType == DimensionType::eCover as u8);
debug_assert_eq!(layer.mSize.mHeightType, DimensionType::eCover as u8);
return BackgroundSize::Cover
}
if DimensionType::eContain as u8 == layer.mSize.mWidthType {
debug_assert!(layer.mSize.mHeightType == DimensionType::eContain as u8);
debug_assert_eq!(layer.mSize.mHeightType, DimensionType::eContain as u8);
return BackgroundSize::Contain
}
BackgroundSize::Explicit {
@ -4368,28 +4368,28 @@ fn static_assert() {
ClipRectOrAuto::auto()
} else {
let left = if self.gecko.mClipFlags & NS_STYLE_CLIP_LEFT_AUTO as u8 != 0 {
debug_assert!(self.gecko.mClip.x == 0);
debug_assert_eq!(self.gecko.mClip.x, 0);
None
} else {
Some(Au(self.gecko.mClip.x).into())
};
let top = if self.gecko.mClipFlags & NS_STYLE_CLIP_TOP_AUTO as u8 != 0 {
debug_assert!(self.gecko.mClip.y == 0);
debug_assert_eq!(self.gecko.mClip.y, 0);
None
} else {
Some(Au(self.gecko.mClip.y).into())
};
let bottom = if self.gecko.mClipFlags & NS_STYLE_CLIP_BOTTOM_AUTO as u8 != 0 {
debug_assert!(self.gecko.mClip.height == 1 << 30); // NS_MAXSIZE
debug_assert_eq!(self.gecko.mClip.height, 1 << 30); // NS_MAXSIZE
None
} else {
Some(Au(self.gecko.mClip.y + self.gecko.mClip.height).into())
};
let right = if self.gecko.mClipFlags & NS_STYLE_CLIP_RIGHT_AUTO as u8 != 0 {
debug_assert!(self.gecko.mClip.width == 1 << 30); // NS_MAXSIZE
debug_assert_eq!(self.gecko.mClip.width, 1 << 30); // NS_MAXSIZE
None
} else {
Some(Au(self.gecko.mClip.x + self.gecko.mClip.width).into())

View file

@ -303,7 +303,7 @@
DeclaredValue::Value(value)
},
PropertyDeclaration::CSSWideKeyword(ref declaration) => {
debug_assert!(declaration.id == LonghandId::${property.camel_case});
debug_assert_eq!(declaration.id, LonghandId::${property.camel_case});
DeclaredValue::CSSWideKeyword(declaration.keyword)
},
PropertyDeclaration::WithVariables(..) => {

View file

@ -55,7 +55,7 @@ impl Drop for RuleTree {
unsafe { self.gc(); }
// After the GC, the free list should be empty.
debug_assert!(self.root.get().next_free.load(Ordering::Relaxed) == FREE_LIST_SENTINEL);
debug_assert_eq!(self.root.get().next_free.load(Ordering::Relaxed), FREE_LIST_SENTINEL);
// Remove the sentinel. This indicates that GCs will no longer occur.
// Any further drops of StrongRuleNodes must occur on the main thread,
@ -846,7 +846,7 @@ malloc_size_of_is_0!(StrongRuleNode);
impl StrongRuleNode {
fn new(n: Box<RuleNode>) -> Self {
debug_assert!(n.parent.is_none() == !n.source.is_some());
debug_assert_eq!(n.parent.is_none(), !n.source.is_some());
let ptr = Box::into_raw(n);
log_new(ptr);
@ -1074,7 +1074,7 @@ impl StrongRuleNode {
me.free_count().store(0, Ordering::Relaxed);
debug_assert!(me.next_free.load(Ordering::Relaxed) == FREE_LIST_SENTINEL);
debug_assert_eq!(me.next_free.load(Ordering::Relaxed), FREE_LIST_SENTINEL);
}
unsafe fn maybe_gc(&self) {

View file

@ -998,7 +998,7 @@ impl Stylist {
// Gecko calls this from sequential mode, so we can directly apply
// the flags.
debug_assert!(thread_state::get() == ThreadState::LAYOUT);
debug_assert_eq!(thread_state::get(), ThreadState::LAYOUT);
let self_flags = flags.for_self();
if !self_flags.is_empty() {
unsafe { element.set_selector_flags(self_flags); }

View file

@ -71,7 +71,7 @@ impl ToCss for TextOverflow {
W: Write,
{
if self.sides_are_logical {
debug_assert!(self.first == TextOverflowSide::Clip);
debug_assert_eq!(self.first, TextOverflowSide::Clip);
self.second.to_css(dest)?;
} else {
self.first.to_css(dest)?;

View file

@ -315,7 +315,7 @@ impl Color {
if let Some(unit) = unit {
written += (&mut serialization[written..]).write(unit.as_bytes()).unwrap();
}
debug_assert!(written == 6);
debug_assert_eq!(written, 6);
parse_hash_color(&serialization).map_err(|()| {
location.new_custom_error(StyleParseErrorKind::UnspecifiedError)
})

View file

@ -4171,7 +4171,7 @@ pub extern "C" fn Servo_StyleSet_GetFontFaceRules(
rules: RawGeckoFontFaceRuleListBorrowedMut,
) {
let data = PerDocumentStyleData::from_ffi(raw_data).borrow();
debug_assert!(rules.len() == 0);
debug_assert_eq!(rules.len(), 0);
let global_style_data = &*GLOBAL_STYLE_DATA;
let guard = global_style_data.shared_lock.read();

View file

@ -387,7 +387,7 @@ macro_rules! define_string_types {
// data.
let this: &$StringRepr = mem::transmute(self);
if this.data.is_null() {
debug_assert!(this.length == 0);
debug_assert_eq!(this.length, 0);
// Use an arbitrary non-null value as the pointer
slice::from_raw_parts(0x1 as *const $char_t, 0)
} else {