Skip to content

Commit b8601a3

Browse files
committed
auto merge of #13160 : FlaPer87/rust/rename-pod, r=thestinger
So far, we've used the term POD "Plain Old Data" to refer to types that can be safely copied. However, this term is not consistent with the other built-in bounds that use verbs instead. This patch renames the `Pod` kind into `Copy`. RFC: 0003-opt-in-builtin-traits r? @nikomatsakis
2 parents 794ee03 + 81ec1f3 commit b8601a3

35 files changed

+233
-218
lines changed

src/doc/guide-unsafe.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ Other features provided by lang items include:
595595
- stack unwinding and general failure; the `eh_personality`, `fail_`
596596
and `fail_bounds_checks` lang items.
597597
- the traits in `std::kinds` used to indicate types that satisfy
598-
various kinds; lang items `send`, `share` and `pod`.
598+
various kinds; lang items `send`, `share` and `copy`.
599599
- the marker types and variance indicators found in
600600
`std::kinds::markers`; lang items `covariant_type`,
601601
`contravariant_lifetime`, `no_share_bound`, etc.

src/doc/rust.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -3439,12 +3439,12 @@ The kinds are:
34393439
This kind includes scalars, owning pointers, owned closures, and
34403440
structural types containing only other owned types.
34413441
All `Send` types are `'static`.
3442-
`Pod`
3442+
`Copy`
34433443
: Types of this kind consist of "Plain Old Data"
34443444
which can be copied by simply moving bits.
34453445
All values of this kind can be implicitly copied.
34463446
This kind includes scalars and immutable references,
3447-
as well as structural types containing other `Pod` types.
3447+
as well as structural types containing other `Copy` types.
34483448
`'static`
34493449
: Types of this kind do not contain any references (except for
34503450
references with the `static` lifetime, which are allowed).

src/etc/vim/syntax/rust.vim

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ syn keyword rustType f64 i8 i16 i32 i64 str Self
5252
" to make it easy to update.
5353

5454
" Core operators {{{3
55-
syn keyword rustTrait Freeze Pod Send Sized
55+
syn keyword rustTrait Freeze Copy Send Sized
5656
syn keyword rustTrait Add Sub Mul Div Rem Neg Not
5757
syn keyword rustTrait BitAnd BitOr BitXor
5858
syn keyword rustTrait Drop

src/libarena/lib.rs

+39-39
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ use std::intrinsics;
4848
struct Chunk {
4949
data: Rc<RefCell<Vec<u8> >>,
5050
fill: Cell<uint>,
51-
is_pod: Cell<bool>,
51+
is_copy: Cell<bool>,
5252
}
5353
impl Chunk {
5454
fn capacity(&self) -> uint {
@@ -86,7 +86,7 @@ pub struct Arena {
8686
// microoptimization, to avoid needing to case on the list to
8787
// access the head.
8888
priv head: Chunk,
89-
priv pod_head: Chunk,
89+
priv copy_head: Chunk,
9090
priv chunks: RefCell<@List<Chunk>>,
9191
}
9292

@@ -98,17 +98,17 @@ impl Arena {
9898
pub fn new_with_size(initial_size: uint) -> Arena {
9999
Arena {
100100
head: chunk(initial_size, false),
101-
pod_head: chunk(initial_size, true),
101+
copy_head: chunk(initial_size, true),
102102
chunks: RefCell::new(@Nil),
103103
}
104104
}
105105
}
106106

107-
fn chunk(size: uint, is_pod: bool) -> Chunk {
107+
fn chunk(size: uint, is_copy: bool) -> Chunk {
108108
Chunk {
109109
data: Rc::new(RefCell::new(Vec::with_capacity(size))),
110110
fill: Cell::new(0u),
111-
is_pod: Cell::new(is_pod),
111+
is_copy: Cell::new(is_copy),
112112
}
113113
}
114114

@@ -118,7 +118,7 @@ impl Drop for Arena {
118118
unsafe {
119119
destroy_chunk(&self.head);
120120
for chunk in self.chunks.get().iter() {
121-
if !chunk.is_pod.get() {
121+
if !chunk.is_copy.get() {
122122
destroy_chunk(chunk);
123123
}
124124
}
@@ -173,61 +173,61 @@ fn un_bitpack_tydesc_ptr(p: uint) -> (*TyDesc, bool) {
173173

174174
impl Arena {
175175
fn chunk_size(&self) -> uint {
176-
self.pod_head.capacity()
176+
self.copy_head.capacity()
177177
}
178178
// Functions for the POD part of the arena
179-
fn alloc_pod_grow(&mut self, n_bytes: uint, align: uint) -> *u8 {
179+
fn alloc_copy_grow(&mut self, n_bytes: uint, align: uint) -> *u8 {
180180
// Allocate a new chunk.
181181
let new_min_chunk_size = cmp::max(n_bytes, self.chunk_size());
182-
self.chunks.set(@Cons(self.pod_head.clone(), self.chunks.get()));
183-
self.pod_head =
182+
self.chunks.set(@Cons(self.copy_head.clone(), self.chunks.get()));
183+
self.copy_head =
184184
chunk(num::next_power_of_two(new_min_chunk_size + 1u), true);
185185

186-
return self.alloc_pod_inner(n_bytes, align);
186+
return self.alloc_copy_inner(n_bytes, align);
187187
}
188188

189189
#[inline]
190-
fn alloc_pod_inner(&mut self, n_bytes: uint, align: uint) -> *u8 {
190+
fn alloc_copy_inner(&mut self, n_bytes: uint, align: uint) -> *u8 {
191191
unsafe {
192192
let this = transmute_mut_region(self);
193-
let start = round_up(this.pod_head.fill.get(), align);
193+
let start = round_up(this.copy_head.fill.get(), align);
194194
let end = start + n_bytes;
195195
if end > self.chunk_size() {
196-
return this.alloc_pod_grow(n_bytes, align);
196+
return this.alloc_copy_grow(n_bytes, align);
197197
}
198-
this.pod_head.fill.set(end);
198+
this.copy_head.fill.set(end);
199199

200200
//debug!("idx = {}, size = {}, align = {}, fill = {}",
201201
// start, n_bytes, align, head.fill.get());
202202

203-
this.pod_head.as_ptr().offset(start as int)
203+
this.copy_head.as_ptr().offset(start as int)
204204
}
205205
}
206206

207207
#[inline]
208-
fn alloc_pod<'a, T>(&'a mut self, op: || -> T) -> &'a T {
208+
fn alloc_copy<'a, T>(&'a mut self, op: || -> T) -> &'a T {
209209
unsafe {
210-
let ptr = self.alloc_pod_inner(mem::size_of::<T>(), mem::min_align_of::<T>());
210+
let ptr = self.alloc_copy_inner(mem::size_of::<T>(), mem::min_align_of::<T>());
211211
let ptr: *mut T = transmute(ptr);
212212
mem::move_val_init(&mut (*ptr), op());
213213
return transmute(ptr);
214214
}
215215
}
216216

217217
// Functions for the non-POD part of the arena
218-
fn alloc_nonpod_grow(&mut self, n_bytes: uint, align: uint)
218+
fn alloc_noncopy_grow(&mut self, n_bytes: uint, align: uint)
219219
-> (*u8, *u8) {
220220
// Allocate a new chunk.
221221
let new_min_chunk_size = cmp::max(n_bytes, self.chunk_size());
222222
self.chunks.set(@Cons(self.head.clone(), self.chunks.get()));
223223
self.head =
224224
chunk(num::next_power_of_two(new_min_chunk_size + 1u), false);
225225

226-
return self.alloc_nonpod_inner(n_bytes, align);
226+
return self.alloc_noncopy_inner(n_bytes, align);
227227
}
228228

229229
#[inline]
230-
fn alloc_nonpod_inner(&mut self, n_bytes: uint, align: uint)
230+
fn alloc_noncopy_inner(&mut self, n_bytes: uint, align: uint)
231231
-> (*u8, *u8) {
232232
unsafe {
233233
let start;
@@ -245,7 +245,7 @@ impl Arena {
245245
}
246246

247247
if end > self.head.capacity() {
248-
return self.alloc_nonpod_grow(n_bytes, align);
248+
return self.alloc_noncopy_grow(n_bytes, align);
249249
}
250250

251251
let head = transmute_mut_region(&mut self.head);
@@ -260,11 +260,11 @@ impl Arena {
260260
}
261261

262262
#[inline]
263-
fn alloc_nonpod<'a, T>(&'a mut self, op: || -> T) -> &'a T {
263+
fn alloc_noncopy<'a, T>(&'a mut self, op: || -> T) -> &'a T {
264264
unsafe {
265265
let tydesc = get_tydesc::<T>();
266266
let (ty_ptr, ptr) =
267-
self.alloc_nonpod_inner(mem::size_of::<T>(), mem::min_align_of::<T>());
267+
self.alloc_noncopy_inner(mem::size_of::<T>(), mem::min_align_of::<T>());
268268
let ty_ptr: *mut uint = transmute(ty_ptr);
269269
let ptr: *mut T = transmute(ptr);
270270
// Write in our tydesc along with a bit indicating that it
@@ -287,9 +287,9 @@ impl Arena {
287287
// FIXME: Borrow check
288288
let this = transmute_mut(self);
289289
if intrinsics::needs_drop::<T>() {
290-
this.alloc_nonpod(op)
290+
this.alloc_noncopy(op)
291291
} else {
292-
this.alloc_pod(op)
292+
this.alloc_copy(op)
293293
}
294294
}
295295
}
@@ -496,7 +496,7 @@ mod tests {
496496
}
497497

498498
#[test]
499-
pub fn test_pod() {
499+
pub fn test_copy() {
500500
let arena = TypedArena::new();
501501
for _ in range(0, 100000) {
502502
arena.alloc(Point {
@@ -508,7 +508,7 @@ mod tests {
508508
}
509509

510510
#[bench]
511-
pub fn bench_pod(bh: &mut BenchHarness) {
511+
pub fn bench_copy(bh: &mut BenchHarness) {
512512
let arena = TypedArena::new();
513513
bh.iter(|| {
514514
arena.alloc(Point {
@@ -520,7 +520,7 @@ mod tests {
520520
}
521521

522522
#[bench]
523-
pub fn bench_pod_nonarena(bh: &mut BenchHarness) {
523+
pub fn bench_copy_nonarena(bh: &mut BenchHarness) {
524524
bh.iter(|| {
525525
~Point {
526526
x: 1,
@@ -531,7 +531,7 @@ mod tests {
531531
}
532532

533533
#[bench]
534-
pub fn bench_pod_old_arena(bh: &mut BenchHarness) {
534+
pub fn bench_copy_old_arena(bh: &mut BenchHarness) {
535535
let arena = Arena::new();
536536
bh.iter(|| {
537537
arena.alloc(|| {
@@ -544,48 +544,48 @@ mod tests {
544544
})
545545
}
546546

547-
struct Nonpod {
547+
struct Noncopy {
548548
string: ~str,
549549
array: Vec<int> ,
550550
}
551551

552552
#[test]
553-
pub fn test_nonpod() {
553+
pub fn test_noncopy() {
554554
let arena = TypedArena::new();
555555
for _ in range(0, 100000) {
556-
arena.alloc(Nonpod {
556+
arena.alloc(Noncopy {
557557
string: ~"hello world",
558558
array: vec!( 1, 2, 3, 4, 5 ),
559559
});
560560
}
561561
}
562562

563563
#[bench]
564-
pub fn bench_nonpod(bh: &mut BenchHarness) {
564+
pub fn bench_noncopy(bh: &mut BenchHarness) {
565565
let arena = TypedArena::new();
566566
bh.iter(|| {
567-
arena.alloc(Nonpod {
567+
arena.alloc(Noncopy {
568568
string: ~"hello world",
569569
array: vec!( 1, 2, 3, 4, 5 ),
570570
})
571571
})
572572
}
573573

574574
#[bench]
575-
pub fn bench_nonpod_nonarena(bh: &mut BenchHarness) {
575+
pub fn bench_noncopy_nonarena(bh: &mut BenchHarness) {
576576
bh.iter(|| {
577-
~Nonpod {
577+
~Noncopy {
578578
string: ~"hello world",
579579
array: vec!( 1, 2, 3, 4, 5 ),
580580
}
581581
})
582582
}
583583

584584
#[bench]
585-
pub fn bench_nonpod_old_arena(bh: &mut BenchHarness) {
585+
pub fn bench_noncopy_old_arena(bh: &mut BenchHarness) {
586586
let arena = Arena::new();
587587
bh.iter(|| {
588-
arena.alloc(|| Nonpod {
588+
arena.alloc(|| Noncopy {
589589
string: ~"hello world",
590590
array: vec!( 1, 2, 3, 4, 5 ),
591591
})

src/libcollections/hashmap.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,15 @@ mod table {
110110
/// Represents an index into a `RawTable` with no key or value in it.
111111
pub struct EmptyIndex {
112112
priv idx: int,
113-
priv nopod: marker::NoPod,
113+
priv nocopy: marker::NoCopy,
114114
}
115115

116116
/// Represents an index into a `RawTable` with a key, value, and hash
117117
/// in it.
118118
pub struct FullIndex {
119119
priv idx: int,
120120
priv hash: SafeHash,
121-
priv nopod: marker::NoPod,
121+
priv nocopy: marker::NoCopy,
122122
}
123123

124124
impl FullIndex {
@@ -237,19 +237,19 @@ mod table {
237237
let idx = index as int;
238238
let hash = unsafe { *self.hashes.offset(idx) };
239239

240-
let nopod = marker::NoPod;
240+
let nocopy = marker::NoCopy;
241241

242242
match hash {
243243
EMPTY_BUCKET =>
244244
Empty(EmptyIndex {
245245
idx: idx,
246-
nopod: nopod
246+
nocopy: nocopy
247247
}),
248248
full_hash =>
249249
Full(FullIndex {
250250
idx: idx,
251251
hash: SafeHash { hash: full_hash },
252-
nopod: nopod,
252+
nocopy: nocopy,
253253
})
254254
}
255255
}
@@ -320,7 +320,7 @@ mod table {
320320

321321
self.size += 1;
322322

323-
FullIndex { idx: idx, hash: hash, nopod: marker::NoPod }
323+
FullIndex { idx: idx, hash: hash, nocopy: marker::NoCopy }
324324
}
325325

326326
/// Removes a key and value from the hashtable.
@@ -347,7 +347,7 @@ mod table {
347347

348348
self.size -= 1;
349349

350-
(EmptyIndex { idx: idx, nopod: marker::NoPod }, k, v)
350+
(EmptyIndex { idx: idx, nocopy: marker::NoCopy }, k, v)
351351
}
352352
}
353353

src/librustc/metadata/tydecode.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ fn parse_bounds(st: &mut PState, conv: conv_did) -> ty::ParamBounds {
591591
param_bounds.builtin_bounds.add(ty::BoundSized);
592592
}
593593
'P' => {
594-
param_bounds.builtin_bounds.add(ty::BoundPod);
594+
param_bounds.builtin_bounds.add(ty::BoundCopy);
595595
}
596596
'T' => {
597597
param_bounds.builtin_bounds.add(ty::BoundShare);

src/librustc/metadata/tyencode.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ fn enc_bounds(w: &mut MemWriter, cx: &ctxt, bs: &ty::ParamBounds) {
394394
ty::BoundSend => mywrite!(w, "S"),
395395
ty::BoundStatic => mywrite!(w, "O"),
396396
ty::BoundSized => mywrite!(w, "Z"),
397-
ty::BoundPod => mywrite!(w, "P"),
397+
ty::BoundCopy => mywrite!(w, "P"),
398398
ty::BoundShare => mywrite!(w, "T"),
399399
}
400400
}

src/librustc/middle/lang_items.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ impl LanguageItems {
8686
Some(ty::BoundSend)
8787
} else if Some(id) == self.sized_trait() {
8888
Some(ty::BoundSized)
89-
} else if Some(id) == self.pod_trait() {
90-
Some(ty::BoundPod)
89+
} else if Some(id) == self.copy_trait() {
90+
Some(ty::BoundCopy)
9191
} else if Some(id) == self.share_trait() {
9292
Some(ty::BoundShare)
9393
} else {
@@ -210,7 +210,7 @@ lets_do_this! {
210210
// Variant name, Name, Method name;
211211
SendTraitLangItem, "send", send_trait;
212212
SizedTraitLangItem, "sized", sized_trait;
213-
PodTraitLangItem, "pod", pod_trait;
213+
CopyTraitLangItem, "copy", copy_trait;
214214
ShareTraitLangItem, "share", share_trait;
215215

216216
DropTraitLangItem, "drop", drop_trait;
@@ -271,7 +271,7 @@ lets_do_this! {
271271
InvariantLifetimeItem, "invariant_lifetime", invariant_lifetime;
272272

273273
NoSendItem, "no_send_bound", no_send_bound;
274-
NoPodItem, "no_pod_bound", no_pod_bound;
274+
NoCopyItem, "no_copy_bound", no_copy_bound;
275275
NoShareItem, "no_share_bound", no_share_bound;
276276
ManagedItem, "managed_bound", managed_bound;
277277
}

0 commit comments

Comments
 (0)