1
Fork 0
mirror of https://github.com/RGBCube/cstree synced 2025-07-27 17:17:45 +00:00

Move vendored servo_arc into crate for publishing (#19)

This commit is contained in:
DQ 2021-02-21 21:45:55 +01:00 committed by GitHub
parent 45241f98c5
commit e5a4ba71df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 18 additions and 74 deletions

View file

@ -12,9 +12,12 @@ readme = "README.md"
lasso = "0.5" lasso = "0.5"
text-size = "1.0.0" text-size = "1.0.0"
fxhash= "0.2.1" fxhash= "0.2.1"
servo_arc = { path = "vendor/servo_arc" }
parking_lot= "0.11.1" parking_lot= "0.11.1"
# Arc
stable_deref_trait = "1.0.0"
nodrop = "0.1.8"
[dependencies.serde] [dependencies.serde]
version = "1.0" version = "1.0"
optional = true optional = true
@ -29,7 +32,7 @@ crossbeam-utils = "0.8"
[features] [features]
default = [] default = []
serde1 = ["serde", "servo_arc/servo"] serde1 = ["serde"]
[package.metadata.docs.rs] [package.metadata.docs.rs]
features = ["serde1"] features = ["serde1"]

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // 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 waste storage on the weak reference count.
//! * We don't do extra RMU operations to handle the possibility of weak references. //! * 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 // The semantics of Arc are alread documented in the Rust docs, so we don't
// duplicate those here. // duplicate those here.
#![allow(warnings)]
#![allow(missing_docs)] #![allow(missing_docs)]
#![allow(clippy::all)] #![allow(clippy::all)]
extern crate nodrop; extern crate nodrop;
#[cfg(feature = "servo")] #[cfg(feature = "serde1")]
extern crate serde; extern crate serde;
extern crate stable_deref_trait; extern crate stable_deref_trait;
use nodrop::NoDrop; use nodrop::NoDrop;
#[cfg(feature = "servo")] #[cfg(feature = "serde1")]
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use stable_deref_trait::{CloneStableDeref, StableDeref}; use stable_deref_trait::{CloneStableDeref, StableDeref};
use std::{ use std::{
@ -93,6 +94,7 @@ fn padding_needed_for(layout: &Layout, align: usize) -> usize {
/// necessarily) at _exactly_ `MAX_REFCOUNT + 1` references. /// necessarily) at _exactly_ `MAX_REFCOUNT + 1` references.
const MAX_REFCOUNT: usize = (isize::MAX) as usize; const MAX_REFCOUNT: usize = (isize::MAX) as usize;
/// See [`std::sync::Arc`].
#[repr(C)] #[repr(C)]
pub struct Arc<T: ?Sized + 'static> { pub struct Arc<T: ?Sized + 'static> {
p: NonNull<ArcInner<T>>, p: NonNull<ArcInner<T>>,
@ -458,7 +460,7 @@ impl<T: ?Sized> AsRef<T> for Arc<T> {
unsafe impl<T: ?Sized> StableDeref for Arc<T> {} unsafe impl<T: ?Sized> StableDeref for Arc<T> {}
unsafe impl<T: ?Sized> CloneStableDeref for Arc<T> {} unsafe impl<T: ?Sized> CloneStableDeref for Arc<T> {}
#[cfg(feature = "servo")] #[cfg(feature = "serde1")]
impl<'de, T: Deserialize<'de>> Deserialize<'de> for Arc<T> { impl<'de, T: Deserialize<'de>> Deserialize<'de> for Arc<T> {
fn deserialize<D>(deserializer: D) -> Result<Arc<T>, D::Error> fn deserialize<D>(deserializer: D) -> Result<Arc<T>, D::Error>
where where
@ -468,7 +470,7 @@ impl<'de, T: Deserialize<'de>> Deserialize<'de> for Arc<T> {
} }
} }
#[cfg(feature = "servo")] #[cfg(feature = "serde1")]
impl<T: Serialize> Serialize for Arc<T> { impl<T: Serialize> Serialize for Arc<T> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where where

View file

@ -5,9 +5,9 @@ use std::{
}; };
use fxhash::FxHasher32; use fxhash::FxHasher32;
use servo_arc::{Arc, HeaderWithLength, ThinArc};
use crate::{ use crate::{
arc::{Arc, HeaderWithLength, ThinArc},
green::{GreenElement, GreenElementRef, PackedGreenElement, SyntaxKind}, green::{GreenElement, GreenElementRef, PackedGreenElement, SyntaxKind},
TextSize, TextSize,
}; };

View file

@ -1,7 +1,6 @@
use servo_arc::Arc;
use std::{fmt, hash, mem::ManuallyDrop, ptr}; 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; use lasso::Spur;
#[repr(align(2))] // to use 1 bit for pointer tagging. NB: this is an at-least annotation #[repr(align(2))] // to use 1 bit for pointer tagging. NB: this is an at-least annotation

View file

@ -50,6 +50,8 @@
)] )]
#![deny(unsafe_code, missing_docs)] #![deny(unsafe_code, missing_docs)]
#[allow(unsafe_code)]
mod arc;
#[allow(unsafe_code)] #[allow(unsafe_code)]
mod green; mod green;
#[allow(unsafe_code)] #[allow(unsafe_code)]
@ -72,6 +74,7 @@ use std::fmt;
pub use text_size::{TextLen, TextRange, TextSize}; pub use text_size::{TextLen, TextRange, TextSize};
pub use crate::{ pub use crate::{
arc::Arc,
green::{Checkpoint, Children, GreenNode, GreenNodeBuilder, GreenToken, NodeCache, SyntaxKind}, green::{Checkpoint, Children, GreenNode, GreenNodeBuilder, GreenToken, NodeCache, SyntaxKind},
syntax::{SyntaxElement, SyntaxElementChildren, SyntaxElementRef, SyntaxNode, SyntaxNodeChildren, SyntaxToken}, syntax::{SyntaxElement, SyntaxElementChildren, SyntaxElementRef, SyntaxNode, SyntaxNodeChildren, SyntaxToken},
syntax_text::SyntaxText, syntax_text::SyntaxText,

View file

@ -16,9 +16,9 @@ use std::{
#[cfg(feature = "serde1")] #[cfg(feature = "serde1")]
use crate::serde_impls::{SerializeWithData, SerializeWithResolver}; use crate::serde_impls::{SerializeWithData, SerializeWithResolver};
use parking_lot::RwLock; use parking_lot::RwLock;
use servo_arc::Arc;
use crate::{ use crate::{
arc::Arc,
green::{GreenElementRef, SyntaxKind}, green::{GreenElementRef, SyntaxKind},
interning::Resolver, interning::Resolver,
Children, Direction, GreenNode, GreenToken, Language, NodeOrToken, SyntaxText, TextRange, TextSize, TokenAtOffset, Children, Direction, GreenNode, GreenToken, Language, NodeOrToken, SyntaxText, TextRange, TextSize, TokenAtOffset,

28
vendor/servo_arc/Cargo.lock generated vendored
View file

@ -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"

View file

@ -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"]