aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/script_task.rs
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2015-11-03 11:19:52 -0800
committerEli Friedman <eli.friedman@gmail.com>2015-11-07 21:17:24 -0800
commit1a50fce67c840123447c9949c9692f4bb5828e5d (patch)
tree43576152ca427142e751abb6de042690499ee638 /components/script/script_task.rs
parentdb1163b1eceb5fef6463c4425e99d974a85a50a8 (diff)
downloadservo-1a50fce67c840123447c9949c9692f4bb5828e5d.tar.gz
servo-1a50fce67c840123447c9949c9692f4bb5828e5d.zip
Clean up some code related to #[no_move].
The patch makes RootCollection a bit safer by making the StackRootTLS hold it in place. The use of no_move in CodeGenRust was leftover from when roots couldn't be moved.
Diffstat (limited to 'components/script/script_task.rs')
-rw-r--r--components/script/script_task.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/components/script/script_task.rs b/components/script/script_task.rs
index 4939a58e086..dc3c97fbe30 100644
--- a/components/script/script_task.rs
+++ b/components/script/script_task.rs
@@ -89,6 +89,7 @@ use std::borrow::ToOwned;
use std::cell::{Cell, RefCell};
use std::collections::HashSet;
use std::io::{Write, stdout};
+use std::marker::PhantomData;
use std::mem as std_mem;
use std::option::Option;
use std::ptr;
@@ -334,18 +335,18 @@ impl TimerEventChan for MainThreadTimerEventChan {
}
}
-pub struct StackRootTLS;
+pub struct StackRootTLS<'a>(PhantomData<&'a u32>);
-impl StackRootTLS {
- pub fn new(roots: &RootCollection) -> StackRootTLS {
+impl<'a> StackRootTLS<'a> {
+ pub fn new(roots: &'a RootCollection) -> StackRootTLS<'a> {
STACK_ROOTS.with(|ref r| {
r.set(Some(RootCollectionPtr(roots as *const _)))
});
- StackRootTLS
+ StackRootTLS(PhantomData)
}
}
-impl Drop for StackRootTLS {
+impl<'a> Drop for StackRootTLS<'a> {
fn drop(&mut self) {
STACK_ROOTS.with(|ref r| r.set(None));
}