diff options
author | Martin Robinson <mrobinson@igalia.com> | 2024-02-22 05:40:37 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-22 04:40:37 +0000 |
commit | 1c2de6dd1d31304187dd9b2e5767681fe16cd68f (patch) | |
tree | d5ae0e6d8fd550b4748b07ea375d9d683e65ae3a /components/servo_arc | |
parent | d4212dca0bd5a778aca859778fd2c82b533e1844 (diff) | |
download | servo-1c2de6dd1d31304187dd9b2e5767681fe16cd68f.tar.gz servo-1c2de6dd1d31304187dd9b2e5767681fe16cd68f.zip |
Revert changes to servo_arc, style_derive, and style_traits (#31387)
This reverts the Rust edition updates to these three traits as well as
incorporates https://phabricator.services.mozilla.com/D117887. The
purpose of this change is to reduce the diff with upstream stylo.
Finally, formatting is disabled for these crates as well.
Diffstat (limited to 'components/servo_arc')
-rw-r--r-- | components/servo_arc/Cargo.toml | 1 | ||||
-rw-r--r-- | components/servo_arc/lib.rs | 39 |
2 files changed, 18 insertions, 22 deletions
diff --git a/components/servo_arc/Cargo.toml b/components/servo_arc/Cargo.toml index 0f50d9cd41f..c975ad55412 100644 --- a/components/servo_arc/Cargo.toml +++ b/components/servo_arc/Cargo.toml @@ -5,7 +5,6 @@ authors = ["The Servo Project Developers"] license = "MIT OR Apache-2.0" repository = "https://github.com/servo/servo" description = "A fork of std::sync::Arc with some extra functionality and without weak references" -edition = "2018" [lib] name = "servo_arc" diff --git a/components/servo_arc/lib.rs b/components/servo_arc/lib.rs index a201e5f7065..cc71827283a 100644 --- a/components/servo_arc/lib.rs +++ b/components/servo_arc/lib.rs @@ -25,23 +25,30 @@ // duplicate those here. #![allow(missing_docs)] +#[cfg(feature = "servo")] +extern crate serde; +extern crate stable_deref_trait; + +#[cfg(feature = "servo")] +use serde::{Deserialize, Serialize}; +use stable_deref_trait::{CloneStableDeref, StableDeref}; use std::alloc::{self, Layout}; +use std::borrow; use std::cmp::Ordering; use std::convert::From; +use std::fmt; use std::hash::{Hash, Hasher}; use std::iter::{ExactSizeIterator, Iterator}; use std::marker::PhantomData; use std::mem::{self, align_of, size_of}; use std::ops::{Deref, DerefMut}; use std::os::raw::c_void; +use std::process; +use std::ptr; +use std::slice; use std::sync::atomic; use std::sync::atomic::Ordering::{Acquire, Relaxed, Release}; -use std::{borrow, fmt, isize, process, ptr, slice, usize}; - -use nodrop::NoDrop; -#[cfg(feature = "servo")] -use serde::{Deserialize, Serialize}; -use stable_deref_trait::{CloneStableDeref, StableDeref}; +use std::{isize, usize}; /// A soft limit on the amount of references that may be made to an `Arc`. /// @@ -811,6 +818,7 @@ impl<H, T> Arc<HeaderSlice<H, [T]>> { /// Creates an Arc for a HeaderSlice using the given header struct and /// iterator to generate the slice. The resulting Arc will be fat. + #[inline] pub fn from_header_and_iter<I>(header: H, items: I) -> Self where I: Iterator<Item = T> + ExactSizeIterator, @@ -904,7 +912,7 @@ impl<H, T> ThinArc<H, T> { { // Synthesize transient Arc, which never touches the refcount of the ArcInner. let transient = unsafe { - NoDrop::new(Arc { + mem::ManuallyDrop::new(Arc { p: ptr::NonNull::new_unchecked(thin_to_thick(self.ptr.as_ptr())), phantom: PhantomData, }) @@ -913,11 +921,6 @@ impl<H, T> ThinArc<H, T> { // Expose the transient Arc to the callback, which may clone it if it wants. let result = f(&transient); - // Forget the transient Arc to leave the refcount untouched. - // XXXManishearth this can be removed when unions stabilize, - // since then NoDrop becomes zero overhead - mem::forget(transient); - // Forward the result. result } @@ -1129,7 +1132,7 @@ impl<'a, T> ArcBorrow<'a, T> { /// Compare two `ArcBorrow`s via pointer equality. Will only return /// true if they come from the same allocation pub fn ptr_eq(this: &Self, other: &Self) -> bool { - std::ptr::eq(this.0, other.0) + this.0 as *const T == other.0 as *const T } /// Temporarily converts |self| into a bonafide Arc and exposes it to the @@ -1141,16 +1144,11 @@ impl<'a, T> ArcBorrow<'a, T> { T: 'static, { // Synthesize transient Arc, which never touches the refcount. - let transient = unsafe { NoDrop::new(Arc::from_raw(self.0)) }; + let transient = unsafe { mem::ManuallyDrop::new(Arc::from_raw(self.0)) }; // Expose the transient Arc to the callback, which may clone it if it wants. let result = f(&transient); - // Forget the transient Arc to leave the refcount untouched. - // XXXManishearth this can be removed when unions stabilize, - // since then NoDrop becomes zero overhead - mem::forget(transient); - // Forward the result. result } @@ -1309,13 +1307,12 @@ impl<A: fmt::Debug, B: fmt::Debug> fmt::Debug for ArcUnion<A, B> { #[cfg(test)] mod tests { + use super::{Arc, HeaderWithLength, ThinArc}; use std::clone::Clone; use std::ops::Drop; use std::sync::atomic; use std::sync::atomic::Ordering::{Acquire, SeqCst}; - use super::{Arc, HeaderWithLength, ThinArc}; - #[derive(PartialEq)] struct Canary(*mut atomic::AtomicUsize); |