diff options
author | Manish Goregaokar <manishsmail@gmail.com> | 2014-09-17 18:17:19 +0530 |
---|---|---|
committer | Manish Goregaokar <manishsmail@gmail.com> | 2014-09-17 18:17:19 +0530 |
commit | 11ba79894a13ddaee4bfcdd64d23fd4b54a041f3 (patch) | |
tree | 5eac047b9fdc394ff30ce52a6dd888f164c6b629 /components/script/dom/bindings/js.rs | |
parent | aa935c7b027bf00bf1f6756b0f5e1f4d0866c964 (diff) | |
parent | f5087e149004e0080a61a2a31d76a5c52ee357e1 (diff) | |
download | servo-11ba79894a13ddaee4bfcdd64d23fd4b54a041f3.tar.gz servo-11ba79894a13ddaee4bfcdd64d23fd4b54a041f3.zip |
Merge pull request #3374 from Manishearth/lint_unrooted_jsmanaged
Add lint for ensuring proper rooting of JS<T>; r=jdm
Diffstat (limited to 'components/script/dom/bindings/js.rs')
-rw-r--r-- | components/script/dom/bindings/js.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/components/script/dom/bindings/js.rs b/components/script/dom/bindings/js.rs index ab8b3e3c7f5..7754adce672 100644 --- a/components/script/dom/bindings/js.rs +++ b/components/script/dom/bindings/js.rs @@ -61,6 +61,7 @@ use std::mem; /// Importantly, it requires explicit rooting in order to interact with the inner value. /// Can be assigned into JS-owned member fields (i.e. `JS<T>` types) safely via the /// `JS<T>::assign` method or `OptionalSettable::assign` (for `Option<JS<T>>` fields). +#[allow(unrooted_must_root)] pub struct Temporary<T> { inner: JS<T>, /// On-stack JS pointer to assuage conservative stack scanner @@ -106,11 +107,13 @@ impl<T: Reflectable> Temporary<T> { } /// A rooted, JS-owned value. Must only be used as a field in other JS-owned types. +#[must_root] pub struct JS<T> { ptr: *const T } impl<T> PartialEq for JS<T> { + #[allow(unrooted_must_root)] fn eq(&self, other: &JS<T>) -> bool { self.ptr == other.ptr } @@ -371,6 +374,7 @@ impl RootCollection { } /// Create a new stack-bounded root that will not outlive this collection + #[allow(unrooted_must_root)] fn new_root<'a, 'b, T: Reflectable>(&'a self, unrooted: &JS<T>) -> Root<'a, 'b, T> { Root::new(self, unrooted) } |