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

Drop flags are dead, long live MIR! #167

Merged
merged 1 commit into from
Aug 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]

name = "string_cache"
version = "0.2.24"
version = "0.2.25"
authors = [ "The Servo Project Developers" ]
description = "A string interning library for Rust, developed as part of the Servo project."
license = "MIT / Apache-2.0"
Expand Down
24 changes: 9 additions & 15 deletions src/atom/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ impl StringCache {

// NOTE: Deriving Eq here implies that a given string must always
// be interned the same way.
#[cfg_attr(feature = "unstable", unsafe_no_drop_flag)] // See tests::atom_drop_is_idempotent
#[derive(Eq, Hash, PartialEq)]
pub struct Atom {
/// This field is public so that the `atom!()` macro can use it.
Expand Down Expand Up @@ -714,9 +713,16 @@ mod tests {

#[test]
fn assert_sizes() {
// Guard against accidental changes to the sizes of things.
use std::mem;
assert_eq!(if cfg!(feature = "unstable") { 8 } else { 16 }, mem::size_of::<super::Atom>());
struct EmptyWithDrop;
impl Drop for EmptyWithDrop {
fn drop(&mut self) {}
}
let compiler_uses_inline_drop_flags = mem::size_of::<EmptyWithDrop>() > 0;

// Guard against accidental changes to the sizes of things.
assert_eq!(mem::size_of::<super::Atom>(),
if compiler_uses_inline_drop_flags { 16 } else { 8 });
assert_eq!(40, mem::size_of::<super::StringCacheEntry>());
}

Expand Down Expand Up @@ -771,18 +777,6 @@ mod tests {
let _: &str = atom.as_ref();
}

/// Atom uses #[unsafe_no_drop_flag] to stay small, so drop() may be called more than once.
/// In calls after the first one, the atom will be filled with a POST_DROP value.
/// drop() must be a no-op in this case.
#[cfg(feature = "unstable")]
#[test]
fn atom_drop_is_idempotent() {
use super::from_packed_dynamic;
unsafe {
assert_eq!(from_packed_dynamic(mem::POST_DROP_U64), None);
}
}

#[test]
fn string_cache_entry_alignment_is_sufficient() {
assert!(mem::align_of::<StringCacheEntry>() >= ENTRY_ALIGNMENT);
Expand Down
3 changes: 1 addition & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
#![crate_type = "rlib"]

#![cfg_attr(test, deny(warnings))]
#![cfg_attr(all(test, feature = "unstable"), feature(test, filling_drop))]
#![cfg_attr(feature = "unstable", feature(unsafe_no_drop_flag))]
#![cfg_attr(all(test, feature = "unstable"), feature(test))]

#[cfg(all(test, feature = "unstable"))] extern crate test;
#[cfg(feature = "log-events")] extern crate rustc_serialize;
Expand Down