Test fixes and rebase conflicts, round 2

This commit is contained in:
Alex Crichton 2015-04-01 16:34:15 -07:00
parent d49b67e255
commit 57f5ac948a
12 changed files with 29 additions and 64 deletions

View file

@ -1347,7 +1347,7 @@ pub fn min_value() -> $T { 0 }
/// Returns the largest value that can be represented by this integer type.
#[stable(feature = "rust1", since = "1.0.0")]
pub fn max_value() -> $T { -1 }
pub fn max_value() -> $T { !0 }
/// Convert a string slice in a given base to an integer.
///

View file

@ -2571,7 +2571,7 @@ pub mod extra {
pub const ERROR_IO_PENDING: c_int = 997;
pub const ERROR_FILE_INVALID : c_int = 1006;
pub const ERROR_NOT_FOUND: c_int = 1168;
pub const INVALID_HANDLE_VALUE: HANDLE = -1 as HANDLE;
pub const INVALID_HANDLE_VALUE: HANDLE = !0 as HANDLE;
pub const DELETE : DWORD = 0x00010000;
pub const READ_CONTROL : DWORD = 0x00020000;
@ -2609,12 +2609,12 @@ pub mod extra {
pub const WAIT_ABANDONED : DWORD = 0x00000080;
pub const WAIT_OBJECT_0 : DWORD = 0x00000000;
pub const WAIT_TIMEOUT : DWORD = 0x00000102;
pub const WAIT_FAILED : DWORD = -1;
pub const WAIT_FAILED : DWORD = !0;
pub const DUPLICATE_CLOSE_SOURCE : DWORD = 0x00000001;
pub const DUPLICATE_SAME_ACCESS : DWORD = 0x00000002;
pub const INFINITE : DWORD = -1;
pub const INFINITE : DWORD = !0;
pub const STILL_ACTIVE : DWORD = 259;
pub const MEM_COMMIT : DWORD = 0x00001000;

View file

@ -342,7 +342,7 @@
/// The receiving-half of Rust's channel type. This half can only be owned by
/// one task
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Receiver<T:Send> {
pub struct Receiver<T> {
inner: UnsafeCell<Flavor<T>>,
}
@ -354,14 +354,14 @@ unsafe impl<T: Send> Send for Receiver<T> { }
/// whenever `next` is called, waiting for a new message, and `None` will be
/// returned when the corresponding channel has hung up.
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Iter<'a, T:Send+'a> {
pub struct Iter<'a, T: 'a> {
rx: &'a Receiver<T>
}
/// The sending-half of Rust's asynchronous channel type. This half can only be
/// owned by one task, but it can be cloned to send to other tasks.
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Sender<T:Send> {
pub struct Sender<T> {
inner: UnsafeCell<Flavor<T>>,
}
@ -372,7 +372,7 @@ unsafe impl<T: Send> Send for Sender<T> { }
/// The sending-half of Rust's synchronous channel type. This half can only be
/// owned by one task, but it can be cloned to send to other tasks.
#[stable(feature = "rust1", since = "1.0.0")]
pub struct SyncSender<T: Send> {
pub struct SyncSender<T> {
inner: Arc<UnsafeCell<sync::Packet<T>>>,
}
@ -433,7 +433,7 @@ pub enum TrySendError<T> {
Disconnected(T),
}
enum Flavor<T:Send> {
enum Flavor<T> {
Oneshot(Arc<UnsafeCell<oneshot::Packet<T>>>),
Stream(Arc<UnsafeCell<stream::Packet<T>>>),
Shared(Arc<UnsafeCell<shared::Packet<T>>>),
@ -441,7 +441,7 @@ enum Flavor<T:Send> {
}
#[doc(hidden)]
trait UnsafeFlavor<T:Send> {
trait UnsafeFlavor<T> {
fn inner_unsafe<'a>(&'a self) -> &'a UnsafeCell<Flavor<T>>;
unsafe fn inner_mut<'a>(&'a self) -> &'a mut Flavor<T> {
&mut *self.inner_unsafe().get()
@ -450,12 +450,12 @@ unsafe fn inner<'a>(&'a self) -> &'a Flavor<T> {
&*self.inner_unsafe().get()
}
}
impl<T:Send> UnsafeFlavor<T> for Sender<T> {
impl<T> UnsafeFlavor<T> for Sender<T> {
fn inner_unsafe<'a>(&'a self) -> &'a UnsafeCell<Flavor<T>> {
&self.inner
}
}
impl<T:Send> UnsafeFlavor<T> for Receiver<T> {
impl<T> UnsafeFlavor<T> for Receiver<T> {
fn inner_unsafe<'a>(&'a self) -> &'a UnsafeCell<Flavor<T>> {
&self.inner
}

View file

@ -72,12 +72,12 @@ struct Node<T> {
/// The multi-producer single-consumer structure. This is not cloneable, but it
/// may be safely shared so long as it is guaranteed that there is only one
/// popper at a time (many pushers are allowed).
pub struct Queue<T: Send> {
pub struct Queue<T> {
head: AtomicPtr<Node<T>>,
tail: UnsafeCell<*mut Node<T>>,
}
unsafe impl<T:Send> Send for Queue<T> { }
unsafe impl<T: Send> Send for Queue<T> { }
unsafe impl<T: Send> Sync for Queue<T> { }
impl<T> Node<T> {

View file

@ -54,7 +54,7 @@
// moves *from* a pointer, ownership of the token is transferred to
// whoever changed the state.
pub struct Packet<T:Send> {
pub struct Packet<T> {
// Internal state of the chan/port pair (stores the blocked task as well)
state: AtomicUsize,
// One-shot data slot location
@ -64,7 +64,7 @@ pub struct Packet<T:Send> {
upgrade: MyUpgrade<T>,
}
pub enum Failure<T:Send> {
pub enum Failure<T> {
Empty,
Disconnected,
Upgraded(Receiver<T>),
@ -76,13 +76,13 @@ pub enum UpgradeResult {
UpWoke(SignalToken),
}
pub enum SelectionResult<T:Send> {
pub enum SelectionResult<T> {
SelCanceled,
SelUpgraded(SignalToken, Receiver<T>),
SelSuccess,
}
enum MyUpgrade<T:Send> {
enum MyUpgrade<T> {
NothingSent,
SendUsed,
GoUp(Receiver<T>),

View file

@ -40,7 +40,7 @@
#[cfg(not(test))]
const MAX_STEALS: isize = 1 << 20;
pub struct Packet<T: Send> {
pub struct Packet<T> {
queue: mpsc::Queue<T>,
cnt: AtomicIsize, // How many items are on this channel
steals: isize, // How many times has a port received without blocking?

View file

@ -57,7 +57,7 @@ struct Node<T> {
/// but it can be safely shared in an Arc if it is guaranteed that there
/// is only one popper and one pusher touching the queue at any one point in
/// time.
pub struct Queue<T: Send> {
pub struct Queue<T> {
// consumer fields
tail: UnsafeCell<*mut Node<T>>, // where to pop from
tail_prev: AtomicPtr<Node<T>>, // where to pop from

View file

@ -39,7 +39,7 @@
#[cfg(not(test))]
const MAX_STEALS: isize = 1 << 20;
pub struct Packet<T:Send> {
pub struct Packet<T> {
queue: spsc::Queue<Message<T>>, // internal queue for all message
cnt: AtomicIsize, // How many items are on this channel
@ -49,7 +49,7 @@ pub struct Packet<T:Send> {
port_dropped: AtomicBool, // flag if the channel has been destroyed.
}
pub enum Failure<T:Send> {
pub enum Failure<T> {
Empty,
Disconnected,
Upgraded(Receiver<T>),
@ -61,7 +61,7 @@ pub enum UpgradeResult {
UpWoke(SignalToken),
}
pub enum SelectionResult<T:Send> {
pub enum SelectionResult<T> {
SelSuccess,
SelCanceled,
SelUpgraded(SignalToken, Receiver<T>),
@ -69,7 +69,7 @@ pub enum SelectionResult<T:Send> {
// Any message could contain an "upgrade request" to a new shared port, so the
// internal queue it's a queue of T, but rather Message<T>
enum Message<T:Send> {
enum Message<T> {
Data(T),
GoUp(Receiver<T>),
}

View file

@ -47,7 +47,7 @@
use sync::mpsc::select::StartResult::{self, Installed, Abort};
use sync::{Mutex, MutexGuard};
pub struct Packet<T: Send> {
pub struct Packet<T> {
/// Only field outside of the mutex. Just done for kicks, but mainly because
/// the other shared channel already had the code implemented
channels: AtomicUsize,

View file

@ -112,7 +112,7 @@
/// *guard += 1;
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Mutex<T: Send> {
pub struct Mutex<T> {
// Note that this static mutex is in a *box*, not inlined into the struct
// itself. Once a native mutex has been used once, its address can never
// change (it can't be moved). This mutex type can be safely moved at any

View file

@ -49,9 +49,9 @@
pub const TOKEN_READ: libc::DWORD = 0x20008;
// Note that these are not actually HANDLEs, just values to pass to GetStdHandle
pub const STD_INPUT_HANDLE: libc::DWORD = -10;
pub const STD_OUTPUT_HANDLE: libc::DWORD = -11;
pub const STD_ERROR_HANDLE: libc::DWORD = -12;
pub const STD_INPUT_HANDLE: libc::DWORD = -10i32 as libc::DWORD;
pub const STD_OUTPUT_HANDLE: libc::DWORD = -11i32 as libc::DWORD;
pub const STD_ERROR_HANDLE: libc::DWORD = -12i32 as libc::DWORD;
#[repr(C)]
#[cfg(target_arch = "x86")]

View file

@ -1,35 +0,0 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::sync::mpsc::channel;
// Test that a class with an unsendable field can't be
// sent
use std::rc::Rc;
struct foo {
i: isize,
j: Rc<String>,
}
fn foo(i:isize, j: Rc<String>) -> foo {
foo {
i: i,
j: j
}
}
fn main() {
let cat = "kitty".to_string();
let (tx, _) = channel();
//~^ ERROR `core::marker::Send` is not implemented
tx.send(foo(42, Rc::new(cat)));
}