Skip to content

Commit

Permalink
Provide safety check helpers in release builds
Browse files Browse the repository at this point in the history
debug_assert! uses

    if cfg!(not(ndebug)) { ... }

so the body in a release build is dead code, but it still needs to compile.
  • Loading branch information
kmcallister committed Oct 24, 2014
1 parent 4dee8ec commit f508a82
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
1 change: 0 additions & 1 deletion components/script/dom/bindings/cell.rs
Expand Up @@ -46,7 +46,6 @@ impl<T> DOMRefCell<T> {
/// 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
}
Expand Down
11 changes: 4 additions & 7 deletions components/util/task_state.rs
Expand Up @@ -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)]
Expand Down Expand Up @@ -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) { }
}

5 comments on commit f508a82

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from jdm
at kmcallister@f508a82

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging kmcallister/servo/domrefcell = f508a82 into auto

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kmcallister/servo/domrefcell = f508a82 merged ok, testing candidate = 0c12f63

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 0c12f63

Please sign in to comment.