Make a bunch of types 'static.

The reasoning for this is explained in a comment in the next patch.

MozReview-Commit-ID: FQgDY77mg3B
This commit is contained in:
Bobby Holley 2017-06-06 14:39:02 -07:00
parent c369d0708c
commit 586a21e1dd
4 changed files with 12 additions and 12 deletions

View file

@ -62,7 +62,7 @@ macro_rules! with_all_bounds {
/// NB: We need Clone so that we can derive(Clone) on struct with that
/// are parameterized on SelectorImpl. See
/// https://github.com/rust-lang/rust/issues/26925
pub trait SelectorImpl: Clone + Sized {
pub trait SelectorImpl: Clone + Sized + 'static {
type AttrValue: $($InSelector)*;
type Identifier: $($InSelector)* + PrecomputedHash;
type ClassName: $($InSelector)* + PrecomputedHash;

View file

@ -69,7 +69,7 @@ macro_rules! offset_of {
/// necessarily) at _exactly_ `MAX_REFCOUNT + 1` references.
const MAX_REFCOUNT: usize = (isize::MAX) as usize;
pub struct Arc<T: ?Sized> {
pub struct Arc<T: ?Sized + 'static> {
// FIXME(bholley): When NonZero/Shared/Unique are stabilized, we should use
// Shared here to get the NonZero optimization. Gankro is working on this.
//
@ -84,7 +84,7 @@ pub struct Arc<T: ?Sized> {
///
/// This lets us build arcs that we can mutate before
/// freezing, without needing to change the allocation
pub struct UniqueArc<T: ?Sized>(Arc<T>);
pub struct UniqueArc<T: ?Sized + 'static>(Arc<T>);
impl<T> UniqueArc<T> {
#[inline]
@ -542,7 +542,7 @@ impl<H> HeaderWithLength<H> {
}
type HeaderSliceWithLength<H, T> = HeaderSlice<HeaderWithLength<H>, T>;
pub struct ThinArc<H, T> {
pub struct ThinArc<H: 'static, T: 'static> {
ptr: *mut ArcInner<HeaderSliceWithLength<H, [T; 1]>>,
}
@ -563,7 +563,7 @@ fn thin_to_thick<H, T>(thin: *mut ArcInner<HeaderSliceWithLength<H, [T; 1]>>)
fake_slice as *mut ArcInner<HeaderSliceWithLength<H, [T]>>
}
impl<H, T> ThinArc<H, T> {
impl<H: 'static, T: 'static> ThinArc<H, T> {
/// Temporarily converts |self| into a bonafide Arc and exposes it to the
/// provided callback. The refcount is not modified.
#[inline(always)]
@ -593,19 +593,19 @@ impl<H, T> Deref for ThinArc<H, T> {
}
}
impl<H, T> Clone for ThinArc<H, T> {
impl<H: 'static, T: 'static> Clone for ThinArc<H, T> {
fn clone(&self) -> Self {
ThinArc::with_arc(self, |a| Arc::into_thin(a.clone()))
}
}
impl<H, T> Drop for ThinArc<H, T> {
impl<H: 'static, T: 'static> Drop for ThinArc<H, T> {
fn drop(&mut self) {
let _ = Arc::from_thin(ThinArc { ptr: self.ptr });
}
}
impl<H, T> Arc<HeaderSliceWithLength<H, [T]>> {
impl<H: 'static, T: 'static> Arc<HeaderSliceWithLength<H, [T]>> {
/// Converts an Arc into a ThinArc. This consumes the Arc, so the refcount
/// is not modified.
pub fn into_thin(a: Self) -> ThinArc<H, T> {
@ -630,7 +630,7 @@ impl<H, T> Arc<HeaderSliceWithLength<H, [T]>> {
}
}
impl<H: PartialEq, T: PartialEq> PartialEq for ThinArc<H, T> {
impl<H: PartialEq + 'static, T: PartialEq + 'static> PartialEq for ThinArc<H, T> {
fn eq(&self, other: &ThinArc<H, T>) -> bool {
ThinArc::with_arc(self, |a| {
ThinArc::with_arc(other, |b| {
@ -640,7 +640,7 @@ impl<H: PartialEq, T: PartialEq> PartialEq for ThinArc<H, T> {
}
}
impl<H: Eq, T: Eq> Eq for ThinArc<H, T> {}
impl<H: Eq + 'static, T: Eq + 'static> Eq for ThinArc<H, T> {}
#[cfg(test)]
mod tests {

View file

@ -11,7 +11,7 @@ use std::ptr;
use stylearc::Arc;
/// Indicates that a given Servo type has a corresponding Gecko FFI type.
pub unsafe trait HasFFI : Sized {
pub unsafe trait HasFFI : Sized + 'static {
/// The corresponding Gecko type that this rust type represents.
///
/// See the examples in `components/style/gecko/conversions.rs`.

View file

@ -2193,7 +2193,7 @@ pub fn get_writing_mode(inheritedbox_style: &style_structs::InheritedBox) -> Wri
}
/// A reference to a style struct of the parent, or our own style struct.
pub enum StyleStructRef<'a, T: 'a> {
pub enum StyleStructRef<'a, T: 'static> {
/// A borrowed struct from the parent, for example, for inheriting style.
Borrowed(&'a Arc<T>),
/// An owned struct, that we've already mutated.