Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug-only dynamic checks for layout and GC use of DOMRefCell #3797

Merged
merged 6 commits into from Oct 25, 2014
Prev

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.
  • Loading branch information
kmcallister committed Oct 24, 2014
commit f508a82582843cb0fdacdcd88be2f73d59529203
@@ -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
}
@@ -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) { }
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.