From f508a82582843cb0fdacdcd88be2f73d59529203 Mon Sep 17 00:00:00 2001 From: Keegan McAllister Date: Fri, 24 Oct 2014 16:45:09 -0700 Subject: [PATCH] Provide safety check helpers in release builds debug_assert! uses if cfg!(not(ndebug)) { ... } so the body in a release build is dead code, but it still needs to compile. --- components/script/dom/bindings/cell.rs | 1 - components/util/task_state.rs | 11 ++++------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/components/script/dom/bindings/cell.rs b/components/script/dom/bindings/cell.rs index f15e829c87b..18385b66f39 100644 --- a/components/script/dom/bindings/cell.rs +++ b/components/script/dom/bindings/cell.rs @@ -46,7 +46,6 @@ impl DOMRefCell { /// Is the cell mutably borrowed? /// /// For safety checks in debug builds only. - #[cfg(not(ndebug))] pub fn is_mutably_borrowed(&self) -> bool { self.borrow.get() == WRITING } diff --git a/components/util/task_state.rs b/components/util/task_state.rs index f760b373285..8ea42949aec 100644 --- a/components/util/task_state.rs +++ b/components/util/task_state.rs @@ -5,14 +5,10 @@ //! Supports dynamic assertions in debug builds about what sort of task is //! running and what state it's in. //! -//! In release builds, `get` is not available; calls must be inside -//! `debug_assert!` or similar. All of the other functions inline away to -//! nothing. +//! In release builds, `get` returns 0. All of the other functions inline +//! away to nothing. -pub use self::imp::{initialize, enter, exit}; - -#[cfg(not(ndebug))] -pub use self::imp::get; +pub use self::imp::{initialize, get, enter, exit}; bitflags! { #[deriving(Show)] @@ -89,6 +85,7 @@ mod imp { mod imp { use super::TaskState; #[inline(always)] pub fn initialize(_: TaskState) { } + #[inline(always)] pub fn get() -> TaskState { TaskState::empty() } #[inline(always)] pub fn enter(_: TaskState) { } #[inline(always)] pub fn exit(_: TaskState) { } }