Skip to content

Commit 7df818d

Browse files
committed
---
yaml --- r: 208622 b: refs/heads/snap-stage3 c: 6e8e6a4 h: refs/heads/master v: v3
1 parent 8d1c25b commit 7df818d

File tree

77 files changed

+303
-1429
lines changed

Some content is hidden

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

77 files changed

+303
-1429
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 38a97becdf3e6a6157f6f7ec2d98ade8d8edc193
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 4d3db3894063a304aa9183dcc198fdadd75edd22
4+
refs/heads/snap-stage3: 6e8e6a4b08e4d2d0e92eb50157e865bf412a3ce8
55
refs/heads/try: 7b4ef47b7805a402d756fb8157101f64880a522f
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d

branches/snap-stage3/AUTHORS.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Aaron Raimist <[email protected]>
88
Aaron Todd <[email protected]>
99
Aaron Turon <[email protected]>
1010
Aaron Weiss <[email protected]>
11-
Abhishek Chanda <abhishek.becs@gmail.com>
11+
Abhishek Chanda <abhishek@cloudscaling.com>
1212
Adam Bozanich <[email protected]>
1313
Adam Jacob <[email protected]>
1414
Adam Roben <[email protected]>

branches/snap-stage3/src/doc/complement-lang-faq.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
There aren't many large programs yet. The Rust [compiler][rustc], 60,000+ lines at the time of writing, is written in Rust. As the oldest body of Rust code it has gone through many iterations of the language, and some parts are nicer to look at than others. It may not be the best code to learn from, but [borrowck] and [resolve] were written recently.
66

77
[rustc]: https://github.com/rust-lang/rust/tree/master/src/librustc
8-
[resolve]: https://github.com/rust-lang/rust/tree/master/src/librustc_resolve
9-
[borrowck]: https://github.com/rust-lang/rust/tree/master/src/librustc_borrowck/borrowck
8+
[resolve]: https://github.com/rust-lang/rust/blob/master/src/librustc/middle/resolve.rs
9+
[borrowck]: https://github.com/rust-lang/rust/blob/master/src/librustc/middle/borrowck/
1010

1111
A research browser engine called [Servo][servo], currently 30,000+ lines across more than a dozen crates, will be exercising a lot of Rust's distinctive type-system and concurrency features, and integrating many native libraries.
1212

@@ -20,8 +20,8 @@ Some examples that demonstrate different aspects of the language:
2020
* The standard library's [json] module. Enums and pattern matching
2121

2222
[sprocketnes]: https://github.com/pcwalton/sprocketnes
23-
[hash]: https://github.com/rust-lang/rust/tree/master/src/libcore/hash
24-
[HashMap]: https://github.com/rust-lang/rust/tree/master/src/libstd/collections/hash
23+
[hash]: https://github.com/rust-lang/rust/blob/master/src/libstd/hash/mod.rs
24+
[HashMap]: https://github.com/rust-lang/rust/blob/master/src/libcollections/hashmap.rs
2525
[json]: https://github.com/rust-lang/rust/blob/master/src/libserialize/json.rs
2626

2727
You may also be interested in browsing [trending Rust repositories][github-rust] on GitHub.

branches/snap-stage3/src/doc/trpl/dining-philosophers.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ from the standard library, and so we need to `use` it.
320320
We now print out two messages, with a `sleep_ms()` in the middle. This will
321321
simulate the time it takes a philosopher to eat.
322322

323-
If you run this program, you should see each philosopher eat in turn:
323+
If you run this program, You should see each philosopher eat in turn:
324324

325325
```text
326326
Baruch Spinoza is eating.
@@ -480,7 +480,7 @@ struct Table {
480480
}
481481
```
482482

483-
This `Table` has a vector of `Mutex`es. A mutex is a way to control
483+
This `Table` has an vector of `Mutex`es. A mutex is a way to control
484484
concurrency: only one thread can access the contents at once. This is exactly
485485
the property we need with our forks. We use an empty tuple, `()`, inside the
486486
mutex, since we’re not actually going to use the value, just hold onto it.

branches/snap-stage3/src/doc/trpl/rust-inside-other-languages.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ fn process() {
104104
let handles: Vec<_> = (0..10).map(|_| {
105105
thread::spawn(|| {
106106
let mut _x = 0;
107-
for _ in (0..5_000_001) {
107+
for _ in (0..5_000_000) {
108108
_x += 1
109109
}
110110
})
@@ -217,7 +217,7 @@ end
217217

218218
Hello.process
219219

220-
puts "done!"
220+
puts "done!
221221
```
222222
223223
Before we can run this, we need to install the `ffi` gem:

branches/snap-stage3/src/grammar/verify.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,11 @@ fn main() {
287287
let options = config::basic_options();
288288
let session = session::build_session(options, None,
289289
syntax::diagnostics::registry::Registry::new(&[]));
290-
let filemap = session.parse_sess.codemap().new_filemap(String::from_str("<n/a>"), code);
290+
let filemap = parse::string_to_filemap(&session.parse_sess,
291+
code,
292+
String::from_str("<n/a>"));
291293
let mut lexer = lexer::StringReader::new(session.diagnostic(), filemap);
292-
let cm = session.codemap();
294+
let ref cm = lexer.span_diagnostic.cm;
293295

294296
// ANTLR
295297
let mut token_file = File::open(&Path::new(&args.next().unwrap())).unwrap();

branches/snap-stage3/src/liballoc/arc.rs

Lines changed: 36 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,11 @@ use core::atomic;
7777
use core::atomic::Ordering::{Relaxed, Release, Acquire, SeqCst};
7878
use core::fmt;
7979
use core::cmp::Ordering;
80-
use core::mem::{min_align_of_val, size_of_val};
81-
use core::intrinsics::drop_in_place;
80+
use core::mem::{min_align_of, size_of};
8281
use core::mem;
8382
use core::nonzero::NonZero;
84-
use core::ops::{Deref, CoerceUnsized};
85-
use core::marker::Unsize;
83+
use core::ops::Deref;
84+
use core::ptr;
8685
use core::hash::{Hash, Hasher};
8786
use heap::deallocate;
8887

@@ -119,16 +118,15 @@ use heap::deallocate;
119118
/// ```
120119
#[unsafe_no_drop_flag]
121120
#[stable(feature = "rust1", since = "1.0.0")]
122-
pub struct Arc<T: ?Sized> {
121+
pub struct Arc<T> {
123122
// FIXME #12808: strange name to try to avoid interfering with
124123
// field accesses of the contained type via Deref
125124
_ptr: NonZero<*mut ArcInner<T>>,
126125
}
127126

128-
unsafe impl<T: ?Sized + Sync + Send> Send for Arc<T> { }
129-
unsafe impl<T: ?Sized + Sync + Send> Sync for Arc<T> { }
127+
unsafe impl<T: Sync + Send> Send for Arc<T> { }
128+
unsafe impl<T: Sync + Send> Sync for Arc<T> { }
130129

131-
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Arc<U>> for Arc<T> {}
132130

133131
/// A weak pointer to an `Arc`.
134132
///
@@ -137,30 +135,30 @@ impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Arc<U>> for Arc<T> {}
137135
#[unsafe_no_drop_flag]
138136
#[unstable(feature = "alloc",
139137
reason = "Weak pointers may not belong in this module.")]
140-
pub struct Weak<T: ?Sized> {
138+
pub struct Weak<T> {
141139
// FIXME #12808: strange name to try to avoid interfering with
142140
// field accesses of the contained type via Deref
143141
_ptr: NonZero<*mut ArcInner<T>>,
144142
}
145143

146-
unsafe impl<T: ?Sized + Sync + Send> Send for Weak<T> { }
147-
unsafe impl<T: ?Sized + Sync + Send> Sync for Weak<T> { }
144+
unsafe impl<T: Sync + Send> Send for Weak<T> { }
145+
unsafe impl<T: Sync + Send> Sync for Weak<T> { }
148146

149147
#[stable(feature = "rust1", since = "1.0.0")]
150-
impl<T: ?Sized + fmt::Debug> fmt::Debug for Weak<T> {
148+
impl<T: fmt::Debug> fmt::Debug for Weak<T> {
151149
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
152150
write!(f, "(Weak)")
153151
}
154152
}
155153

156-
struct ArcInner<T: ?Sized> {
154+
struct ArcInner<T> {
157155
strong: atomic::AtomicUsize,
158156
weak: atomic::AtomicUsize,
159157
data: T,
160158
}
161159

162-
unsafe impl<T: ?Sized + Sync + Send> Send for ArcInner<T> {}
163-
unsafe impl<T: ?Sized + Sync + Send> Sync for ArcInner<T> {}
160+
unsafe impl<T: Sync + Send> Send for ArcInner<T> {}
161+
unsafe impl<T: Sync + Send> Sync for ArcInner<T> {}
164162

165163
impl<T> Arc<T> {
166164
/// Constructs a new `Arc<T>`.
@@ -184,9 +182,7 @@ impl<T> Arc<T> {
184182
};
185183
Arc { _ptr: unsafe { NonZero::new(mem::transmute(x)) } }
186184
}
187-
}
188185

189-
impl<T: ?Sized> Arc<T> {
190186
/// Downgrades the `Arc<T>` to a `Weak<T>` reference.
191187
///
192188
/// # Examples
@@ -208,7 +204,7 @@ impl<T: ?Sized> Arc<T> {
208204
}
209205
}
210206

211-
impl<T: ?Sized> Arc<T> {
207+
impl<T> Arc<T> {
212208
#[inline]
213209
fn inner(&self) -> &ArcInner<T> {
214210
// This unsafety is ok because while this arc is alive we're guaranteed
@@ -226,24 +222,24 @@ impl<T: ?Sized> Arc<T> {
226222

227223
// Destroy the data at this time, even though we may not free the box
228224
// allocation itself (there may still be weak pointers lying around).
229-
drop_in_place(&mut (*ptr).data);
225+
drop(ptr::read(&self.inner().data));
230226

231227
if self.inner().weak.fetch_sub(1, Release) == 1 {
232228
atomic::fence(Acquire);
233-
deallocate(ptr as *mut u8, size_of_val(&*ptr), min_align_of_val(&*ptr))
229+
deallocate(ptr as *mut u8, size_of::<ArcInner<T>>(), min_align_of::<ArcInner<T>>())
234230
}
235231
}
236232
}
237233

238234
/// Get the number of weak references to this value.
239235
#[inline]
240236
#[unstable(feature = "alloc")]
241-
pub fn weak_count<T: ?Sized>(this: &Arc<T>) -> usize { this.inner().weak.load(SeqCst) - 1 }
237+
pub fn weak_count<T>(this: &Arc<T>) -> usize { this.inner().weak.load(SeqCst) - 1 }
242238

243239
/// Get the number of strong references to this value.
244240
#[inline]
245241
#[unstable(feature = "alloc")]
246-
pub fn strong_count<T: ?Sized>(this: &Arc<T>) -> usize { this.inner().strong.load(SeqCst) }
242+
pub fn strong_count<T>(this: &Arc<T>) -> usize { this.inner().strong.load(SeqCst) }
247243

248244

249245
/// Returns a mutable reference to the contained value if the `Arc<T>` is unique.
@@ -268,7 +264,7 @@ pub fn strong_count<T: ?Sized>(this: &Arc<T>) -> usize { this.inner().strong.loa
268264
/// ```
269265
#[inline]
270266
#[unstable(feature = "alloc")]
271-
pub fn get_mut<T: ?Sized>(this: &mut Arc<T>) -> Option<&mut T> {
267+
pub fn get_mut<T>(this: &mut Arc<T>) -> Option<&mut T> {
272268
if strong_count(this) == 1 && weak_count(this) == 0 {
273269
// This unsafety is ok because we're guaranteed that the pointer
274270
// returned is the *only* pointer that will ever be returned to T. Our
@@ -283,7 +279,7 @@ pub fn get_mut<T: ?Sized>(this: &mut Arc<T>) -> Option<&mut T> {
283279
}
284280

285281
#[stable(feature = "rust1", since = "1.0.0")]
286-
impl<T: ?Sized> Clone for Arc<T> {
282+
impl<T> Clone for Arc<T> {
287283
/// Makes a clone of the `Arc<T>`.
288284
///
289285
/// This increases the strong reference count.
@@ -317,7 +313,7 @@ impl<T: ?Sized> Clone for Arc<T> {
317313
}
318314

319315
#[stable(feature = "rust1", since = "1.0.0")]
320-
impl<T: ?Sized> Deref for Arc<T> {
316+
impl<T> Deref for Arc<T> {
321317
type Target = T;
322318

323319
#[inline]
@@ -360,7 +356,7 @@ impl<T: Clone> Arc<T> {
360356
}
361357

362358
#[stable(feature = "rust1", since = "1.0.0")]
363-
impl<T: ?Sized> Drop for Arc<T> {
359+
impl<T> Drop for Arc<T> {
364360
/// Drops the `Arc<T>`.
365361
///
366362
/// This will decrement the strong reference count. If the strong reference
@@ -394,7 +390,7 @@ impl<T: ?Sized> Drop for Arc<T> {
394390
// it's run more than once)
395391
let ptr = *self._ptr;
396392
// if ptr.is_null() { return }
397-
if ptr as usize == 0 || ptr as usize == mem::POST_DROP_USIZE { return }
393+
if ptr.is_null() || ptr as usize == mem::POST_DROP_USIZE { return }
398394

399395
// Because `fetch_sub` is already atomic, we do not need to synchronize
400396
// with other threads unless we are going to delete the object. This
@@ -428,7 +424,7 @@ impl<T: ?Sized> Drop for Arc<T> {
428424

429425
#[unstable(feature = "alloc",
430426
reason = "Weak pointers may not belong in this module.")]
431-
impl<T: ?Sized> Weak<T> {
427+
impl<T> Weak<T> {
432428
/// Upgrades a weak reference to a strong reference.
433429
///
434430
/// Upgrades the `Weak<T>` reference to an `Arc<T>`, if possible.
@@ -469,7 +465,7 @@ impl<T: ?Sized> Weak<T> {
469465

470466
#[unstable(feature = "alloc",
471467
reason = "Weak pointers may not belong in this module.")]
472-
impl<T: ?Sized> Clone for Weak<T> {
468+
impl<T> Clone for Weak<T> {
473469
/// Makes a clone of the `Weak<T>`.
474470
///
475471
/// This increases the weak reference count.
@@ -493,7 +489,7 @@ impl<T: ?Sized> Clone for Weak<T> {
493489
}
494490

495491
#[stable(feature = "rust1", since = "1.0.0")]
496-
impl<T: ?Sized> Drop for Weak<T> {
492+
impl<T> Drop for Weak<T> {
497493
/// Drops the `Weak<T>`.
498494
///
499495
/// This will decrement the weak reference count.
@@ -524,22 +520,21 @@ impl<T: ?Sized> Drop for Weak<T> {
524520
let ptr = *self._ptr;
525521

526522
// see comments above for why this check is here
527-
if ptr as usize == 0 || ptr as usize == mem::POST_DROP_USIZE { return }
523+
if ptr.is_null() || ptr as usize == mem::POST_DROP_USIZE { return }
528524

529525
// If we find out that we were the last weak pointer, then its time to
530526
// deallocate the data entirely. See the discussion in Arc::drop() about
531527
// the memory orderings
532528
if self.inner().weak.fetch_sub(1, Release) == 1 {
533529
atomic::fence(Acquire);
534-
unsafe { deallocate(ptr as *mut u8,
535-
size_of_val(&*ptr),
536-
min_align_of_val(&*ptr)) }
530+
unsafe { deallocate(ptr as *mut u8, size_of::<ArcInner<T>>(),
531+
min_align_of::<ArcInner<T>>()) }
537532
}
538533
}
539534
}
540535

541536
#[stable(feature = "rust1", since = "1.0.0")]
542-
impl<T: ?Sized + PartialEq> PartialEq for Arc<T> {
537+
impl<T: PartialEq> PartialEq for Arc<T> {
543538
/// Equality for two `Arc<T>`s.
544539
///
545540
/// Two `Arc<T>`s are equal if their inner value are equal.
@@ -571,7 +566,7 @@ impl<T: ?Sized + PartialEq> PartialEq for Arc<T> {
571566
fn ne(&self, other: &Arc<T>) -> bool { *(*self) != *(*other) }
572567
}
573568
#[stable(feature = "rust1", since = "1.0.0")]
574-
impl<T: ?Sized + PartialOrd> PartialOrd for Arc<T> {
569+
impl<T: PartialOrd> PartialOrd for Arc<T> {
575570
/// Partial comparison for two `Arc<T>`s.
576571
///
577572
/// The two are compared by calling `partial_cmp()` on their inner values.
@@ -650,21 +645,21 @@ impl<T: ?Sized + PartialOrd> PartialOrd for Arc<T> {
650645
fn ge(&self, other: &Arc<T>) -> bool { *(*self) >= *(*other) }
651646
}
652647
#[stable(feature = "rust1", since = "1.0.0")]
653-
impl<T: ?Sized + Ord> Ord for Arc<T> {
648+
impl<T: Ord> Ord for Arc<T> {
654649
fn cmp(&self, other: &Arc<T>) -> Ordering { (**self).cmp(&**other) }
655650
}
656651
#[stable(feature = "rust1", since = "1.0.0")]
657-
impl<T: ?Sized + Eq> Eq for Arc<T> {}
652+
impl<T: Eq> Eq for Arc<T> {}
658653

659654
#[stable(feature = "rust1", since = "1.0.0")]
660-
impl<T: ?Sized + fmt::Display> fmt::Display for Arc<T> {
655+
impl<T: fmt::Display> fmt::Display for Arc<T> {
661656
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
662657
fmt::Display::fmt(&**self, f)
663658
}
664659
}
665660

666661
#[stable(feature = "rust1", since = "1.0.0")]
667-
impl<T: ?Sized + fmt::Debug> fmt::Debug for Arc<T> {
662+
impl<T: fmt::Debug> fmt::Debug for Arc<T> {
668663
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
669664
fmt::Debug::fmt(&**self, f)
670665
}
@@ -684,7 +679,7 @@ impl<T: Default> Default for Arc<T> {
684679
}
685680

686681
#[stable(feature = "rust1", since = "1.0.0")]
687-
impl<T: ?Sized + Hash> Hash for Arc<T> {
682+
impl<T: Hash> Hash for Arc<T> {
688683
fn hash<H: Hasher>(&self, state: &mut H) {
689684
(**self).hash(state)
690685
}
@@ -911,13 +906,4 @@ mod tests {
911906
// Make sure deriving works with Arc<T>
912907
#[derive(Eq, Ord, PartialEq, PartialOrd, Clone, Debug, Default)]
913908
struct Foo { inner: Arc<i32> }
914-
915-
#[test]
916-
fn test_unsized() {
917-
let x: Arc<[i32]> = Arc::new([1, 2, 3]);
918-
assert_eq!(format!("{:?}", x), "[1, 2, 3]");
919-
let y = x.clone().downgrade();
920-
drop(x);
921-
assert!(y.upgrade().is_none());
922-
}
923909
}

0 commit comments

Comments
 (0)