mirror of
https://github.com/rust-lang/rust
synced 2024-09-15 22:50:55 +00:00
Test fixes and rebase conflicts, round 2
This commit is contained in:
parent
d49b67e255
commit
57f5ac948a
|
@ -1347,7 +1347,7 @@ pub fn min_value() -> $T { 0 }
|
||||||
|
|
||||||
/// Returns the largest value that can be represented by this integer type.
|
/// Returns the largest value that can be represented by this integer type.
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[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.
|
/// Convert a string slice in a given base to an integer.
|
||||||
///
|
///
|
||||||
|
|
|
@ -2571,7 +2571,7 @@ pub mod extra {
|
||||||
pub const ERROR_IO_PENDING: c_int = 997;
|
pub const ERROR_IO_PENDING: c_int = 997;
|
||||||
pub const ERROR_FILE_INVALID : c_int = 1006;
|
pub const ERROR_FILE_INVALID : c_int = 1006;
|
||||||
pub const ERROR_NOT_FOUND: c_int = 1168;
|
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 DELETE : DWORD = 0x00010000;
|
||||||
pub const READ_CONTROL : DWORD = 0x00020000;
|
pub const READ_CONTROL : DWORD = 0x00020000;
|
||||||
|
@ -2609,12 +2609,12 @@ pub mod extra {
|
||||||
pub const WAIT_ABANDONED : DWORD = 0x00000080;
|
pub const WAIT_ABANDONED : DWORD = 0x00000080;
|
||||||
pub const WAIT_OBJECT_0 : DWORD = 0x00000000;
|
pub const WAIT_OBJECT_0 : DWORD = 0x00000000;
|
||||||
pub const WAIT_TIMEOUT : DWORD = 0x00000102;
|
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_CLOSE_SOURCE : DWORD = 0x00000001;
|
||||||
pub const DUPLICATE_SAME_ACCESS : DWORD = 0x00000002;
|
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 STILL_ACTIVE : DWORD = 259;
|
||||||
|
|
||||||
pub const MEM_COMMIT : DWORD = 0x00001000;
|
pub const MEM_COMMIT : DWORD = 0x00001000;
|
||||||
|
|
|
@ -342,7 +342,7 @@
|
||||||
/// The receiving-half of Rust's channel type. This half can only be owned by
|
/// The receiving-half of Rust's channel type. This half can only be owned by
|
||||||
/// one task
|
/// one task
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub struct Receiver<T:Send> {
|
pub struct Receiver<T> {
|
||||||
inner: UnsafeCell<Flavor<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
|
/// whenever `next` is called, waiting for a new message, and `None` will be
|
||||||
/// returned when the corresponding channel has hung up.
|
/// returned when the corresponding channel has hung up.
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub struct Iter<'a, T:Send+'a> {
|
pub struct Iter<'a, T: 'a> {
|
||||||
rx: &'a Receiver<T>
|
rx: &'a Receiver<T>
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The sending-half of Rust's asynchronous channel type. This half can only be
|
/// 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.
|
/// owned by one task, but it can be cloned to send to other tasks.
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub struct Sender<T:Send> {
|
pub struct Sender<T> {
|
||||||
inner: UnsafeCell<Flavor<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
|
/// 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.
|
/// owned by one task, but it can be cloned to send to other tasks.
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub struct SyncSender<T: Send> {
|
pub struct SyncSender<T> {
|
||||||
inner: Arc<UnsafeCell<sync::Packet<T>>>,
|
inner: Arc<UnsafeCell<sync::Packet<T>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -433,7 +433,7 @@ pub enum TrySendError<T> {
|
||||||
Disconnected(T),
|
Disconnected(T),
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Flavor<T:Send> {
|
enum Flavor<T> {
|
||||||
Oneshot(Arc<UnsafeCell<oneshot::Packet<T>>>),
|
Oneshot(Arc<UnsafeCell<oneshot::Packet<T>>>),
|
||||||
Stream(Arc<UnsafeCell<stream::Packet<T>>>),
|
Stream(Arc<UnsafeCell<stream::Packet<T>>>),
|
||||||
Shared(Arc<UnsafeCell<shared::Packet<T>>>),
|
Shared(Arc<UnsafeCell<shared::Packet<T>>>),
|
||||||
|
@ -441,7 +441,7 @@ enum Flavor<T:Send> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
trait UnsafeFlavor<T:Send> {
|
trait UnsafeFlavor<T> {
|
||||||
fn inner_unsafe<'a>(&'a self) -> &'a UnsafeCell<Flavor<T>>;
|
fn inner_unsafe<'a>(&'a self) -> &'a UnsafeCell<Flavor<T>>;
|
||||||
unsafe fn inner_mut<'a>(&'a self) -> &'a mut Flavor<T> {
|
unsafe fn inner_mut<'a>(&'a self) -> &'a mut Flavor<T> {
|
||||||
&mut *self.inner_unsafe().get()
|
&mut *self.inner_unsafe().get()
|
||||||
|
@ -450,12 +450,12 @@ unsafe fn inner<'a>(&'a self) -> &'a Flavor<T> {
|
||||||
&*self.inner_unsafe().get()
|
&*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>> {
|
fn inner_unsafe<'a>(&'a self) -> &'a UnsafeCell<Flavor<T>> {
|
||||||
&self.inner
|
&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>> {
|
fn inner_unsafe<'a>(&'a self) -> &'a UnsafeCell<Flavor<T>> {
|
||||||
&self.inner
|
&self.inner
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,12 +72,12 @@ struct Node<T> {
|
||||||
/// The multi-producer single-consumer structure. This is not cloneable, but it
|
/// 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
|
/// may be safely shared so long as it is guaranteed that there is only one
|
||||||
/// popper at a time (many pushers are allowed).
|
/// popper at a time (many pushers are allowed).
|
||||||
pub struct Queue<T: Send> {
|
pub struct Queue<T> {
|
||||||
head: AtomicPtr<Node<T>>,
|
head: AtomicPtr<Node<T>>,
|
||||||
tail: UnsafeCell<*mut 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> { }
|
unsafe impl<T: Send> Sync for Queue<T> { }
|
||||||
|
|
||||||
impl<T> Node<T> {
|
impl<T> Node<T> {
|
||||||
|
|
|
@ -54,7 +54,7 @@
|
||||||
// moves *from* a pointer, ownership of the token is transferred to
|
// moves *from* a pointer, ownership of the token is transferred to
|
||||||
// whoever changed the state.
|
// 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)
|
// Internal state of the chan/port pair (stores the blocked task as well)
|
||||||
state: AtomicUsize,
|
state: AtomicUsize,
|
||||||
// One-shot data slot location
|
// One-shot data slot location
|
||||||
|
@ -64,7 +64,7 @@ pub struct Packet<T:Send> {
|
||||||
upgrade: MyUpgrade<T>,
|
upgrade: MyUpgrade<T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum Failure<T:Send> {
|
pub enum Failure<T> {
|
||||||
Empty,
|
Empty,
|
||||||
Disconnected,
|
Disconnected,
|
||||||
Upgraded(Receiver<T>),
|
Upgraded(Receiver<T>),
|
||||||
|
@ -76,13 +76,13 @@ pub enum UpgradeResult {
|
||||||
UpWoke(SignalToken),
|
UpWoke(SignalToken),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum SelectionResult<T:Send> {
|
pub enum SelectionResult<T> {
|
||||||
SelCanceled,
|
SelCanceled,
|
||||||
SelUpgraded(SignalToken, Receiver<T>),
|
SelUpgraded(SignalToken, Receiver<T>),
|
||||||
SelSuccess,
|
SelSuccess,
|
||||||
}
|
}
|
||||||
|
|
||||||
enum MyUpgrade<T:Send> {
|
enum MyUpgrade<T> {
|
||||||
NothingSent,
|
NothingSent,
|
||||||
SendUsed,
|
SendUsed,
|
||||||
GoUp(Receiver<T>),
|
GoUp(Receiver<T>),
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
const MAX_STEALS: isize = 1 << 20;
|
const MAX_STEALS: isize = 1 << 20;
|
||||||
|
|
||||||
pub struct Packet<T: Send> {
|
pub struct Packet<T> {
|
||||||
queue: mpsc::Queue<T>,
|
queue: mpsc::Queue<T>,
|
||||||
cnt: AtomicIsize, // How many items are on this channel
|
cnt: AtomicIsize, // How many items are on this channel
|
||||||
steals: isize, // How many times has a port received without blocking?
|
steals: isize, // How many times has a port received without blocking?
|
||||||
|
|
|
@ -57,7 +57,7 @@ struct Node<T> {
|
||||||
/// but it can be safely shared in an Arc if it is guaranteed that there
|
/// 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
|
/// is only one popper and one pusher touching the queue at any one point in
|
||||||
/// time.
|
/// time.
|
||||||
pub struct Queue<T: Send> {
|
pub struct Queue<T> {
|
||||||
// consumer fields
|
// consumer fields
|
||||||
tail: UnsafeCell<*mut Node<T>>, // where to pop from
|
tail: UnsafeCell<*mut Node<T>>, // where to pop from
|
||||||
tail_prev: AtomicPtr<Node<T>>, // where to pop from
|
tail_prev: AtomicPtr<Node<T>>, // where to pop from
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
const MAX_STEALS: isize = 1 << 20;
|
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
|
queue: spsc::Queue<Message<T>>, // internal queue for all message
|
||||||
|
|
||||||
cnt: AtomicIsize, // How many items are on this channel
|
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.
|
port_dropped: AtomicBool, // flag if the channel has been destroyed.
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum Failure<T:Send> {
|
pub enum Failure<T> {
|
||||||
Empty,
|
Empty,
|
||||||
Disconnected,
|
Disconnected,
|
||||||
Upgraded(Receiver<T>),
|
Upgraded(Receiver<T>),
|
||||||
|
@ -61,7 +61,7 @@ pub enum UpgradeResult {
|
||||||
UpWoke(SignalToken),
|
UpWoke(SignalToken),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum SelectionResult<T:Send> {
|
pub enum SelectionResult<T> {
|
||||||
SelSuccess,
|
SelSuccess,
|
||||||
SelCanceled,
|
SelCanceled,
|
||||||
SelUpgraded(SignalToken, Receiver<T>),
|
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
|
// 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>
|
// internal queue it's a queue of T, but rather Message<T>
|
||||||
enum Message<T:Send> {
|
enum Message<T> {
|
||||||
Data(T),
|
Data(T),
|
||||||
GoUp(Receiver<T>),
|
GoUp(Receiver<T>),
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
use sync::mpsc::select::StartResult::{self, Installed, Abort};
|
use sync::mpsc::select::StartResult::{self, Installed, Abort};
|
||||||
use sync::{Mutex, MutexGuard};
|
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
|
/// Only field outside of the mutex. Just done for kicks, but mainly because
|
||||||
/// the other shared channel already had the code implemented
|
/// the other shared channel already had the code implemented
|
||||||
channels: AtomicUsize,
|
channels: AtomicUsize,
|
||||||
|
|
|
@ -112,7 +112,7 @@
|
||||||
/// *guard += 1;
|
/// *guard += 1;
|
||||||
/// ```
|
/// ```
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[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
|
// 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
|
// 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
|
// change (it can't be moved). This mutex type can be safely moved at any
|
||||||
|
|
|
@ -49,9 +49,9 @@
|
||||||
pub const TOKEN_READ: libc::DWORD = 0x20008;
|
pub const TOKEN_READ: libc::DWORD = 0x20008;
|
||||||
|
|
||||||
// Note that these are not actually HANDLEs, just values to pass to GetStdHandle
|
// Note that these are not actually HANDLEs, just values to pass to GetStdHandle
|
||||||
pub const STD_INPUT_HANDLE: libc::DWORD = -10;
|
pub const STD_INPUT_HANDLE: libc::DWORD = -10i32 as libc::DWORD;
|
||||||
pub const STD_OUTPUT_HANDLE: libc::DWORD = -11;
|
pub const STD_OUTPUT_HANDLE: libc::DWORD = -11i32 as libc::DWORD;
|
||||||
pub const STD_ERROR_HANDLE: libc::DWORD = -12;
|
pub const STD_ERROR_HANDLE: libc::DWORD = -12i32 as libc::DWORD;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[cfg(target_arch = "x86")]
|
#[cfg(target_arch = "x86")]
|
||||||
|
|
|
@ -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)));
|
|
||||||
}
|
|
Loading…
Reference in a new issue