diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2014-08-27 21:46:52 -0400 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2014-08-27 21:46:52 -0400 |
| commit | 1b487a890695e7d6dfbfe5dcd7d4fa0e8ca8003f (patch) | |
| tree | 552fabade603ab0d148a49ae3cf1abd3f399740a /src/librustrt | |
| parent | 3ee047ae1ffab454270bc1859b3beef3556ef8f9 (diff) | |
| download | rust-1b487a890695e7d6dfbfe5dcd7d4fa0e8ca8003f.tar.gz rust-1b487a890695e7d6dfbfe5dcd7d4fa0e8ca8003f.zip | |
Implement generalized object and type parameter bounds (Fixes #16462)
Diffstat (limited to 'src/librustrt')
| -rw-r--r-- | src/librustrt/exclusive.rs | 12 | ||||
| -rw-r--r-- | src/librustrt/lib.rs | 3 | ||||
| -rw-r--r-- | src/librustrt/local_data.rs | 10 | ||||
| -rw-r--r-- | src/librustrt/rtio.rs | 4 | ||||
| -rw-r--r-- | src/librustrt/task.rs | 8 |
5 files changed, 29 insertions, 8 deletions
diff --git a/src/librustrt/exclusive.rs b/src/librustrt/exclusive.rs index 179d050f598..28514bec5b4 100644 --- a/src/librustrt/exclusive.rs +++ b/src/librustrt/exclusive.rs @@ -26,7 +26,8 @@ pub struct Exclusive<T> { data: UnsafeCell<T>, } -/// An RAII guard returned via `lock` +/// stage0 only +#[cfg(stage0)] pub struct ExclusiveGuard<'a, T> { // FIXME #12808: strange name to try to avoid interfering with // field accesses of the contained type via Deref @@ -34,6 +35,15 @@ pub struct ExclusiveGuard<'a, T> { _guard: mutex::LockGuard<'a>, } +/// An RAII guard returned via `lock` +#[cfg(not(stage0))] +pub struct ExclusiveGuard<'a, T:'a> { + // FIXME #12808: strange name to try to avoid interfering with + // field accesses of the contained type via Deref + _data: &'a mut T, + _guard: mutex::LockGuard<'a>, +} + impl<T: Send> Exclusive<T> { /// Creates a new `Exclusive` which will protect the data provided. pub fn new(user_data: T) -> Exclusive<T> { diff --git a/src/librustrt/lib.rs b/src/librustrt/lib.rs index 70ce85ee649..5ca46a728c3 100644 --- a/src/librustrt/lib.rs +++ b/src/librustrt/lib.rs @@ -19,6 +19,7 @@ #![feature(macro_rules, phase, globs, thread_local, managed_boxes, asm)] #![feature(linkage, lang_items, unsafe_destructor, default_type_params)] #![feature(import_shadowing)] +#![feature(issue_5723_bootstrap)] #![no_std] #![experimental] @@ -98,7 +99,7 @@ pub trait Runtime { fn can_block(&self) -> bool; // FIXME: This is a serious code smell and this should not exist at all. - fn wrap(self: Box<Self>) -> Box<Any>; + fn wrap(self: Box<Self>) -> Box<Any+'static>; } /// The default error code of the rust runtime if the main task fails instead diff --git a/src/librustrt/local_data.rs b/src/librustrt/local_data.rs index 6a0b599179c..fedea3c31e0 100644 --- a/src/librustrt/local_data.rs +++ b/src/librustrt/local_data.rs @@ -144,6 +144,16 @@ unsafe fn get_local_map<'a>() -> Option<&'a mut Map> { /// /// The task-local data can be accessed through this value, and when this /// structure is dropped it will return the borrow on the data. +#[cfg(not(stage0))] +pub struct Ref<T:'static> { + // FIXME #12808: strange names to try to avoid interfering with + // field accesses of the contained type via Deref + _inner: &'static TLDValueBox<T>, + _marker: marker::NoSend +} + +/// stage0 only +#[cfg(stage0)] pub struct Ref<T> { // FIXME #12808: strange names to try to avoid interfering with // field accesses of the contained type via Deref diff --git a/src/librustrt/rtio.rs b/src/librustrt/rtio.rs index 261d544a241..1afd88edbc2 100644 --- a/src/librustrt/rtio.rs +++ b/src/librustrt/rtio.rs @@ -120,7 +120,7 @@ pub struct ProcessConfig<'a> { } pub struct LocalIo<'a> { - factory: &'a mut IoFactory, + factory: &'a mut IoFactory+'a, } #[unsafe_destructor] @@ -174,7 +174,7 @@ impl<'a> LocalIo<'a> { } } - pub fn new<'a>(io: &'a mut IoFactory) -> LocalIo<'a> { + pub fn new<'a>(io: &'a mut IoFactory+'a) -> LocalIo<'a> { LocalIo { factory: io } } diff --git a/src/librustrt/task.rs b/src/librustrt/task.rs index acd53535e3b..e39071864a7 100644 --- a/src/librustrt/task.rs +++ b/src/librustrt/task.rs @@ -103,7 +103,7 @@ pub struct Task { pub name: Option<SendStr>, state: TaskState, - imp: Option<Box<Runtime + Send>>, + imp: Option<Box<Runtime + Send + 'static>>, } // Once a task has entered the `Armed` state it must be destroyed via `drop`, @@ -353,14 +353,14 @@ impl Task { /// Inserts a runtime object into this task, transferring ownership to the /// task. It is illegal to replace a previous runtime object in this task /// with this argument. - pub fn put_runtime(&mut self, ops: Box<Runtime + Send>) { + pub fn put_runtime(&mut self, ops: Box<Runtime + Send + 'static>) { assert!(self.imp.is_none()); self.imp = Some(ops); } /// Removes the runtime from this task, transferring ownership to the /// caller. - pub fn take_runtime(&mut self) -> Box<Runtime + Send> { + pub fn take_runtime(&mut self) -> Box<Runtime + Send + 'static> { assert!(self.imp.is_some()); self.imp.take().unwrap() } @@ -390,7 +390,7 @@ impl Task { Ok(t) => Some(t), Err(t) => { let data = mem::transmute::<_, raw::TraitObject>(t).data; - let obj: Box<Runtime + Send> = + let obj: Box<Runtime + Send + 'static> = mem::transmute(raw::TraitObject { vtable: vtable, data: data, |
