Skip to content

Commit d49b67e

Browse files
committed
rollup merge of rust-lang#23176: huonw/rm-bounds
2 parents f92e7ab + 0f6b43a commit d49b67e

File tree

10 files changed

+38
-36
lines changed

10 files changed

+38
-36
lines changed

src/liballoc/arc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ impl<T> Deref for Arc<T> {
321321
}
322322
}
323323

324-
impl<T: Send + Sync + Clone> Arc<T> {
324+
impl<T: Clone> Arc<T> {
325325
/// Make a mutable reference from the given `Arc<T>`.
326326
///
327327
/// This is also referred to as a copy-on-write operation because the inner
@@ -465,7 +465,7 @@ impl<T> Weak<T> {
465465

466466
#[unstable(feature = "alloc",
467467
reason = "Weak pointers may not belong in this module.")]
468-
impl<T: Sync + Send> Clone for Weak<T> {
468+
impl<T> Clone for Weak<T> {
469469
/// Makes a clone of the `Weak<T>`.
470470
///
471471
/// This increases the weak reference count.

src/libstd/sync/mpsc/mod.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ impl<T:Send> UnsafeFlavor<T> for Receiver<T> {
488488
/// println!("{:?}", rx.recv().unwrap());
489489
/// ```
490490
#[stable(feature = "rust1", since = "1.0.0")]
491-
pub fn channel<T: Send>() -> (Sender<T>, Receiver<T>) {
491+
pub fn channel<T>() -> (Sender<T>, Receiver<T>) {
492492
let a = Arc::new(UnsafeCell::new(oneshot::Packet::new()));
493493
(Sender::new(Flavor::Oneshot(a.clone())), Receiver::new(Flavor::Oneshot(a)))
494494
}
@@ -528,7 +528,7 @@ pub fn channel<T: Send>() -> (Sender<T>, Receiver<T>) {
528528
/// assert_eq!(rx.recv().unwrap(), 2);
529529
/// ```
530530
#[stable(feature = "rust1", since = "1.0.0")]
531-
pub fn sync_channel<T: Send>(bound: usize) -> (SyncSender<T>, Receiver<T>) {
531+
pub fn sync_channel<T>(bound: usize) -> (SyncSender<T>, Receiver<T>) {
532532
let a = Arc::new(UnsafeCell::new(sync::Packet::new(bound)));
533533
(SyncSender::new(a.clone()), Receiver::new(Flavor::Sync(a)))
534534
}
@@ -537,7 +537,7 @@ pub fn sync_channel<T: Send>(bound: usize) -> (SyncSender<T>, Receiver<T>) {
537537
// Sender
538538
////////////////////////////////////////////////////////////////////////////////
539539

540-
impl<T: Send> Sender<T> {
540+
impl<T> Sender<T> {
541541
fn new(inner: Flavor<T>) -> Sender<T> {
542542
Sender {
543543
inner: UnsafeCell::new(inner),
@@ -619,7 +619,7 @@ impl<T: Send> Sender<T> {
619619
}
620620

621621
#[stable(feature = "rust1", since = "1.0.0")]
622-
impl<T: Send> Clone for Sender<T> {
622+
impl<T> Clone for Sender<T> {
623623
fn clone(&self) -> Sender<T> {
624624
let (packet, sleeper, guard) = match *unsafe { self.inner() } {
625625
Flavor::Oneshot(ref p) => {
@@ -665,7 +665,7 @@ impl<T: Send> Clone for Sender<T> {
665665

666666
#[unsafe_destructor]
667667
#[stable(feature = "rust1", since = "1.0.0")]
668-
impl<T: Send> Drop for Sender<T> {
668+
impl<T> Drop for Sender<T> {
669669
fn drop(&mut self) {
670670
match *unsafe { self.inner_mut() } {
671671
Flavor::Oneshot(ref mut p) => unsafe { (*p.get()).drop_chan(); },
@@ -680,7 +680,7 @@ impl<T: Send> Drop for Sender<T> {
680680
// SyncSender
681681
////////////////////////////////////////////////////////////////////////////////
682682

683-
impl<T: Send> SyncSender<T> {
683+
impl<T> SyncSender<T> {
684684
fn new(inner: Arc<UnsafeCell<sync::Packet<T>>>) -> SyncSender<T> {
685685
SyncSender { inner: inner }
686686
}
@@ -720,7 +720,7 @@ impl<T: Send> SyncSender<T> {
720720
}
721721

722722
#[stable(feature = "rust1", since = "1.0.0")]
723-
impl<T: Send> Clone for SyncSender<T> {
723+
impl<T> Clone for SyncSender<T> {
724724
fn clone(&self) -> SyncSender<T> {
725725
unsafe { (*self.inner.get()).clone_chan(); }
726726
return SyncSender::new(self.inner.clone());
@@ -729,7 +729,7 @@ impl<T: Send> Clone for SyncSender<T> {
729729

730730
#[unsafe_destructor]
731731
#[stable(feature = "rust1", since = "1.0.0")]
732-
impl<T: Send> Drop for SyncSender<T> {
732+
impl<T> Drop for SyncSender<T> {
733733
fn drop(&mut self) {
734734
unsafe { (*self.inner.get()).drop_chan(); }
735735
}
@@ -739,7 +739,7 @@ impl<T: Send> Drop for SyncSender<T> {
739739
// Receiver
740740
////////////////////////////////////////////////////////////////////////////////
741741

742-
impl<T: Send> Receiver<T> {
742+
impl<T> Receiver<T> {
743743
fn new(inner: Flavor<T>) -> Receiver<T> {
744744
Receiver { inner: UnsafeCell::new(inner) }
745745
}
@@ -858,7 +858,7 @@ impl<T: Send> Receiver<T> {
858858
}
859859
}
860860

861-
impl<T: Send> select::Packet for Receiver<T> {
861+
impl<T> select::Packet for Receiver<T> {
862862
fn can_recv(&self) -> bool {
863863
loop {
864864
let new_port = match *unsafe { self.inner() } {
@@ -945,15 +945,15 @@ impl<T: Send> select::Packet for Receiver<T> {
945945
}
946946

947947
#[stable(feature = "rust1", since = "1.0.0")]
948-
impl<'a, T: Send> Iterator for Iter<'a, T> {
948+
impl<'a, T> Iterator for Iter<'a, T> {
949949
type Item = T;
950950

951951
fn next(&mut self) -> Option<T> { self.rx.recv().ok() }
952952
}
953953

954954
#[unsafe_destructor]
955955
#[stable(feature = "rust1", since = "1.0.0")]
956-
impl<T: Send> Drop for Receiver<T> {
956+
impl<T> Drop for Receiver<T> {
957957
fn drop(&mut self) {
958958
match *unsafe { self.inner_mut() } {
959959
Flavor::Oneshot(ref mut p) => unsafe { (*p.get()).drop_port(); },

src/libstd/sync/mpsc/mpsc_queue.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ impl<T> Node<T> {
8989
}
9090
}
9191

92-
impl<T: Send> Queue<T> {
92+
impl<T> Queue<T> {
9393
/// Creates a new queue that is safe to share among multiple producers and
9494
/// one consumer.
9595
pub fn new() -> Queue<T> {
@@ -140,7 +140,7 @@ impl<T: Send> Queue<T> {
140140

141141
#[unsafe_destructor]
142142
#[stable(feature = "rust1", since = "1.0.0")]
143-
impl<T: Send> Drop for Queue<T> {
143+
impl<T> Drop for Queue<T> {
144144
fn drop(&mut self) {
145145
unsafe {
146146
let mut cur = *self.tail.get();

src/libstd/sync/mpsc/oneshot.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ enum MyUpgrade<T:Send> {
8888
GoUp(Receiver<T>),
8989
}
9090

91-
impl<T: Send> Packet<T> {
91+
impl<T> Packet<T> {
9292
pub fn new() -> Packet<T> {
9393
Packet {
9494
data: None,
@@ -368,7 +368,7 @@ impl<T: Send> Packet<T> {
368368
}
369369

370370
#[unsafe_destructor]
371-
impl<T: Send> Drop for Packet<T> {
371+
impl<T> Drop for Packet<T> {
372372
fn drop(&mut self) {
373373
assert_eq!(self.state.load(Ordering::SeqCst), DISCONNECTED);
374374
}

src/libstd/sync/mpsc/shared.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pub enum Failure {
6464
Disconnected,
6565
}
6666

67-
impl<T: Send> Packet<T> {
67+
impl<T> Packet<T> {
6868
// Creation of a packet *must* be followed by a call to postinit_lock
6969
// and later by inherit_blocker
7070
pub fn new() -> Packet<T> {
@@ -474,7 +474,7 @@ impl<T: Send> Packet<T> {
474474
}
475475

476476
#[unsafe_destructor]
477-
impl<T: Send> Drop for Packet<T> {
477+
impl<T> Drop for Packet<T> {
478478
fn drop(&mut self) {
479479
// Note that this load is not only an assert for correctness about
480480
// disconnection, but also a proper fence before the read of

src/libstd/sync/mpsc/spsc_queue.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ unsafe impl<T: Send> Send for Queue<T> { }
7878

7979
unsafe impl<T: Send> Sync for Queue<T> { }
8080

81-
impl<T: Send> Node<T> {
81+
impl<T> Node<T> {
8282
fn new() -> *mut Node<T> {
8383
unsafe {
8484
boxed::into_raw(box Node {
@@ -89,7 +89,7 @@ impl<T: Send> Node<T> {
8989
}
9090
}
9191

92-
impl<T: Send> Queue<T> {
92+
impl<T> Queue<T> {
9393
/// Creates a new queue.
9494
///
9595
/// This is unsafe as the type system doesn't enforce a single
@@ -227,7 +227,7 @@ impl<T: Send> Queue<T> {
227227
}
228228

229229
#[unsafe_destructor]
230-
impl<T: Send> Drop for Queue<T> {
230+
impl<T> Drop for Queue<T> {
231231
fn drop(&mut self) {
232232
unsafe {
233233
let mut cur = *self.first.get();

src/libstd/sync/mpsc/stream.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ enum Message<T:Send> {
7474
GoUp(Receiver<T>),
7575
}
7676

77-
impl<T: Send> Packet<T> {
77+
impl<T> Packet<T> {
7878
pub fn new() -> Packet<T> {
7979
Packet {
8080
queue: unsafe { spsc::Queue::new(128) },
@@ -472,7 +472,7 @@ impl<T: Send> Packet<T> {
472472
}
473473

474474
#[unsafe_destructor]
475-
impl<T: Send> Drop for Packet<T> {
475+
impl<T> Drop for Packet<T> {
476476
fn drop(&mut self) {
477477
// Note that this load is not only an assert for correctness about
478478
// disconnection, but also a proper fence before the read of

src/libstd/sync/mpsc/sync.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,10 @@ pub enum Failure {
113113

114114
/// Atomically blocks the current thread, placing it into `slot`, unlocking `lock`
115115
/// in the meantime. This re-locks the mutex upon returning.
116-
fn wait<'a, 'b, T: Send>(lock: &'a Mutex<State<T>>,
117-
mut guard: MutexGuard<'b, State<T>>,
118-
f: fn(SignalToken) -> Blocker)
119-
-> MutexGuard<'a, State<T>>
116+
fn wait<'a, 'b, T>(lock: &'a Mutex<State<T>>,
117+
mut guard: MutexGuard<'b, State<T>>,
118+
f: fn(SignalToken) -> Blocker)
119+
-> MutexGuard<'a, State<T>>
120120
{
121121
let (wait_token, signal_token) = blocking::tokens();
122122
match mem::replace(&mut guard.blocker, f(signal_token)) {
@@ -136,7 +136,7 @@ fn wakeup<T>(token: SignalToken, guard: MutexGuard<State<T>>) {
136136
token.signal();
137137
}
138138

139-
impl<T: Send> Packet<T> {
139+
impl<T> Packet<T> {
140140
pub fn new(cap: usize) -> Packet<T> {
141141
Packet {
142142
channels: AtomicUsize::new(1),
@@ -412,7 +412,7 @@ impl<T: Send> Packet<T> {
412412
}
413413

414414
#[unsafe_destructor]
415-
impl<T: Send> Drop for Packet<T> {
415+
impl<T> Drop for Packet<T> {
416416
fn drop(&mut self) {
417417
assert_eq!(self.channels.load(Ordering::SeqCst), 0);
418418
let mut guard = self.lock.lock().unwrap();

src/libstd/sync/mutex.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ pub struct Mutex<T: Send> {
122122
data: UnsafeCell<T>,
123123
}
124124

125+
// these are the only places where `T: Send` matters; all other
126+
// functionality works fine on a single thread.
125127
unsafe impl<T: Send> Send for Mutex<T> { }
126128

127129
unsafe impl<T: Send> Sync for Mutex<T> { }
@@ -181,7 +183,7 @@ pub const MUTEX_INIT: StaticMutex = StaticMutex {
181183
poison: poison::FLAG_INIT,
182184
};
183185

184-
impl<T: Send> Mutex<T> {
186+
impl<T> Mutex<T> {
185187
/// Creates a new mutex in an unlocked state ready for use.
186188
#[stable(feature = "rust1", since = "1.0.0")]
187189
pub fn new(t: T) -> Mutex<T> {
@@ -244,7 +246,7 @@ impl<T: Send> Mutex<T> {
244246

245247
#[unsafe_destructor]
246248
#[stable(feature = "rust1", since = "1.0.0")]
247-
impl<T: Send> Drop for Mutex<T> {
249+
impl<T> Drop for Mutex<T> {
248250
fn drop(&mut self) {
249251
// This is actually safe b/c we know that there is no further usage of
250252
// this mutex (it's up to the user to arrange for a mutex to get
@@ -254,7 +256,7 @@ impl<T: Send> Drop for Mutex<T> {
254256
}
255257

256258
#[stable(feature = "rust1", since = "1.0.0")]
257-
impl<T: fmt::Debug + Send + 'static> fmt::Debug for Mutex<T> {
259+
impl<T: fmt::Debug + 'static> fmt::Debug for Mutex<T> {
258260
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
259261
match self.try_lock() {
260262
Ok(guard) => write!(f, "Mutex {{ data: {:?} }}", *guard),

src/libstd/sync/rwlock.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ pub struct RwLockWriteGuard<'a, T: 'a> {
130130

131131
impl<'a, T> !marker::Send for RwLockWriteGuard<'a, T> {}
132132

133-
impl<T: Send + Sync> RwLock<T> {
133+
impl<T> RwLock<T> {
134134
/// Creates a new instance of an `RwLock<T>` which is unlocked.
135135
///
136136
/// # Examples
@@ -258,7 +258,7 @@ impl<T> Drop for RwLock<T> {
258258
}
259259

260260
#[stable(feature = "rust1", since = "1.0.0")]
261-
impl<T: fmt::Debug + Send + Sync> fmt::Debug for RwLock<T> {
261+
impl<T: fmt::Debug> fmt::Debug for RwLock<T> {
262262
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
263263
match self.try_read() {
264264
Ok(guard) => write!(f, "RwLock {{ data: {:?} }}", *guard),

0 commit comments

Comments
 (0)