Skip to content

Commit 59ad1c0

Browse files
committed
Merge pull request #19832 from japaric/no-nocopy
Remove internal uses of the `NoCopy` marker Reviewed-by: alexcrichton
2 parents 387385e + c3778fa commit 59ad1c0

File tree

11 files changed

+19
-48
lines changed

11 files changed

+19
-48
lines changed

src/libcollections/btree/node.rs

-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ pub use self::TraversalItem::*;
1818
use core::prelude::*;
1919

2020
use core::{slice, mem, ptr, cmp, num, raw};
21-
use core::kinds::marker;
2221
use core::iter::Zip;
2322
use core::borrow::BorrowFrom;
2423
use alloc::heap;
@@ -175,7 +174,6 @@ fn calculate_offsets_generic<K, V>(capacity: uint, is_leaf: bool) -> (uint, uint
175174
struct RawItems<T> {
176175
head: *const T,
177176
tail: *const T,
178-
marker: marker::NoCopy
179177
}
180178

181179
impl<T> RawItems<T> {
@@ -188,13 +186,11 @@ impl<T> RawItems<T> {
188186
RawItems {
189187
head: ptr,
190188
tail: (ptr as uint + len) as *const T,
191-
marker: marker::NoCopy
192189
}
193190
} else {
194191
RawItems {
195192
head: ptr,
196193
tail: ptr.offset(len as int),
197-
marker: marker::NoCopy
198194
}
199195
}
200196
}

src/libcollections/ring_buf.rs

-2
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,6 @@ impl<T> RingBuf<T> {
402402
cap: self.cap,
403403
ptr: self.ptr,
404404
marker: marker::ContravariantLifetime::<'a>,
405-
marker2: marker::NoCopy
406405
}
407406
}
408407

@@ -952,7 +951,6 @@ pub struct MutItems<'a, T:'a> {
952951
head: uint,
953952
cap: uint,
954953
marker: marker::ContravariantLifetime<'a>,
955-
marker2: marker::NoCopy
956954
}
957955

958956
impl<'a, T> Iterator<&'a mut T> for MutItems<'a, T> {

src/libcore/atomic.rs

+7-12
Original file line numberDiff line numberDiff line change
@@ -15,36 +15,31 @@
1515
pub use self::Ordering::*;
1616

1717
use intrinsics;
18-
use std::kinds::marker;
1918
use cell::UnsafeCell;
2019
use kinds::Copy;
2120

2221
/// A boolean type which can be safely shared between threads.
2322
#[stable]
2423
pub struct AtomicBool {
2524
v: UnsafeCell<uint>,
26-
nocopy: marker::NoCopy
2725
}
2826

2927
/// A signed integer type which can be safely shared between threads.
3028
#[stable]
3129
pub struct AtomicInt {
3230
v: UnsafeCell<int>,
33-
nocopy: marker::NoCopy
3431
}
3532

3633
/// An unsigned integer type which can be safely shared between threads.
3734
#[stable]
3835
pub struct AtomicUint {
3936
v: UnsafeCell<uint>,
40-
nocopy: marker::NoCopy
4137
}
4238

4339
/// A raw pointer type which can be safely shared between threads.
4440
#[stable]
4541
pub struct AtomicPtr<T> {
4642
p: UnsafeCell<uint>,
47-
nocopy: marker::NoCopy
4843
}
4944

5045
/// Atomic memory orderings
@@ -87,15 +82,15 @@ impl Copy for Ordering {}
8782
/// An `AtomicBool` initialized to `false`.
8883
#[unstable = "may be renamed, pending conventions for static initalizers"]
8984
pub const INIT_ATOMIC_BOOL: AtomicBool =
90-
AtomicBool { v: UnsafeCell { value: 0 }, nocopy: marker::NoCopy };
85+
AtomicBool { v: UnsafeCell { value: 0 } };
9186
/// An `AtomicInt` initialized to `0`.
9287
#[unstable = "may be renamed, pending conventions for static initalizers"]
9388
pub const INIT_ATOMIC_INT: AtomicInt =
94-
AtomicInt { v: UnsafeCell { value: 0 }, nocopy: marker::NoCopy };
89+
AtomicInt { v: UnsafeCell { value: 0 } };
9590
/// An `AtomicUint` initialized to `0`.
9691
#[unstable = "may be renamed, pending conventions for static initalizers"]
9792
pub const INIT_ATOMIC_UINT: AtomicUint =
98-
AtomicUint { v: UnsafeCell { value: 0, }, nocopy: marker::NoCopy };
93+
AtomicUint { v: UnsafeCell { value: 0, } };
9994

10095
// NB: Needs to be -1 (0b11111111...) to make fetch_nand work correctly
10196
const UINT_TRUE: uint = -1;
@@ -115,7 +110,7 @@ impl AtomicBool {
115110
#[stable]
116111
pub fn new(v: bool) -> AtomicBool {
117112
let val = if v { UINT_TRUE } else { 0 };
118-
AtomicBool { v: UnsafeCell::new(val), nocopy: marker::NoCopy }
113+
AtomicBool { v: UnsafeCell::new(val) }
119114
}
120115

121116
/// Loads a value from the bool.
@@ -355,7 +350,7 @@ impl AtomicInt {
355350
#[inline]
356351
#[stable]
357352
pub fn new(v: int) -> AtomicInt {
358-
AtomicInt {v: UnsafeCell::new(v), nocopy: marker::NoCopy}
353+
AtomicInt {v: UnsafeCell::new(v)}
359354
}
360355

361356
/// Loads a value from the int.
@@ -541,7 +536,7 @@ impl AtomicUint {
541536
#[inline]
542537
#[stable]
543538
pub fn new(v: uint) -> AtomicUint {
544-
AtomicUint { v: UnsafeCell::new(v), nocopy: marker::NoCopy }
539+
AtomicUint { v: UnsafeCell::new(v) }
545540
}
546541

547542
/// Loads a value from the uint.
@@ -728,7 +723,7 @@ impl<T> AtomicPtr<T> {
728723
#[inline]
729724
#[stable]
730725
pub fn new(p: *mut T) -> AtomicPtr<T> {
731-
AtomicPtr { p: UnsafeCell::new(p as uint), nocopy: marker::NoCopy }
726+
AtomicPtr { p: UnsafeCell::new(p as uint) }
732727
}
733728

734729
/// Loads a value from the pointer.

src/libcore/cell.rs

-2
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,6 @@ impl<T:PartialEq + Copy> PartialEq for Cell<T> {
234234
pub struct RefCell<T> {
235235
value: UnsafeCell<T>,
236236
borrow: Cell<BorrowFlag>,
237-
nocopy: marker::NoCopy,
238237
noshare: marker::NoSync,
239238
}
240239

@@ -251,7 +250,6 @@ impl<T> RefCell<T> {
251250
RefCell {
252251
value: UnsafeCell::new(value),
253252
borrow: Cell::new(UNUSED),
254-
nocopy: marker::NoCopy,
255253
noshare: marker::NoSync,
256254
}
257255
}

src/libcore/slice.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -292,13 +292,11 @@ impl<T> SliceExt<T> for [T] {
292292
if mem::size_of::<T>() == 0 {
293293
MutItems{ptr: p,
294294
end: (p as uint + self.len()) as *mut T,
295-
marker: marker::ContravariantLifetime::<'a>,
296-
marker2: marker::NoCopy}
295+
marker: marker::ContravariantLifetime::<'a>}
297296
} else {
298297
MutItems{ptr: p,
299298
end: p.offset(self.len() as int),
300-
marker: marker::ContravariantLifetime::<'a>,
301-
marker2: marker::NoCopy}
299+
marker: marker::ContravariantLifetime::<'a>}
302300
}
303301
}
304302
}
@@ -818,7 +816,6 @@ pub struct MutItems<'a, T: 'a> {
818816
ptr: *mut T,
819817
end: *mut T,
820818
marker: marker::ContravariantLifetime<'a>,
821-
marker2: marker::NoCopy
822819
}
823820

824821
#[experimental]

src/librustc/util/snapshot_vec.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
//! those changes.
2121
use self::UndoLog::*;
2222

23-
use std::kinds::marker;
2423
use std::mem;
2524

2625
#[deriving(PartialEq)]
@@ -47,10 +46,9 @@ pub struct SnapshotVec<T,U,D> {
4746
delegate: D
4847
}
4948

49+
// Snapshots are tokens that should be created/consumed linearly.
50+
#[allow(missing_copy_implementations)]
5051
pub struct Snapshot {
51-
// Snapshots are tokens that should be created/consumed linearly.
52-
marker: marker::NoCopy,
53-
5452
// Length of the undo log at the time the snapshot was taken.
5553
length: uint,
5654
}
@@ -112,8 +110,7 @@ impl<T,U,D:SnapshotVecDelegate<T,U>> SnapshotVec<T,U,D> {
112110
pub fn start_snapshot(&mut self) -> Snapshot {
113111
let length = self.undo_log.len();
114112
self.undo_log.push(OpenSnapshot);
115-
Snapshot { length: length,
116-
marker: marker::NoCopy }
113+
Snapshot { length: length }
117114
}
118115

119116
fn assert_open_snapshot(&self, snapshot: &Snapshot) {

src/librustrt/task.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ use alloc::boxed::Box;
2020
use core::any::Any;
2121
use core::atomic::{AtomicUint, SeqCst};
2222
use core::iter::{IteratorExt, Take};
23-
use core::kinds::marker;
2423
use core::ops::FnOnce;
2524
use core::mem;
2625
use core::ops::FnMut;
@@ -95,7 +94,6 @@ pub enum BlockedTask {
9594
/// Per-task state related to task death, killing, panic, etc.
9695
pub struct Death {
9796
pub on_exit: Option<Thunk<Result>>,
98-
marker: marker::NoCopy,
9997
}
10098

10199
pub struct BlockedTasks {
@@ -499,7 +497,7 @@ impl BlockedTask {
499497

500498
impl Death {
501499
pub fn new() -> Death {
502-
Death { on_exit: None, marker: marker::NoCopy }
500+
Death { on_exit: None }
503501
}
504502
}
505503

src/libstd/rand/os.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,10 @@ mod imp {
186186
/// service provider with the `PROV_RSA_FULL` type.
187187
/// - iOS: calls SecRandomCopyBytes as /dev/(u)random is sandboxed
188188
/// This does not block.
189+
#[allow(missing_copy_implementations)]
189190
pub struct OsRng {
190-
marker: marker::NoCopy
191+
// dummy field to ensure that this struct cannot be constructed outside of this module
192+
_dummy: (),
191193
}
192194

193195
#[repr(C)]
@@ -205,7 +207,7 @@ mod imp {
205207
impl OsRng {
206208
/// Create a new `OsRng`.
207209
pub fn new() -> IoResult<OsRng> {
208-
Ok(OsRng {marker: marker::NoCopy} )
210+
Ok(OsRng { _dummy: () })
209211
}
210212
}
211213

src/libstd/sys/common/thread_local.rs

-3
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858

5959
use prelude::*;
6060

61-
use kinds::marker;
6261
use rustrt::exclusive::Exclusive;
6362
use sync::atomic::{mod, AtomicUint};
6463
use sync::{Once, ONCE_INIT};
@@ -100,7 +99,6 @@ pub struct StaticKey {
10099
/// Inner contents of `StaticKey`, created by the `INIT_INNER` constant.
101100
pub struct StaticKeyInner {
102101
key: AtomicUint,
103-
nc: marker::NoCopy,
104102
}
105103

106104
/// A type for a safely managed OS-based TLS slot.
@@ -141,7 +139,6 @@ pub const INIT: StaticKey = StaticKey {
141139
/// This value allows specific configuration of the destructor for a TLS key.
142140
pub const INIT_INNER: StaticKeyInner = StaticKeyInner {
143141
key: atomic::INIT_ATOMIC_UINT,
144-
nc: marker::NoCopy,
145142
};
146143

147144
static INIT_KEYS: Once = ONCE_INIT;

src/libstd/task.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ use boxed::Box;
4949
use comm::channel;
5050
use core::ops::FnOnce;
5151
use io::{Writer, stdio};
52-
use kinds::{Send, marker};
52+
use kinds::Send;
5353
use option::Option;
5454
use option::Option::{None, Some};
5555
use result::Result;
@@ -83,7 +83,6 @@ pub struct TaskBuilder {
8383
stderr: Option<Box<Writer + Send>>,
8484
// Optionally wrap the eventual task body
8585
gen_body: Option<Thunk<Thunk, Thunk>>,
86-
nocopy: marker::NoCopy,
8786
}
8887

8988
impl TaskBuilder {
@@ -96,7 +95,6 @@ impl TaskBuilder {
9695
stdout: None,
9796
stderr: None,
9897
gen_body: None,
99-
nocopy: marker::NoCopy,
10098
}
10199
}
102100
}
@@ -137,7 +135,7 @@ impl TaskBuilder {
137135
on_exit: Option<Thunk<task::Result>>)
138136
{
139137
let TaskBuilder {
140-
name, stack_size, stdout, stderr, mut gen_body, nocopy: _
138+
name, stack_size, stdout, stderr, mut gen_body
141139
} = self;
142140

143141
let f = match gen_body.take() {

src/libstd/thread_local/mod.rs

-5
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ macro_rules! __thread_local_inner(
185185
inner: ::std::cell::UnsafeCell { value: $init },
186186
dtor_registered: ::std::cell::UnsafeCell { value: false },
187187
dtor_running: ::std::cell::UnsafeCell { value: false },
188-
marker: ::std::kinds::marker::NoCopy,
189188
}
190189
};
191190

@@ -247,7 +246,6 @@ mod imp {
247246

248247
use cell::UnsafeCell;
249248
use intrinsics;
250-
use kinds::marker;
251249
use ptr;
252250

253251
#[doc(hidden)]
@@ -264,9 +262,6 @@ mod imp {
264262
// these variables are thread-local, not global.
265263
pub dtor_registered: UnsafeCell<bool>, // should be Cell
266264
pub dtor_running: UnsafeCell<bool>, // should be Cell
267-
268-
// These shouldn't be copied around.
269-
pub marker: marker::NoCopy,
270265
}
271266

272267
#[doc(hidden)]

0 commit comments

Comments
 (0)