Skip to content

Commit 068344e

Browse files
committed
---
yaml --- r: 180158 b: refs/heads/tmp c: bbbb571 h: refs/heads/master v: v3
1 parent a0a0e58 commit 068344e

File tree

91 files changed

+301
-2052
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+301
-2052
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
3434
refs/heads/beta: 44a287e6eb22ec3c2a687fc156813577464017f7
3535
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3636
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
37-
refs/heads/tmp: c9fdfdb2bb53565953c2a7fbf1e1e938804f32e6
37+
refs/heads/tmp: bbbb571fee01532f63b105150654db8db0b01bf7

branches/tmp/src/libarena/lib.rs

Lines changed: 21 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ use std::cell::{Cell, RefCell};
4242
use std::cmp;
4343
use std::intrinsics::{TyDesc, get_tydesc};
4444
use std::intrinsics;
45-
use std::marker;
4645
use std::mem;
4746
use std::num::{Int, UnsignedInt};
4847
use std::ptr;
@@ -89,29 +88,27 @@ impl Chunk {
8988
/// than objects without destructors. This reduces overhead when initializing
9089
/// plain-old-data (`Copy` types) and means we don't need to waste time running
9190
/// their destructors.
92-
pub struct Arena<'longer_than_self> {
91+
pub struct Arena {
9392
// The head is separated out from the list as a unbenchmarked
9493
// microoptimization, to avoid needing to case on the list to access the
9594
// head.
9695
head: RefCell<Chunk>,
9796
copy_head: RefCell<Chunk>,
9897
chunks: RefCell<Vec<Chunk>>,
99-
_invariant: marker::InvariantLifetime<'longer_than_self>,
10098
}
10199

102-
impl<'a> Arena<'a> {
100+
impl Arena {
103101
/// Allocates a new Arena with 32 bytes preallocated.
104-
pub fn new() -> Arena<'a> {
102+
pub fn new() -> Arena {
105103
Arena::new_with_size(32)
106104
}
107105

108106
/// Allocates a new Arena with `initial_size` bytes preallocated.
109-
pub fn new_with_size(initial_size: usize) -> Arena<'a> {
107+
pub fn new_with_size(initial_size: usize) -> Arena {
110108
Arena {
111109
head: RefCell::new(chunk(initial_size, false)),
112110
copy_head: RefCell::new(chunk(initial_size, true)),
113111
chunks: RefCell::new(Vec::new()),
114-
_invariant: marker::InvariantLifetime,
115112
}
116113
}
117114
}
@@ -125,7 +122,7 @@ fn chunk(size: usize, is_copy: bool) -> Chunk {
125122
}
126123

127124
#[unsafe_destructor]
128-
impl<'longer_than_self> Drop for Arena<'longer_than_self> {
125+
impl Drop for Arena {
129126
fn drop(&mut self) {
130127
unsafe {
131128
destroy_chunk(&*self.head.borrow());
@@ -183,7 +180,7 @@ fn un_bitpack_tydesc_ptr(p: usize) -> (*const TyDesc, bool) {
183180
((p & !1) as *const TyDesc, p & 1 == 1)
184181
}
185182

186-
impl<'longer_than_self> Arena<'longer_than_self> {
183+
impl Arena {
187184
fn chunk_size(&self) -> usize {
188185
self.copy_head.borrow().capacity()
189186
}
@@ -296,7 +293,7 @@ impl<'longer_than_self> Arena<'longer_than_self> {
296293
/// Allocates a new item in the arena, using `op` to initialize the value,
297294
/// and returns a reference to it.
298295
#[inline]
299-
pub fn alloc<T:'longer_than_self, F>(&self, op: F) -> &mut T where F: FnOnce() -> T {
296+
pub fn alloc<T, F>(&self, op: F) -> &mut T where F: FnOnce() -> T {
300297
unsafe {
301298
if intrinsics::needs_drop::<T>() {
302299
self.alloc_noncopy(op)
@@ -320,6 +317,20 @@ fn test_arena_destructors() {
320317
}
321318
}
322319

320+
#[test]
321+
fn test_arena_alloc_nested() {
322+
struct Inner { value: usize }
323+
struct Outer<'a> { inner: &'a Inner }
324+
325+
let arena = Arena::new();
326+
327+
let result = arena.alloc(|| Outer {
328+
inner: arena.alloc(|| Inner { value: 10 })
329+
});
330+
331+
assert_eq!(result.inner.value, 10);
332+
}
333+
323334
#[test]
324335
#[should_fail]
325336
fn test_arena_destructors_fail() {
@@ -354,10 +365,6 @@ pub struct TypedArena<T> {
354365

355366
/// A pointer to the first arena segment.
356367
first: RefCell<*mut TypedArenaChunk<T>>,
357-
358-
/// Marker indicating that dropping the arena causes its owned
359-
/// instances of `T` to be dropped.
360-
_own: marker::PhantomData<T>,
361368
}
362369

363370
struct TypedArenaChunk<T> {
@@ -453,7 +460,6 @@ impl<T> TypedArena<T> {
453460
ptr: Cell::new((*chunk).start() as *const T),
454461
end: Cell::new((*chunk).end() as *const T),
455462
first: RefCell::new(chunk),
456-
_own: marker::PhantomData,
457463
}
458464
}
459465
}
@@ -517,41 +523,6 @@ mod tests {
517523
z: i32,
518524
}
519525

520-
#[test]
521-
fn test_arena_alloc_nested() {
522-
struct Inner { value: u8 }
523-
struct Outer<'a> { inner: &'a Inner }
524-
enum EI<'e> { I(Inner), O(Outer<'e>) }
525-
526-
struct Wrap<'a>(TypedArena<EI<'a>>);
527-
528-
impl<'a> Wrap<'a> {
529-
fn alloc_inner<F:Fn() -> Inner>(&self, f: F) -> &Inner {
530-
let r: &EI = self.0.alloc(EI::I(f()));
531-
if let &EI::I(ref i) = r {
532-
i
533-
} else {
534-
panic!("mismatch");
535-
}
536-
}
537-
fn alloc_outer<F:Fn() -> Outer<'a>>(&self, f: F) -> &Outer {
538-
let r: &EI = self.0.alloc(EI::O(f()));
539-
if let &EI::O(ref o) = r {
540-
o
541-
} else {
542-
panic!("mismatch");
543-
}
544-
}
545-
}
546-
547-
let arena = Wrap(TypedArena::new());
548-
549-
let result = arena.alloc_outer(|| Outer {
550-
inner: arena.alloc_inner(|| Inner { value: 10 }) });
551-
552-
assert_eq!(result.inner.value, 10);
553-
}
554-
555526
#[test]
556527
pub fn test_copy() {
557528
let arena = TypedArena::new();

branches/tmp/src/libcollections/btree/node.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ impl<T> Drop for RawItems<T> {
278278
#[unsafe_destructor]
279279
impl<K, V> Drop for Node<K, V> {
280280
fn drop(&mut self) {
281-
if self.keys.ptr.is_null() {
281+
if self.keys.0.is_null() {
282282
// We have already cleaned up this node.
283283
return;
284284
}
@@ -292,7 +292,7 @@ impl<K, V> Drop for Node<K, V> {
292292
self.destroy();
293293
}
294294

295-
self.keys.ptr = ptr::null_mut();
295+
self.keys.0 = ptr::null_mut();
296296
}
297297
}
298298

@@ -337,18 +337,18 @@ impl<K, V> Node<K, V> {
337337
unsafe fn destroy(&mut self) {
338338
let (alignment, size) =
339339
calculate_allocation_generic::<K, V>(self.capacity(), self.is_leaf());
340-
heap::deallocate(self.keys.ptr as *mut u8, size, alignment);
340+
heap::deallocate(self.keys.0 as *mut u8, size, alignment);
341341
}
342342

343343
#[inline]
344344
pub fn as_slices<'a>(&'a self) -> (&'a [K], &'a [V]) {
345345
unsafe {(
346346
mem::transmute(raw::Slice {
347-
data: self.keys.ptr,
347+
data: self.keys.0,
348348
len: self.len()
349349
}),
350350
mem::transmute(raw::Slice {
351-
data: self.vals.ptr,
351+
data: self.vals.0,
352352
len: self.len()
353353
})
354354
)}
@@ -368,7 +368,7 @@ impl<K, V> Node<K, V> {
368368
} else {
369369
unsafe {
370370
mem::transmute(raw::Slice {
371-
data: self.edges.ptr,
371+
data: self.edges.0,
372372
len: self.len() + 1
373373
})
374374
}
@@ -586,7 +586,7 @@ impl <K, V> Node<K, V> {
586586

587587
/// If the node has any children
588588
pub fn is_leaf(&self) -> bool {
589-
self.edges.ptr.is_null()
589+
self.edges.0.is_null()
590590
}
591591

592592
/// if the node has too few elements
@@ -1064,7 +1064,7 @@ impl<K, V> Node<K, V> {
10641064
vals: RawItems::from_slice(self.vals()),
10651065
edges: RawItems::from_slice(self.edges()),
10661066

1067-
ptr: self.keys.ptr as *mut u8,
1067+
ptr: self.keys.0 as *mut u8,
10681068
capacity: self.capacity(),
10691069
is_leaf: self.is_leaf()
10701070
},

branches/tmp/src/libcollections/fmt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@
401401
//! them with the same character. For example, the `{` character is escaped with
402402
//! `{{` and the `}` character is escaped with `}}`.
403403
404-
#![unstable(feature = "std_misc")]
404+
#![stable(feature = "rust1", since = "1.0.0")]
405405

406406
pub use core::fmt::{Formatter, Result, Writer, rt};
407407
pub use core::fmt::{Show, String, Octal, Binary};

branches/tmp/src/libcollections/vec.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ use core::default::Default;
5757
use core::fmt;
5858
use core::hash::{self, Hash};
5959
use core::iter::{repeat, FromIterator, IntoIterator};
60-
use core::marker::{self, ContravariantLifetime, InvariantType};
60+
use core::marker::{ContravariantLifetime, InvariantType};
6161
use core::mem;
6262
use core::nonzero::NonZero;
6363
use core::num::{Int, UnsignedInt};
@@ -140,7 +140,6 @@ pub struct Vec<T> {
140140
ptr: NonZero<*mut T>,
141141
len: usize,
142142
cap: usize,
143-
_own: marker::PhantomData<T>,
144143
}
145144

146145
unsafe impl<T: Send> Send for Vec<T> { }
@@ -167,7 +166,7 @@ impl<T> Vec<T> {
167166
// non-null value which is fine since we never call deallocate on the ptr
168167
// if cap is 0. The reason for this is because the pointer of a slice
169168
// being NULL would break the null pointer optimization for enums.
170-
unsafe { Vec::from_raw_parts(EMPTY as *mut T, 0, 0) }
169+
Vec { ptr: unsafe { NonZero::new(EMPTY as *mut T) }, len: 0, cap: 0 }
171170
}
172171

173172
/// Constructs a new, empty `Vec<T>` with the specified capacity.
@@ -199,15 +198,15 @@ impl<T> Vec<T> {
199198
#[stable(feature = "rust1", since = "1.0.0")]
200199
pub fn with_capacity(capacity: usize) -> Vec<T> {
201200
if mem::size_of::<T>() == 0 {
202-
unsafe { Vec::from_raw_parts(EMPTY as *mut T, 0, usize::MAX) }
201+
Vec { ptr: unsafe { NonZero::new(EMPTY as *mut T) }, len: 0, cap: usize::MAX }
203202
} else if capacity == 0 {
204203
Vec::new()
205204
} else {
206205
let size = capacity.checked_mul(mem::size_of::<T>())
207206
.expect("capacity overflow");
208207
let ptr = unsafe { allocate(size, mem::min_align_of::<T>()) };
209208
if ptr.is_null() { ::alloc::oom() }
210-
unsafe { Vec::from_raw_parts(ptr as *mut T, 0, capacity) }
209+
Vec { ptr: unsafe { NonZero::new(ptr as *mut T) }, len: 0, cap: capacity }
211210
}
212211
}
213212

@@ -248,12 +247,7 @@ impl<T> Vec<T> {
248247
#[stable(feature = "rust1", since = "1.0.0")]
249248
pub unsafe fn from_raw_parts(ptr: *mut T, length: usize,
250249
capacity: usize) -> Vec<T> {
251-
Vec {
252-
ptr: NonZero::new(ptr),
253-
len: length,
254-
cap: capacity,
255-
_own: marker::PhantomData,
256-
}
250+
Vec { ptr: NonZero::new(ptr), len: length, cap: capacity }
257251
}
258252

259253
/// Creates a vector by copying the elements from a raw pointer.
@@ -1632,7 +1626,7 @@ impl<T> IntoIter<T> {
16321626
for _x in self.by_ref() { }
16331627
let IntoIter { allocation, cap, ptr: _ptr, end: _end } = self;
16341628
mem::forget(self);
1635-
Vec::from_raw_parts(allocation, 0, cap)
1629+
Vec { ptr: NonZero::new(allocation), cap: cap, len: 0 }
16361630
}
16371631
}
16381632
}

branches/tmp/src/libcore/fmt/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ pub trait Debug {
268268
fn fmt(&self, &mut Formatter) -> Result;
269269
}
270270

271+
#[allow(deprecated)]
271272
impl<T: Show + ?Sized> Debug for T {
272273
#[allow(deprecated)]
273274
fn fmt(&self, f: &mut Formatter) -> Result { Show::fmt(self, f) }
@@ -295,6 +296,7 @@ pub trait Display {
295296
fn fmt(&self, &mut Formatter) -> Result;
296297
}
297298

299+
#[allow(deprecated)]
298300
impl<T: String + ?Sized> Display for T {
299301
#[allow(deprecated)]
300302
fn fmt(&self, f: &mut Formatter) -> Result { String::fmt(self, f) }

branches/tmp/src/libcore/marker.rs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -202,24 +202,6 @@ pub unsafe trait Sync {
202202
// Empty
203203
}
204204

205-
/// A marker type that indicates to the compiler that the instances
206-
/// of the type itself owns instances of the type parameter `T`.
207-
///
208-
/// This is used to indicate that one or more instances of the type
209-
/// `T` could be dropped when instances of the type itself is dropped,
210-
/// though that may not be apparent from the other structure of the
211-
/// type itself. For example, the type may hold a `*mut T`, which the
212-
/// compiler does not automatically treat as owned.
213-
#[unstable(feature = "core",
214-
reason = "Newly added to deal with scoping and destructor changes")]
215-
#[lang="phantom_data"]
216-
#[derive(PartialEq, Eq, PartialOrd, Ord)]
217-
pub struct PhantomData<T: ?Sized>;
218-
219-
impl<T: ?Sized> Copy for PhantomData<T> {}
220-
impl<T: ?Sized> Clone for PhantomData<T> {
221-
fn clone(&self) -> PhantomData<T> { *self }
222-
}
223205

224206
/// A marker type whose type parameter `T` is considered to be
225207
/// covariant with respect to the type itself. This is (typically)

branches/tmp/src/libcore/ops.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,8 +1119,7 @@ impl<'a, T: ?Sized> DerefMut for &'a mut T {
11191119

11201120
/// A version of the call operator that takes an immutable receiver.
11211121
#[lang="fn"]
1122-
#[unstable(feature = "core",
1123-
reason = "uncertain about variadic generics, input versus associated types")]
1122+
#[stable(feature = "rust1", since = "1.0.0")]
11241123
#[rustc_paren_sugar]
11251124
pub trait Fn<Args> {
11261125
type Output;
@@ -1131,8 +1130,7 @@ pub trait Fn<Args> {
11311130

11321131
/// A version of the call operator that takes a mutable receiver.
11331132
#[lang="fn_mut"]
1134-
#[unstable(feature = "core",
1135-
reason = "uncertain about variadic generics, input versus associated types")]
1133+
#[stable(feature = "rust1", since = "1.0.0")]
11361134
#[rustc_paren_sugar]
11371135
pub trait FnMut<Args> {
11381136
type Output;
@@ -1143,8 +1141,7 @@ pub trait FnMut<Args> {
11431141

11441142
/// A version of the call operator that takes a by-value receiver.
11451143
#[lang="fn_once"]
1146-
#[unstable(feature = "core",
1147-
reason = "uncertain about variadic generics, input versus associated types")]
1144+
#[stable(feature = "rust1", since = "1.0.0")]
11481145
#[rustc_paren_sugar]
11491146
pub trait FnOnce<Args> {
11501147
type Output;

0 commit comments

Comments
 (0)