From 4c0ee074c66671cc5cdc1b883b4d8f449c53f4c2 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Fri, 26 Aug 2016 14:33:24 +0200 Subject: [PATCH] Drop flags are dead, long live MIR! --- Cargo.toml | 2 +- src/atom/mod.rs | 24 +++++++++--------------- src/lib.rs | 3 +-- 3 files changed, 11 insertions(+), 18 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e29218d..5d707cd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/src/atom/mod.rs b/src/atom/mod.rs index 85a6402..e3f6b8b 100644 --- a/src/atom/mod.rs +++ b/src/atom/mod.rs @@ -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. @@ -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::()); + struct EmptyWithDrop; + impl Drop for EmptyWithDrop { + fn drop(&mut self) {} + } + let compiler_uses_inline_drop_flags = mem::size_of::() > 0; + + // Guard against accidental changes to the sizes of things. + assert_eq!(mem::size_of::(), + if compiler_uses_inline_drop_flags { 16 } else { 8 }); assert_eq!(40, mem::size_of::()); } @@ -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::() >= ENTRY_ALIGNMENT); diff --git a/src/lib.rs b/src/lib.rs index 471207b..b466a77 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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;