From e5a4ba71dfeaaaffe1e6d903f22b34d83bb56519 Mon Sep 17 00:00:00 2001 From: DQ Date: Sun, 21 Feb 2021 21:45:55 +0100 Subject: [PATCH] Move vendored `servo_arc` into crate for publishing (#19) --- Cargo.toml | 7 ++++-- vendor/servo_arc/lib.rs => src/arc.rs | 12 +++++---- src/green/node.rs | 2 +- src/green/token.rs | 3 +-- src/lib.rs | 3 +++ src/syntax.rs | 2 +- vendor/servo_arc/Cargo.lock | 28 --------------------- vendor/servo_arc/Cargo.toml | 35 --------------------------- 8 files changed, 18 insertions(+), 74 deletions(-) rename vendor/servo_arc/lib.rs => src/arc.rs (99%) delete mode 100644 vendor/servo_arc/Cargo.lock delete mode 100644 vendor/servo_arc/Cargo.toml diff --git a/Cargo.toml b/Cargo.toml index fe45624..5cd8d70 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,9 +12,12 @@ readme = "README.md" lasso = "0.5" text-size = "1.0.0" fxhash= "0.2.1" -servo_arc = { path = "vendor/servo_arc" } parking_lot= "0.11.1" +# Arc +stable_deref_trait = "1.0.0" +nodrop = "0.1.8" + [dependencies.serde] version = "1.0" optional = true @@ -29,7 +32,7 @@ crossbeam-utils = "0.8" [features] default = [] -serde1 = ["serde", "servo_arc/servo"] +serde1 = ["serde"] [package.metadata.docs.rs] features = ["serde1"] diff --git a/vendor/servo_arc/lib.rs b/src/arc.rs similarity index 99% rename from vendor/servo_arc/lib.rs rename to src/arc.rs index 743f9ee..e5d6319 100644 --- a/vendor/servo_arc/lib.rs +++ b/src/arc.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! Fork of Arc for Servo. This has the following advantages over std::sync::Arc: +//! Fork of fork of Arc for Servo. This has the following advantages over std::sync::Arc: //! //! * We don't waste storage on the weak reference count. //! * We don't do extra RMU operations to handle the possibility of weak references. @@ -21,16 +21,17 @@ // The semantics of Arc are alread documented in the Rust docs, so we don't // duplicate those here. +#![allow(warnings)] #![allow(missing_docs)] #![allow(clippy::all)] extern crate nodrop; -#[cfg(feature = "servo")] +#[cfg(feature = "serde1")] extern crate serde; extern crate stable_deref_trait; use nodrop::NoDrop; -#[cfg(feature = "servo")] +#[cfg(feature = "serde1")] use serde::{Deserialize, Serialize}; use stable_deref_trait::{CloneStableDeref, StableDeref}; use std::{ @@ -93,6 +94,7 @@ fn padding_needed_for(layout: &Layout, align: usize) -> usize { /// necessarily) at _exactly_ `MAX_REFCOUNT + 1` references. const MAX_REFCOUNT: usize = (isize::MAX) as usize; +/// See [`std::sync::Arc`]. #[repr(C)] pub struct Arc { p: NonNull>, @@ -458,7 +460,7 @@ impl AsRef for Arc { unsafe impl StableDeref for Arc {} unsafe impl CloneStableDeref for Arc {} -#[cfg(feature = "servo")] +#[cfg(feature = "serde1")] impl<'de, T: Deserialize<'de>> Deserialize<'de> for Arc { fn deserialize(deserializer: D) -> Result, D::Error> where @@ -468,7 +470,7 @@ impl<'de, T: Deserialize<'de>> Deserialize<'de> for Arc { } } -#[cfg(feature = "servo")] +#[cfg(feature = "serde1")] impl Serialize for Arc { fn serialize(&self, serializer: S) -> Result where diff --git a/src/green/node.rs b/src/green/node.rs index 1d7f632..8a5af9d 100644 --- a/src/green/node.rs +++ b/src/green/node.rs @@ -5,9 +5,9 @@ use std::{ }; use fxhash::FxHasher32; -use servo_arc::{Arc, HeaderWithLength, ThinArc}; use crate::{ + arc::{Arc, HeaderWithLength, ThinArc}, green::{GreenElement, GreenElementRef, PackedGreenElement, SyntaxKind}, TextSize, }; diff --git a/src/green/token.rs b/src/green/token.rs index a59039e..20e12b3 100644 --- a/src/green/token.rs +++ b/src/green/token.rs @@ -1,7 +1,6 @@ -use servo_arc::Arc; use std::{fmt, hash, mem::ManuallyDrop, ptr}; -use crate::{green::SyntaxKind, interning::Resolver, TextSize}; +use crate::{arc::Arc, green::SyntaxKind, interning::Resolver, TextSize}; use lasso::Spur; #[repr(align(2))] // to use 1 bit for pointer tagging. NB: this is an at-least annotation diff --git a/src/lib.rs b/src/lib.rs index 914ae8b..6644868 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -50,6 +50,8 @@ )] #![deny(unsafe_code, missing_docs)] +#[allow(unsafe_code)] +mod arc; #[allow(unsafe_code)] mod green; #[allow(unsafe_code)] @@ -72,6 +74,7 @@ use std::fmt; pub use text_size::{TextLen, TextRange, TextSize}; pub use crate::{ + arc::Arc, green::{Checkpoint, Children, GreenNode, GreenNodeBuilder, GreenToken, NodeCache, SyntaxKind}, syntax::{SyntaxElement, SyntaxElementChildren, SyntaxElementRef, SyntaxNode, SyntaxNodeChildren, SyntaxToken}, syntax_text::SyntaxText, diff --git a/src/syntax.rs b/src/syntax.rs index c7eb326..65c7c22 100644 --- a/src/syntax.rs +++ b/src/syntax.rs @@ -16,9 +16,9 @@ use std::{ #[cfg(feature = "serde1")] use crate::serde_impls::{SerializeWithData, SerializeWithResolver}; use parking_lot::RwLock; -use servo_arc::Arc; use crate::{ + arc::Arc, green::{GreenElementRef, SyntaxKind}, interning::Resolver, Children, Direction, GreenNode, GreenToken, Language, NodeOrToken, SyntaxText, TextRange, TextSize, TokenAtOffset, diff --git a/vendor/servo_arc/Cargo.lock b/vendor/servo_arc/Cargo.lock deleted file mode 100644 index 29593f2..0000000 --- a/vendor/servo_arc/Cargo.lock +++ /dev/null @@ -1,28 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "nodrop" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" - -[[package]] -name = "serde" -version = "1.0.119" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bdd36f49e35b61d49efd8aa7fc068fd295961fd2286d0b2ee9a4c7a14e99cc3" - -[[package]] -name = "servo_arc" -version = "0.1.1" -dependencies = [ - "nodrop", - "serde", - "stable_deref_trait", -] - -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" diff --git a/vendor/servo_arc/Cargo.toml b/vendor/servo_arc/Cargo.toml deleted file mode 100644 index 419858a..0000000 --- a/vendor/servo_arc/Cargo.toml +++ /dev/null @@ -1,35 +0,0 @@ -# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO -# -# When uploading crates to the registry Cargo will automatically -# "normalize" Cargo.toml files for maximal compatibility -# with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g. crates.io) dependencies -# -# If you believe there's an error in this file please file an -# issue against the rust-lang/cargo repository. If you're -# editing this file be aware that the upstream Cargo.toml -# will likely look very different (and much more reasonable) - -[package] -name = "servo_arc" -version = "0.1.1" -authors = ["The Servo Project Developers"] -description = "A fork of std::sync::Arc with some extra functionality and without weak references" -license = "MIT/Apache-2.0" -repository = "https://github.com/servo/servo" - -[lib] -name = "servo_arc" -path = "lib.rs" -[dependencies.nodrop] -version = "0.1.8" - -[dependencies.serde] -version = "1.0" -optional = true - -[dependencies.stable_deref_trait] -version = "1.0.0" - -[features] -servo = ["serde"]