diff options
author | Ms2ger <ms2ger@gmail.com> | 2015-01-01 09:39:17 +0100 |
---|---|---|
committer | Ms2ger <ms2ger@gmail.com> | 2015-01-01 20:36:43 +0100 |
commit | 95ec20bd976c5fe7b9c56e150cf7e909b27fe624 (patch) | |
tree | c56ec21019e28e475fb0c3bd8d7cf3d5e965cdaf | |
parent | 111a196e9d300164391d12ab292c1d4c0ef2b44a (diff) | |
download | servo-95ec20bd976c5fe7b9c56e150cf7e909b27fe624.tar.gz servo-95ec20bd976c5fe7b9c56e150cf7e909b27fe624.zip |
Remove the 'a lifetime from Root.
It does not add any safety, as the reference is constructed from a raw pointer
without limiting the lifetime in any way.
-rw-r--r-- | components/script/dom/bindings/codegen/Configuration.py | 2 | ||||
-rw-r--r-- | components/script/dom/bindings/conversions.rs | 2 | ||||
-rw-r--r-- | components/script/dom/bindings/global.rs | 8 | ||||
-rw-r--r-- | components/script/dom/bindings/js.rs | 42 |
4 files changed, 27 insertions, 27 deletions
diff --git a/components/script/dom/bindings/codegen/Configuration.py b/components/script/dom/bindings/codegen/Configuration.py index be3ff10ab68..6ebe6467e52 100644 --- a/components/script/dom/bindings/codegen/Configuration.py +++ b/components/script/dom/bindings/codegen/Configuration.py @@ -156,7 +156,7 @@ class Descriptor(DescriptorProvider): self.needsRooting = True self.returnType = "Temporary<%s>" % ifaceName self.argumentType = "JSRef<%s>" % ifaceName - self.memberType = "Root<'a, 'b, %s>" % ifaceName + self.memberType = "Root<'b, %s>" % ifaceName self.nativeType = "JS<%s>" % ifaceName self.concreteType = ifaceName diff --git a/components/script/dom/bindings/conversions.rs b/components/script/dom/bindings/conversions.rs index 08c2abb9e8b..2931e7d700d 100644 --- a/components/script/dom/bindings/conversions.rs +++ b/components/script/dom/bindings/conversions.rs @@ -471,7 +471,7 @@ impl<T: Reflectable+IDLInterface> FromJSValConvertible<()> for JS<T> { } } -impl<'a, 'b, T: Reflectable> ToJSValConvertible for Root<'a, 'b, T> { +impl<'b, T: Reflectable> ToJSValConvertible for Root<'b, T> { fn to_jsval(&self, cx: *mut JSContext) -> JSVal { self.reflector().to_jsval(cx) } diff --git a/components/script/dom/bindings/global.rs b/components/script/dom/bindings/global.rs index 38e018fe24f..259d3f6b2b3 100644 --- a/components/script/dom/bindings/global.rs +++ b/components/script/dom/bindings/global.rs @@ -32,9 +32,9 @@ pub enum GlobalRef<'a> { } /// A stack-based rooted reference to a global object. -pub enum GlobalRoot<'a, 'b> { - Window(Root<'a, 'b, window::Window>), - Worker(Root<'a, 'b, WorkerGlobalScope>), +pub enum GlobalRoot<'b> { + Window(Root<'b, window::Window>), + Worker(Root<'b, WorkerGlobalScope>), } /// A traced reference to a global object, for use in fields of traced Rust @@ -98,7 +98,7 @@ impl<'a> Reflectable for GlobalRef<'a> { } } -impl<'a, 'b> GlobalRoot<'a, 'b> { +impl<'b> GlobalRoot<'b> { /// Obtain a safe reference to the global object that cannot outlive the /// lifetime of this root. pub fn root_ref<'c>(&'c self) -> GlobalRef<'c> { diff --git a/components/script/dom/bindings/js.rs b/components/script/dom/bindings/js.rs index a1957f6797a..20029a45d9e 100644 --- a/components/script/dom/bindings/js.rs +++ b/components/script/dom/bindings/js.rs @@ -91,7 +91,7 @@ impl<T: Reflectable> Temporary<T> { } /// Create a stack-bounded root for this value. - pub fn root<'a, 'b>(self) -> Root<'a, 'b, T> { + pub fn root<'b>(self) -> Root<'b, T> { let collection = StackRoots.get().unwrap(); unsafe { Root::new(&**collection, &self.inner) @@ -150,7 +150,7 @@ impl<T: Reflectable> JS<T> { /// Root this JS-owned value to prevent its collection as garbage. - pub fn root<'a, 'b>(&self) -> Root<'a, 'b, T> { + pub fn root<'b>(&self) -> Root<'b, T> { let collection = StackRoots.get().unwrap(); unsafe { Root::new(&**collection, self) @@ -310,7 +310,7 @@ pub trait RootedReference<T> { fn root_ref<'a>(&'a self) -> Option<JSRef<'a, T>>; } -impl<'a, 'b, T: Reflectable> RootedReference<T> for Option<Root<'a, 'b, T>> { +impl<'b, T: Reflectable> RootedReference<T> for Option<Root<'b, T>> { fn root_ref<'a>(&'a self) -> Option<JSRef<'a, T>> { self.as_ref().map(|root| root.root_ref()) } @@ -321,7 +321,7 @@ pub trait OptionalRootedReference<T> { fn root_ref<'a>(&'a self) -> Option<Option<JSRef<'a, T>>>; } -impl<'a, 'b, T: Reflectable> OptionalRootedReference<T> for Option<Option<Root<'a, 'b, T>>> { +impl<'b, T: Reflectable> OptionalRootedReference<T> for Option<Option<Root<'b, T>>> { fn root_ref<'a>(&'a self) -> Option<Option<JSRef<'a, T>>> { self.as_ref().map(|inner| inner.root_ref()) } @@ -367,11 +367,11 @@ impl<T: Assignable<U>, U: Reflectable> OptionalSettable<T> for Cell<Option<JS<U> /// Root a rootable `Option` type (used for `Option<Temporary<T>>`) pub trait OptionalRootable<T> { - fn root<'a, 'b>(self) -> Option<Root<'a, 'b, T>>; + fn root<'b>(self) -> Option<Root<'b, T>>; } impl<T: Reflectable> OptionalRootable<T> for Option<Temporary<T>> { - fn root<'a, 'b>(self) -> Option<Root<'a, 'b, T>> { + fn root<'b>(self) -> Option<Root<'b, T>> { self.map(|inner| inner.root()) } } @@ -389,22 +389,22 @@ impl<'a, T: Reflectable> OptionalUnrootable<T> for Option<JSRef<'a, T>> { /// Root a rootable `Option` type (used for `Option<JS<T>>`) pub trait OptionalRootedRootable<T> { - fn root<'a, 'b>(&self) -> Option<Root<'a, 'b, T>>; + fn root<'b>(&self) -> Option<Root<'b, T>>; } impl<T: Reflectable> OptionalRootedRootable<T> for Option<JS<T>> { - fn root<'a, 'b>(&self) -> Option<Root<'a, 'b, T>> { + fn root<'b>(&self) -> Option<Root<'b, T>> { self.as_ref().map(|inner| inner.root()) } } /// Root a rootable `Option<Option>` type (used for `Option<Option<JS<T>>>`) pub trait OptionalOptionalRootedRootable<T> { - fn root<'a, 'b>(&self) -> Option<Option<Root<'a, 'b, T>>>; + fn root<'b>(&self) -> Option<Option<Root<'b, T>>>; } impl<T: Reflectable> OptionalOptionalRootedRootable<T> for Option<Option<JS<T>>> { - fn root<'a, 'b>(&self) -> Option<Option<Root<'a, 'b, T>>> { + fn root<'b>(&self) -> Option<Option<Root<'b, T>>> { self.as_ref().map(|inner| inner.root()) } } @@ -412,17 +412,17 @@ impl<T: Reflectable> OptionalOptionalRootedRootable<T> for Option<Option<JS<T>>> /// Root a rootable `Result` type (any of `Temporary<T>` or `JS<T>`) pub trait ResultRootable<T,U> { - fn root<'a, 'b>(self) -> Result<Root<'a, 'b, T>, U>; + fn root<'b>(self) -> Result<Root<'b, T>, U>; } impl<T: Reflectable, U> ResultRootable<T, U> for Result<Temporary<T>, U> { - fn root<'a, 'b>(self) -> Result<Root<'a, 'b, T>, U> { + fn root<'b>(self) -> Result<Root<'b, T>, U> { self.map(|inner| inner.root()) } } impl<T: Reflectable, U> ResultRootable<T, U> for Result<JS<T>, U> { - fn root<'a, 'b>(self) -> Result<Root<'a, 'b, T>, U> { + fn root<'b>(self) -> Result<Root<'b, T>, U> { self.map(|inner| inner.root()) } } @@ -459,7 +459,7 @@ impl RootCollection { } /// Track a stack-based root to ensure LIFO root ordering - fn root<'a, 'b, T: Reflectable>(&self, untracked: &Root<'a, 'b, T>) { + fn root<'b, T: Reflectable>(&self, untracked: &Root<'b, T>) { unsafe { let roots = self.roots.get(); (*roots).push(untracked.js_ptr); @@ -468,7 +468,7 @@ impl RootCollection { } /// Stop tracking a stack-based root, asserting if LIFO root ordering has been violated - fn unroot<'a, 'b, T: Reflectable>(&self, rooted: &Root<'a, 'b, T>) { + fn unroot<'b, T: Reflectable>(&self, rooted: &Root<'b, T>) { unsafe { let roots = self.roots.get(); debug!("unrooting {} (expecting {}", @@ -485,20 +485,20 @@ impl RootCollection { /// for the same JS value. `Root`s cannot outlive the associated `RootCollection` object. /// Attempts to transfer ownership of a `Root` via moving will trigger dynamic unrooting /// failures due to incorrect ordering. -pub struct Root<'a, 'b, T> { +pub struct Root<'b, T> { /// List that ensures correct dynamic root ordering - root_list: &'a RootCollection, + root_list: &'static RootCollection, /// Reference to rooted value that must not outlive this container jsref: JSRef<'b, T>, /// On-stack JS pointer to assuage conservative stack scanner js_ptr: *mut JSObject, } -impl<'b, 'a: 'b, T: Reflectable> Root<'a, 'b, T> { +impl<'b, T: Reflectable> Root<'b, T> { /// Create a new stack-bounded root for the provided JS-owned value. /// It cannot not outlive its associated `RootCollection`, and it contains a `JSRef` /// which cannot outlive this new `Root`. - fn new(roots: &'a RootCollection, unrooted: &JS<T>) -> Root<'a, 'b, T> { + fn new(roots: &'static RootCollection, unrooted: &JS<T>) -> Root<'b, T> { let root = Root { root_list: roots, jsref: JSRef { @@ -519,13 +519,13 @@ impl<'b, 'a: 'b, T: Reflectable> Root<'a, 'b, T> { } #[unsafe_destructor] -impl<'b, 'a: 'b, T: Reflectable> Drop for Root<'a, 'b, T> { +impl<'b, T: Reflectable> Drop for Root<'b, T> { fn drop(&mut self) { self.root_list.unroot(self); } } -impl<'b, 'a: 'b, T: Reflectable> Deref<JSRef<'b, T>> for Root<'a, 'b, T> { +impl<'b, T: Reflectable> Deref<JSRef<'b, T>> for Root<'b, T> { fn deref<'c>(&'c self) -> &'c JSRef<'b, T> { &self.jsref } |